babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919
  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 is SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending is DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending is SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending is SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending is 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 is CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending is 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 is 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 is SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending is 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 is SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /**
  651. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  652. * Alpha will be set to DST ALPHA
  653. */
  654. static readonly ALPHA_EXCLUSION: number;
  655. /** Defines that alpha blending equation a SUM */
  656. static readonly ALPHA_EQUATION_ADD: number;
  657. /** Defines that alpha blending equation a SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  659. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  661. /** Defines that alpha blending equation a MAX operation */
  662. static readonly ALPHA_EQUATION_MAX: number;
  663. /** Defines that alpha blending equation a MIN operation */
  664. static readonly ALPHA_EQUATION_MIN: number;
  665. /**
  666. * Defines that alpha blending equation a DARKEN operation:
  667. * It takes the min of the src and sums the alpha channels.
  668. */
  669. static readonly ALPHA_EQUATION_DARKEN: number;
  670. /** Defines that the ressource is not delayed*/
  671. static readonly DELAYLOADSTATE_NONE: number;
  672. /** Defines that the ressource was successfully delay loaded */
  673. static readonly DELAYLOADSTATE_LOADED: number;
  674. /** Defines that the ressource is currently delay loading */
  675. static readonly DELAYLOADSTATE_LOADING: number;
  676. /** Defines that the ressource is delayed and has not started loading */
  677. static readonly DELAYLOADSTATE_NOTLOADED: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  679. static readonly NEVER: number;
  680. /** 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 */
  681. static readonly ALWAYS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  683. static readonly LESS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  685. static readonly EQUAL: number;
  686. /** 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 */
  687. static readonly LEQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  689. static readonly GREATER: number;
  690. /** 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 */
  691. static readonly GEQUAL: number;
  692. /** 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 */
  693. static readonly NOTEQUAL: number;
  694. /** Passed to stencilOperation to specify that stencil value must be kept */
  695. static readonly KEEP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be replaced */
  697. static readonly REPLACE: number;
  698. /** Passed to stencilOperation to specify that stencil value must be incremented */
  699. static readonly INCR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be decremented */
  701. static readonly DECR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be inverted */
  703. static readonly INVERT: number;
  704. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  705. static readonly INCR_WRAP: number;
  706. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  707. static readonly DECR_WRAP: number;
  708. /** Texture is not repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  710. /** Texture is repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  712. /** Texture is repeating and mirrored */
  713. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  714. /** ALPHA */
  715. static readonly TEXTUREFORMAT_ALPHA: number;
  716. /** LUMINANCE */
  717. static readonly TEXTUREFORMAT_LUMINANCE: number;
  718. /** LUMINANCE_ALPHA */
  719. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  720. /** RGB */
  721. static readonly TEXTUREFORMAT_RGB: number;
  722. /** RGBA */
  723. static readonly TEXTUREFORMAT_RGBA: number;
  724. /** RED */
  725. static readonly TEXTUREFORMAT_RED: number;
  726. /** RED (2nd reference) */
  727. static readonly TEXTUREFORMAT_R: number;
  728. /** RG */
  729. static readonly TEXTUREFORMAT_RG: number;
  730. /** RED_INTEGER */
  731. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  732. /** RED_INTEGER (2nd reference) */
  733. static readonly TEXTUREFORMAT_R_INTEGER: number;
  734. /** RG_INTEGER */
  735. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  736. /** RGB_INTEGER */
  737. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  738. /** RGBA_INTEGER */
  739. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  740. /** UNSIGNED_BYTE */
  741. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  742. /** UNSIGNED_BYTE (2nd reference) */
  743. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  744. /** FLOAT */
  745. static readonly TEXTURETYPE_FLOAT: number;
  746. /** HALF_FLOAT */
  747. static readonly TEXTURETYPE_HALF_FLOAT: number;
  748. /** BYTE */
  749. static readonly TEXTURETYPE_BYTE: number;
  750. /** SHORT */
  751. static readonly TEXTURETYPE_SHORT: number;
  752. /** UNSIGNED_SHORT */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  754. /** INT */
  755. static readonly TEXTURETYPE_INT: number;
  756. /** UNSIGNED_INT */
  757. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  758. /** UNSIGNED_SHORT_4_4_4_4 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  760. /** UNSIGNED_SHORT_5_5_5_1 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  762. /** UNSIGNED_SHORT_5_6_5 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  764. /** UNSIGNED_INT_2_10_10_10_REV */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  766. /** UNSIGNED_INT_24_8 */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  768. /** UNSIGNED_INT_10F_11F_11F_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  770. /** UNSIGNED_INT_5_9_9_9_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  772. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  773. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  774. /** nearest is mag = nearest and min = nearest and mip = nearest */
  775. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  776. /** Bilinear is mag = linear and min = linear and mip = nearest */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** Trilinear is mag = linear and min = linear and mip = linear */
  779. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** Bilinear is mag = linear and min = linear and mip = nearest */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  786. /** mag = nearest and min = nearest and mip = nearest */
  787. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = nearest */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = linear */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  792. /** mag = nearest and min = linear and mip = none */
  793. static readonly TEXTURE_NEAREST_LINEAR: number;
  794. /** mag = nearest and min = nearest and mip = none */
  795. static readonly TEXTURE_NEAREST_NEAREST: number;
  796. /** mag = linear and min = nearest and mip = nearest */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  798. /** mag = linear and min = nearest and mip = linear */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = linear and mip = none */
  801. static readonly TEXTURE_LINEAR_LINEAR: number;
  802. /** mag = linear and min = nearest and mip = none */
  803. static readonly TEXTURE_LINEAR_NEAREST: number;
  804. /** Explicit coordinates mode */
  805. static readonly TEXTURE_EXPLICIT_MODE: number;
  806. /** Spherical coordinates mode */
  807. static readonly TEXTURE_SPHERICAL_MODE: number;
  808. /** Planar coordinates mode */
  809. static readonly TEXTURE_PLANAR_MODE: number;
  810. /** Cubic coordinates mode */
  811. static readonly TEXTURE_CUBIC_MODE: number;
  812. /** Projection coordinates mode */
  813. static readonly TEXTURE_PROJECTION_MODE: number;
  814. /** Skybox coordinates mode */
  815. static readonly TEXTURE_SKYBOX_MODE: number;
  816. /** Inverse Cubic coordinates mode */
  817. static readonly TEXTURE_INVCUBIC_MODE: number;
  818. /** Equirectangular coordinates mode */
  819. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed Mirrored coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  824. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  825. static readonly SCALEMODE_FLOOR: number;
  826. /** Defines that texture rescaling will look for the nearest power of 2 size */
  827. static readonly SCALEMODE_NEAREST: number;
  828. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  829. static readonly SCALEMODE_CEILING: number;
  830. /**
  831. * The dirty texture flag value
  832. */
  833. static readonly MATERIAL_TextureDirtyFlag: number;
  834. /**
  835. * The dirty light flag value
  836. */
  837. static readonly MATERIAL_LightDirtyFlag: number;
  838. /**
  839. * The dirty fresnel flag value
  840. */
  841. static readonly MATERIAL_FresnelDirtyFlag: number;
  842. /**
  843. * The dirty attribute flag value
  844. */
  845. static readonly MATERIAL_AttributesDirtyFlag: number;
  846. /**
  847. * The dirty misc flag value
  848. */
  849. static readonly MATERIAL_MiscDirtyFlag: number;
  850. /**
  851. * The all dirty flag value
  852. */
  853. static readonly MATERIAL_AllDirtyFlag: number;
  854. /**
  855. * Returns the triangle fill mode
  856. */
  857. static readonly MATERIAL_TriangleFillMode: number;
  858. /**
  859. * Returns the wireframe mode
  860. */
  861. static readonly MATERIAL_WireFrameFillMode: number;
  862. /**
  863. * Returns the point fill mode
  864. */
  865. static readonly MATERIAL_PointFillMode: number;
  866. /**
  867. * Returns the point list draw mode
  868. */
  869. static readonly MATERIAL_PointListDrawMode: number;
  870. /**
  871. * Returns the line list draw mode
  872. */
  873. static readonly MATERIAL_LineListDrawMode: number;
  874. /**
  875. * Returns the line loop draw mode
  876. */
  877. static readonly MATERIAL_LineLoopDrawMode: number;
  878. /**
  879. * Returns the line strip draw mode
  880. */
  881. static readonly MATERIAL_LineStripDrawMode: number;
  882. /**
  883. * Returns the triangle strip draw mode
  884. */
  885. static readonly MATERIAL_TriangleStripDrawMode: number;
  886. /**
  887. * Returns the triangle fan draw mode
  888. */
  889. static readonly MATERIAL_TriangleFanDrawMode: number;
  890. /**
  891. * Stores the clock-wise side orientation
  892. */
  893. static readonly MATERIAL_ClockWiseSideOrientation: number;
  894. /**
  895. * Stores the counter clock-wise side orientation
  896. */
  897. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  898. /**
  899. * Nothing
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_NothingTrigger: number;
  903. /**
  904. * On pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPickTrigger: number;
  908. /**
  909. * On left pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnLeftPickTrigger: number;
  913. /**
  914. * On right pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnRightPickTrigger: number;
  918. /**
  919. * On center pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnCenterPickTrigger: number;
  923. /**
  924. * On pick down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickDownTrigger: number;
  928. /**
  929. * On double pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnDoublePickTrigger: number;
  933. /**
  934. * On pick up
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickUpTrigger: number;
  938. /**
  939. * On pick out.
  940. * This trigger will only be raised if you also declared a OnPickDown
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickOutTrigger: number;
  944. /**
  945. * On long press
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnLongPressTrigger: number;
  949. /**
  950. * On pointer over
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOverTrigger: number;
  954. /**
  955. * On pointer out
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnPointerOutTrigger: number;
  959. /**
  960. * On every frame
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnEveryFrameTrigger: number;
  964. /**
  965. * On intersection enter
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionEnterTrigger: number;
  969. /**
  970. * On intersection exit
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnIntersectionExitTrigger: number;
  974. /**
  975. * On key down
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyDownTrigger: number;
  979. /**
  980. * On key up
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnKeyUpTrigger: number;
  984. /**
  985. * Billboard mode will only apply to Y axis
  986. */
  987. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  988. /**
  989. * Billboard mode will apply to all axes
  990. */
  991. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  992. /**
  993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  994. */
  995. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  996. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  997. * Test order :
  998. * Is the bounding sphere outside the frustum ?
  999. * If not, are the bounding box vertices outside the frustum ?
  1000. * It not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1003. /** Culling strategy : Bounding Sphere Only.
  1004. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1005. * It's also less accurate than the standard because some not visible objects can still be selected.
  1006. * Test : is the bounding sphere outside the frustum ?
  1007. * If not, then the cullable object is in the frustum.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1010. /** Culling strategy : Optimistic Inclusion.
  1011. * This in an inclusion test first, then the standard exclusion test.
  1012. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * Anyway, it's as accurate as the standard strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the default culling strategy.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1020. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1021. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1022. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1030. /**
  1031. * No logging while loading
  1032. */
  1033. static readonly SCENELOADER_NO_LOGGING: number;
  1034. /**
  1035. * Minimal logging while loading
  1036. */
  1037. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1038. /**
  1039. * Summary logging while loading
  1040. */
  1041. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1042. /**
  1043. * Detailled logging while loading
  1044. */
  1045. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1046. }
  1047. }
  1048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1049. import { Nullable } from "babylonjs/types";
  1050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1051. /**
  1052. * This represents the required contract to create a new type of texture loader.
  1053. */
  1054. export interface IInternalTextureLoader {
  1055. /**
  1056. * Defines wether the loader supports cascade loading the different faces.
  1057. */
  1058. supportCascades: boolean;
  1059. /**
  1060. * This returns if the loader support the current file information.
  1061. * @param extension defines the file extension of the file being loaded
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @param fallback defines the fallback internal texture if any
  1064. * @param isBase64 defines whether the texture is encoded as a base64
  1065. * @param isBuffer defines whether the texture data are stored as a buffer
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1069. /**
  1070. * Transform the url before loading if required.
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the transformed texture
  1074. */
  1075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1076. /**
  1077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1078. * @param rootUrl the url of the texture
  1079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1080. * @returns the fallback texture
  1081. */
  1082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1083. /**
  1084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1085. * @param data contains the texture data
  1086. * @param texture defines the BabylonJS internal texture
  1087. * @param createPolynomials will be true if polynomials have been requested
  1088. * @param onLoad defines the callback to trigger once the texture is ready
  1089. * @param onError defines the callback to trigger in case of error
  1090. */
  1091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1092. /**
  1093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param callback defines the method to call once ready to upload
  1097. */
  1098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/IPipelineContext" {
  1102. /**
  1103. * Class used to store and describe the pipeline context associated with an effect
  1104. */
  1105. export interface IPipelineContext {
  1106. /**
  1107. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1108. */
  1109. isAsync: boolean;
  1110. /**
  1111. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1112. */
  1113. isReady: boolean;
  1114. /** @hidden */
  1115. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1116. }
  1117. }
  1118. declare module "babylonjs/Meshes/dataBuffer" {
  1119. /**
  1120. * Class used to store gfx data (like WebGLBuffer)
  1121. */
  1122. export class DataBuffer {
  1123. /**
  1124. * Gets or sets the number of objects referencing this buffer
  1125. */
  1126. references: number;
  1127. /** Gets or sets the size of the underlying buffer */
  1128. capacity: number;
  1129. /**
  1130. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1131. */
  1132. is32Bits: boolean;
  1133. /**
  1134. * Gets the underlying buffer
  1135. */
  1136. readonly underlyingResource: any;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1140. /** @hidden */
  1141. export interface IShaderProcessor {
  1142. attributeProcessor?: (attribute: string) => string;
  1143. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1144. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1145. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1146. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1147. lineProcessor?: (line: string, isFragment: boolean) => string;
  1148. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1149. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1153. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1154. /** @hidden */
  1155. export interface ProcessingOptions {
  1156. defines: string[];
  1157. indexParameters: any;
  1158. isFragment: boolean;
  1159. shouldUseHighPrecisionShader: boolean;
  1160. supportsUniformBuffers: boolean;
  1161. shadersRepository: string;
  1162. includesShadersStore: {
  1163. [key: string]: string;
  1164. };
  1165. processor?: IShaderProcessor;
  1166. version: string;
  1167. platformName: string;
  1168. lookForClosingBracketForUniformBuffer?: boolean;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1172. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1173. /** @hidden */
  1174. export class ShaderCodeNode {
  1175. line: string;
  1176. children: ShaderCodeNode[];
  1177. additionalDefineKey?: string;
  1178. additionalDefineValue?: string;
  1179. isValid(preprocessors: {
  1180. [key: string]: string;
  1181. }): boolean;
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1188. /** @hidden */
  1189. export class ShaderCodeCursor {
  1190. private _lines;
  1191. lineIndex: number;
  1192. readonly currentLine: string;
  1193. readonly canRead: boolean;
  1194. lines: string[];
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1198. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1199. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1200. /** @hidden */
  1201. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1202. process(preprocessors: {
  1203. [key: string]: string;
  1204. }, options: ProcessingOptions): string;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1208. /** @hidden */
  1209. export class ShaderDefineExpression {
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. 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>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. 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;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. 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;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. /** @hidden */
  1474. export class ShaderProcessor {
  1475. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1476. private static _ProcessPrecision;
  1477. private static _ExtractOperation;
  1478. private static _BuildSubExpression;
  1479. private static _BuildExpression;
  1480. private static _MoveCursorWithinIf;
  1481. private static _MoveCursor;
  1482. private static _EvaluatePreProcessors;
  1483. private static _PreparePreProcessors;
  1484. private static _ProcessShaderConversion;
  1485. private static _ProcessIncludes;
  1486. }
  1487. }
  1488. declare module "babylonjs/Maths/math.like" {
  1489. import { float, int, DeepImmutable } from "babylonjs/types";
  1490. /**
  1491. * @hidden
  1492. */
  1493. export interface IColor4Like {
  1494. r: float;
  1495. g: float;
  1496. b: float;
  1497. a: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IColor3Like {
  1503. r: float;
  1504. g: float;
  1505. b: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IVector4Like {
  1511. x: float;
  1512. y: float;
  1513. z: float;
  1514. w: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IVector3Like {
  1520. x: float;
  1521. y: float;
  1522. z: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector2Like {
  1528. x: float;
  1529. y: float;
  1530. }
  1531. /**
  1532. * @hidden
  1533. */
  1534. export interface IMatrixLike {
  1535. toArray(): DeepImmutable<Float32Array>;
  1536. updateFlag: int;
  1537. }
  1538. /**
  1539. * @hidden
  1540. */
  1541. export interface IViewportLike {
  1542. x: float;
  1543. y: float;
  1544. width: float;
  1545. height: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IPlaneLike {
  1551. normal: IVector3Like;
  1552. d: float;
  1553. normalize(): void;
  1554. }
  1555. }
  1556. declare module "babylonjs/Materials/iEffectFallbacks" {
  1557. import { Effect } from "babylonjs/Materials/effect";
  1558. /**
  1559. * Interface used to define common properties for effect fallbacks
  1560. */
  1561. export interface IEffectFallbacks {
  1562. /**
  1563. * Removes the defines that should be removed when falling back.
  1564. * @param currentDefines defines the current define statements for the shader.
  1565. * @param effect defines the current effect we try to compile
  1566. * @returns The resulting defines with defines of the current rank removed.
  1567. */
  1568. reduce(currentDefines: string, effect: Effect): string;
  1569. /**
  1570. * Removes the fallback from the bound mesh.
  1571. */
  1572. unBindMesh(): void;
  1573. /**
  1574. * Checks to see if more fallbacks are still availible.
  1575. */
  1576. hasMoreFallbacks: boolean;
  1577. }
  1578. }
  1579. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1580. /**
  1581. * Class used to evalaute queries containing `and` and `or` operators
  1582. */
  1583. export class AndOrNotEvaluator {
  1584. /**
  1585. * Evaluate a query
  1586. * @param query defines the query to evaluate
  1587. * @param evaluateCallback defines the callback used to filter result
  1588. * @returns true if the query matches
  1589. */
  1590. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1591. private static _HandleParenthesisContent;
  1592. private static _SimplifyNegation;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/tags" {
  1596. /**
  1597. * Class used to store custom tags
  1598. */
  1599. export class Tags {
  1600. /**
  1601. * Adds support for tags on the given object
  1602. * @param obj defines the object to use
  1603. */
  1604. static EnableFor(obj: any): void;
  1605. /**
  1606. * Removes tags support
  1607. * @param obj defines the object to use
  1608. */
  1609. static DisableFor(obj: any): void;
  1610. /**
  1611. * Gets a boolean indicating if the given object has tags
  1612. * @param obj defines the object to use
  1613. * @returns a boolean
  1614. */
  1615. static HasTags(obj: any): boolean;
  1616. /**
  1617. * Gets the tags available on a given object
  1618. * @param obj defines the object to use
  1619. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1620. * @returns the tags
  1621. */
  1622. static GetTags(obj: any, asString?: boolean): any;
  1623. /**
  1624. * Adds tags to an object
  1625. * @param obj defines the object to use
  1626. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1627. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1628. */
  1629. static AddTagsTo(obj: any, tagsString: string): void;
  1630. /**
  1631. * @hidden
  1632. */
  1633. static _AddTagTo(obj: any, tag: string): void;
  1634. /**
  1635. * Removes specific tags from a specific object
  1636. * @param obj defines the object to use
  1637. * @param tagsString defines the tags to remove
  1638. */
  1639. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1640. /**
  1641. * @hidden
  1642. */
  1643. static _RemoveTagFrom(obj: any, tag: string): void;
  1644. /**
  1645. * Defines if tags hosted on an object match a given query
  1646. * @param obj defines the object to use
  1647. * @param tagsQuery defines the tag query
  1648. * @returns a boolean
  1649. */
  1650. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1651. }
  1652. }
  1653. declare module "babylonjs/Maths/math.scalar" {
  1654. /**
  1655. * Scalar computation library
  1656. */
  1657. export class Scalar {
  1658. /**
  1659. * Two pi constants convenient for computation.
  1660. */
  1661. static TwoPi: number;
  1662. /**
  1663. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1664. * @param a number
  1665. * @param b number
  1666. * @param epsilon (default = 1.401298E-45)
  1667. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. */
  1669. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1670. /**
  1671. * Returns a string : the upper case translation of the number i to hexadecimal.
  1672. * @param i number
  1673. * @returns the upper case translation of the number i to hexadecimal.
  1674. */
  1675. static ToHex(i: number): string;
  1676. /**
  1677. * Returns -1 if value is negative and +1 is value is positive.
  1678. * @param value the value
  1679. * @returns the value itself if it's equal to zero.
  1680. */
  1681. static Sign(value: number): number;
  1682. /**
  1683. * Returns the value itself if it's between min and max.
  1684. * Returns min if the value is lower than min.
  1685. * Returns max if the value is greater than max.
  1686. * @param value the value to clmap
  1687. * @param min the min value to clamp to (default: 0)
  1688. * @param max the max value to clamp to (default: 1)
  1689. * @returns the clamped value
  1690. */
  1691. static Clamp(value: number, min?: number, max?: number): number;
  1692. /**
  1693. * the log2 of value.
  1694. * @param value the value to compute log2 of
  1695. * @returns the log2 of value.
  1696. */
  1697. static Log2(value: number): number;
  1698. /**
  1699. * Loops the value, so that it is never larger than length and never smaller than 0.
  1700. *
  1701. * This is similar to the modulo operator but it works with floating point numbers.
  1702. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1703. * With t = 5 and length = 2.5, the result would be 0.0.
  1704. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1705. * @param value the value
  1706. * @param length the length
  1707. * @returns the looped value
  1708. */
  1709. static Repeat(value: number, length: number): number;
  1710. /**
  1711. * Normalize the value between 0.0 and 1.0 using min and max values
  1712. * @param value value to normalize
  1713. * @param min max to normalize between
  1714. * @param max min to normalize between
  1715. * @returns the normalized value
  1716. */
  1717. static Normalize(value: number, min: number, max: number): number;
  1718. /**
  1719. * Denormalize the value from 0.0 and 1.0 using min and max values
  1720. * @param normalized value to denormalize
  1721. * @param min max to denormalize between
  1722. * @param max min to denormalize between
  1723. * @returns the denormalized value
  1724. */
  1725. static Denormalize(normalized: number, min: number, max: number): number;
  1726. /**
  1727. * Calculates the shortest difference between two given angles given in degrees.
  1728. * @param current current angle in degrees
  1729. * @param target target angle in degrees
  1730. * @returns the delta
  1731. */
  1732. static DeltaAngle(current: number, target: number): number;
  1733. /**
  1734. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1735. * @param tx value
  1736. * @param length length
  1737. * @returns The returned value will move back and forth between 0 and length
  1738. */
  1739. static PingPong(tx: number, length: number): number;
  1740. /**
  1741. * Interpolates between min and max with smoothing at the limits.
  1742. *
  1743. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1744. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1745. * @param from from
  1746. * @param to to
  1747. * @param tx value
  1748. * @returns the smooth stepped value
  1749. */
  1750. static SmoothStep(from: number, to: number, tx: number): number;
  1751. /**
  1752. * Moves a value current towards target.
  1753. *
  1754. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1755. * Negative values of maxDelta pushes the value away from target.
  1756. * @param current current value
  1757. * @param target target value
  1758. * @param maxDelta max distance to move
  1759. * @returns resulting value
  1760. */
  1761. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1762. /**
  1763. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1764. *
  1765. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1766. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1767. * @param current current value
  1768. * @param target target value
  1769. * @param maxDelta max distance to move
  1770. * @returns resulting angle
  1771. */
  1772. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1773. /**
  1774. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1775. * @param start start value
  1776. * @param end target value
  1777. * @param amount amount to lerp between
  1778. * @returns the lerped value
  1779. */
  1780. static Lerp(start: number, end: number, amount: number): number;
  1781. /**
  1782. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1783. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1784. * @param start start value
  1785. * @param end target value
  1786. * @param amount amount to lerp between
  1787. * @returns the lerped value
  1788. */
  1789. static LerpAngle(start: number, end: number, amount: number): number;
  1790. /**
  1791. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1792. * @param a start value
  1793. * @param b target value
  1794. * @param value value between a and b
  1795. * @returns the inverseLerp value
  1796. */
  1797. static InverseLerp(a: number, b: number, value: number): number;
  1798. /**
  1799. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1800. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1801. * @param value1 spline value
  1802. * @param tangent1 spline value
  1803. * @param value2 spline value
  1804. * @param tangent2 spline value
  1805. * @param amount input value
  1806. * @returns hermite result
  1807. */
  1808. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1809. /**
  1810. * Returns a random float number between and min and max values
  1811. * @param min min value of random
  1812. * @param max max value of random
  1813. * @returns random value
  1814. */
  1815. static RandomRange(min: number, max: number): number;
  1816. /**
  1817. * This function returns percentage of a number in a given range.
  1818. *
  1819. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1820. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1821. * @param number to convert to percentage
  1822. * @param min min range
  1823. * @param max max range
  1824. * @returns the percentage
  1825. */
  1826. static RangeToPercent(number: number, min: number, max: number): number;
  1827. /**
  1828. * This function returns number that corresponds to the percentage in a given range.
  1829. *
  1830. * PercentToRange(0.34,0,100) will return 34.
  1831. * @param percent to convert to number
  1832. * @param min min range
  1833. * @param max max range
  1834. * @returns the number
  1835. */
  1836. static PercentToRange(percent: number, min: number, max: number): number;
  1837. /**
  1838. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1839. * @param angle The angle to normalize in radian.
  1840. * @return The converted angle.
  1841. */
  1842. static NormalizeRadians(angle: number): number;
  1843. }
  1844. }
  1845. declare module "babylonjs/Maths/math.constants" {
  1846. /**
  1847. * Constant used to convert a value to gamma space
  1848. * @ignorenaming
  1849. */
  1850. export const ToGammaSpace: number;
  1851. /**
  1852. * Constant used to convert a value to linear space
  1853. * @ignorenaming
  1854. */
  1855. export const ToLinearSpace = 2.2;
  1856. /**
  1857. * Constant used to define the minimal number value in Babylon.js
  1858. * @ignorenaming
  1859. */
  1860. let Epsilon: number;
  1861. export { Epsilon };
  1862. }
  1863. declare module "babylonjs/Maths/math.viewport" {
  1864. /**
  1865. * Class used to represent a viewport on screen
  1866. */
  1867. export class Viewport {
  1868. /** viewport left coordinate */
  1869. x: number;
  1870. /** viewport top coordinate */
  1871. y: number;
  1872. /**viewport width */
  1873. width: number;
  1874. /** viewport height */
  1875. height: number;
  1876. /**
  1877. * Creates a Viewport object located at (x, y) and sized (width, height)
  1878. * @param x defines viewport left coordinate
  1879. * @param y defines viewport top coordinate
  1880. * @param width defines the viewport width
  1881. * @param height defines the viewport height
  1882. */
  1883. constructor(
  1884. /** viewport left coordinate */
  1885. x: number,
  1886. /** viewport top coordinate */
  1887. y: number,
  1888. /**viewport width */
  1889. width: number,
  1890. /** viewport height */
  1891. height: number);
  1892. /**
  1893. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1894. * @param renderWidth defines the rendering width
  1895. * @param renderHeight defines the rendering height
  1896. * @returns a new Viewport
  1897. */
  1898. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1899. /**
  1900. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1901. * @param renderWidth defines the rendering width
  1902. * @param renderHeight defines the rendering height
  1903. * @param ref defines the target viewport
  1904. * @returns the current viewport
  1905. */
  1906. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1907. /**
  1908. * Returns a new Viewport copied from the current one
  1909. * @returns a new Viewport
  1910. */
  1911. clone(): Viewport;
  1912. }
  1913. }
  1914. declare module "babylonjs/Misc/arrayTools" {
  1915. /**
  1916. * Class containing a set of static utilities functions for arrays.
  1917. */
  1918. export class ArrayTools {
  1919. /**
  1920. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1921. * @param size the number of element to construct and put in the array
  1922. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1923. * @returns a new array filled with new objects
  1924. */
  1925. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1926. }
  1927. }
  1928. declare module "babylonjs/Maths/math.vector" {
  1929. import { Viewport } from "babylonjs/Maths/math.viewport";
  1930. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1931. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1932. /**
  1933. * Class representing a vector containing 2 coordinates
  1934. */
  1935. export class Vector2 {
  1936. /** defines the first coordinate */
  1937. x: number;
  1938. /** defines the second coordinate */
  1939. y: number;
  1940. /**
  1941. * Creates a new Vector2 from the given x and y coordinates
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. */
  1945. constructor(
  1946. /** defines the first coordinate */
  1947. x?: number,
  1948. /** defines the second coordinate */
  1949. y?: number);
  1950. /**
  1951. * Gets a string with the Vector2 coordinates
  1952. * @returns a string with the Vector2 coordinates
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Gets class name
  1957. * @returns the string "Vector2"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Gets current vector hash code
  1962. * @returns the Vector2 hash code as a number
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1967. * @param array defines the source array
  1968. * @param index defines the offset in source array
  1969. * @returns the current Vector2
  1970. */
  1971. toArray(array: FloatArray, index?: number): Vector2;
  1972. /**
  1973. * Copy the current vector to an array
  1974. * @returns a new array with 2 elements: the Vector2 coordinates.
  1975. */
  1976. asArray(): number[];
  1977. /**
  1978. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1979. * @param source defines the source Vector2
  1980. * @returns the current updated Vector2
  1981. */
  1982. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1983. /**
  1984. * Sets the Vector2 coordinates with the given floats
  1985. * @param x defines the first coordinate
  1986. * @param y defines the second coordinate
  1987. * @returns the current updated Vector2
  1988. */
  1989. copyFromFloats(x: number, y: number): Vector2;
  1990. /**
  1991. * Sets the Vector2 coordinates with the given floats
  1992. * @param x defines the first coordinate
  1993. * @param y defines the second coordinate
  1994. * @returns the current updated Vector2
  1995. */
  1996. set(x: number, y: number): Vector2;
  1997. /**
  1998. * Add another vector with the current one
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2001. */
  2002. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns a new Vector2
  2020. */
  2021. addVector3(otherVector: Vector3): Vector2;
  2022. /**
  2023. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. subtract(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Multiplies in place the current Vector2 coordinates by the given ones
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2049. * @param otherVector defines the other vector
  2050. * @returns a new Vector2
  2051. */
  2052. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @param result defines the target vector
  2057. * @returns the unmodified current Vector2
  2058. */
  2059. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2060. /**
  2061. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2062. * @param x defines the first coordinate
  2063. * @param y defines the second coordinate
  2064. * @returns a new Vector2
  2065. */
  2066. multiplyByFloats(x: number, y: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2069. * @param otherVector defines the other vector
  2070. * @returns a new Vector2
  2071. */
  2072. divide(otherVector: Vector2): Vector2;
  2073. /**
  2074. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @param result defines the target vector
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2080. /**
  2081. * Divides the current Vector2 coordinates by the given ones
  2082. * @param otherVector defines the other vector
  2083. * @returns the current updated Vector2
  2084. */
  2085. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Gets a new Vector2 with current Vector2 negated coordinates
  2088. * @returns a new Vector2
  2089. */
  2090. negate(): Vector2;
  2091. /**
  2092. * Multiply the Vector2 coordinates by scale
  2093. * @param scale defines the scaling factor
  2094. * @returns the current updated Vector2
  2095. */
  2096. scaleInPlace(scale: number): Vector2;
  2097. /**
  2098. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2099. * @param scale defines the scaling factor
  2100. * @returns a new Vector2
  2101. */
  2102. scale(scale: number): Vector2;
  2103. /**
  2104. * Scale the current Vector2 values by a factor to a given Vector2
  2105. * @param scale defines the scale factor
  2106. * @param result defines the Vector2 object where to store the result
  2107. * @returns the unmodified current Vector2
  2108. */
  2109. scaleToRef(scale: number, result: Vector2): Vector2;
  2110. /**
  2111. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2112. * @param scale defines the scale factor
  2113. * @param result defines the Vector2 object where to store the result
  2114. * @returns the unmodified current Vector2
  2115. */
  2116. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2117. /**
  2118. * Gets a boolean if two vectors are equals
  2119. * @param otherVector defines the other vector
  2120. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2121. */
  2122. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2123. /**
  2124. * Gets a boolean if two vectors are equals (using an epsilon value)
  2125. * @param otherVector defines the other vector
  2126. * @param epsilon defines the minimal distance to consider equality
  2127. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2128. */
  2129. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. floor(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 from current Vector2 floored values
  2137. * @returns a new Vector2
  2138. */
  2139. fract(): Vector2;
  2140. /**
  2141. * Gets the length of the vector
  2142. * @returns the vector length (float)
  2143. */
  2144. length(): number;
  2145. /**
  2146. * Gets the vector squared length
  2147. * @returns the vector squared length (float)
  2148. */
  2149. lengthSquared(): number;
  2150. /**
  2151. * Normalize the vector
  2152. * @returns the current updated Vector2
  2153. */
  2154. normalize(): Vector2;
  2155. /**
  2156. * Gets a new Vector2 copied from the Vector2
  2157. * @returns a new Vector2
  2158. */
  2159. clone(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(0, 0)
  2162. * @returns a new Vector2
  2163. */
  2164. static Zero(): Vector2;
  2165. /**
  2166. * Gets a new Vector2(1, 1)
  2167. * @returns a new Vector2
  2168. */
  2169. static One(): Vector2;
  2170. /**
  2171. * Gets a new Vector2 set from the given index element of the given array
  2172. * @param array defines the data source
  2173. * @param offset defines the offset in the data source
  2174. * @returns a new Vector2
  2175. */
  2176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2177. /**
  2178. * Sets "result" from the given index element of the given array
  2179. * @param array defines the data source
  2180. * @param offset defines the offset in the data source
  2181. * @param result defines the target vector
  2182. */
  2183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2184. /**
  2185. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2186. * @param value1 defines 1st point of control
  2187. * @param value2 defines 2nd point of control
  2188. * @param value3 defines 3rd point of control
  2189. * @param value4 defines 4th point of control
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * 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".
  2196. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2197. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2198. * @param value defines the value to clamp
  2199. * @param min defines the lower limit
  2200. * @param max defines the upper limit
  2201. * @returns a new Vector2
  2202. */
  2203. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2204. /**
  2205. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2206. * @param value1 defines the 1st control point
  2207. * @param tangent1 defines the outgoing tangent
  2208. * @param value2 defines the 2nd control point
  2209. * @param tangent2 defines the incoming tangent
  2210. * @param amount defines the interpolation factor
  2211. * @returns a new Vector2
  2212. */
  2213. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2216. * @param start defines the start vector
  2217. * @param end defines the end vector
  2218. * @param amount defines the interpolation factor
  2219. * @returns a new Vector2
  2220. */
  2221. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2222. /**
  2223. * Gets the dot product of the vector "left" and the vector "right"
  2224. * @param left defines first vector
  2225. * @param right defines second vector
  2226. * @returns the dot product (float)
  2227. */
  2228. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2229. /**
  2230. * Returns a new Vector2 equal to the normalized given vector
  2231. * @param vector defines the vector to normalize
  2232. * @returns a new Vector2
  2233. */
  2234. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2237. * @param left defines 1st vector
  2238. * @param right defines 2nd vector
  2239. * @returns a new Vector2
  2240. */
  2241. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2244. * @param left defines 1st vector
  2245. * @param right defines 2nd vector
  2246. * @returns a new Vector2
  2247. */
  2248. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2251. * @param vector defines the vector to transform
  2252. * @param transformation defines the matrix to apply
  2253. * @returns a new Vector2
  2254. */
  2255. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2256. /**
  2257. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2258. * @param vector defines the vector to transform
  2259. * @param transformation defines the matrix to apply
  2260. * @param result defines the target vector
  2261. */
  2262. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2263. /**
  2264. * Determines if a given vector is included in a triangle
  2265. * @param p defines the vector to test
  2266. * @param p0 defines 1st triangle point
  2267. * @param p1 defines 2nd triangle point
  2268. * @param p2 defines 3rd triangle point
  2269. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2270. */
  2271. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2272. /**
  2273. * Gets the distance between the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns the distance between vectors
  2277. */
  2278. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2279. /**
  2280. * Returns the squared distance between the vectors "value1" and "value2"
  2281. * @param value1 defines first vector
  2282. * @param value2 defines second vector
  2283. * @returns the squared distance between vectors
  2284. */
  2285. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2286. /**
  2287. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2288. * @param value1 defines first vector
  2289. * @param value2 defines second vector
  2290. * @returns a new Vector2
  2291. */
  2292. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2293. /**
  2294. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2295. * @param p defines the middle point
  2296. * @param segA defines one point of the segment
  2297. * @param segB defines the other point of the segment
  2298. * @returns the shortest distance
  2299. */
  2300. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2301. }
  2302. /**
  2303. * Class used to store (x,y,z) vector representation
  2304. * A Vector3 is the main object used in 3D geometry
  2305. * It can represent etiher the coordinates of a point the space, either a direction
  2306. * Reminder: js uses a left handed forward facing system
  2307. */
  2308. export class Vector3 {
  2309. /**
  2310. * Defines the first coordinates (on X axis)
  2311. */
  2312. x: number;
  2313. /**
  2314. * Defines the second coordinates (on Y axis)
  2315. */
  2316. y: number;
  2317. /**
  2318. * Defines the third coordinates (on Z axis)
  2319. */
  2320. z: number;
  2321. private static _UpReadOnly;
  2322. private static _ZeroReadOnly;
  2323. /**
  2324. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2325. * @param x defines the first coordinates (on X axis)
  2326. * @param y defines the second coordinates (on Y axis)
  2327. * @param z defines the third coordinates (on Z axis)
  2328. */
  2329. constructor(
  2330. /**
  2331. * Defines the first coordinates (on X axis)
  2332. */
  2333. x?: number,
  2334. /**
  2335. * Defines the second coordinates (on Y axis)
  2336. */
  2337. y?: number,
  2338. /**
  2339. * Defines the third coordinates (on Z axis)
  2340. */
  2341. z?: number);
  2342. /**
  2343. * Creates a string representation of the Vector3
  2344. * @returns a string with the Vector3 coordinates.
  2345. */
  2346. toString(): string;
  2347. /**
  2348. * Gets the class name
  2349. * @returns the string "Vector3"
  2350. */
  2351. getClassName(): string;
  2352. /**
  2353. * Creates the Vector3 hash code
  2354. * @returns a number which tends to be unique between Vector3 instances
  2355. */
  2356. getHashCode(): number;
  2357. /**
  2358. * Creates an array containing three elements : the coordinates of the Vector3
  2359. * @returns a new array of numbers
  2360. */
  2361. asArray(): number[];
  2362. /**
  2363. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2364. * @param array defines the destination array
  2365. * @param index defines the offset in the destination array
  2366. * @returns the current Vector3
  2367. */
  2368. toArray(array: FloatArray, index?: number): Vector3;
  2369. /**
  2370. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2371. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2372. */
  2373. toQuaternion(): Quaternion;
  2374. /**
  2375. * Adds the given vector to the current Vector3
  2376. * @param otherVector defines the second operand
  2377. * @returns the current updated Vector3
  2378. */
  2379. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the given coordinates to the current Vector3
  2382. * @param x defines the x coordinate of the operand
  2383. * @param y defines the y coordinate of the operand
  2384. * @param z defines the z coordinate of the operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2388. /**
  2389. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Subtract the given vector from the current Vector3
  2403. * @param otherVector defines the second operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2407. /**
  2408. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns the resulting Vector3
  2426. */
  2427. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2428. /**
  2429. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2430. * @param x defines the x coordinate of the operand
  2431. * @param y defines the y coordinate of the operand
  2432. * @param z defines the z coordinate of the operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2437. /**
  2438. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2439. * @returns a new Vector3
  2440. */
  2441. negate(): Vector3;
  2442. /**
  2443. * Multiplies the Vector3 coordinates by the float "scale"
  2444. * @param scale defines the multiplier factor
  2445. * @returns the current updated Vector3
  2446. */
  2447. scaleInPlace(scale: number): Vector3;
  2448. /**
  2449. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2450. * @param scale defines the multiplier factor
  2451. * @returns a new Vector3
  2452. */
  2453. scale(scale: number): Vector3;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2456. * @param scale defines the multiplier factor
  2457. * @param result defines the Vector3 object where to store the result
  2458. * @returns the current Vector3
  2459. */
  2460. scaleToRef(scale: number, result: Vector3): Vector3;
  2461. /**
  2462. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2463. * @param scale defines the scale factor
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the unmodified current Vector3
  2466. */
  2467. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2468. /**
  2469. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2470. * @param otherVector defines the second operand
  2471. * @returns true if both vectors are equals
  2472. */
  2473. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2474. /**
  2475. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2476. * @param otherVector defines the second operand
  2477. * @param epsilon defines the minimal distance to define values as equals
  2478. * @returns true if both vectors are distant less than epsilon
  2479. */
  2480. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2481. /**
  2482. * Returns true if the current Vector3 coordinates equals the given floats
  2483. * @param x defines the x coordinate of the operand
  2484. * @param y defines the y coordinate of the operand
  2485. * @param z defines the z coordinate of the operand
  2486. * @returns true if both vectors are equals
  2487. */
  2488. equalsToFloats(x: number, y: number, z: number): boolean;
  2489. /**
  2490. * Multiplies the current Vector3 coordinates by the given ones
  2491. * @param otherVector defines the second operand
  2492. * @returns the current updated Vector3
  2493. */
  2494. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2495. /**
  2496. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2497. * @param otherVector defines the second operand
  2498. * @returns the new Vector3
  2499. */
  2500. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2503. * @param otherVector defines the second operand
  2504. * @param result defines the Vector3 object where to store the result
  2505. * @returns the current Vector3
  2506. */
  2507. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2510. * @param x defines the x coordinate of the operand
  2511. * @param y defines the y coordinate of the operand
  2512. * @param z defines the z coordinate of the operand
  2513. * @returns the new Vector3
  2514. */
  2515. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2516. /**
  2517. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Divides the current Vector3 coordinates by the given ones.
  2531. * @param otherVector defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. divideInPlace(otherVector: Vector3): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2537. * @param other defines the second operand
  2538. * @returns the current updated Vector3
  2539. */
  2540. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2541. /**
  2542. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2543. * @param other defines the second operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2557. * @param x defines the x coordinate of the operand
  2558. * @param y defines the y coordinate of the operand
  2559. * @param z defines the z coordinate of the operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2563. /**
  2564. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2565. * Check if is non uniform within a certain amount of decimal places to account for this
  2566. * @param epsilon the amount the values can differ
  2567. * @returns if the the vector is non uniform to a certain number of decimal places
  2568. */
  2569. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2570. /**
  2571. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2572. */
  2573. readonly isNonUniform: boolean;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. floor(): Vector3;
  2579. /**
  2580. * Gets a new Vector3 from current Vector3 floored values
  2581. * @returns a new Vector3
  2582. */
  2583. fract(): Vector3;
  2584. /**
  2585. * Gets the length of the Vector3
  2586. * @returns the length of the Vector3
  2587. */
  2588. length(): number;
  2589. /**
  2590. * Gets the squared length of the Vector3
  2591. * @returns squared length of the Vector3
  2592. */
  2593. lengthSquared(): number;
  2594. /**
  2595. * Normalize the current Vector3.
  2596. * Please note that this is an in place operation.
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalize(): Vector3;
  2600. /**
  2601. * Reorders the x y z properties of the vector in place
  2602. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2603. * @returns the current updated vector
  2604. */
  2605. reorderInPlace(order: string): this;
  2606. /**
  2607. * Rotates the vector around 0,0,0 by a quaternion
  2608. * @param quaternion the rotation quaternion
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2613. /**
  2614. * Rotates a vector around a given point
  2615. * @param quaternion the rotation quaternion
  2616. * @param point the point to rotate around
  2617. * @param result vector to store the result
  2618. * @returns the resulting vector
  2619. */
  2620. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2621. /**
  2622. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2623. * The cross product is then orthogonal to both current and "other"
  2624. * @param other defines the right operand
  2625. * @returns the cross product
  2626. */
  2627. cross(other: Vector3): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 with the given input length.
  2630. * Please note that this is an in place operation.
  2631. * @param len the length of the vector
  2632. * @returns the current updated Vector3
  2633. */
  2634. normalizeFromLength(len: number): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to a new vector
  2637. * @returns the new Vector3
  2638. */
  2639. normalizeToNew(): Vector3;
  2640. /**
  2641. * Normalize the current Vector3 to the reference
  2642. * @param reference define the Vector3 to update
  2643. * @returns the updated Vector3
  2644. */
  2645. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Creates a new Vector3 copied from the current Vector3
  2648. * @returns the new Vector3
  2649. */
  2650. clone(): Vector3;
  2651. /**
  2652. * Copies the given vector coordinates to the current Vector3 ones
  2653. * @param source defines the source Vector3
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. copyFromFloats(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given floats to the current Vector3 coordinates
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the current updated Vector3
  2671. */
  2672. set(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Copies the given float to the current Vector3 coordinates
  2675. * @param v defines the x, y and z coordinates of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. setAll(v: number): Vector3;
  2679. /**
  2680. * Get the clip factor between two vectors
  2681. * @param vector0 defines the first operand
  2682. * @param vector1 defines the second operand
  2683. * @param axis defines the axis to use
  2684. * @param size defines the size along the axis
  2685. * @returns the clip factor
  2686. */
  2687. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2688. /**
  2689. * Get angle between two vectors
  2690. * @param vector0 angle between vector0 and vector1
  2691. * @param vector1 angle between vector0 and vector1
  2692. * @param normal direction of the normal
  2693. * @return the angle between vector0 and vector1
  2694. */
  2695. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2696. /**
  2697. * Returns a new Vector3 set from the index "offset" of the given array
  2698. * @param array defines the source array
  2699. * @param offset defines the offset in the source array
  2700. * @returns the new Vector3
  2701. */
  2702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @returns the new Vector3
  2708. * @deprecated Please use FromArray instead.
  2709. */
  2710. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2711. /**
  2712. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2713. * @param array defines the source array
  2714. * @param offset defines the offset in the source array
  2715. * @param result defines the Vector3 where to store the result
  2716. */
  2717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2720. * @param array defines the source array
  2721. * @param offset defines the offset in the source array
  2722. * @param result defines the Vector3 where to store the result
  2723. * @deprecated Please use FromArrayToRef instead.
  2724. */
  2725. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2726. /**
  2727. * Sets the given vector "result" with the given floats.
  2728. * @param x defines the x coordinate of the source
  2729. * @param y defines the y coordinate of the source
  2730. * @param z defines the z coordinate of the source
  2731. * @param result defines the Vector3 where to store the result
  2732. */
  2733. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2736. * @returns a new empty Vector3
  2737. */
  2738. static Zero(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2741. * @returns a new unit Vector3
  2742. */
  2743. static One(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2746. * @returns a new up Vector3
  2747. */
  2748. static Up(): Vector3;
  2749. /**
  2750. * Gets a up Vector3 that must not be updated
  2751. */
  2752. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2753. /**
  2754. * Gets a zero Vector3 that must not be updated
  2755. */
  2756. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2759. * @returns a new down Vector3
  2760. */
  2761. static Down(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Forward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2769. * @returns a new forward Vector3
  2770. */
  2771. static Backward(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2774. * @returns a new right Vector3
  2775. */
  2776. static Right(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2779. * @returns a new left Vector3
  2780. */
  2781. static Left(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @returns the transformed Vector3
  2788. */
  2789. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2792. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2793. * @param vector defines the Vector3 to transform
  2794. * @param transformation defines the transformation matrix
  2795. * @param result defines the Vector3 where to store the result
  2796. */
  2797. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2798. /**
  2799. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2800. * This method computes tranformed coordinates only, not transformed direction vectors
  2801. * @param x define the x coordinate of the source vector
  2802. * @param y define the y coordinate of the source vector
  2803. * @param z define the z coordinate of the source vector
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @returns the new Vector3
  2814. */
  2815. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param vector defines the Vector3 to transform
  2820. * @param transformation defines the transformation matrix
  2821. * @param result defines the Vector3 where to store the result
  2822. */
  2823. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2824. /**
  2825. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2826. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2827. * @param x define the x coordinate of the source vector
  2828. * @param y define the y coordinate of the source vector
  2829. * @param z define the z coordinate of the source vector
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2836. * @param value1 defines the first control point
  2837. * @param value2 defines the second control point
  2838. * @param value3 defines the third control point
  2839. * @param value4 defines the fourth control point
  2840. * @param amount defines the amount on the spline to use
  2841. * @returns the new Vector3
  2842. */
  2843. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2844. /**
  2845. * 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"
  2846. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2847. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2848. * @param value defines the current value
  2849. * @param min defines the lower range value
  2850. * @param max defines the upper range value
  2851. * @returns the new Vector3
  2852. */
  2853. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2864. /**
  2865. * Checks if a given vector is inside a specific range
  2866. * @param v defines the vector to test
  2867. * @param min defines the minimum range
  2868. * @param max defines the maximum range
  2869. */
  2870. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2871. /**
  2872. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2873. * @param value1 defines the first control point
  2874. * @param tangent1 defines the first tangent vector
  2875. * @param value2 defines the second control point
  2876. * @param tangent2 defines the second tangent vector
  2877. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @returns the new Vector3
  2887. */
  2888. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2891. * @param start defines the start value
  2892. * @param end defines the end value
  2893. * @param amount max defines amount between both (between 0 and 1)
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2897. /**
  2898. * Returns the dot product (float) between the vectors "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the dot product
  2902. */
  2903. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2904. /**
  2905. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @returns the cross product
  2910. */
  2911. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the cross product of "left" and "right"
  2914. * The cross product is then orthogonal to both "left" and "right"
  2915. * @param left defines the left operand
  2916. * @param right defines the right operand
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2920. /**
  2921. * Returns a new Vector3 as the normalization of the given vector
  2922. * @param vector defines the Vector3 to normalize
  2923. * @returns the new Vector3
  2924. */
  2925. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2926. /**
  2927. * Sets the given vector "result" with the normalization of the given first vector
  2928. * @param vector defines the Vector3 to normalize
  2929. * @param result defines the Vector3 where to store the result
  2930. */
  2931. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2932. /**
  2933. * Project a Vector3 onto screen space
  2934. * @param vector defines the Vector3 to project
  2935. * @param world defines the world matrix to use
  2936. * @param transform defines the transform (view x projection) matrix to use
  2937. * @param viewport defines the screen viewport to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2941. /** @hidden */
  2942. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2943. /**
  2944. * Unproject from screen space to object space
  2945. * @param source defines the screen space Vector3 to use
  2946. * @param viewportWidth defines the current width of the viewport
  2947. * @param viewportHeight defines the current height of the viewport
  2948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2949. * @param transform defines the transform (view x projection) matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param view defines the view matrix to use
  2971. * @param projection defines the projection matrix to use
  2972. * @param result defines the Vector3 where to store the result
  2973. */
  2974. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2975. /**
  2976. * Unproject from screen space to object space
  2977. * @param sourceX defines the screen space x coordinate to use
  2978. * @param sourceY defines the screen space y coordinate to use
  2979. * @param sourceZ defines the screen space z coordinate to use
  2980. * @param viewportWidth defines the current width of the viewport
  2981. * @param viewportHeight defines the current height of the viewport
  2982. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2983. * @param view defines the view matrix to use
  2984. * @param projection defines the projection matrix to use
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Gets the minimal coordinate values between two Vector3
  2990. * @param left defines the first operand
  2991. * @param right defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Gets the maximal coordinate values between two Vector3
  2997. * @param left defines the first operand
  2998. * @param right defines the second operand
  2999. * @returns the new Vector3
  3000. */
  3001. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3002. /**
  3003. * Returns the distance between the vectors "value1" and "value2"
  3004. * @param value1 defines the first operand
  3005. * @param value2 defines the second operand
  3006. * @returns the distance
  3007. */
  3008. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3009. /**
  3010. * Returns the squared distance between the vectors "value1" and "value2"
  3011. * @param value1 defines the first operand
  3012. * @param value2 defines the second operand
  3013. * @returns the squared distance
  3014. */
  3015. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3016. /**
  3017. * Returns a new Vector3 located at the center between "value1" and "value2"
  3018. * @param value1 defines the first operand
  3019. * @param value2 defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3025. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3026. * to something in order to rotate it from its local system to the given target system
  3027. * Note: axis1, axis2 and axis3 are normalized during this operation
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @returns a new Vector3
  3032. */
  3033. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3036. * @param axis1 defines the first axis
  3037. * @param axis2 defines the second axis
  3038. * @param axis3 defines the third axis
  3039. * @param ref defines the Vector3 where to store the result
  3040. */
  3041. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3042. }
  3043. /**
  3044. * Vector4 class created for EulerAngle class conversion to Quaternion
  3045. */
  3046. export class Vector4 {
  3047. /** x value of the vector */
  3048. x: number;
  3049. /** y value of the vector */
  3050. y: number;
  3051. /** z value of the vector */
  3052. z: number;
  3053. /** w value of the vector */
  3054. w: number;
  3055. /**
  3056. * Creates a Vector4 object from the given floats.
  3057. * @param x x value of the vector
  3058. * @param y y value of the vector
  3059. * @param z z value of the vector
  3060. * @param w w value of the vector
  3061. */
  3062. constructor(
  3063. /** x value of the vector */
  3064. x: number,
  3065. /** y value of the vector */
  3066. y: number,
  3067. /** z value of the vector */
  3068. z: number,
  3069. /** w value of the vector */
  3070. w: number);
  3071. /**
  3072. * Returns the string with the Vector4 coordinates.
  3073. * @returns a string containing all the vector values
  3074. */
  3075. toString(): string;
  3076. /**
  3077. * Returns the string "Vector4".
  3078. * @returns "Vector4"
  3079. */
  3080. getClassName(): string;
  3081. /**
  3082. * Returns the Vector4 hash code.
  3083. * @returns a unique hash code
  3084. */
  3085. getHashCode(): number;
  3086. /**
  3087. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3088. * @returns the resulting array
  3089. */
  3090. asArray(): number[];
  3091. /**
  3092. * Populates the given array from the given index with the Vector4 coordinates.
  3093. * @param array array to populate
  3094. * @param index index of the array to start at (default: 0)
  3095. * @returns the Vector4.
  3096. */
  3097. toArray(array: FloatArray, index?: number): Vector4;
  3098. /**
  3099. * Adds the given vector to the current Vector4.
  3100. * @param otherVector the vector to add
  3101. * @returns the updated Vector4.
  3102. */
  3103. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3104. /**
  3105. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3106. * @param otherVector the vector to add
  3107. * @returns the resulting vector
  3108. */
  3109. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3112. * @param otherVector the vector to add
  3113. * @param result the vector to store the result
  3114. * @returns the current Vector4.
  3115. */
  3116. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3117. /**
  3118. * Subtract in place the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @returns the updated Vector4.
  3121. */
  3122. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3123. /**
  3124. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3125. * @param otherVector the vector to add
  3126. * @returns the new vector with the result
  3127. */
  3128. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3131. * @param otherVector the vector to subtract
  3132. * @param result the vector to store the result
  3133. * @returns the current Vector4.
  3134. */
  3135. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. */
  3139. /**
  3140. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3141. * @param x value to subtract
  3142. * @param y value to subtract
  3143. * @param z value to subtract
  3144. * @param w value to subtract
  3145. * @returns new vector containing the result
  3146. */
  3147. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3148. /**
  3149. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3150. * @param x value to subtract
  3151. * @param y value to subtract
  3152. * @param z value to subtract
  3153. * @param w value to subtract
  3154. * @param result the vector to store the result in
  3155. * @returns the current Vector4.
  3156. */
  3157. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3160. * @returns a new vector with the negated values
  3161. */
  3162. negate(): Vector4;
  3163. /**
  3164. * Multiplies the current Vector4 coordinates by scale (float).
  3165. * @param scale the number to scale with
  3166. * @returns the updated Vector4.
  3167. */
  3168. scaleInPlace(scale: number): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns a new vector with the result
  3173. */
  3174. scale(scale: number): Vector4;
  3175. /**
  3176. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @param result a vector to store the result in
  3179. * @returns the current Vector4.
  3180. */
  3181. scaleToRef(scale: number, result: Vector4): Vector4;
  3182. /**
  3183. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3184. * @param scale defines the scale factor
  3185. * @param result defines the Vector4 object where to store the result
  3186. * @returns the unmodified current Vector4
  3187. */
  3188. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3189. /**
  3190. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3191. * @param otherVector the vector to compare against
  3192. * @returns true if they are equal
  3193. */
  3194. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3197. * @param otherVector vector to compare against
  3198. * @param epsilon (Default: very small number)
  3199. * @returns true if they are equal
  3200. */
  3201. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3202. /**
  3203. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3204. * @param x x value to compare against
  3205. * @param y y value to compare against
  3206. * @param z z value to compare against
  3207. * @param w w value to compare against
  3208. * @returns true if equal
  3209. */
  3210. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3211. /**
  3212. * Multiplies in place the current Vector4 by the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @returns the updated Vector4.
  3215. */
  3216. multiplyInPlace(otherVector: Vector4): Vector4;
  3217. /**
  3218. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns resulting new vector
  3221. */
  3222. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @param result vector to store the result
  3227. * @returns the current Vector4.
  3228. */
  3229. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3230. /**
  3231. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3232. * @param x x value multiply with
  3233. * @param y y value multiply with
  3234. * @param z z value multiply with
  3235. * @param w w value multiply with
  3236. * @returns resulting new vector
  3237. */
  3238. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3239. /**
  3240. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3241. * @param otherVector vector to devide with
  3242. * @returns resulting new vector
  3243. */
  3244. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @param result vector to store the result
  3249. * @returns the current Vector4.
  3250. */
  3251. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3252. /**
  3253. * Divides the current Vector3 coordinates by the given ones.
  3254. * @param otherVector vector to devide with
  3255. * @returns the updated Vector3.
  3256. */
  3257. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3260. * @param other defines the second operand
  3261. * @returns the current updated Vector4
  3262. */
  3263. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector4 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. floor(): Vector4;
  3275. /**
  3276. * Gets a new Vector4 from current Vector3 floored values
  3277. * @returns a new Vector4
  3278. */
  3279. fract(): Vector4;
  3280. /**
  3281. * Returns the Vector4 length (float).
  3282. * @returns the length
  3283. */
  3284. length(): number;
  3285. /**
  3286. * Returns the Vector4 squared length (float).
  3287. * @returns the length squared
  3288. */
  3289. lengthSquared(): number;
  3290. /**
  3291. * Normalizes in place the Vector4.
  3292. * @returns the updated Vector4.
  3293. */
  3294. normalize(): Vector4;
  3295. /**
  3296. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3297. * @returns this converted to a new vector3
  3298. */
  3299. toVector3(): Vector3;
  3300. /**
  3301. * Returns a new Vector4 copied from the current one.
  3302. * @returns the new cloned vector
  3303. */
  3304. clone(): Vector4;
  3305. /**
  3306. * Updates the current Vector4 with the given one coordinates.
  3307. * @param source the source vector to copy from
  3308. * @returns the updated Vector4.
  3309. */
  3310. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Updates the current Vector4 coordinates with the given floats.
  3313. * @param x float to copy from
  3314. * @param y float to copy from
  3315. * @param z float to copy from
  3316. * @param w float to copy from
  3317. * @returns the updated Vector4.
  3318. */
  3319. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3320. /**
  3321. * Updates the current Vector4 coordinates with the given floats.
  3322. * @param x float to set from
  3323. * @param y float to set from
  3324. * @param z float to set from
  3325. * @param w float to set from
  3326. * @returns the updated Vector4.
  3327. */
  3328. set(x: number, y: number, z: number, w: number): Vector4;
  3329. /**
  3330. * Copies the given float to the current Vector3 coordinates
  3331. * @param v defines the x, y, z and w coordinates of the operand
  3332. * @returns the current updated Vector3
  3333. */
  3334. setAll(v: number): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set from the starting index of the given array.
  3337. * @param array the array to pull values from
  3338. * @param offset the offset into the array to start at
  3339. * @returns the new vector
  3340. */
  3341. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3342. /**
  3343. * Updates the given vector "result" from the starting index of the given array.
  3344. * @param array the array to pull values from
  3345. * @param offset the offset into the array to start at
  3346. * @param result the vector to store the result in
  3347. */
  3348. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3349. /**
  3350. * Updates the given vector "result" from the starting index of the given Float32Array.
  3351. * @param array the array to pull values from
  3352. * @param offset the offset into the array to start at
  3353. * @param result the vector to store the result in
  3354. */
  3355. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3356. /**
  3357. * Updates the given vector "result" coordinates from the given floats.
  3358. * @param x float to set from
  3359. * @param y float to set from
  3360. * @param z float to set from
  3361. * @param w float to set from
  3362. * @param result the vector to the floats in
  3363. */
  3364. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3365. /**
  3366. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3367. * @returns the new vector
  3368. */
  3369. static Zero(): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3372. * @returns the new vector
  3373. */
  3374. static One(): Vector4;
  3375. /**
  3376. * Returns a new normalized Vector4 from the given one.
  3377. * @param vector the vector to normalize
  3378. * @returns the vector
  3379. */
  3380. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the normalization of the given one.
  3383. * @param vector the vector to normalize
  3384. * @param result the vector to store the result in
  3385. */
  3386. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3387. /**
  3388. * Returns a vector with the minimum values from the left and right vectors
  3389. * @param left left vector to minimize
  3390. * @param right right vector to minimize
  3391. * @returns a new vector with the minimum of the left and right vector values
  3392. */
  3393. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a vector with the maximum values from the left and right vectors
  3396. * @param left left vector to maximize
  3397. * @param right right vector to maximize
  3398. * @returns a new vector with the maximum of the left and right vector values
  3399. */
  3400. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3401. /**
  3402. * Returns the distance (float) between the vectors "value1" and "value2".
  3403. * @param value1 value to calulate the distance between
  3404. * @param value2 value to calulate the distance between
  3405. * @return the distance between the two vectors
  3406. */
  3407. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3408. /**
  3409. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3410. * @param value1 value to calulate the distance between
  3411. * @param value2 value to calulate the distance between
  3412. * @return the distance between the two vectors squared
  3413. */
  3414. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3415. /**
  3416. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3417. * @param value1 value to calulate the center between
  3418. * @param value2 value to calulate the center between
  3419. * @return the center between the two vectors
  3420. */
  3421. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param vector the vector to transform
  3426. * @param transformation the transformation matrix to apply
  3427. * @returns the new vector
  3428. */
  3429. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the result in
  3436. */
  3437. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param x value to transform
  3442. * @param y value to transform
  3443. * @param z value to transform
  3444. * @param w value to transform
  3445. * @param transformation the transformation matrix to apply
  3446. * @param result the vector to store the results in
  3447. */
  3448. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3449. /**
  3450. * Creates a new Vector4 from a Vector3
  3451. * @param source defines the source data
  3452. * @param w defines the 4th component (default is 0)
  3453. * @returns a new Vector4
  3454. */
  3455. static FromVector3(source: Vector3, w?: number): Vector4;
  3456. }
  3457. /**
  3458. * Class used to store quaternion data
  3459. * @see https://en.wikipedia.org/wiki/Quaternion
  3460. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3461. */
  3462. export class Quaternion {
  3463. /** defines the first component (0 by default) */
  3464. x: number;
  3465. /** defines the second component (0 by default) */
  3466. y: number;
  3467. /** defines the third component (0 by default) */
  3468. z: number;
  3469. /** defines the fourth component (1.0 by default) */
  3470. w: number;
  3471. /**
  3472. * Creates a new Quaternion from the given floats
  3473. * @param x defines the first component (0 by default)
  3474. * @param y defines the second component (0 by default)
  3475. * @param z defines the third component (0 by default)
  3476. * @param w defines the fourth component (1.0 by default)
  3477. */
  3478. constructor(
  3479. /** defines the first component (0 by default) */
  3480. x?: number,
  3481. /** defines the second component (0 by default) */
  3482. y?: number,
  3483. /** defines the third component (0 by default) */
  3484. z?: number,
  3485. /** defines the fourth component (1.0 by default) */
  3486. w?: number);
  3487. /**
  3488. * Gets a string representation for the current quaternion
  3489. * @returns a string with the Quaternion coordinates
  3490. */
  3491. toString(): string;
  3492. /**
  3493. * Gets the class name of the quaternion
  3494. * @returns the string "Quaternion"
  3495. */
  3496. getClassName(): string;
  3497. /**
  3498. * Gets a hash code for this quaternion
  3499. * @returns the quaternion hash code
  3500. */
  3501. getHashCode(): number;
  3502. /**
  3503. * Copy the quaternion to an array
  3504. * @returns a new array populated with 4 elements from the quaternion coordinates
  3505. */
  3506. asArray(): number[];
  3507. /**
  3508. * Check if two quaternions are equals
  3509. * @param otherQuaternion defines the second operand
  3510. * @return true if the current quaternion and the given one coordinates are strictly equals
  3511. */
  3512. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3513. /**
  3514. * Clone the current quaternion
  3515. * @returns a new quaternion copied from the current one
  3516. */
  3517. clone(): Quaternion;
  3518. /**
  3519. * Copy a quaternion to the current one
  3520. * @param other defines the other quaternion
  3521. * @returns the updated current quaternion
  3522. */
  3523. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Updates the current quaternion with the given float coordinates
  3526. * @param x defines the x coordinate
  3527. * @param y defines the y coordinate
  3528. * @param z defines the z coordinate
  3529. * @param w defines the w coordinate
  3530. * @returns the updated current quaternion
  3531. */
  3532. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3533. /**
  3534. * Updates the current quaternion from the given float coordinates
  3535. * @param x defines the x coordinate
  3536. * @param y defines the y coordinate
  3537. * @param z defines the z coordinate
  3538. * @param w defines the w coordinate
  3539. * @returns the updated current quaternion
  3540. */
  3541. set(x: number, y: number, z: number, w: number): Quaternion;
  3542. /**
  3543. * Adds two quaternions
  3544. * @param other defines the second operand
  3545. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3546. */
  3547. add(other: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Add a quaternion to the current one
  3550. * @param other defines the quaternion to add
  3551. * @returns the current quaternion
  3552. */
  3553. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Subtract two quaternions
  3556. * @param other defines the second operand
  3557. * @returns a new quaternion as the subtraction result of the given one from the current one
  3558. */
  3559. subtract(other: Quaternion): Quaternion;
  3560. /**
  3561. * Multiplies the current quaternion by a scale factor
  3562. * @param value defines the scale factor
  3563. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3564. */
  3565. scale(value: number): Quaternion;
  3566. /**
  3567. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3568. * @param scale defines the scale factor
  3569. * @param result defines the Quaternion object where to store the result
  3570. * @returns the unmodified current quaternion
  3571. */
  3572. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies in place the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns the current modified quaternion
  3577. */
  3578. scaleInPlace(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies two quaternions
  3588. * @param q1 defines the second operand
  3589. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3590. */
  3591. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3592. /**
  3593. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3594. * @param q1 defines the second operand
  3595. * @param result defines the target quaternion
  3596. * @returns the current quaternion
  3597. */
  3598. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3599. /**
  3600. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3601. * @param q1 defines the second operand
  3602. * @returns the currentupdated quaternion
  3603. */
  3604. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3607. * @param ref defines the target quaternion
  3608. * @returns the current quaternion
  3609. */
  3610. conjugateToRef(ref: Quaternion): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns the current updated quaternion
  3614. */
  3615. conjugateInPlace(): Quaternion;
  3616. /**
  3617. * Conjugates in place (1-q) the current quaternion
  3618. * @returns a new quaternion
  3619. */
  3620. conjugate(): Quaternion;
  3621. /**
  3622. * Gets length of current quaternion
  3623. * @returns the quaternion length (float)
  3624. */
  3625. length(): number;
  3626. /**
  3627. * Normalize in place the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. normalize(): Quaternion;
  3631. /**
  3632. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3633. * @param order is a reserved parameter and is ignore for now
  3634. * @returns a new Vector3 containing the Euler angles
  3635. */
  3636. toEulerAngles(order?: string): Vector3;
  3637. /**
  3638. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3639. * @param result defines the vector which will be filled with the Euler angles
  3640. * @param order is a reserved parameter and is ignore for now
  3641. * @returns the current unchanged quaternion
  3642. */
  3643. toEulerAnglesToRef(result: Vector3): Quaternion;
  3644. /**
  3645. * Updates the given rotation matrix with the current quaternion values
  3646. * @param result defines the target matrix
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toRotationMatrix(result: Matrix): Quaternion;
  3650. /**
  3651. * Updates the current quaternion from the given rotation matrix values
  3652. * @param matrix defines the source matrix
  3653. * @returns the current updated quaternion
  3654. */
  3655. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3656. /**
  3657. * Creates a new quaternion from a rotation matrix
  3658. * @param matrix defines the source matrix
  3659. * @returns a new quaternion created from the given rotation matrix values
  3660. */
  3661. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Updates the given quaternion with the given rotation matrix values
  3664. * @param matrix defines the source matrix
  3665. * @param result defines the target quaternion
  3666. */
  3667. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3668. /**
  3669. * Returns the dot product (float) between the quaternions "left" and "right"
  3670. * @param left defines the left operand
  3671. * @param right defines the right operand
  3672. * @returns the dot product
  3673. */
  3674. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3675. /**
  3676. * Checks if the two quaternions are close to each other
  3677. * @param quat0 defines the first quaternion to check
  3678. * @param quat1 defines the second quaternion to check
  3679. * @returns true if the two quaternions are close to each other
  3680. */
  3681. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3682. /**
  3683. * Creates an empty quaternion
  3684. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3685. */
  3686. static Zero(): Quaternion;
  3687. /**
  3688. * Inverse a given quaternion
  3689. * @param q defines the source quaternion
  3690. * @returns a new quaternion as the inverted current quaternion
  3691. */
  3692. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @param result the quaternion the result will be stored in
  3697. * @returns the result quaternion
  3698. */
  3699. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3700. /**
  3701. * Creates an identity quaternion
  3702. * @returns the identity quaternion
  3703. */
  3704. static Identity(): Quaternion;
  3705. /**
  3706. * Gets a boolean indicating if the given quaternion is identity
  3707. * @param quaternion defines the quaternion to check
  3708. * @returns true if the quaternion is identity
  3709. */
  3710. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3711. /**
  3712. * Creates a quaternion from a rotation around an axis
  3713. * @param axis defines the axis to use
  3714. * @param angle defines the angle to use
  3715. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3716. */
  3717. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3718. /**
  3719. * Creates a rotation around an axis and stores it into the given quaternion
  3720. * @param axis defines the axis to use
  3721. * @param angle defines the angle to use
  3722. * @param result defines the target quaternion
  3723. * @returns the target quaternion
  3724. */
  3725. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from data stored into an array
  3728. * @param array defines the data source
  3729. * @param offset defines the offset in the source array where the data starts
  3730. * @returns a new quaternion
  3731. */
  3732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3733. /**
  3734. * Create a quaternion from Euler rotation angles
  3735. * @param x Pitch
  3736. * @param y Yaw
  3737. * @param z Roll
  3738. * @returns the new Quaternion
  3739. */
  3740. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3741. /**
  3742. * Updates a quaternion from Euler rotation angles
  3743. * @param x Pitch
  3744. * @param y Yaw
  3745. * @param z Roll
  3746. * @param result the quaternion to store the result
  3747. * @returns the updated quaternion
  3748. */
  3749. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3750. /**
  3751. * Create a quaternion from Euler rotation vector
  3752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3753. * @returns the new Quaternion
  3754. */
  3755. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3756. /**
  3757. * Updates a quaternion from Euler rotation vector
  3758. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3763. /**
  3764. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3765. * @param yaw defines the rotation around Y axis
  3766. * @param pitch defines the rotation around X axis
  3767. * @param roll defines the rotation around Z axis
  3768. * @returns the new quaternion
  3769. */
  3770. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3771. /**
  3772. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3773. * @param yaw defines the rotation around Y axis
  3774. * @param pitch defines the rotation around X axis
  3775. * @param roll defines the rotation around Z axis
  3776. * @param result defines the target quaternion
  3777. */
  3778. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3779. /**
  3780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3781. * @param alpha defines the rotation around first axis
  3782. * @param beta defines the rotation around second axis
  3783. * @param gamma defines the rotation around third axis
  3784. * @returns the new quaternion
  3785. */
  3786. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3789. * @param alpha defines the rotation around first axis
  3790. * @param beta defines the rotation around second axis
  3791. * @param gamma defines the rotation around third axis
  3792. * @param result defines the target quaternion
  3793. */
  3794. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3795. /**
  3796. * 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)
  3797. * @param axis1 defines the first axis
  3798. * @param axis2 defines the second axis
  3799. * @param axis3 defines the third axis
  3800. * @returns the new quaternion
  3801. */
  3802. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3803. /**
  3804. * 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
  3805. * @param axis1 defines the first axis
  3806. * @param axis2 defines the second axis
  3807. * @param axis3 defines the third axis
  3808. * @param ref defines the target quaternion
  3809. */
  3810. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3811. /**
  3812. * Interpolates between two quaternions
  3813. * @param left defines first quaternion
  3814. * @param right defines second quaternion
  3815. * @param amount defines the gradient to use
  3816. * @returns the new interpolated quaternion
  3817. */
  3818. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3819. /**
  3820. * Interpolates between two quaternions and stores it into a target quaternion
  3821. * @param left defines first quaternion
  3822. * @param right defines second quaternion
  3823. * @param amount defines the gradient to use
  3824. * @param result defines the target quaternion
  3825. */
  3826. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3827. /**
  3828. * Interpolate between two quaternions using Hermite interpolation
  3829. * @param value1 defines first quaternion
  3830. * @param tangent1 defines the incoming tangent
  3831. * @param value2 defines second quaternion
  3832. * @param tangent2 defines the outgoing tangent
  3833. * @param amount defines the target quaternion
  3834. * @returns the new interpolated quaternion
  3835. */
  3836. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3837. }
  3838. /**
  3839. * Class used to store matrix data (4x4)
  3840. */
  3841. export class Matrix {
  3842. private static _updateFlagSeed;
  3843. private static _identityReadOnly;
  3844. private _isIdentity;
  3845. private _isIdentityDirty;
  3846. private _isIdentity3x2;
  3847. private _isIdentity3x2Dirty;
  3848. /**
  3849. * Gets the update flag of the matrix which is an unique number for the matrix.
  3850. * It will be incremented every time the matrix data change.
  3851. * You can use it to speed the comparison between two versions of the same matrix.
  3852. */
  3853. updateFlag: number;
  3854. private readonly _m;
  3855. /**
  3856. * Gets the internal data of the matrix
  3857. */
  3858. readonly m: DeepImmutable<Float32Array>;
  3859. /** @hidden */
  3860. _markAsUpdated(): void;
  3861. /** @hidden */
  3862. private _updateIdentityStatus;
  3863. /**
  3864. * Creates an empty matrix (filled with zeros)
  3865. */
  3866. constructor();
  3867. /**
  3868. * Check if the current matrix is identity
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentity(): boolean;
  3872. /**
  3873. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3874. * @returns true is the matrix is the identity matrix
  3875. */
  3876. isIdentityAs3x2(): boolean;
  3877. /**
  3878. * Gets the determinant of the matrix
  3879. * @returns the matrix determinant
  3880. */
  3881. determinant(): number;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array
  3885. */
  3886. toArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Returns the matrix as a Float32Array
  3889. * @returns the matrix underlying array.
  3890. */
  3891. asArray(): DeepImmutable<Float32Array>;
  3892. /**
  3893. * Inverts the current matrix in place
  3894. * @returns the current inverted matrix
  3895. */
  3896. invert(): Matrix;
  3897. /**
  3898. * Sets all the matrix elements to zero
  3899. * @returns the current matrix
  3900. */
  3901. reset(): Matrix;
  3902. /**
  3903. * Adds the current matrix with a second one
  3904. * @param other defines the matrix to add
  3905. * @returns a new matrix as the addition of the current matrix and the given one
  3906. */
  3907. add(other: DeepImmutable<Matrix>): Matrix;
  3908. /**
  3909. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3910. * @param other defines the matrix to add
  3911. * @param result defines the target matrix
  3912. * @returns the current matrix
  3913. */
  3914. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3915. /**
  3916. * Adds in place the given matrix to the current matrix
  3917. * @param other defines the second operand
  3918. * @returns the current updated matrix
  3919. */
  3920. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix to the current inverted Matrix
  3923. * @param other defines the target matrix
  3924. * @returns the unmodified current matrix
  3925. */
  3926. invertToRef(other: Matrix): Matrix;
  3927. /**
  3928. * add a value at the specified position in the current Matrix
  3929. * @param index the index of the value within the matrix. between 0 and 15.
  3930. * @param value the value to be added
  3931. * @returns the current updated matrix
  3932. */
  3933. addAtIndex(index: number, value: number): Matrix;
  3934. /**
  3935. * mutiply the specified position in the current Matrix by a value
  3936. * @param index the index of the value within the matrix. between 0 and 15.
  3937. * @param value the value to be added
  3938. * @returns the current updated matrix
  3939. */
  3940. multiplyAtIndex(index: number, value: number): Matrix;
  3941. /**
  3942. * Inserts the translation vector (using 3 floats) in the current matrix
  3943. * @param x defines the 1st component of the translation
  3944. * @param y defines the 2nd component of the translation
  3945. * @param z defines the 3rd component of the translation
  3946. * @returns the current updated matrix
  3947. */
  3948. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3949. /**
  3950. * Adds the translation vector (using 3 floats) in the current matrix
  3951. * @param x defines the 1st component of the translation
  3952. * @param y defines the 2nd component of the translation
  3953. * @param z defines the 3rd component of the translation
  3954. * @returns the current updated matrix
  3955. */
  3956. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3957. /**
  3958. * Inserts the translation vector in the current matrix
  3959. * @param vector3 defines the translation to insert
  3960. * @returns the current updated matrix
  3961. */
  3962. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3963. /**
  3964. * Gets the translation value of the current matrix
  3965. * @returns a new Vector3 as the extracted translation from the matrix
  3966. */
  3967. getTranslation(): Vector3;
  3968. /**
  3969. * Fill a Vector3 with the extracted translation from the matrix
  3970. * @param result defines the Vector3 where to store the translation
  3971. * @returns the current matrix
  3972. */
  3973. getTranslationToRef(result: Vector3): Matrix;
  3974. /**
  3975. * Remove rotation and scaling part from the matrix
  3976. * @returns the updated matrix
  3977. */
  3978. removeRotationAndScaling(): Matrix;
  3979. /**
  3980. * Multiply two matrices
  3981. * @param other defines the second operand
  3982. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3983. */
  3984. multiply(other: DeepImmutable<Matrix>): Matrix;
  3985. /**
  3986. * Copy the current matrix from the given one
  3987. * @param other defines the source matrix
  3988. * @returns the current updated matrix
  3989. */
  3990. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3991. /**
  3992. * Populates the given array from the starting index with the current matrix values
  3993. * @param array defines the target array
  3994. * @param offset defines the offset in the target array where to start storing values
  3995. * @returns the current matrix
  3996. */
  3997. copyToArray(array: Float32Array, offset?: number): Matrix;
  3998. /**
  3999. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4000. * @param other defines the second operand
  4001. * @param result defines the matrix where to store the multiplication
  4002. * @returns the current matrix
  4003. */
  4004. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4005. /**
  4006. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4007. * @param other defines the second operand
  4008. * @param result defines the array where to store the multiplication
  4009. * @param offset defines the offset in the target array where to start storing values
  4010. * @returns the current matrix
  4011. */
  4012. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4013. /**
  4014. * Check equality between this matrix and a second one
  4015. * @param value defines the second matrix to compare
  4016. * @returns true is the current matrix and the given one values are strictly equal
  4017. */
  4018. equals(value: DeepImmutable<Matrix>): boolean;
  4019. /**
  4020. * Clone the current matrix
  4021. * @returns a new matrix from the current matrix
  4022. */
  4023. clone(): Matrix;
  4024. /**
  4025. * Returns the name of the current matrix class
  4026. * @returns the string "Matrix"
  4027. */
  4028. getClassName(): string;
  4029. /**
  4030. * Gets the hash code of the current matrix
  4031. * @returns the hash code
  4032. */
  4033. getHashCode(): number;
  4034. /**
  4035. * Decomposes the current Matrix into a translation, rotation and scaling components
  4036. * @param scale defines the scale vector3 given as a reference to update
  4037. * @param rotation defines the rotation quaternion given as a reference to update
  4038. * @param translation defines the translation vector3 given as a reference to update
  4039. * @returns true if operation was successful
  4040. */
  4041. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4042. /**
  4043. * Gets specific row of the matrix
  4044. * @param index defines the number of the row to get
  4045. * @returns the index-th row of the current matrix as a new Vector4
  4046. */
  4047. getRow(index: number): Nullable<Vector4>;
  4048. /**
  4049. * Sets the index-th row of the current matrix to the vector4 values
  4050. * @param index defines the number of the row to set
  4051. * @param row defines the target vector4
  4052. * @returns the updated current matrix
  4053. */
  4054. setRow(index: number, row: Vector4): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix
  4057. * @returns the new transposed matrix
  4058. */
  4059. transpose(): Matrix;
  4060. /**
  4061. * Compute the transpose of the matrix and store it in a given matrix
  4062. * @param result defines the target matrix
  4063. * @returns the current matrix
  4064. */
  4065. transposeToRef(result: Matrix): Matrix;
  4066. /**
  4067. * Sets the index-th row of the current matrix with the given 4 x float values
  4068. * @param index defines the row index
  4069. * @param x defines the x component to set
  4070. * @param y defines the y component to set
  4071. * @param z defines the z component to set
  4072. * @param w defines the w component to set
  4073. * @returns the updated current matrix
  4074. */
  4075. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4076. /**
  4077. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4078. * @param scale defines the scale factor
  4079. * @returns a new matrix
  4080. */
  4081. scale(scale: number): Matrix;
  4082. /**
  4083. * Scale the current matrix values by a factor to a given result matrix
  4084. * @param scale defines the scale factor
  4085. * @param result defines the matrix to store the result
  4086. * @returns the current matrix
  4087. */
  4088. scaleToRef(scale: number, result: Matrix): Matrix;
  4089. /**
  4090. * Scale the current matrix values by a factor and add the result to a given matrix
  4091. * @param scale defines the scale factor
  4092. * @param result defines the Matrix to store the result
  4093. * @returns the current matrix
  4094. */
  4095. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4096. /**
  4097. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4098. * @param ref matrix to store the result
  4099. */
  4100. toNormalMatrix(ref: Matrix): void;
  4101. /**
  4102. * Gets only rotation part of the current matrix
  4103. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4104. */
  4105. getRotationMatrix(): Matrix;
  4106. /**
  4107. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4108. * @param result defines the target matrix to store data to
  4109. * @returns the current matrix
  4110. */
  4111. getRotationMatrixToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Toggles model matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleModelMatrixHandInPlace(): void;
  4116. /**
  4117. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4118. */
  4119. toggleProjectionMatrixHandInPlace(): void;
  4120. /**
  4121. * Creates a matrix from an array
  4122. * @param array defines the source array
  4123. * @param offset defines an offset in the source array
  4124. * @returns a new Matrix set from the starting index of the given array
  4125. */
  4126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4127. /**
  4128. * Copy the content of an array into a given matrix
  4129. * @param array defines the source array
  4130. * @param offset defines an offset in the source array
  4131. * @param result defines the target matrix
  4132. */
  4133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4134. /**
  4135. * Stores an array into a matrix after having multiplied each component by a given factor
  4136. * @param array defines the source array
  4137. * @param offset defines the offset in the source array
  4138. * @param scale defines the scaling factor
  4139. * @param result defines the target matrix
  4140. */
  4141. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4142. /**
  4143. * Gets an identity matrix that must not be updated
  4144. */
  4145. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4146. /**
  4147. * Stores a list of values (16) inside a given matrix
  4148. * @param initialM11 defines 1st value of 1st row
  4149. * @param initialM12 defines 2nd value of 1st row
  4150. * @param initialM13 defines 3rd value of 1st row
  4151. * @param initialM14 defines 4th value of 1st row
  4152. * @param initialM21 defines 1st value of 2nd row
  4153. * @param initialM22 defines 2nd value of 2nd row
  4154. * @param initialM23 defines 3rd value of 2nd row
  4155. * @param initialM24 defines 4th value of 2nd row
  4156. * @param initialM31 defines 1st value of 3rd row
  4157. * @param initialM32 defines 2nd value of 3rd row
  4158. * @param initialM33 defines 3rd value of 3rd row
  4159. * @param initialM34 defines 4th value of 3rd row
  4160. * @param initialM41 defines 1st value of 4th row
  4161. * @param initialM42 defines 2nd value of 4th row
  4162. * @param initialM43 defines 3rd value of 4th row
  4163. * @param initialM44 defines 4th value of 4th row
  4164. * @param result defines the target matrix
  4165. */
  4166. 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;
  4167. /**
  4168. * Creates new matrix from a list of values (16)
  4169. * @param initialM11 defines 1st value of 1st row
  4170. * @param initialM12 defines 2nd value of 1st row
  4171. * @param initialM13 defines 3rd value of 1st row
  4172. * @param initialM14 defines 4th value of 1st row
  4173. * @param initialM21 defines 1st value of 2nd row
  4174. * @param initialM22 defines 2nd value of 2nd row
  4175. * @param initialM23 defines 3rd value of 2nd row
  4176. * @param initialM24 defines 4th value of 2nd row
  4177. * @param initialM31 defines 1st value of 3rd row
  4178. * @param initialM32 defines 2nd value of 3rd row
  4179. * @param initialM33 defines 3rd value of 3rd row
  4180. * @param initialM34 defines 4th value of 3rd row
  4181. * @param initialM41 defines 1st value of 4th row
  4182. * @param initialM42 defines 2nd value of 4th row
  4183. * @param initialM43 defines 3rd value of 4th row
  4184. * @param initialM44 defines 4th value of 4th row
  4185. * @returns the new matrix
  4186. */
  4187. 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;
  4188. /**
  4189. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4190. * @param scale defines the scale vector3
  4191. * @param rotation defines the rotation quaternion
  4192. * @param translation defines the translation vector3
  4193. * @returns a new matrix
  4194. */
  4195. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4196. /**
  4197. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4198. * @param scale defines the scale vector3
  4199. * @param rotation defines the rotation quaternion
  4200. * @param translation defines the translation vector3
  4201. * @param result defines the target matrix
  4202. */
  4203. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4204. /**
  4205. * Creates a new identity matrix
  4206. * @returns a new identity matrix
  4207. */
  4208. static Identity(): Matrix;
  4209. /**
  4210. * Creates a new identity matrix and stores the result in a given matrix
  4211. * @param result defines the target matrix
  4212. */
  4213. static IdentityToRef(result: Matrix): void;
  4214. /**
  4215. * Creates a new zero matrix
  4216. * @returns a new zero matrix
  4217. */
  4218. static Zero(): Matrix;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the X axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationX(angle: number): Matrix;
  4225. /**
  4226. * Creates a new matrix as the invert of a given matrix
  4227. * @param source defines the source matrix
  4228. * @returns the new matrix
  4229. */
  4230. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4233. * @param angle defines the angle (in radians) to use
  4234. * @param result defines the target matrix
  4235. */
  4236. static RotationXToRef(angle: number, result: Matrix): void;
  4237. /**
  4238. * Creates a new rotation matrix for "angle" radians around the Y axis
  4239. * @param angle defines the angle (in radians) to use
  4240. * @return the new matrix
  4241. */
  4242. static RotationY(angle: number): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4245. * @param angle defines the angle (in radians) to use
  4246. * @param result defines the target matrix
  4247. */
  4248. static RotationYToRef(angle: number, result: Matrix): void;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the Z axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationZ(angle: number): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationZToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the given axis
  4263. * @param axis defines the axis to use
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4270. * @param axis defines the axis to use
  4271. * @param angle defines the angle (in radians) to use
  4272. * @param result defines the target matrix
  4273. */
  4274. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4275. /**
  4276. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4277. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4278. * @param from defines the vector to align
  4279. * @param to defines the vector to align to
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4283. /**
  4284. * Creates a rotation matrix
  4285. * @param yaw defines the yaw angle in radians (Y axis)
  4286. * @param pitch defines the pitch angle in radians (X axis)
  4287. * @param roll defines the roll angle in radians (X axis)
  4288. * @returns the new rotation matrix
  4289. */
  4290. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4291. /**
  4292. * Creates a rotation matrix and stores it in a given matrix
  4293. * @param yaw defines the yaw angle in radians (Y axis)
  4294. * @param pitch defines the pitch angle in radians (X axis)
  4295. * @param roll defines the roll angle in radians (X axis)
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4299. /**
  4300. * Creates a scaling matrix
  4301. * @param x defines the scale factor on X axis
  4302. * @param y defines the scale factor on Y axis
  4303. * @param z defines the scale factor on Z axis
  4304. * @returns the new matrix
  4305. */
  4306. static Scaling(x: number, y: number, z: number): Matrix;
  4307. /**
  4308. * Creates a scaling matrix and stores it in a given matrix
  4309. * @param x defines the scale factor on X axis
  4310. * @param y defines the scale factor on Y axis
  4311. * @param z defines the scale factor on Z axis
  4312. * @param result defines the target matrix
  4313. */
  4314. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4315. /**
  4316. * Creates a translation matrix
  4317. * @param x defines the translation on X axis
  4318. * @param y defines the translation on Y axis
  4319. * @param z defines the translationon Z axis
  4320. * @returns the new matrix
  4321. */
  4322. static Translation(x: number, y: number, z: number): Matrix;
  4323. /**
  4324. * Creates a translation matrix and stores it in a given matrix
  4325. * @param x defines the translation on X axis
  4326. * @param y defines the translation on Y axis
  4327. * @param z defines the translationon Z axis
  4328. * @param result defines the target matrix
  4329. */
  4330. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4331. /**
  4332. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4333. * @param startValue defines the start value
  4334. * @param endValue defines the end value
  4335. * @param gradient defines the gradient factor
  4336. * @returns the new matrix
  4337. */
  4338. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4339. /**
  4340. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4341. * @param startValue defines the start value
  4342. * @param endValue defines the end value
  4343. * @param gradient defines the gradient factor
  4344. * @param result defines the Matrix object where to store data
  4345. */
  4346. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4347. /**
  4348. * Builds a new matrix whose values are computed by:
  4349. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4350. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4351. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4352. * @param startValue defines the first matrix
  4353. * @param endValue defines the second matrix
  4354. * @param gradient defines the gradient between the two matrices
  4355. * @returns the new matrix
  4356. */
  4357. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4358. /**
  4359. * Update a matrix to values which are computed by:
  4360. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4361. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4362. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4363. * @param startValue defines the first matrix
  4364. * @param endValue defines the second matrix
  4365. * @param gradient defines the gradient between the two matrices
  4366. * @param result defines the target matrix
  4367. */
  4368. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * 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"
  4371. * This function works in left handed mode
  4372. * @param eye defines the final position of the entity
  4373. * @param target defines where the entity should look at
  4374. * @param up defines the up vector for the entity
  4375. * @returns the new matrix
  4376. */
  4377. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * 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".
  4380. * This function works in left handed mode
  4381. * @param eye defines the final position of the entity
  4382. * @param target defines where the entity should look at
  4383. * @param up defines the up vector for the entity
  4384. * @param result defines the target matrix
  4385. */
  4386. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4387. /**
  4388. * 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"
  4389. * This function works in right handed mode
  4390. * @param eye defines the final position of the entity
  4391. * @param target defines where the entity should look at
  4392. * @param up defines the up vector for the entity
  4393. * @returns the new matrix
  4394. */
  4395. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4396. /**
  4397. * 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".
  4398. * This function works in right handed mode
  4399. * @param eye defines the final position of the entity
  4400. * @param target defines where the entity should look at
  4401. * @param up defines the up vector for the entity
  4402. * @param result defines the target matrix
  4403. */
  4404. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4405. /**
  4406. * Create a left-handed orthographic projection matrix
  4407. * @param width defines the viewport width
  4408. * @param height defines the viewport height
  4409. * @param znear defines the near clip plane
  4410. * @param zfar defines the far clip plane
  4411. * @returns a new matrix as a left-handed orthographic projection matrix
  4412. */
  4413. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4414. /**
  4415. * Store a left-handed orthographic projection to a given matrix
  4416. * @param width defines the viewport width
  4417. * @param height defines the viewport height
  4418. * @param znear defines the near clip plane
  4419. * @param zfar defines the far clip plane
  4420. * @param result defines the target matrix
  4421. */
  4422. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4423. /**
  4424. * Create a left-handed orthographic projection matrix
  4425. * @param left defines the viewport left coordinate
  4426. * @param right defines the viewport right coordinate
  4427. * @param bottom defines the viewport bottom coordinate
  4428. * @param top defines the viewport top coordinate
  4429. * @param znear defines the near clip plane
  4430. * @param zfar defines the far clip plane
  4431. * @returns a new matrix as a left-handed orthographic projection matrix
  4432. */
  4433. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4434. /**
  4435. * Stores a left-handed orthographic projection into a given matrix
  4436. * @param left defines the viewport left coordinate
  4437. * @param right defines the viewport right coordinate
  4438. * @param bottom defines the viewport bottom coordinate
  4439. * @param top defines the viewport top coordinate
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Creates a right-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a right-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a right-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a left-handed perspective projection matrix
  4469. * @param width defines the viewport width
  4470. * @param height defines the viewport height
  4471. * @param znear defines the near clip plane
  4472. * @param zfar defines the far clip plane
  4473. * @returns a new matrix as a left-handed perspective projection matrix
  4474. */
  4475. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4476. /**
  4477. * Creates a left-handed perspective projection matrix
  4478. * @param fov defines the horizontal field of view
  4479. * @param aspect defines the aspect ratio
  4480. * @param znear defines the near clip plane
  4481. * @param zfar defines the far clip plane
  4482. * @returns a new matrix as a left-handed perspective projection matrix
  4483. */
  4484. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4485. /**
  4486. * Stores a left-handed perspective projection into a given matrix
  4487. * @param fov defines the horizontal field of view
  4488. * @param aspect defines the aspect ratio
  4489. * @param znear defines the near clip plane
  4490. * @param zfar defines the far clip plane
  4491. * @param result defines the target matrix
  4492. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4493. */
  4494. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4495. /**
  4496. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4497. * @param fov defines the horizontal field of view
  4498. * @param aspect defines the aspect ratio
  4499. * @param znear defines the near clip plane
  4500. * @param zfar not used as infinity is used as far clip
  4501. * @param result defines the target matrix
  4502. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4503. */
  4504. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4505. /**
  4506. * Creates a right-handed perspective projection matrix
  4507. * @param fov defines the horizontal field of view
  4508. * @param aspect defines the aspect ratio
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @returns a new matrix as a right-handed perspective projection matrix
  4512. */
  4513. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4514. /**
  4515. * Stores a right-handed perspective projection into a given matrix
  4516. * @param fov defines the horizontal field of view
  4517. * @param aspect defines the aspect ratio
  4518. * @param znear defines the near clip plane
  4519. * @param zfar defines the far clip plane
  4520. * @param result defines the target matrix
  4521. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4522. */
  4523. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4524. /**
  4525. * Stores a right-handed perspective projection into a given matrix
  4526. * @param fov defines the horizontal field of view
  4527. * @param aspect defines the aspect ratio
  4528. * @param znear defines the near clip plane
  4529. * @param zfar not used as infinity is used as far clip
  4530. * @param result defines the target matrix
  4531. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4532. */
  4533. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4534. /**
  4535. * Stores a perspective projection for WebVR info a given matrix
  4536. * @param fov defines the field of view
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @param result defines the target matrix
  4540. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4541. */
  4542. static PerspectiveFovWebVRToRef(fov: {
  4543. upDegrees: number;
  4544. downDegrees: number;
  4545. leftDegrees: number;
  4546. rightDegrees: number;
  4547. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4548. /**
  4549. * Computes a complete transformation matrix
  4550. * @param viewport defines the viewport to use
  4551. * @param world defines the world matrix
  4552. * @param view defines the view matrix
  4553. * @param projection defines the projection matrix
  4554. * @param zmin defines the near clip plane
  4555. * @param zmax defines the far clip plane
  4556. * @returns the transformation matrix
  4557. */
  4558. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4559. /**
  4560. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4561. * @param matrix defines the matrix to use
  4562. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4563. */
  4564. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4565. /**
  4566. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4567. * @param matrix defines the matrix to use
  4568. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4569. */
  4570. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4571. /**
  4572. * Compute the transpose of a given matrix
  4573. * @param matrix defines the matrix to transpose
  4574. * @returns the new matrix
  4575. */
  4576. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4577. /**
  4578. * Compute the transpose of a matrix and store it in a target matrix
  4579. * @param matrix defines the matrix to transpose
  4580. * @param result defines the target matrix
  4581. */
  4582. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4583. /**
  4584. * Computes a reflection matrix from a plane
  4585. * @param plane defines the reflection plane
  4586. * @returns a new matrix
  4587. */
  4588. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4589. /**
  4590. * Computes a reflection matrix from a plane
  4591. * @param plane defines the reflection plane
  4592. * @param result defines the target matrix
  4593. */
  4594. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4595. /**
  4596. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4597. * @param xaxis defines the value of the 1st axis
  4598. * @param yaxis defines the value of the 2nd axis
  4599. * @param zaxis defines the value of the 3rd axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4603. /**
  4604. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4605. * @param quat defines the quaternion to use
  4606. * @param result defines the target matrix
  4607. */
  4608. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4609. }
  4610. /**
  4611. * @hidden
  4612. */
  4613. export class TmpVectors {
  4614. static Vector2: Vector2[];
  4615. static Vector3: Vector3[];
  4616. static Vector4: Vector4[];
  4617. static Quaternion: Quaternion[];
  4618. static Matrix: Matrix[];
  4619. }
  4620. }
  4621. declare module "babylonjs/Maths/math.path" {
  4622. import { DeepImmutable, Nullable } from "babylonjs/types";
  4623. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4624. /**
  4625. * Defines potential orientation for back face culling
  4626. */
  4627. export enum Orientation {
  4628. /**
  4629. * Clockwise
  4630. */
  4631. CW = 0,
  4632. /** Counter clockwise */
  4633. CCW = 1
  4634. }
  4635. /** Class used to represent a Bezier curve */
  4636. export class BezierCurve {
  4637. /**
  4638. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4639. * @param t defines the time
  4640. * @param x1 defines the left coordinate on X axis
  4641. * @param y1 defines the left coordinate on Y axis
  4642. * @param x2 defines the right coordinate on X axis
  4643. * @param y2 defines the right coordinate on Y axis
  4644. * @returns the interpolated value
  4645. */
  4646. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4647. }
  4648. /**
  4649. * Defines angle representation
  4650. */
  4651. export class Angle {
  4652. private _radians;
  4653. /**
  4654. * Creates an Angle object of "radians" radians (float).
  4655. * @param radians the angle in radians
  4656. */
  4657. constructor(radians: number);
  4658. /**
  4659. * Get value in degrees
  4660. * @returns the Angle value in degrees (float)
  4661. */
  4662. degrees(): number;
  4663. /**
  4664. * Get value in radians
  4665. * @returns the Angle value in radians (float)
  4666. */
  4667. radians(): number;
  4668. /**
  4669. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4670. * @param a defines first vector
  4671. * @param b defines second vector
  4672. * @returns a new Angle
  4673. */
  4674. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in radians
  4677. * @param radians defines the angle value in radians
  4678. * @returns a new Angle
  4679. */
  4680. static FromRadians(radians: number): Angle;
  4681. /**
  4682. * Gets a new Angle object from the given float in degrees
  4683. * @param degrees defines the angle value in degrees
  4684. * @returns a new Angle
  4685. */
  4686. static FromDegrees(degrees: number): Angle;
  4687. }
  4688. /**
  4689. * This represents an arc in a 2d space.
  4690. */
  4691. export class Arc2 {
  4692. /** Defines the start point of the arc */
  4693. startPoint: Vector2;
  4694. /** Defines the mid point of the arc */
  4695. midPoint: Vector2;
  4696. /** Defines the end point of the arc */
  4697. endPoint: Vector2;
  4698. /**
  4699. * Defines the center point of the arc.
  4700. */
  4701. centerPoint: Vector2;
  4702. /**
  4703. * Defines the radius of the arc.
  4704. */
  4705. radius: number;
  4706. /**
  4707. * Defines the angle of the arc (from mid point to end point).
  4708. */
  4709. angle: Angle;
  4710. /**
  4711. * Defines the start angle of the arc (from start point to middle point).
  4712. */
  4713. startAngle: Angle;
  4714. /**
  4715. * Defines the orientation of the arc (clock wise/counter clock wise).
  4716. */
  4717. orientation: Orientation;
  4718. /**
  4719. * Creates an Arc object from the three given points : start, middle and end.
  4720. * @param startPoint Defines the start point of the arc
  4721. * @param midPoint Defines the midlle point of the arc
  4722. * @param endPoint Defines the end point of the arc
  4723. */
  4724. constructor(
  4725. /** Defines the start point of the arc */
  4726. startPoint: Vector2,
  4727. /** Defines the mid point of the arc */
  4728. midPoint: Vector2,
  4729. /** Defines the end point of the arc */
  4730. endPoint: Vector2);
  4731. }
  4732. /**
  4733. * Represents a 2D path made up of multiple 2D points
  4734. */
  4735. export class Path2 {
  4736. private _points;
  4737. private _length;
  4738. /**
  4739. * If the path start and end point are the same
  4740. */
  4741. closed: boolean;
  4742. /**
  4743. * Creates a Path2 object from the starting 2D coordinates x and y.
  4744. * @param x the starting points x value
  4745. * @param y the starting points y value
  4746. */
  4747. constructor(x: number, y: number);
  4748. /**
  4749. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4750. * @param x the added points x value
  4751. * @param y the added points y value
  4752. * @returns the updated Path2.
  4753. */
  4754. addLineTo(x: number, y: number): Path2;
  4755. /**
  4756. * 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.
  4757. * @param midX middle point x value
  4758. * @param midY middle point y value
  4759. * @param endX end point x value
  4760. * @param endY end point y value
  4761. * @param numberOfSegments (default: 36)
  4762. * @returns the updated Path2.
  4763. */
  4764. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4765. /**
  4766. * Closes the Path2.
  4767. * @returns the Path2.
  4768. */
  4769. close(): Path2;
  4770. /**
  4771. * Gets the sum of the distance between each sequential point in the path
  4772. * @returns the Path2 total length (float).
  4773. */
  4774. length(): number;
  4775. /**
  4776. * Gets the points which construct the path
  4777. * @returns the Path2 internal array of points.
  4778. */
  4779. getPoints(): Vector2[];
  4780. /**
  4781. * Retreives the point at the distance aways from the starting point
  4782. * @param normalizedLengthPosition the length along the path to retreive the point from
  4783. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4784. */
  4785. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4786. /**
  4787. * Creates a new path starting from an x and y position
  4788. * @param x starting x value
  4789. * @param y starting y value
  4790. * @returns a new Path2 starting at the coordinates (x, y).
  4791. */
  4792. static StartingAt(x: number, y: number): Path2;
  4793. }
  4794. /**
  4795. * Represents a 3D path made up of multiple 3D points
  4796. */
  4797. export class Path3D {
  4798. /**
  4799. * an array of Vector3, the curve axis of the Path3D
  4800. */
  4801. path: Vector3[];
  4802. private _curve;
  4803. private _distances;
  4804. private _tangents;
  4805. private _normals;
  4806. private _binormals;
  4807. private _raw;
  4808. private _alignTangentsWithPath;
  4809. private readonly _pointAtData;
  4810. /**
  4811. * new Path3D(path, normal, raw)
  4812. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4813. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4814. * @param path an array of Vector3, the curve axis of the Path3D
  4815. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4816. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4817. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4818. */
  4819. constructor(
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getCurve(): Vector3[];
  4829. /**
  4830. * Returns the Path3D array of successive Vector3 designing its curve.
  4831. * @returns the Path3D array of successive Vector3 designing its curve.
  4832. */
  4833. getPoints(): Vector3[];
  4834. /**
  4835. * @returns the computed length (float) of the path.
  4836. */
  4837. length(): number;
  4838. /**
  4839. * Returns an array populated with tangent vectors on each Path3D curve point.
  4840. * @returns an array populated with tangent vectors on each Path3D curve point.
  4841. */
  4842. getTangents(): Vector3[];
  4843. /**
  4844. * Returns an array populated with normal vectors on each Path3D curve point.
  4845. * @returns an array populated with normal vectors on each Path3D curve point.
  4846. */
  4847. getNormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with binormal vectors on each Path3D curve point.
  4850. * @returns an array populated with binormal vectors on each Path3D curve point.
  4851. */
  4852. getBinormals(): Vector3[];
  4853. /**
  4854. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4855. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4856. */
  4857. getDistances(): number[];
  4858. /**
  4859. * Returns an interpolated point along this path
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @returns a new Vector3 as the point
  4862. */
  4863. getPointAt(position: number): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4868. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4869. */
  4870. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4875. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4876. */
  4877. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4882. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4883. */
  4884. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4885. /**
  4886. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4887. * @param position the position of the point along this path, from 0.0 to 1.0
  4888. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4889. */
  4890. getDistanceAt(position: number): number;
  4891. /**
  4892. * Returns the array index of the previous point of an interpolated point along this path
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the array index
  4895. */
  4896. getPreviousPointIndexAt(position: number): number;
  4897. /**
  4898. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4899. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4900. * @returns the sub position
  4901. */
  4902. getSubPositionAt(position: number): number;
  4903. /**
  4904. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4905. * @param target the vector of which to get the closest position to
  4906. * @returns the position of the closest virtual point on this path to the target vector
  4907. */
  4908. getClosestPositionTo(target: Vector3): number;
  4909. /**
  4910. * Returns a sub path (slice) of this path
  4911. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4912. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4913. * @returns a sub path (slice) of this path
  4914. */
  4915. slice(start?: number, end?: number): Path3D;
  4916. /**
  4917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4918. * @param path path which all values are copied into the curves points
  4919. * @param firstNormal which should be projected onto the curve
  4920. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4921. * @returns the same object updated.
  4922. */
  4923. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4924. private _compute;
  4925. private _getFirstNonNullVector;
  4926. private _getLastNonNullVector;
  4927. private _normalVector;
  4928. /**
  4929. * Updates the point at data for an interpolated point along this curve
  4930. * @param position the position of the point along this curve, from 0.0 to 1.0
  4931. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4932. * @returns the (updated) point at data
  4933. */
  4934. private _updatePointAtData;
  4935. /**
  4936. * Updates the point at data from the specified parameters
  4937. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4938. * @param point the interpolated point
  4939. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4940. */
  4941. private _setPointAtData;
  4942. /**
  4943. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4944. */
  4945. private _updateInterpolationMatrix;
  4946. }
  4947. /**
  4948. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4949. * A Curve3 is designed from a series of successive Vector3.
  4950. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4951. */
  4952. export class Curve3 {
  4953. private _points;
  4954. private _length;
  4955. /**
  4956. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4957. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4958. * @param v1 (Vector3) the control point
  4959. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4960. * @param nbPoints (integer) the wanted number of points in the curve
  4961. * @returns the created Curve3
  4962. */
  4963. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4964. /**
  4965. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4966. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4967. * @param v1 (Vector3) the first control point
  4968. * @param v2 (Vector3) the second control point
  4969. * @param v3 (Vector3) the end point of the Cubic Bezier
  4970. * @param nbPoints (integer) the wanted number of points in the curve
  4971. * @returns the created Curve3
  4972. */
  4973. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4974. /**
  4975. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4976. * @param p1 (Vector3) the origin point of the Hermite Spline
  4977. * @param t1 (Vector3) the tangent vector at the origin point
  4978. * @param p2 (Vector3) the end point of the Hermite Spline
  4979. * @param t2 (Vector3) the tangent vector at the end point
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a CatmullRom Spline curve :
  4986. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4987. * @param nbPoints (integer) the wanted number of points between each curve control points
  4988. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4992. /**
  4993. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4994. * A Curve3 is designed from a series of successive Vector3.
  4995. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4996. * @param points points which make up the curve
  4997. */
  4998. constructor(points: Vector3[]);
  4999. /**
  5000. * @returns the Curve3 stored array of successive Vector3
  5001. */
  5002. getPoints(): Vector3[];
  5003. /**
  5004. * @returns the computed length (float) of the curve.
  5005. */
  5006. length(): number;
  5007. /**
  5008. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5009. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5010. * curveA and curveB keep unchanged.
  5011. * @param curve the curve to continue from this curve
  5012. * @returns the newly constructed curve
  5013. */
  5014. continue(curve: DeepImmutable<Curve3>): Curve3;
  5015. private _computeLength;
  5016. }
  5017. }
  5018. declare module "babylonjs/Animations/easing" {
  5019. /**
  5020. * This represents the main contract an easing function should follow.
  5021. * Easing functions are used throughout the animation system.
  5022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5023. */
  5024. export interface IEasingFunction {
  5025. /**
  5026. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5027. * of the easing function.
  5028. * The link below provides some of the most common examples of easing functions.
  5029. * @see https://easings.net/
  5030. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5031. * @returns the corresponding value on the curve defined by the easing function
  5032. */
  5033. ease(gradient: number): number;
  5034. }
  5035. /**
  5036. * Base class used for every default easing function.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export class EasingFunction implements IEasingFunction {
  5040. /**
  5041. * Interpolation follows the mathematical formula associated with the easing function.
  5042. */
  5043. static readonly EASINGMODE_EASEIN: number;
  5044. /**
  5045. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5046. */
  5047. static readonly EASINGMODE_EASEOUT: number;
  5048. /**
  5049. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5050. */
  5051. static readonly EASINGMODE_EASEINOUT: number;
  5052. private _easingMode;
  5053. /**
  5054. * Sets the easing mode of the current function.
  5055. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5056. */
  5057. setEasingMode(easingMode: number): void;
  5058. /**
  5059. * Gets the current easing mode.
  5060. * @returns the easing mode
  5061. */
  5062. getEasingMode(): number;
  5063. /**
  5064. * @hidden
  5065. */
  5066. easeInCore(gradient: number): number;
  5067. /**
  5068. * Given an input gradient between 0 and 1, this returns the corresponding value
  5069. * of the easing function.
  5070. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5071. * @returns the corresponding value on the curve defined by the easing function
  5072. */
  5073. ease(gradient: number): number;
  5074. }
  5075. /**
  5076. * Easing function with a circle shape (see link below).
  5077. * @see https://easings.net/#easeInCirc
  5078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5079. */
  5080. export class CircleEase extends EasingFunction implements IEasingFunction {
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a ease back shape (see link below).
  5086. * @see https://easings.net/#easeInBack
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class BackEase extends EasingFunction implements IEasingFunction {
  5090. /** Defines the amplitude of the function */
  5091. amplitude: number;
  5092. /**
  5093. * Instantiates a back ease easing
  5094. * @see https://easings.net/#easeInBack
  5095. * @param amplitude Defines the amplitude of the function
  5096. */
  5097. constructor(
  5098. /** Defines the amplitude of the function */
  5099. amplitude?: number);
  5100. /** @hidden */
  5101. easeInCore(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a bouncing shape (see link below).
  5105. * @see https://easings.net/#easeInBounce
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class BounceEase extends EasingFunction implements IEasingFunction {
  5109. /** Defines the number of bounces */
  5110. bounces: number;
  5111. /** Defines the amplitude of the bounce */
  5112. bounciness: number;
  5113. /**
  5114. * Instantiates a bounce easing
  5115. * @see https://easings.net/#easeInBounce
  5116. * @param bounces Defines the number of bounces
  5117. * @param bounciness Defines the amplitude of the bounce
  5118. */
  5119. constructor(
  5120. /** Defines the number of bounces */
  5121. bounces?: number,
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness?: number);
  5124. /** @hidden */
  5125. easeInCore(gradient: number): number;
  5126. }
  5127. /**
  5128. * Easing function with a power of 3 shape (see link below).
  5129. * @see https://easings.net/#easeInCubic
  5130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5131. */
  5132. export class CubicEase extends EasingFunction implements IEasingFunction {
  5133. /** @hidden */
  5134. easeInCore(gradient: number): number;
  5135. }
  5136. /**
  5137. * Easing function with an elastic shape (see link below).
  5138. * @see https://easings.net/#easeInElastic
  5139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5140. */
  5141. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5142. /** Defines the number of oscillations*/
  5143. oscillations: number;
  5144. /** Defines the amplitude of the oscillations*/
  5145. springiness: number;
  5146. /**
  5147. * Instantiates an elastic easing function
  5148. * @see https://easings.net/#easeInElastic
  5149. * @param oscillations Defines the number of oscillations
  5150. * @param springiness Defines the amplitude of the oscillations
  5151. */
  5152. constructor(
  5153. /** Defines the number of oscillations*/
  5154. oscillations?: number,
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness?: number);
  5157. /** @hidden */
  5158. easeInCore(gradient: number): number;
  5159. }
  5160. /**
  5161. * Easing function with an exponential shape (see link below).
  5162. * @see https://easings.net/#easeInExpo
  5163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5164. */
  5165. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5166. /** Defines the exponent of the function */
  5167. exponent: number;
  5168. /**
  5169. * Instantiates an exponential easing function
  5170. * @see https://easings.net/#easeInExpo
  5171. * @param exponent Defines the exponent of the function
  5172. */
  5173. constructor(
  5174. /** Defines the exponent of the function */
  5175. exponent?: number);
  5176. /** @hidden */
  5177. easeInCore(gradient: number): number;
  5178. }
  5179. /**
  5180. * Easing function with a power shape (see link below).
  5181. * @see https://easings.net/#easeInQuad
  5182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5183. */
  5184. export class PowerEase extends EasingFunction implements IEasingFunction {
  5185. /** Defines the power of the function */
  5186. power: number;
  5187. /**
  5188. * Instantiates an power base easing function
  5189. * @see https://easings.net/#easeInQuad
  5190. * @param power Defines the power of the function
  5191. */
  5192. constructor(
  5193. /** Defines the power of the function */
  5194. power?: number);
  5195. /** @hidden */
  5196. easeInCore(gradient: number): number;
  5197. }
  5198. /**
  5199. * Easing function with a power of 2 shape (see link below).
  5200. * @see https://easings.net/#easeInQuad
  5201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5202. */
  5203. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power of 4 shape (see link below).
  5209. * @see https://easings.net/#easeInQuart
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5213. /** @hidden */
  5214. easeInCore(gradient: number): number;
  5215. }
  5216. /**
  5217. * Easing function with a power of 5 shape (see link below).
  5218. * @see https://easings.net/#easeInQuint
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a sin shape (see link below).
  5227. * @see https://easings.net/#easeInSine
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class SineEase extends EasingFunction implements IEasingFunction {
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a bezier shape (see link below).
  5236. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5240. /** Defines the x component of the start tangent in the bezier curve */
  5241. x1: number;
  5242. /** Defines the y component of the start tangent in the bezier curve */
  5243. y1: number;
  5244. /** Defines the x component of the end tangent in the bezier curve */
  5245. x2: number;
  5246. /** Defines the y component of the end tangent in the bezier curve */
  5247. y2: number;
  5248. /**
  5249. * Instantiates a bezier function
  5250. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5251. * @param x1 Defines the x component of the start tangent in the bezier curve
  5252. * @param y1 Defines the y component of the start tangent in the bezier curve
  5253. * @param x2 Defines the x component of the end tangent in the bezier curve
  5254. * @param y2 Defines the y component of the end tangent in the bezier curve
  5255. */
  5256. constructor(
  5257. /** Defines the x component of the start tangent in the bezier curve */
  5258. x1?: number,
  5259. /** Defines the y component of the start tangent in the bezier curve */
  5260. y1?: number,
  5261. /** Defines the x component of the end tangent in the bezier curve */
  5262. x2?: number,
  5263. /** Defines the y component of the end tangent in the bezier curve */
  5264. y2?: number);
  5265. /** @hidden */
  5266. easeInCore(gradient: number): number;
  5267. }
  5268. }
  5269. declare module "babylonjs/Maths/math.color" {
  5270. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5271. /**
  5272. * Class used to hold a RBG color
  5273. */
  5274. export class Color3 {
  5275. /**
  5276. * Defines the red component (between 0 and 1, default is 0)
  5277. */
  5278. r: number;
  5279. /**
  5280. * Defines the green component (between 0 and 1, default is 0)
  5281. */
  5282. g: number;
  5283. /**
  5284. * Defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. b: number;
  5287. /**
  5288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5289. * @param r defines the red component (between 0 and 1, default is 0)
  5290. * @param g defines the green component (between 0 and 1, default is 0)
  5291. * @param b defines the blue component (between 0 and 1, default is 0)
  5292. */
  5293. constructor(
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r?: number,
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g?: number,
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b?: number);
  5306. /**
  5307. * Creates a string with the Color3 current values
  5308. * @returns the string representation of the Color3 object
  5309. */
  5310. toString(): string;
  5311. /**
  5312. * Returns the string "Color3"
  5313. * @returns "Color3"
  5314. */
  5315. getClassName(): string;
  5316. /**
  5317. * Compute the Color3 hash code
  5318. * @returns an unique number that can be used to hash Color3 objects
  5319. */
  5320. getHashCode(): number;
  5321. /**
  5322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5323. * @param array defines the array where to store the r,g,b components
  5324. * @param index defines an optional index in the target array to define where to start storing values
  5325. * @returns the current Color3 object
  5326. */
  5327. toArray(array: FloatArray, index?: number): Color3;
  5328. /**
  5329. * Returns a new Color4 object from the current Color3 and the given alpha
  5330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5331. * @returns a new Color4 object
  5332. */
  5333. toColor4(alpha?: number): Color4;
  5334. /**
  5335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5336. * @returns the new array
  5337. */
  5338. asArray(): number[];
  5339. /**
  5340. * Returns the luminance value
  5341. * @returns a float value
  5342. */
  5343. toLuminance(): number;
  5344. /**
  5345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5346. * @param otherColor defines the second operand
  5347. * @returns the new Color3 object
  5348. */
  5349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5350. /**
  5351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5352. * @param otherColor defines the second operand
  5353. * @param result defines the Color3 object where to store the result
  5354. * @returns the current Color3
  5355. */
  5356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5357. /**
  5358. * Determines equality between Color3 objects
  5359. * @param otherColor defines the second operand
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equals(otherColor: DeepImmutable<Color3>): boolean;
  5363. /**
  5364. * Determines equality between the current Color3 object and a set of r,b,g values
  5365. * @param r defines the red component to check
  5366. * @param g defines the green component to check
  5367. * @param b defines the blue component to check
  5368. * @returns true if the rgb values are equal to the given ones
  5369. */
  5370. equalsFloats(r: number, g: number, b: number): boolean;
  5371. /**
  5372. * Multiplies in place each rgb value by scale
  5373. * @param scale defines the scaling factor
  5374. * @returns the updated Color3
  5375. */
  5376. scale(scale: number): Color3;
  5377. /**
  5378. * Multiplies the rgb values by scale and stores the result into "result"
  5379. * @param scale defines the scaling factor
  5380. * @param result defines the Color3 object where to store the result
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Scale the current Color3 values by a factor and add the result to a given Color3
  5386. * @param scale defines the scale factor
  5387. * @param result defines color to store the result into
  5388. * @returns the unmodified current Color3
  5389. */
  5390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5391. /**
  5392. * Clamps the rgb values by the min and max values and stores the result into "result"
  5393. * @param min defines minimum clamping value (default is 0)
  5394. * @param max defines maximum clamping value (default is 1)
  5395. * @param result defines color to store the result into
  5396. * @returns the original Color3
  5397. */
  5398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5399. /**
  5400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5401. * @param otherColor defines the second operand
  5402. * @returns the new Color3
  5403. */
  5404. add(otherColor: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5407. * @param otherColor defines the second operand
  5408. * @param result defines Color3 object to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5412. /**
  5413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5414. * @param otherColor defines the second operand
  5415. * @returns the new Color3
  5416. */
  5417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5418. /**
  5419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5420. * @param otherColor defines the second operand
  5421. * @param result defines Color3 object to store the result into
  5422. * @returns the unmodified current Color3
  5423. */
  5424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5425. /**
  5426. * Copy the current object
  5427. * @returns a new Color3 copied the current one
  5428. */
  5429. clone(): Color3;
  5430. /**
  5431. * Copies the rgb values from the source in the current Color3
  5432. * @param source defines the source Color3 object
  5433. * @returns the updated Color3 object
  5434. */
  5435. copyFrom(source: DeepImmutable<Color3>): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. copyFromFloats(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Updates the Color3 rgb values from the given floats
  5446. * @param r defines the red component to read from
  5447. * @param g defines the green component to read from
  5448. * @param b defines the blue component to read from
  5449. * @returns the current Color3 object
  5450. */
  5451. set(r: number, g: number, b: number): Color3;
  5452. /**
  5453. * Compute the Color3 hexadecimal code as a string
  5454. * @returns a string containing the hexadecimal representation of the Color3 object
  5455. */
  5456. toHexString(): string;
  5457. /**
  5458. * Computes a new Color3 converted from the current one to linear space
  5459. * @returns a new Color3 object
  5460. */
  5461. toLinearSpace(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @returns a new color3 representing the HSV values
  5465. */
  5466. toHSV(): Color3;
  5467. /**
  5468. * Converts current color in rgb space to HSV values
  5469. * @param result defines the Color3 where to store the HSV values
  5470. */
  5471. toHSVToRef(result: Color3): void;
  5472. /**
  5473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5474. * @param convertedColor defines the Color3 object where to store the linear space version
  5475. * @returns the unmodified Color3
  5476. */
  5477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to gamma space
  5480. * @returns a new Color3 object
  5481. */
  5482. toGammaSpace(): Color3;
  5483. /**
  5484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5485. * @param convertedColor defines the Color3 object where to store the gamma space version
  5486. * @returns the unmodified Color3
  5487. */
  5488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5489. private static _BlackReadOnly;
  5490. /**
  5491. * Convert Hue, saturation and value to a Color3 (RGB)
  5492. * @param hue defines the hue
  5493. * @param saturation defines the saturation
  5494. * @param value defines the value
  5495. * @param result defines the Color3 where to store the RGB values
  5496. */
  5497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5498. /**
  5499. * Creates a new Color3 from the string containing valid hexadecimal values
  5500. * @param hex defines a string containing valid hexadecimal values
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromHexString(hex: string): Color3;
  5504. /**
  5505. * Creates a new Color3 from the starting index of the given array
  5506. * @param array defines the source array
  5507. * @param offset defines an offset in the source array
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5511. /**
  5512. * Creates a new Color3 from integer values (< 256)
  5513. * @param r defines the red component to read from (value between 0 and 255)
  5514. * @param g defines the green component to read from (value between 0 and 255)
  5515. * @param b defines the blue component to read from (value between 0 and 255)
  5516. * @returns a new Color3 object
  5517. */
  5518. static FromInts(r: number, g: number, b: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param start defines the start Color3 value
  5522. * @param end defines the end Color3 value
  5523. * @param amount defines the gradient value between start and end
  5524. * @returns a new Color3 object
  5525. */
  5526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5527. /**
  5528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5529. * @param left defines the start value
  5530. * @param right defines the end value
  5531. * @param amount defines the gradient factor
  5532. * @param result defines the Color3 object where to store the result
  5533. */
  5534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5535. /**
  5536. * Returns a Color3 value containing a red color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Red(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a green color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Green(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a blue color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Blue(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a black color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Black(): Color3;
  5555. /**
  5556. * Gets a Color3 value containing a black color that must not be updated
  5557. */
  5558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5559. /**
  5560. * Returns a Color3 value containing a white color
  5561. * @returns a new Color3 object
  5562. */
  5563. static White(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a purple color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Purple(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a magenta color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Magenta(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a yellow color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Yellow(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a gray color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Gray(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a teal color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Teal(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a random color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Random(): Color3;
  5594. }
  5595. /**
  5596. * Class used to hold a RBGA color
  5597. */
  5598. export class Color4 {
  5599. /**
  5600. * Defines the red component (between 0 and 1, default is 0)
  5601. */
  5602. r: number;
  5603. /**
  5604. * Defines the green component (between 0 and 1, default is 0)
  5605. */
  5606. g: number;
  5607. /**
  5608. * Defines the blue component (between 0 and 1, default is 0)
  5609. */
  5610. b: number;
  5611. /**
  5612. * Defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. a: number;
  5615. /**
  5616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5617. * @param r defines the red component (between 0 and 1, default is 0)
  5618. * @param g defines the green component (between 0 and 1, default is 0)
  5619. * @param b defines the blue component (between 0 and 1, default is 0)
  5620. * @param a defines the alpha component (between 0 and 1, default is 1)
  5621. */
  5622. constructor(
  5623. /**
  5624. * Defines the red component (between 0 and 1, default is 0)
  5625. */
  5626. r?: number,
  5627. /**
  5628. * Defines the green component (between 0 and 1, default is 0)
  5629. */
  5630. g?: number,
  5631. /**
  5632. * Defines the blue component (between 0 and 1, default is 0)
  5633. */
  5634. b?: number,
  5635. /**
  5636. * Defines the alpha component (between 0 and 1, default is 1)
  5637. */
  5638. a?: number);
  5639. /**
  5640. * Adds in place the given Color4 values to the current Color4 object
  5641. * @param right defines the second operand
  5642. * @returns the current updated Color4 object
  5643. */
  5644. addInPlace(right: DeepImmutable<Color4>): Color4;
  5645. /**
  5646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5647. * @returns the new array
  5648. */
  5649. asArray(): number[];
  5650. /**
  5651. * Stores from the starting index in the given array the Color4 successive values
  5652. * @param array defines the array where to store the r,g,b components
  5653. * @param index defines an optional index in the target array to define where to start storing values
  5654. * @returns the current Color4 object
  5655. */
  5656. toArray(array: number[], index?: number): Color4;
  5657. /**
  5658. * Determines equality between Color4 objects
  5659. * @param otherColor defines the second operand
  5660. * @returns true if the rgba values are equal to the given ones
  5661. */
  5662. equals(otherColor: DeepImmutable<Color4>): boolean;
  5663. /**
  5664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5665. * @param right defines the second operand
  5666. * @returns a new Color4 object
  5667. */
  5668. add(right: DeepImmutable<Color4>): Color4;
  5669. /**
  5670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5671. * @param right defines the second operand
  5672. * @returns a new Color4 object
  5673. */
  5674. subtract(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5677. * @param right defines the second operand
  5678. * @param result defines the Color4 object where to store the result
  5679. * @returns the current Color4 object
  5680. */
  5681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5682. /**
  5683. * Creates a new Color4 with the current Color4 values multiplied by scale
  5684. * @param scale defines the scaling factor to apply
  5685. * @returns a new Color4 object
  5686. */
  5687. scale(scale: number): Color4;
  5688. /**
  5689. * Multiplies the current Color4 values by scale and stores the result in "result"
  5690. * @param scale defines the scaling factor to apply
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the current unmodified Color4
  5693. */
  5694. scaleToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Scale the current Color4 values by a factor and add the result to a given Color4
  5697. * @param scale defines the scale factor
  5698. * @param result defines the Color4 object where to store the result
  5699. * @returns the unmodified current Color4
  5700. */
  5701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5702. /**
  5703. * Clamps the rgb values by the min and max values and stores the result into "result"
  5704. * @param min defines minimum clamping value (default is 0)
  5705. * @param max defines maximum clamping value (default is 1)
  5706. * @param result defines color to store the result into.
  5707. * @returns the cuurent Color4
  5708. */
  5709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5710. /**
  5711. * Multipy an Color4 value by another and return a new Color4 object
  5712. * @param color defines the Color4 value to multiply by
  5713. * @returns a new Color4 object
  5714. */
  5715. multiply(color: Color4): Color4;
  5716. /**
  5717. * Multipy a Color4 value by another and push the result in a reference value
  5718. * @param color defines the Color4 value to multiply by
  5719. * @param result defines the Color4 to fill the result in
  5720. * @returns the result Color4
  5721. */
  5722. multiplyToRef(color: Color4, result: Color4): Color4;
  5723. /**
  5724. * Creates a string with the Color4 current values
  5725. * @returns the string representation of the Color4 object
  5726. */
  5727. toString(): string;
  5728. /**
  5729. * Returns the string "Color4"
  5730. * @returns "Color4"
  5731. */
  5732. getClassName(): string;
  5733. /**
  5734. * Compute the Color4 hash code
  5735. * @returns an unique number that can be used to hash Color4 objects
  5736. */
  5737. getHashCode(): number;
  5738. /**
  5739. * Creates a new Color4 copied from the current one
  5740. * @returns a new Color4 object
  5741. */
  5742. clone(): Color4;
  5743. /**
  5744. * Copies the given Color4 values into the current one
  5745. * @param source defines the source Color4 object
  5746. * @returns the current updated Color4 object
  5747. */
  5748. copyFrom(source: Color4): Color4;
  5749. /**
  5750. * Copies the given float values into the current one
  5751. * @param r defines the red component to read from
  5752. * @param g defines the green component to read from
  5753. * @param b defines the blue component to read from
  5754. * @param a defines the alpha component to read from
  5755. * @returns the current updated Color4 object
  5756. */
  5757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5758. /**
  5759. * Copies the given float values into the current one
  5760. * @param r defines the red component to read from
  5761. * @param g defines the green component to read from
  5762. * @param b defines the blue component to read from
  5763. * @param a defines the alpha component to read from
  5764. * @returns the current updated Color4 object
  5765. */
  5766. set(r: number, g: number, b: number, a: number): Color4;
  5767. /**
  5768. * Compute the Color4 hexadecimal code as a string
  5769. * @returns a string containing the hexadecimal representation of the Color4 object
  5770. */
  5771. toHexString(): string;
  5772. /**
  5773. * Computes a new Color4 converted from the current one to linear space
  5774. * @returns a new Color4 object
  5775. */
  5776. toLinearSpace(): Color4;
  5777. /**
  5778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5779. * @param convertedColor defines the Color4 object where to store the linear space version
  5780. * @returns the unmodified Color4
  5781. */
  5782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to gamma space
  5785. * @returns a new Color4 object
  5786. */
  5787. toGammaSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the gamma space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Creates a new Color4 from the string containing valid hexadecimal values
  5796. * @param hex defines a string containing valid hexadecimal values
  5797. * @returns a new Color4 object
  5798. */
  5799. static FromHexString(hex: string): Color4;
  5800. /**
  5801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @returns a new Color4 object
  5806. */
  5807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5808. /**
  5809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5810. * @param left defines the start value
  5811. * @param right defines the end value
  5812. * @param amount defines the gradient factor
  5813. * @param result defines the Color4 object where to store data
  5814. */
  5815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5816. /**
  5817. * Creates a new Color4 from a Color3 and an alpha value
  5818. * @param color3 defines the source Color3 to read from
  5819. * @param alpha defines the alpha component (1.0 by default)
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5823. /**
  5824. * Creates a new Color4 from the starting index element of the given array
  5825. * @param array defines the source array to read from
  5826. * @param offset defines the offset in the source array
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5830. /**
  5831. * Creates a new Color3 from integer values (< 256)
  5832. * @param r defines the red component to read from (value between 0 and 255)
  5833. * @param g defines the green component to read from (value between 0 and 255)
  5834. * @param b defines the blue component to read from (value between 0 and 255)
  5835. * @param a defines the alpha component to read from (value between 0 and 255)
  5836. * @returns a new Color3 object
  5837. */
  5838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5839. /**
  5840. * Check the content of a given array and convert it to an array containing RGBA data
  5841. * If the original array was already containing count * 4 values then it is returned directly
  5842. * @param colors defines the array to check
  5843. * @param count defines the number of RGBA data to expect
  5844. * @returns an array containing count * 4 values (RGBA)
  5845. */
  5846. static CheckColors4(colors: number[], count: number): number[];
  5847. }
  5848. /**
  5849. * @hidden
  5850. */
  5851. export class TmpColors {
  5852. static Color3: Color3[];
  5853. static Color4: Color4[];
  5854. }
  5855. }
  5856. declare module "babylonjs/Animations/animationKey" {
  5857. /**
  5858. * Defines an interface which represents an animation key frame
  5859. */
  5860. export interface IAnimationKey {
  5861. /**
  5862. * Frame of the key frame
  5863. */
  5864. frame: number;
  5865. /**
  5866. * Value at the specifies key frame
  5867. */
  5868. value: any;
  5869. /**
  5870. * The input tangent for the cubic hermite spline
  5871. */
  5872. inTangent?: any;
  5873. /**
  5874. * The output tangent for the cubic hermite spline
  5875. */
  5876. outTangent?: any;
  5877. /**
  5878. * The animation interpolation type
  5879. */
  5880. interpolation?: AnimationKeyInterpolation;
  5881. }
  5882. /**
  5883. * Enum for the animation key frame interpolation type
  5884. */
  5885. export enum AnimationKeyInterpolation {
  5886. /**
  5887. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5888. */
  5889. STEP = 1
  5890. }
  5891. }
  5892. declare module "babylonjs/Animations/animationRange" {
  5893. /**
  5894. * Represents the range of an animation
  5895. */
  5896. export class AnimationRange {
  5897. /**The name of the animation range**/
  5898. name: string;
  5899. /**The starting frame of the animation */
  5900. from: number;
  5901. /**The ending frame of the animation*/
  5902. to: number;
  5903. /**
  5904. * Initializes the range of an animation
  5905. * @param name The name of the animation range
  5906. * @param from The starting frame of the animation
  5907. * @param to The ending frame of the animation
  5908. */
  5909. constructor(
  5910. /**The name of the animation range**/
  5911. name: string,
  5912. /**The starting frame of the animation */
  5913. from: number,
  5914. /**The ending frame of the animation*/
  5915. to: number);
  5916. /**
  5917. * Makes a copy of the animation range
  5918. * @returns A copy of the animation range
  5919. */
  5920. clone(): AnimationRange;
  5921. }
  5922. }
  5923. declare module "babylonjs/Animations/animationEvent" {
  5924. /**
  5925. * Composed of a frame, and an action function
  5926. */
  5927. export class AnimationEvent {
  5928. /** The frame for which the event is triggered **/
  5929. frame: number;
  5930. /** The event to perform when triggered **/
  5931. action: (currentFrame: number) => void;
  5932. /** Specifies if the event should be triggered only once**/
  5933. onlyOnce?: boolean | undefined;
  5934. /**
  5935. * Specifies if the animation event is done
  5936. */
  5937. isDone: boolean;
  5938. /**
  5939. * Initializes the animation event
  5940. * @param frame The frame for which the event is triggered
  5941. * @param action The event to perform when triggered
  5942. * @param onlyOnce Specifies if the event should be triggered only once
  5943. */
  5944. constructor(
  5945. /** The frame for which the event is triggered **/
  5946. frame: number,
  5947. /** The event to perform when triggered **/
  5948. action: (currentFrame: number) => void,
  5949. /** Specifies if the event should be triggered only once**/
  5950. onlyOnce?: boolean | undefined);
  5951. /** @hidden */
  5952. _clone(): AnimationEvent;
  5953. }
  5954. }
  5955. declare module "babylonjs/Behaviors/behavior" {
  5956. import { Nullable } from "babylonjs/types";
  5957. /**
  5958. * Interface used to define a behavior
  5959. */
  5960. export interface Behavior<T> {
  5961. /** gets or sets behavior's name */
  5962. name: string;
  5963. /**
  5964. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5965. */
  5966. init(): void;
  5967. /**
  5968. * Called when the behavior is attached to a target
  5969. * @param target defines the target where the behavior is attached to
  5970. */
  5971. attach(target: T): void;
  5972. /**
  5973. * Called when the behavior is detached from its target
  5974. */
  5975. detach(): void;
  5976. }
  5977. /**
  5978. * Interface implemented by classes supporting behaviors
  5979. */
  5980. export interface IBehaviorAware<T> {
  5981. /**
  5982. * Attach a behavior
  5983. * @param behavior defines the behavior to attach
  5984. * @returns the current host
  5985. */
  5986. addBehavior(behavior: Behavior<T>): T;
  5987. /**
  5988. * Remove a behavior from the current object
  5989. * @param behavior defines the behavior to detach
  5990. * @returns the current host
  5991. */
  5992. removeBehavior(behavior: Behavior<T>): T;
  5993. /**
  5994. * Gets a behavior using its name to search
  5995. * @param name defines the name to search
  5996. * @returns the behavior or null if not found
  5997. */
  5998. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5999. }
  6000. }
  6001. declare module "babylonjs/Misc/smartArray" {
  6002. /**
  6003. * Defines an array and its length.
  6004. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6005. */
  6006. export interface ISmartArrayLike<T> {
  6007. /**
  6008. * The data of the array.
  6009. */
  6010. data: Array<T>;
  6011. /**
  6012. * The active length of the array.
  6013. */
  6014. length: number;
  6015. }
  6016. /**
  6017. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6018. */
  6019. export class SmartArray<T> implements ISmartArrayLike<T> {
  6020. /**
  6021. * The full set of data from the array.
  6022. */
  6023. data: Array<T>;
  6024. /**
  6025. * The active length of the array.
  6026. */
  6027. length: number;
  6028. protected _id: number;
  6029. /**
  6030. * Instantiates a Smart Array.
  6031. * @param capacity defines the default capacity of the array.
  6032. */
  6033. constructor(capacity: number);
  6034. /**
  6035. * Pushes a value at the end of the active data.
  6036. * @param value defines the object to push in the array.
  6037. */
  6038. push(value: T): void;
  6039. /**
  6040. * Iterates over the active data and apply the lambda to them.
  6041. * @param func defines the action to apply on each value.
  6042. */
  6043. forEach(func: (content: T) => void): void;
  6044. /**
  6045. * Sorts the full sets of data.
  6046. * @param compareFn defines the comparison function to apply.
  6047. */
  6048. sort(compareFn: (a: T, b: T) => number): void;
  6049. /**
  6050. * Resets the active data to an empty array.
  6051. */
  6052. reset(): void;
  6053. /**
  6054. * Releases all the data from the array as well as the array.
  6055. */
  6056. dispose(): void;
  6057. /**
  6058. * Concats the active data with a given array.
  6059. * @param array defines the data to concatenate with.
  6060. */
  6061. concat(array: any): void;
  6062. /**
  6063. * Returns the position of a value in the active data.
  6064. * @param value defines the value to find the index for
  6065. * @returns the index if found in the active data otherwise -1
  6066. */
  6067. indexOf(value: T): number;
  6068. /**
  6069. * Returns whether an element is part of the active data.
  6070. * @param value defines the value to look for
  6071. * @returns true if found in the active data otherwise false
  6072. */
  6073. contains(value: T): boolean;
  6074. private static _GlobalId;
  6075. }
  6076. /**
  6077. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6078. * The data in this array can only be present once
  6079. */
  6080. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6081. private _duplicateId;
  6082. /**
  6083. * Pushes a value at the end of the active data.
  6084. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6085. * @param value defines the object to push in the array.
  6086. */
  6087. push(value: T): void;
  6088. /**
  6089. * Pushes a value at the end of the active data.
  6090. * If the data is already present, it won t be added again
  6091. * @param value defines the object to push in the array.
  6092. * @returns true if added false if it was already present
  6093. */
  6094. pushNoDuplicate(value: T): boolean;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Concats the active data with a given array.
  6101. * This ensures no dupplicate will be present in the result.
  6102. * @param array defines the data to concatenate with.
  6103. */
  6104. concatWithNoDuplicate(array: any): void;
  6105. }
  6106. }
  6107. declare module "babylonjs/Cameras/cameraInputsManager" {
  6108. import { Nullable } from "babylonjs/types";
  6109. import { Camera } from "babylonjs/Cameras/camera";
  6110. /**
  6111. * @ignore
  6112. * This is a list of all the different input types that are available in the application.
  6113. * Fo instance: ArcRotateCameraGamepadInput...
  6114. */
  6115. export var CameraInputTypes: {};
  6116. /**
  6117. * This is the contract to implement in order to create a new input class.
  6118. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6119. */
  6120. export interface ICameraInput<TCamera extends Camera> {
  6121. /**
  6122. * Defines the camera the input is attached to.
  6123. */
  6124. camera: Nullable<TCamera>;
  6125. /**
  6126. * Gets the class name of the current intput.
  6127. * @returns the class name
  6128. */
  6129. getClassName(): string;
  6130. /**
  6131. * Get the friendly name associated with the input class.
  6132. * @returns the input friendly name
  6133. */
  6134. getSimpleName(): string;
  6135. /**
  6136. * Attach the input controls to a specific dom element to get the input from.
  6137. * @param element Defines the element the controls should be listened from
  6138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6139. */
  6140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6141. /**
  6142. * Detach the current controls from the specified dom element.
  6143. * @param element Defines the element to stop listening the inputs from
  6144. */
  6145. detachControl(element: Nullable<HTMLElement>): void;
  6146. /**
  6147. * Update the current camera state depending on the inputs that have been used this frame.
  6148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6149. */
  6150. checkInputs?: () => void;
  6151. }
  6152. /**
  6153. * Represents a map of input types to input instance or input index to input instance.
  6154. */
  6155. export interface CameraInputsMap<TCamera extends Camera> {
  6156. /**
  6157. * Accessor to the input by input type.
  6158. */
  6159. [name: string]: ICameraInput<TCamera>;
  6160. /**
  6161. * Accessor to the input by input index.
  6162. */
  6163. [idx: number]: ICameraInput<TCamera>;
  6164. }
  6165. /**
  6166. * This represents the input manager used within a camera.
  6167. * It helps dealing with all the different kind of input attached to a camera.
  6168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6169. */
  6170. export class CameraInputsManager<TCamera extends Camera> {
  6171. /**
  6172. * Defines the list of inputs attahed to the camera.
  6173. */
  6174. attached: CameraInputsMap<TCamera>;
  6175. /**
  6176. * Defines the dom element the camera is collecting inputs from.
  6177. * This is null if the controls have not been attached.
  6178. */
  6179. attachedElement: Nullable<HTMLElement>;
  6180. /**
  6181. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6182. */
  6183. noPreventDefault: boolean;
  6184. /**
  6185. * Defined the camera the input manager belongs to.
  6186. */
  6187. camera: TCamera;
  6188. /**
  6189. * Update the current camera state depending on the inputs that have been used this frame.
  6190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6191. */
  6192. checkInputs: () => void;
  6193. /**
  6194. * Instantiate a new Camera Input Manager.
  6195. * @param camera Defines the camera the input manager blongs to
  6196. */
  6197. constructor(camera: TCamera);
  6198. /**
  6199. * Add an input method to a camera
  6200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6201. * @param input camera input method
  6202. */
  6203. add(input: ICameraInput<TCamera>): void;
  6204. /**
  6205. * Remove a specific input method from a camera
  6206. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6207. * @param inputToRemove camera input method
  6208. */
  6209. remove(inputToRemove: ICameraInput<TCamera>): void;
  6210. /**
  6211. * Remove a specific input type from a camera
  6212. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6213. * @param inputType the type of the input to remove
  6214. */
  6215. removeByType(inputType: string): void;
  6216. private _addCheckInputs;
  6217. /**
  6218. * Attach the input controls to the currently attached dom element to listen the events from.
  6219. * @param input Defines the input to attach
  6220. */
  6221. attachInput(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6224. * @param element Defines the dom element to collect the events from
  6225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6226. */
  6227. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6228. /**
  6229. * Detach the current manager inputs controls from a specific dom element.
  6230. * @param element Defines the dom element to collect the events from
  6231. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6232. */
  6233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6234. /**
  6235. * Rebuild the dynamic inputCheck function from the current list of
  6236. * defined inputs in the manager.
  6237. */
  6238. rebuildInputCheck(): void;
  6239. /**
  6240. * Remove all attached input methods from a camera
  6241. */
  6242. clear(): void;
  6243. /**
  6244. * Serialize the current input manager attached to a camera.
  6245. * This ensures than once parsed,
  6246. * the input associated to the camera will be identical to the current ones
  6247. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6248. */
  6249. serialize(serializedCamera: any): void;
  6250. /**
  6251. * Parses an input manager serialized JSON to restore the previous list of inputs
  6252. * and states associated to a camera.
  6253. * @param parsedCamera Defines the JSON to parse
  6254. */
  6255. parse(parsedCamera: any): void;
  6256. }
  6257. }
  6258. declare module "babylonjs/Meshes/buffer" {
  6259. import { Nullable, DataArray } from "babylonjs/types";
  6260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6261. /**
  6262. * Class used to store data that will be store in GPU memory
  6263. */
  6264. export class Buffer {
  6265. private _engine;
  6266. private _buffer;
  6267. /** @hidden */
  6268. _data: Nullable<DataArray>;
  6269. private _updatable;
  6270. private _instanced;
  6271. private _divisor;
  6272. /**
  6273. * Gets the byte stride.
  6274. */
  6275. readonly byteStride: number;
  6276. /**
  6277. * Constructor
  6278. * @param engine the engine
  6279. * @param data the data to use for this buffer
  6280. * @param updatable whether the data is updatable
  6281. * @param stride the stride (optional)
  6282. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6283. * @param instanced whether the buffer is instanced (optional)
  6284. * @param useBytes set to true if the stride in in bytes (optional)
  6285. * @param divisor sets an optional divisor for instances (1 by default)
  6286. */
  6287. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6288. /**
  6289. * Create a new VertexBuffer based on the current buffer
  6290. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6291. * @param offset defines offset in the buffer (0 by default)
  6292. * @param size defines the size in floats of attributes (position is 3 for instance)
  6293. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6294. * @param instanced defines if the vertex buffer contains indexed data
  6295. * @param useBytes defines if the offset and stride are in bytes *
  6296. * @param divisor sets an optional divisor for instances (1 by default)
  6297. * @returns the new vertex buffer
  6298. */
  6299. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6300. /**
  6301. * Gets a boolean indicating if the Buffer is updatable?
  6302. * @returns true if the buffer is updatable
  6303. */
  6304. isUpdatable(): boolean;
  6305. /**
  6306. * Gets current buffer's data
  6307. * @returns a DataArray or null
  6308. */
  6309. getData(): Nullable<DataArray>;
  6310. /**
  6311. * Gets underlying native buffer
  6312. * @returns underlying native buffer
  6313. */
  6314. getBuffer(): Nullable<DataBuffer>;
  6315. /**
  6316. * Gets the stride in float32 units (i.e. byte stride / 4).
  6317. * May not be an integer if the byte stride is not divisible by 4.
  6318. * @returns the stride in float32 units
  6319. * @deprecated Please use byteStride instead.
  6320. */
  6321. getStrideSize(): number;
  6322. /**
  6323. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6324. * @param data defines the data to store
  6325. */
  6326. create(data?: Nullable<DataArray>): void;
  6327. /** @hidden */
  6328. _rebuild(): void;
  6329. /**
  6330. * Update current buffer data
  6331. * @param data defines the data to store
  6332. */
  6333. update(data: DataArray): void;
  6334. /**
  6335. * Updates the data directly.
  6336. * @param data the new data
  6337. * @param offset the new offset
  6338. * @param vertexCount the vertex count (optional)
  6339. * @param useBytes set to true if the offset is in bytes
  6340. */
  6341. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6342. /**
  6343. * Release all resources
  6344. */
  6345. dispose(): void;
  6346. }
  6347. /**
  6348. * Specialized buffer used to store vertex data
  6349. */
  6350. export class VertexBuffer {
  6351. /** @hidden */
  6352. _buffer: Buffer;
  6353. private _kind;
  6354. private _size;
  6355. private _ownsBuffer;
  6356. private _instanced;
  6357. private _instanceDivisor;
  6358. /**
  6359. * The byte type.
  6360. */
  6361. static readonly BYTE: number;
  6362. /**
  6363. * The unsigned byte type.
  6364. */
  6365. static readonly UNSIGNED_BYTE: number;
  6366. /**
  6367. * The short type.
  6368. */
  6369. static readonly SHORT: number;
  6370. /**
  6371. * The unsigned short type.
  6372. */
  6373. static readonly UNSIGNED_SHORT: number;
  6374. /**
  6375. * The integer type.
  6376. */
  6377. static readonly INT: number;
  6378. /**
  6379. * The unsigned integer type.
  6380. */
  6381. static readonly UNSIGNED_INT: number;
  6382. /**
  6383. * The float type.
  6384. */
  6385. static readonly FLOAT: number;
  6386. /**
  6387. * Gets or sets the instance divisor when in instanced mode
  6388. */
  6389. instanceDivisor: number;
  6390. /**
  6391. * Gets the byte stride.
  6392. */
  6393. readonly byteStride: number;
  6394. /**
  6395. * Gets the byte offset.
  6396. */
  6397. readonly byteOffset: number;
  6398. /**
  6399. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6400. */
  6401. readonly normalized: boolean;
  6402. /**
  6403. * Gets the data type of each component in the array.
  6404. */
  6405. readonly type: number;
  6406. /**
  6407. * Constructor
  6408. * @param engine the engine
  6409. * @param data the data to use for this vertex buffer
  6410. * @param kind the vertex buffer kind
  6411. * @param updatable whether the data is updatable
  6412. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6413. * @param stride the stride (optional)
  6414. * @param instanced whether the buffer is instanced (optional)
  6415. * @param offset the offset of the data (optional)
  6416. * @param size the number of components (optional)
  6417. * @param type the type of the component (optional)
  6418. * @param normalized whether the data contains normalized data (optional)
  6419. * @param useBytes set to true if stride and offset are in bytes (optional)
  6420. * @param divisor defines the instance divisor to use (1 by default)
  6421. */
  6422. 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);
  6423. /** @hidden */
  6424. _rebuild(): void;
  6425. /**
  6426. * Returns the kind of the VertexBuffer (string)
  6427. * @returns a string
  6428. */
  6429. getKind(): string;
  6430. /**
  6431. * Gets a boolean indicating if the VertexBuffer is updatable?
  6432. * @returns true if the buffer is updatable
  6433. */
  6434. isUpdatable(): boolean;
  6435. /**
  6436. * Gets current buffer's data
  6437. * @returns a DataArray or null
  6438. */
  6439. getData(): Nullable<DataArray>;
  6440. /**
  6441. * Gets underlying native buffer
  6442. * @returns underlying native buffer
  6443. */
  6444. getBuffer(): Nullable<DataBuffer>;
  6445. /**
  6446. * Gets the stride in float32 units (i.e. byte stride / 4).
  6447. * May not be an integer if the byte stride is not divisible by 4.
  6448. * @returns the stride in float32 units
  6449. * @deprecated Please use byteStride instead.
  6450. */
  6451. getStrideSize(): number;
  6452. /**
  6453. * Returns the offset as a multiple of the type byte length.
  6454. * @returns the offset in bytes
  6455. * @deprecated Please use byteOffset instead.
  6456. */
  6457. getOffset(): number;
  6458. /**
  6459. * Returns the number of components per vertex attribute (integer)
  6460. * @returns the size in float
  6461. */
  6462. getSize(): number;
  6463. /**
  6464. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6465. * @returns true if this buffer is instanced
  6466. */
  6467. getIsInstanced(): boolean;
  6468. /**
  6469. * Returns the instancing divisor, zero for non-instanced (integer).
  6470. * @returns a number
  6471. */
  6472. getInstanceDivisor(): number;
  6473. /**
  6474. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6475. * @param data defines the data to store
  6476. */
  6477. create(data?: DataArray): void;
  6478. /**
  6479. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6480. * This function will create a new buffer if the current one is not updatable
  6481. * @param data defines the data to store
  6482. */
  6483. update(data: DataArray): void;
  6484. /**
  6485. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6486. * Returns the directly updated WebGLBuffer.
  6487. * @param data the new data
  6488. * @param offset the new offset
  6489. * @param useBytes set to true if the offset is in bytes
  6490. */
  6491. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6492. /**
  6493. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6494. */
  6495. dispose(): void;
  6496. /**
  6497. * Enumerates each value of this vertex buffer as numbers.
  6498. * @param count the number of values to enumerate
  6499. * @param callback the callback function called for each value
  6500. */
  6501. forEach(count: number, callback: (value: number, index: number) => void): void;
  6502. /**
  6503. * Positions
  6504. */
  6505. static readonly PositionKind: string;
  6506. /**
  6507. * Normals
  6508. */
  6509. static readonly NormalKind: string;
  6510. /**
  6511. * Tangents
  6512. */
  6513. static readonly TangentKind: string;
  6514. /**
  6515. * Texture coordinates
  6516. */
  6517. static readonly UVKind: string;
  6518. /**
  6519. * Texture coordinates 2
  6520. */
  6521. static readonly UV2Kind: string;
  6522. /**
  6523. * Texture coordinates 3
  6524. */
  6525. static readonly UV3Kind: string;
  6526. /**
  6527. * Texture coordinates 4
  6528. */
  6529. static readonly UV4Kind: string;
  6530. /**
  6531. * Texture coordinates 5
  6532. */
  6533. static readonly UV5Kind: string;
  6534. /**
  6535. * Texture coordinates 6
  6536. */
  6537. static readonly UV6Kind: string;
  6538. /**
  6539. * Colors
  6540. */
  6541. static readonly ColorKind: string;
  6542. /**
  6543. * Matrix indices (for bones)
  6544. */
  6545. static readonly MatricesIndicesKind: string;
  6546. /**
  6547. * Matrix weights (for bones)
  6548. */
  6549. static readonly MatricesWeightsKind: string;
  6550. /**
  6551. * Additional matrix indices (for bones)
  6552. */
  6553. static readonly MatricesIndicesExtraKind: string;
  6554. /**
  6555. * Additional matrix weights (for bones)
  6556. */
  6557. static readonly MatricesWeightsExtraKind: string;
  6558. /**
  6559. * Deduces the stride given a kind.
  6560. * @param kind The kind string to deduce
  6561. * @returns The deduced stride
  6562. */
  6563. static DeduceStride(kind: string): number;
  6564. /**
  6565. * Gets the byte length of the given type.
  6566. * @param type the type
  6567. * @returns the number of bytes
  6568. */
  6569. static GetTypeByteLength(type: number): number;
  6570. /**
  6571. * Enumerates each value of the given parameters as numbers.
  6572. * @param data the data to enumerate
  6573. * @param byteOffset the byte offset of the data
  6574. * @param byteStride the byte stride of the data
  6575. * @param componentCount the number of components per element
  6576. * @param componentType the type of the component
  6577. * @param count the number of values to enumerate
  6578. * @param normalized whether the data is normalized
  6579. * @param callback the callback function called for each value
  6580. */
  6581. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6582. private static _GetFloatValue;
  6583. }
  6584. }
  6585. declare module "babylonjs/Collisions/intersectionInfo" {
  6586. import { Nullable } from "babylonjs/types";
  6587. /**
  6588. * @hidden
  6589. */
  6590. export class IntersectionInfo {
  6591. bu: Nullable<number>;
  6592. bv: Nullable<number>;
  6593. distance: number;
  6594. faceId: number;
  6595. subMeshId: number;
  6596. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6597. }
  6598. }
  6599. declare module "babylonjs/Maths/math.plane" {
  6600. import { DeepImmutable } from "babylonjs/types";
  6601. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6602. /**
  6603. * Represens a plane by the equation ax + by + cz + d = 0
  6604. */
  6605. export class Plane {
  6606. private static _TmpMatrix;
  6607. /**
  6608. * Normal of the plane (a,b,c)
  6609. */
  6610. normal: Vector3;
  6611. /**
  6612. * d component of the plane
  6613. */
  6614. d: number;
  6615. /**
  6616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6617. * @param a a component of the plane
  6618. * @param b b component of the plane
  6619. * @param c c component of the plane
  6620. * @param d d component of the plane
  6621. */
  6622. constructor(a: number, b: number, c: number, d: number);
  6623. /**
  6624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6625. */
  6626. asArray(): number[];
  6627. /**
  6628. * @returns a new plane copied from the current Plane.
  6629. */
  6630. clone(): Plane;
  6631. /**
  6632. * @returns the string "Plane".
  6633. */
  6634. getClassName(): string;
  6635. /**
  6636. * @returns the Plane hash code.
  6637. */
  6638. getHashCode(): number;
  6639. /**
  6640. * Normalize the current Plane in place.
  6641. * @returns the updated Plane.
  6642. */
  6643. normalize(): Plane;
  6644. /**
  6645. * Applies a transformation the plane and returns the result
  6646. * @param transformation the transformation matrix to be applied to the plane
  6647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6648. */
  6649. transform(transformation: DeepImmutable<Matrix>): Plane;
  6650. /**
  6651. * Calcualtte the dot product between the point and the plane normal
  6652. * @param point point to calculate the dot product with
  6653. * @returns the dot product (float) of the point coordinates and the plane normal.
  6654. */
  6655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6656. /**
  6657. * Updates the current Plane from the plane defined by the three given points.
  6658. * @param point1 one of the points used to contruct the plane
  6659. * @param point2 one of the points used to contruct the plane
  6660. * @param point3 one of the points used to contruct the plane
  6661. * @returns the updated Plane.
  6662. */
  6663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6664. /**
  6665. * Checks if the plane is facing a given direction
  6666. * @param direction the direction to check if the plane is facing
  6667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6668. * @returns True is the vector "direction" is the same side than the plane normal.
  6669. */
  6670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6671. /**
  6672. * Calculates the distance to a point
  6673. * @param point point to calculate distance to
  6674. * @returns the signed distance (float) from the given point to the Plane.
  6675. */
  6676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6677. /**
  6678. * Creates a plane from an array
  6679. * @param array the array to create a plane from
  6680. * @returns a new Plane from the given array.
  6681. */
  6682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6683. /**
  6684. * Creates a plane from three points
  6685. * @param point1 point used to create the plane
  6686. * @param point2 point used to create the plane
  6687. * @param point3 point used to create the plane
  6688. * @returns a new Plane defined by the three given points.
  6689. */
  6690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6691. /**
  6692. * Creates a plane from an origin point and a normal
  6693. * @param origin origin of the plane to be constructed
  6694. * @param normal normal of the plane to be constructed
  6695. * @returns a new Plane the normal vector to this plane at the given origin point.
  6696. * Note : the vector "normal" is updated because normalized.
  6697. */
  6698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Calculates the distance from a plane and a point
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @param point point to calculate distance to
  6704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6705. */
  6706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6707. }
  6708. }
  6709. declare module "babylonjs/Culling/boundingSphere" {
  6710. import { DeepImmutable } from "babylonjs/types";
  6711. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6712. import { Plane } from "babylonjs/Maths/math.plane";
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module "babylonjs/Culling/boundingBox" {
  6799. import { DeepImmutable } from "babylonjs/types";
  6800. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6801. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6802. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6803. import { Plane } from "babylonjs/Maths/math.plane";
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module "babylonjs/Collisions/collider" {
  6949. import { Nullable, IndicesArray } from "babylonjs/types";
  6950. import { Vector3 } from "babylonjs/Maths/math.vector";
  6951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6952. import { Plane } from "babylonjs/Maths/math.plane";
  6953. /** @hidden */
  6954. export class Collider {
  6955. /** Define if a collision was found */
  6956. collisionFound: boolean;
  6957. /**
  6958. * Define last intersection point in local space
  6959. */
  6960. intersectionPoint: Vector3;
  6961. /**
  6962. * Define last collided mesh
  6963. */
  6964. collidedMesh: Nullable<AbstractMesh>;
  6965. private _collisionPoint;
  6966. private _planeIntersectionPoint;
  6967. private _tempVector;
  6968. private _tempVector2;
  6969. private _tempVector3;
  6970. private _tempVector4;
  6971. private _edge;
  6972. private _baseToVertex;
  6973. private _destinationPoint;
  6974. private _slidePlaneNormal;
  6975. private _displacementVector;
  6976. /** @hidden */
  6977. _radius: Vector3;
  6978. /** @hidden */
  6979. _retry: number;
  6980. private _velocity;
  6981. private _basePoint;
  6982. private _epsilon;
  6983. /** @hidden */
  6984. _velocityWorldLength: number;
  6985. /** @hidden */
  6986. _basePointWorld: Vector3;
  6987. private _velocityWorld;
  6988. private _normalizedVelocity;
  6989. /** @hidden */
  6990. _initialVelocity: Vector3;
  6991. /** @hidden */
  6992. _initialPosition: Vector3;
  6993. private _nearestDistance;
  6994. private _collisionMask;
  6995. collisionMask: number;
  6996. /**
  6997. * Gets the plane normal used to compute the sliding response (in local space)
  6998. */
  6999. readonly slidePlaneNormal: Vector3;
  7000. /** @hidden */
  7001. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7002. /** @hidden */
  7003. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7004. /** @hidden */
  7005. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7006. /** @hidden */
  7007. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7008. /** @hidden */
  7009. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _getResponse(pos: Vector3, vel: Vector3): void;
  7012. }
  7013. }
  7014. declare module "babylonjs/Culling/boundingInfo" {
  7015. import { DeepImmutable } from "babylonjs/types";
  7016. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7017. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7018. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7019. import { Plane } from "babylonjs/Maths/math.plane";
  7020. import { Collider } from "babylonjs/Collisions/collider";
  7021. /**
  7022. * Interface for cullable objects
  7023. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7024. */
  7025. export interface ICullable {
  7026. /**
  7027. * Checks if the object or part of the object is in the frustum
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isInFrustum(frustumPlanes: Plane[]): boolean;
  7032. /**
  7033. * Checks if a cullable object (mesh...) is in the camera frustum
  7034. * Unlike isInFrustum this cheks the full bounding box
  7035. * @param frustumPlanes Camera near/planes
  7036. * @returns true if the object is in frustum otherwise false
  7037. */
  7038. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7039. }
  7040. /**
  7041. * Info for a bounding data of a mesh
  7042. */
  7043. export class BoundingInfo implements ICullable {
  7044. /**
  7045. * Bounding box for the mesh
  7046. */
  7047. readonly boundingBox: BoundingBox;
  7048. /**
  7049. * Bounding sphere for the mesh
  7050. */
  7051. readonly boundingSphere: BoundingSphere;
  7052. private _isLocked;
  7053. private static readonly TmpVector3;
  7054. /**
  7055. * Constructs bounding info
  7056. * @param minimum min vector of the bounding box/sphere
  7057. * @param maximum max vector of the bounding box/sphere
  7058. * @param worldMatrix defines the new world matrix
  7059. */
  7060. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7061. /**
  7062. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7063. * @param min defines the new minimum vector (in local space)
  7064. * @param max defines the new maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7068. /**
  7069. * min vector of the bounding box/sphere
  7070. */
  7071. readonly minimum: Vector3;
  7072. /**
  7073. * max vector of the bounding box/sphere
  7074. */
  7075. readonly maximum: Vector3;
  7076. /**
  7077. * If the info is locked and won't be updated to avoid perf overhead
  7078. */
  7079. isLocked: boolean;
  7080. /**
  7081. * Updates the bounding sphere and box
  7082. * @param world world matrix to be used to update
  7083. */
  7084. update(world: DeepImmutable<Matrix>): void;
  7085. /**
  7086. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7087. * @param center New center of the bounding info
  7088. * @param extend New extend of the bounding info
  7089. * @returns the current bounding info
  7090. */
  7091. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7092. /**
  7093. * Scale the current bounding info by applying a scale factor
  7094. * @param factor defines the scale factor to apply
  7095. * @returns the current bounding info
  7096. */
  7097. scale(factor: number): BoundingInfo;
  7098. /**
  7099. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7100. * @param frustumPlanes defines the frustum to test
  7101. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7102. * @returns true if the bounding info is in the frustum planes
  7103. */
  7104. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7105. /**
  7106. * Gets the world distance between the min and max points of the bounding box
  7107. */
  7108. readonly diagonalLength: number;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. /** @hidden */
  7117. _checkCollision(collider: Collider): boolean;
  7118. /**
  7119. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7120. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7121. * @param point the point to check intersection with
  7122. * @returns if the point intersects
  7123. */
  7124. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7127. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7128. * @param boundingInfo the bounding info to check intersection with
  7129. * @param precise if the intersection should be done using OBB
  7130. * @returns if the bounding info intersects
  7131. */
  7132. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7133. }
  7134. }
  7135. declare module "babylonjs/Maths/math.functions" {
  7136. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7137. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7138. /**
  7139. * Extracts minimum and maximum values from a list of indexed positions
  7140. * @param positions defines the positions to use
  7141. * @param indices defines the indices to the positions
  7142. * @param indexStart defines the start index
  7143. * @param indexCount defines the end index
  7144. * @param bias defines bias value to add to the result
  7145. * @return minimum and maximum values
  7146. */
  7147. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7148. minimum: Vector3;
  7149. maximum: Vector3;
  7150. };
  7151. /**
  7152. * Extracts minimum and maximum values from a list of positions
  7153. * @param positions defines the positions to use
  7154. * @param start defines the start index in the positions array
  7155. * @param count defines the number of positions to handle
  7156. * @param bias defines bias value to add to the result
  7157. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7158. * @return minimum and maximum values
  7159. */
  7160. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7161. minimum: Vector3;
  7162. maximum: Vector3;
  7163. };
  7164. }
  7165. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7167. /** @hidden */
  7168. export class WebGLDataBuffer extends DataBuffer {
  7169. private _buffer;
  7170. constructor(resource: WebGLBuffer);
  7171. readonly underlyingResource: any;
  7172. }
  7173. }
  7174. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7175. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7176. import { Nullable } from "babylonjs/types";
  7177. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7178. /** @hidden */
  7179. export class WebGLPipelineContext implements IPipelineContext {
  7180. engine: ThinEngine;
  7181. program: Nullable<WebGLProgram>;
  7182. context?: WebGLRenderingContext;
  7183. vertexShader?: WebGLShader;
  7184. fragmentShader?: WebGLShader;
  7185. isParallelCompiled: boolean;
  7186. onCompiled?: () => void;
  7187. transformFeedback?: WebGLTransformFeedback | null;
  7188. vertexCompilationError: Nullable<string>;
  7189. fragmentCompilationError: Nullable<string>;
  7190. programLinkError: Nullable<string>;
  7191. programValidationError: Nullable<string>;
  7192. readonly isAsync: boolean;
  7193. readonly isReady: boolean;
  7194. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7195. }
  7196. }
  7197. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7198. import { FloatArray, Nullable } from "babylonjs/types";
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7201. module "babylonjs/Engines/thinEngine" {
  7202. interface ThinEngine {
  7203. /**
  7204. * Create an uniform buffer
  7205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7206. * @param elements defines the content of the uniform buffer
  7207. * @returns the webGL uniform buffer
  7208. */
  7209. createUniformBuffer(elements: FloatArray): DataBuffer;
  7210. /**
  7211. * Create a dynamic uniform buffer
  7212. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7213. * @param elements defines the content of the uniform buffer
  7214. * @returns the webGL uniform buffer
  7215. */
  7216. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7217. /**
  7218. * Update an existing uniform buffer
  7219. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7220. * @param uniformBuffer defines the target uniform buffer
  7221. * @param elements defines the content to update
  7222. * @param offset defines the offset in the uniform buffer where update should start
  7223. * @param count defines the size of the data to update
  7224. */
  7225. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7226. /**
  7227. * Bind an uniform buffer to the current webGL context
  7228. * @param buffer defines the buffer to bind
  7229. */
  7230. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7231. /**
  7232. * Bind a buffer to the current webGL context at a given location
  7233. * @param buffer defines the buffer to bind
  7234. * @param location defines the index where to bind the buffer
  7235. */
  7236. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7237. /**
  7238. * Bind a specific block at a given index in a specific shader program
  7239. * @param pipelineContext defines the pipeline context to use
  7240. * @param blockName defines the block name
  7241. * @param index defines the index where to bind the block
  7242. */
  7243. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7244. }
  7245. }
  7246. }
  7247. declare module "babylonjs/Materials/uniformBuffer" {
  7248. import { Nullable, FloatArray } from "babylonjs/types";
  7249. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7250. import { Engine } from "babylonjs/Engines/engine";
  7251. import { Effect } from "babylonjs/Materials/effect";
  7252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7253. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7254. import { Color3 } from "babylonjs/Maths/math.color";
  7255. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7256. /**
  7257. * Uniform buffer objects.
  7258. *
  7259. * Handles blocks of uniform on the GPU.
  7260. *
  7261. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7262. *
  7263. * For more information, please refer to :
  7264. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7265. */
  7266. export class UniformBuffer {
  7267. private _engine;
  7268. private _buffer;
  7269. private _data;
  7270. private _bufferData;
  7271. private _dynamic?;
  7272. private _uniformLocations;
  7273. private _uniformSizes;
  7274. private _uniformLocationPointer;
  7275. private _needSync;
  7276. private _noUBO;
  7277. private _currentEffect;
  7278. /** @hidden */
  7279. _alreadyBound: boolean;
  7280. private static _MAX_UNIFORM_SIZE;
  7281. private static _tempBuffer;
  7282. /**
  7283. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7288. /**
  7289. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7294. /**
  7295. * Lambda to Update a single float in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateFloat: (name: string, x: number) => void;
  7300. /**
  7301. * Lambda to Update a vec2 of float in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7306. /**
  7307. * Lambda to Update a vec3 of float in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update a vec4 of float in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7318. /**
  7319. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7320. * This is dynamic to allow compat with webgl 1 and 2.
  7321. * You will need to pass the name of the uniform as well as the value.
  7322. */
  7323. updateMatrix: (name: string, mat: Matrix) => void;
  7324. /**
  7325. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7326. * This is dynamic to allow compat with webgl 1 and 2.
  7327. * You will need to pass the name of the uniform as well as the value.
  7328. */
  7329. updateVector3: (name: string, vector: Vector3) => void;
  7330. /**
  7331. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7332. * This is dynamic to allow compat with webgl 1 and 2.
  7333. * You will need to pass the name of the uniform as well as the value.
  7334. */
  7335. updateVector4: (name: string, vector: Vector4) => void;
  7336. /**
  7337. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7338. * This is dynamic to allow compat with webgl 1 and 2.
  7339. * You will need to pass the name of the uniform as well as the value.
  7340. */
  7341. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7342. /**
  7343. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7344. * This is dynamic to allow compat with webgl 1 and 2.
  7345. * You will need to pass the name of the uniform as well as the value.
  7346. */
  7347. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7348. /**
  7349. * Instantiates a new Uniform buffer objects.
  7350. *
  7351. * Handles blocks of uniform on the GPU.
  7352. *
  7353. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7354. *
  7355. * For more information, please refer to :
  7356. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7357. * @param engine Define the engine the buffer is associated with
  7358. * @param data Define the data contained in the buffer
  7359. * @param dynamic Define if the buffer is updatable
  7360. */
  7361. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7362. /**
  7363. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7364. * or just falling back on setUniformXXX calls.
  7365. */
  7366. readonly useUbo: boolean;
  7367. /**
  7368. * Indicates if the WebGL underlying uniform buffer is in sync
  7369. * with the javascript cache data.
  7370. */
  7371. readonly isSync: boolean;
  7372. /**
  7373. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7374. * Also, a dynamic UniformBuffer will disable cache verification and always
  7375. * update the underlying WebGL uniform buffer to the GPU.
  7376. * @returns if Dynamic, otherwise false
  7377. */
  7378. isDynamic(): boolean;
  7379. /**
  7380. * The data cache on JS side.
  7381. * @returns the underlying data as a float array
  7382. */
  7383. getData(): Float32Array;
  7384. /**
  7385. * The underlying WebGL Uniform buffer.
  7386. * @returns the webgl buffer
  7387. */
  7388. getBuffer(): Nullable<DataBuffer>;
  7389. /**
  7390. * std140 layout specifies how to align data within an UBO structure.
  7391. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7392. * for specs.
  7393. */
  7394. private _fillAlignment;
  7395. /**
  7396. * Adds an uniform in the buffer.
  7397. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7398. * for the layout to be correct !
  7399. * @param name Name of the uniform, as used in the uniform block in the shader.
  7400. * @param size Data size, or data directly.
  7401. */
  7402. addUniform(name: string, size: number | number[]): void;
  7403. /**
  7404. * Adds a Matrix 4x4 to the uniform buffer.
  7405. * @param name Name of the uniform, as used in the uniform block in the shader.
  7406. * @param mat A 4x4 matrix.
  7407. */
  7408. addMatrix(name: string, mat: Matrix): void;
  7409. /**
  7410. * Adds a vec2 to the uniform buffer.
  7411. * @param name Name of the uniform, as used in the uniform block in the shader.
  7412. * @param x Define the x component value of the vec2
  7413. * @param y Define the y component value of the vec2
  7414. */
  7415. addFloat2(name: string, x: number, y: number): void;
  7416. /**
  7417. * Adds a vec3 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. * @param x Define the x component value of the vec3
  7420. * @param y Define the y component value of the vec3
  7421. * @param z Define the z component value of the vec3
  7422. */
  7423. addFloat3(name: string, x: number, y: number, z: number): void;
  7424. /**
  7425. * Adds a vec3 to the uniform buffer.
  7426. * @param name Name of the uniform, as used in the uniform block in the shader.
  7427. * @param color Define the vec3 from a Color
  7428. */
  7429. addColor3(name: string, color: Color3): void;
  7430. /**
  7431. * Adds a vec4 to the uniform buffer.
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param color Define the rgb components from a Color
  7434. * @param alpha Define the a component of the vec4
  7435. */
  7436. addColor4(name: string, color: Color3, alpha: number): void;
  7437. /**
  7438. * Adds a vec3 to the uniform buffer.
  7439. * @param name Name of the uniform, as used in the uniform block in the shader.
  7440. * @param vector Define the vec3 components from a Vector
  7441. */
  7442. addVector3(name: string, vector: Vector3): void;
  7443. /**
  7444. * Adds a Matrix 3x3 to the uniform buffer.
  7445. * @param name Name of the uniform, as used in the uniform block in the shader.
  7446. */
  7447. addMatrix3x3(name: string): void;
  7448. /**
  7449. * Adds a Matrix 2x2 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. */
  7452. addMatrix2x2(name: string): void;
  7453. /**
  7454. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7455. */
  7456. create(): void;
  7457. /** @hidden */
  7458. _rebuild(): void;
  7459. /**
  7460. * Updates the WebGL Uniform Buffer on the GPU.
  7461. * If the `dynamic` flag is set to true, no cache comparison is done.
  7462. * Otherwise, the buffer will be updated only if the cache differs.
  7463. */
  7464. update(): void;
  7465. /**
  7466. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7467. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7468. * @param data Define the flattened data
  7469. * @param size Define the size of the data.
  7470. */
  7471. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7472. private _valueCache;
  7473. private _cacheMatrix;
  7474. private _updateMatrix3x3ForUniform;
  7475. private _updateMatrix3x3ForEffect;
  7476. private _updateMatrix2x2ForEffect;
  7477. private _updateMatrix2x2ForUniform;
  7478. private _updateFloatForEffect;
  7479. private _updateFloatForUniform;
  7480. private _updateFloat2ForEffect;
  7481. private _updateFloat2ForUniform;
  7482. private _updateFloat3ForEffect;
  7483. private _updateFloat3ForUniform;
  7484. private _updateFloat4ForEffect;
  7485. private _updateFloat4ForUniform;
  7486. private _updateMatrixForEffect;
  7487. private _updateMatrixForUniform;
  7488. private _updateVector3ForEffect;
  7489. private _updateVector3ForUniform;
  7490. private _updateVector4ForEffect;
  7491. private _updateVector4ForUniform;
  7492. private _updateColor3ForEffect;
  7493. private _updateColor3ForUniform;
  7494. private _updateColor4ForEffect;
  7495. private _updateColor4ForUniform;
  7496. /**
  7497. * Sets a sampler uniform on the effect.
  7498. * @param name Define the name of the sampler.
  7499. * @param texture Define the texture to set in the sampler
  7500. */
  7501. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7502. /**
  7503. * Directly updates the value of the uniform in the cache AND on the GPU.
  7504. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7505. * @param data Define the flattened data
  7506. */
  7507. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7508. /**
  7509. * Binds this uniform buffer to an effect.
  7510. * @param effect Define the effect to bind the buffer to
  7511. * @param name Name of the uniform block in the shader.
  7512. */
  7513. bindToEffect(effect: Effect, name: string): void;
  7514. /**
  7515. * Disposes the uniform buffer.
  7516. */
  7517. dispose(): void;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/iInspectable" {
  7521. /**
  7522. * Enum that determines the text-wrapping mode to use.
  7523. */
  7524. export enum InspectableType {
  7525. /**
  7526. * Checkbox for booleans
  7527. */
  7528. Checkbox = 0,
  7529. /**
  7530. * Sliders for numbers
  7531. */
  7532. Slider = 1,
  7533. /**
  7534. * Vector3
  7535. */
  7536. Vector3 = 2,
  7537. /**
  7538. * Quaternions
  7539. */
  7540. Quaternion = 3,
  7541. /**
  7542. * Color3
  7543. */
  7544. Color3 = 4,
  7545. /**
  7546. * String
  7547. */
  7548. String = 5
  7549. }
  7550. /**
  7551. * Interface used to define custom inspectable properties.
  7552. * This interface is used by the inspector to display custom property grids
  7553. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7554. */
  7555. export interface IInspectable {
  7556. /**
  7557. * Gets the label to display
  7558. */
  7559. label: string;
  7560. /**
  7561. * Gets the name of the property to edit
  7562. */
  7563. propertyName: string;
  7564. /**
  7565. * Gets the type of the editor to use
  7566. */
  7567. type: InspectableType;
  7568. /**
  7569. * Gets the minimum value of the property when using in "slider" mode
  7570. */
  7571. min?: number;
  7572. /**
  7573. * Gets the maximum value of the property when using in "slider" mode
  7574. */
  7575. max?: number;
  7576. /**
  7577. * Gets the setp to use when using in "slider" mode
  7578. */
  7579. step?: number;
  7580. }
  7581. }
  7582. declare module "babylonjs/Misc/timingTools" {
  7583. /**
  7584. * Class used to provide helper for timing
  7585. */
  7586. export class TimingTools {
  7587. /**
  7588. * Polyfill for setImmediate
  7589. * @param action defines the action to execute after the current execution block
  7590. */
  7591. static SetImmediate(action: () => void): void;
  7592. }
  7593. }
  7594. declare module "babylonjs/Misc/instantiationTools" {
  7595. /**
  7596. * Class used to enable instatition of objects by class name
  7597. */
  7598. export class InstantiationTools {
  7599. /**
  7600. * Use this object to register external classes like custom textures or material
  7601. * to allow the laoders to instantiate them
  7602. */
  7603. static RegisteredExternalClasses: {
  7604. [key: string]: Object;
  7605. };
  7606. /**
  7607. * Tries to instantiate a new object from a given class name
  7608. * @param className defines the class name to instantiate
  7609. * @returns the new object or null if the system was not able to do the instantiation
  7610. */
  7611. static Instantiate(className: string): any;
  7612. }
  7613. }
  7614. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7615. /**
  7616. * Define options used to create a depth texture
  7617. */
  7618. export class DepthTextureCreationOptions {
  7619. /** Specifies whether or not a stencil should be allocated in the texture */
  7620. generateStencil?: boolean;
  7621. /** Specifies whether or not bilinear filtering is enable on the texture */
  7622. bilinearFiltering?: boolean;
  7623. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7624. comparisonFunction?: number;
  7625. /** Specifies if the created texture is a cube texture */
  7626. isCube?: boolean;
  7627. }
  7628. }
  7629. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7631. import { Nullable } from "babylonjs/types";
  7632. import { Scene } from "babylonjs/scene";
  7633. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7634. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7635. module "babylonjs/Engines/thinEngine" {
  7636. interface ThinEngine {
  7637. /**
  7638. * Creates a depth stencil cube texture.
  7639. * This is only available in WebGL 2.
  7640. * @param size The size of face edge in the cube texture.
  7641. * @param options The options defining the cube texture.
  7642. * @returns The cube texture
  7643. */
  7644. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7645. /**
  7646. * Creates a cube texture
  7647. * @param rootUrl defines the url where the files to load is located
  7648. * @param scene defines the current scene
  7649. * @param files defines the list of files to load (1 per face)
  7650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7651. * @param onLoad defines an optional callback raised when the texture is loaded
  7652. * @param onError defines an optional callback raised if there is an issue to load the texture
  7653. * @param format defines the format of the data
  7654. * @param forcedExtension defines the extension to use to pick the right loader
  7655. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7656. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7657. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7658. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7659. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /**
  7664. * Creates a cube texture
  7665. * @param rootUrl defines the url where the files to load is located
  7666. * @param scene defines the current scene
  7667. * @param files defines the list of files to load (1 per face)
  7668. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7669. * @param onLoad defines an optional callback raised when the texture is loaded
  7670. * @param onError defines an optional callback raised if there is an issue to load the texture
  7671. * @param format defines the format of the data
  7672. * @param forcedExtension defines the extension to use to pick the right loader
  7673. * @returns the cube texture as an InternalTexture
  7674. */
  7675. 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;
  7676. /**
  7677. * Creates a cube texture
  7678. * @param rootUrl defines the url where the files to load is located
  7679. * @param scene defines the current scene
  7680. * @param files defines the list of files to load (1 per face)
  7681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7682. * @param onLoad defines an optional callback raised when the texture is loaded
  7683. * @param onError defines an optional callback raised if there is an issue to load the texture
  7684. * @param format defines the format of the data
  7685. * @param forcedExtension defines the extension to use to pick the right loader
  7686. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7687. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7688. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. 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;
  7692. /** @hidden */
  7693. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7694. /** @hidden */
  7695. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7696. /** @hidden */
  7697. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7698. /** @hidden */
  7699. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7700. /**
  7701. * @hidden
  7702. */
  7703. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7704. }
  7705. }
  7706. }
  7707. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7708. import { Nullable } from "babylonjs/types";
  7709. import { Scene } from "babylonjs/scene";
  7710. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7712. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7713. /**
  7714. * Class for creating a cube texture
  7715. */
  7716. export class CubeTexture extends BaseTexture {
  7717. private _delayedOnLoad;
  7718. /**
  7719. * The url of the texture
  7720. */
  7721. url: string;
  7722. /**
  7723. * Gets or sets the center of the bounding box associated with the cube texture.
  7724. * It must define where the camera used to render the texture was set
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. boundingBoxPosition: Vector3;
  7728. private _boundingBoxSize;
  7729. /**
  7730. * Gets or sets the size of the bounding box associated with the cube texture
  7731. * When defined, the cubemap will switch to local mode
  7732. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7733. * @example https://www.babylonjs-playground.com/#RNASML
  7734. */
  7735. /**
  7736. * Returns the bounding box size
  7737. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7738. */
  7739. boundingBoxSize: Vector3;
  7740. protected _rotationY: number;
  7741. /**
  7742. * Sets texture matrix rotation angle around Y axis in radians.
  7743. */
  7744. /**
  7745. * Gets texture matrix rotation angle around Y axis radians.
  7746. */
  7747. rotationY: number;
  7748. /**
  7749. * Are mip maps generated for this texture or not.
  7750. */
  7751. readonly noMipmap: boolean;
  7752. private _noMipmap;
  7753. private _files;
  7754. protected _forcedExtension: Nullable<string>;
  7755. private _extensions;
  7756. private _textureMatrix;
  7757. private _format;
  7758. private _createPolynomials;
  7759. /** @hidden */
  7760. _prefiltered: boolean;
  7761. /**
  7762. * Creates a cube texture from an array of image urls
  7763. * @param files defines an array of image urls
  7764. * @param scene defines the hosting scene
  7765. * @param noMipmap specifies if mip maps are not used
  7766. * @returns a cube texture
  7767. */
  7768. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7769. /**
  7770. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7771. * @param url defines the url of the prefiltered texture
  7772. * @param scene defines the scene the texture is attached to
  7773. * @param forcedExtension defines the extension of the file if different from the url
  7774. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7775. * @return the prefiltered texture
  7776. */
  7777. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7778. /**
  7779. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7780. * as prefiltered data.
  7781. * @param rootUrl defines the url of the texture or the root name of the six images
  7782. * @param scene defines the scene the texture is attached to
  7783. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7784. * @param noMipmap defines if mipmaps should be created or not
  7785. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7786. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7787. * @param onError defines a callback triggered in case of error during load
  7788. * @param format defines the internal format to use for the texture once loaded
  7789. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7790. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7791. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7792. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7793. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7794. * @return the cube texture
  7795. */
  7796. 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);
  7797. /**
  7798. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7799. */
  7800. readonly isPrefiltered: boolean;
  7801. /**
  7802. * Get the current class name of the texture useful for serialization or dynamic coding.
  7803. * @returns "CubeTexture"
  7804. */
  7805. getClassName(): string;
  7806. /**
  7807. * Update the url (and optional buffer) of this texture if url was null during construction.
  7808. * @param url the url of the texture
  7809. * @param forcedExtension defines the extension to use
  7810. * @param onLoad callback called when the texture is loaded (defaults to null)
  7811. */
  7812. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7813. /**
  7814. * Delays loading of the cube texture
  7815. * @param forcedExtension defines the extension to use
  7816. */
  7817. delayLoad(forcedExtension?: string): void;
  7818. /**
  7819. * Returns the reflection texture matrix
  7820. * @returns the reflection texture matrix
  7821. */
  7822. getReflectionTextureMatrix(): Matrix;
  7823. /**
  7824. * Sets the reflection texture matrix
  7825. * @param value Reflection texture matrix
  7826. */
  7827. setReflectionTextureMatrix(value: Matrix): void;
  7828. /**
  7829. * Parses text to create a cube texture
  7830. * @param parsedTexture define the serialized text to read from
  7831. * @param scene defines the hosting scene
  7832. * @param rootUrl defines the root url of the cube texture
  7833. * @returns a cube texture
  7834. */
  7835. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7836. /**
  7837. * Makes a clone, or deep copy, of the cube texture
  7838. * @returns a new cube texture
  7839. */
  7840. clone(): CubeTexture;
  7841. }
  7842. }
  7843. declare module "babylonjs/Materials/materialDefines" {
  7844. /**
  7845. * Manages the defines for the Material
  7846. */
  7847. export class MaterialDefines {
  7848. /** @hidden */
  7849. protected _keys: string[];
  7850. private _isDirty;
  7851. /** @hidden */
  7852. _renderId: number;
  7853. /** @hidden */
  7854. _areLightsDirty: boolean;
  7855. /** @hidden */
  7856. _areLightsDisposed: boolean;
  7857. /** @hidden */
  7858. _areAttributesDirty: boolean;
  7859. /** @hidden */
  7860. _areTexturesDirty: boolean;
  7861. /** @hidden */
  7862. _areFresnelDirty: boolean;
  7863. /** @hidden */
  7864. _areMiscDirty: boolean;
  7865. /** @hidden */
  7866. _areImageProcessingDirty: boolean;
  7867. /** @hidden */
  7868. _normals: boolean;
  7869. /** @hidden */
  7870. _uvs: boolean;
  7871. /** @hidden */
  7872. _needNormals: boolean;
  7873. /** @hidden */
  7874. _needUVs: boolean;
  7875. [id: string]: any;
  7876. /**
  7877. * Specifies if the material needs to be re-calculated
  7878. */
  7879. readonly isDirty: boolean;
  7880. /**
  7881. * Marks the material to indicate that it has been re-calculated
  7882. */
  7883. markAsProcessed(): void;
  7884. /**
  7885. * Marks the material to indicate that it needs to be re-calculated
  7886. */
  7887. markAsUnprocessed(): void;
  7888. /**
  7889. * Marks the material to indicate all of its defines need to be re-calculated
  7890. */
  7891. markAllAsDirty(): void;
  7892. /**
  7893. * Marks the material to indicate that image processing needs to be re-calculated
  7894. */
  7895. markAsImageProcessingDirty(): void;
  7896. /**
  7897. * Marks the material to indicate the lights need to be re-calculated
  7898. * @param disposed Defines whether the light is dirty due to dispose or not
  7899. */
  7900. markAsLightDirty(disposed?: boolean): void;
  7901. /**
  7902. * Marks the attribute state as changed
  7903. */
  7904. markAsAttributesDirty(): void;
  7905. /**
  7906. * Marks the texture state as changed
  7907. */
  7908. markAsTexturesDirty(): void;
  7909. /**
  7910. * Marks the fresnel state as changed
  7911. */
  7912. markAsFresnelDirty(): void;
  7913. /**
  7914. * Marks the misc state as changed
  7915. */
  7916. markAsMiscDirty(): void;
  7917. /**
  7918. * Rebuilds the material defines
  7919. */
  7920. rebuild(): void;
  7921. /**
  7922. * Specifies if two material defines are equal
  7923. * @param other - A material define instance to compare to
  7924. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7925. */
  7926. isEqual(other: MaterialDefines): boolean;
  7927. /**
  7928. * Clones this instance's defines to another instance
  7929. * @param other - material defines to clone values to
  7930. */
  7931. cloneTo(other: MaterialDefines): void;
  7932. /**
  7933. * Resets the material define values
  7934. */
  7935. reset(): void;
  7936. /**
  7937. * Converts the material define values to a string
  7938. * @returns - String of material define information
  7939. */
  7940. toString(): string;
  7941. }
  7942. }
  7943. declare module "babylonjs/Materials/colorCurves" {
  7944. import { Effect } from "babylonjs/Materials/effect";
  7945. /**
  7946. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7947. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7948. * 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;
  7949. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7950. */
  7951. export class ColorCurves {
  7952. private _dirty;
  7953. private _tempColor;
  7954. private _globalCurve;
  7955. private _highlightsCurve;
  7956. private _midtonesCurve;
  7957. private _shadowsCurve;
  7958. private _positiveCurve;
  7959. private _negativeCurve;
  7960. private _globalHue;
  7961. private _globalDensity;
  7962. private _globalSaturation;
  7963. private _globalExposure;
  7964. /**
  7965. * Gets the global Hue value.
  7966. * 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).
  7967. */
  7968. /**
  7969. * Sets the global Hue value.
  7970. * 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).
  7971. */
  7972. globalHue: number;
  7973. /**
  7974. * Gets the global Density value.
  7975. * 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.
  7976. * Values less than zero provide a filter of opposite hue.
  7977. */
  7978. /**
  7979. * Sets the global Density value.
  7980. * 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.
  7981. * Values less than zero provide a filter of opposite hue.
  7982. */
  7983. globalDensity: number;
  7984. /**
  7985. * Gets the global Saturation value.
  7986. * 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.
  7987. */
  7988. /**
  7989. * Sets the global Saturation value.
  7990. * 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.
  7991. */
  7992. globalSaturation: number;
  7993. /**
  7994. * Gets the global Exposure value.
  7995. * 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.
  7996. */
  7997. /**
  7998. * Sets the global Exposure value.
  7999. * 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.
  8000. */
  8001. globalExposure: number;
  8002. private _highlightsHue;
  8003. private _highlightsDensity;
  8004. private _highlightsSaturation;
  8005. private _highlightsExposure;
  8006. /**
  8007. * Gets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. /**
  8011. * Sets the highlights Hue value.
  8012. * 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).
  8013. */
  8014. highlightsHue: number;
  8015. /**
  8016. * Gets the highlights Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. /**
  8021. * Sets the highlights Density value.
  8022. * 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.
  8023. * Values less than zero provide a filter of opposite hue.
  8024. */
  8025. highlightsDensity: number;
  8026. /**
  8027. * Gets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. /**
  8031. * Sets the highlights Saturation value.
  8032. * 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.
  8033. */
  8034. highlightsSaturation: number;
  8035. /**
  8036. * Gets the highlights Exposure value.
  8037. * 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.
  8038. */
  8039. /**
  8040. * Sets the highlights Exposure value.
  8041. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8042. */
  8043. highlightsExposure: number;
  8044. private _midtonesHue;
  8045. private _midtonesDensity;
  8046. private _midtonesSaturation;
  8047. private _midtonesExposure;
  8048. /**
  8049. * Gets the midtones Hue value.
  8050. * 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).
  8051. */
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. midtonesHue: number;
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. /**
  8063. * Sets the midtones Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. midtonesDensity: number;
  8068. /**
  8069. * Gets the midtones Saturation value.
  8070. * 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.
  8071. */
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * 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.
  8075. */
  8076. midtonesSaturation: number;
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * 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.
  8080. */
  8081. /**
  8082. * Sets the midtones Exposure value.
  8083. * 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.
  8084. */
  8085. midtonesExposure: number;
  8086. private _shadowsHue;
  8087. private _shadowsDensity;
  8088. private _shadowsSaturation;
  8089. private _shadowsExposure;
  8090. /**
  8091. * Gets the shadows Hue value.
  8092. * 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).
  8093. */
  8094. /**
  8095. * Sets the shadows Hue value.
  8096. * 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).
  8097. */
  8098. shadowsHue: number;
  8099. /**
  8100. * Gets the shadows Density value.
  8101. * 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.
  8102. * Values less than zero provide a filter of opposite hue.
  8103. */
  8104. /**
  8105. * Sets the shadows Density value.
  8106. * 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.
  8107. * Values less than zero provide a filter of opposite hue.
  8108. */
  8109. shadowsDensity: number;
  8110. /**
  8111. * Gets the shadows Saturation value.
  8112. * 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.
  8113. */
  8114. /**
  8115. * Sets the shadows Saturation value.
  8116. * 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.
  8117. */
  8118. shadowsSaturation: number;
  8119. /**
  8120. * Gets the shadows Exposure value.
  8121. * 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.
  8122. */
  8123. /**
  8124. * Sets the shadows Exposure value.
  8125. * 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.
  8126. */
  8127. shadowsExposure: number;
  8128. /**
  8129. * Returns the class name
  8130. * @returns The class name
  8131. */
  8132. getClassName(): string;
  8133. /**
  8134. * Binds the color curves to the shader.
  8135. * @param colorCurves The color curve to bind
  8136. * @param effect The effect to bind to
  8137. * @param positiveUniform The positive uniform shader parameter
  8138. * @param neutralUniform The neutral uniform shader parameter
  8139. * @param negativeUniform The negative uniform shader parameter
  8140. */
  8141. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8142. /**
  8143. * Prepare the list of uniforms associated with the ColorCurves effects.
  8144. * @param uniformsList The list of uniforms used in the effect
  8145. */
  8146. static PrepareUniforms(uniformsList: string[]): void;
  8147. /**
  8148. * Returns color grading data based on a hue, density, saturation and exposure value.
  8149. * @param filterHue The hue of the color filter.
  8150. * @param filterDensity The density of the color filter.
  8151. * @param saturation The saturation.
  8152. * @param exposure The exposure.
  8153. * @param result The result data container.
  8154. */
  8155. private getColorGradingDataToRef;
  8156. /**
  8157. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8158. * @param value The input slider value in range [-100,100].
  8159. * @returns Adjusted value.
  8160. */
  8161. private static applyColorGradingSliderNonlinear;
  8162. /**
  8163. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8164. * @param hue The hue (H) input.
  8165. * @param saturation The saturation (S) input.
  8166. * @param brightness The brightness (B) input.
  8167. * @result An RGBA color represented as Vector4.
  8168. */
  8169. private static fromHSBToRef;
  8170. /**
  8171. * Returns a value clamped between min and max
  8172. * @param value The value to clamp
  8173. * @param min The minimum of value
  8174. * @param max The maximum of value
  8175. * @returns The clamped value.
  8176. */
  8177. private static clamp;
  8178. /**
  8179. * Clones the current color curve instance.
  8180. * @return The cloned curves
  8181. */
  8182. clone(): ColorCurves;
  8183. /**
  8184. * Serializes the current color curve instance to a json representation.
  8185. * @return a JSON representation
  8186. */
  8187. serialize(): any;
  8188. /**
  8189. * Parses the color curve from a json representation.
  8190. * @param source the JSON source to parse
  8191. * @return The parsed curves
  8192. */
  8193. static Parse(source: any): ColorCurves;
  8194. }
  8195. }
  8196. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8197. import { Observable } from "babylonjs/Misc/observable";
  8198. import { Nullable } from "babylonjs/types";
  8199. import { Color4 } from "babylonjs/Maths/math.color";
  8200. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8201. import { Effect } from "babylonjs/Materials/effect";
  8202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8203. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. /**
  8269. * Sets wether the color curves effect is enabled.
  8270. */
  8271. colorCurvesEnabled: boolean;
  8272. private _colorGradingTexture;
  8273. /**
  8274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8275. */
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. colorGradingTexture: Nullable<BaseTexture>;
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. /**
  8285. * Sets wether the color grading effect is enabled.
  8286. */
  8287. colorGradingEnabled: boolean;
  8288. private _colorGradingWithGreenDepth;
  8289. /**
  8290. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8291. */
  8292. /**
  8293. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. colorGradingWithGreenDepth: boolean;
  8296. private _colorGradingBGR;
  8297. /**
  8298. * Gets wether the color grading texture contains BGR values.
  8299. */
  8300. /**
  8301. * Sets wether the color grading texture contains BGR values.
  8302. */
  8303. colorGradingBGR: boolean;
  8304. /** @hidden */
  8305. _exposure: number;
  8306. /**
  8307. * Gets the Exposure used in the effect.
  8308. */
  8309. /**
  8310. * Sets the Exposure used in the effect.
  8311. */
  8312. exposure: number;
  8313. private _toneMappingEnabled;
  8314. /**
  8315. * Gets wether the tone mapping effect is enabled.
  8316. */
  8317. /**
  8318. * Sets wether the tone mapping effect is enabled.
  8319. */
  8320. toneMappingEnabled: boolean;
  8321. private _toneMappingType;
  8322. /**
  8323. * Gets the type of tone mapping effect.
  8324. */
  8325. /**
  8326. * Sets the type of tone mapping effect used in BabylonJS.
  8327. */
  8328. toneMappingType: number;
  8329. protected _contrast: number;
  8330. /**
  8331. * Gets the contrast used in the effect.
  8332. */
  8333. /**
  8334. * Sets the contrast used in the effect.
  8335. */
  8336. contrast: number;
  8337. /**
  8338. * Vignette stretch size.
  8339. */
  8340. vignetteStretch: number;
  8341. /**
  8342. * Vignette centre X Offset.
  8343. */
  8344. vignetteCentreX: number;
  8345. /**
  8346. * Vignette centre Y Offset.
  8347. */
  8348. vignetteCentreY: number;
  8349. /**
  8350. * Vignette weight or intensity of the vignette effect.
  8351. */
  8352. vignetteWeight: number;
  8353. /**
  8354. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8355. * if vignetteEnabled is set to true.
  8356. */
  8357. vignetteColor: Color4;
  8358. /**
  8359. * Camera field of view used by the Vignette effect.
  8360. */
  8361. vignetteCameraFov: number;
  8362. private _vignetteBlendMode;
  8363. /**
  8364. * Gets the vignette blend mode allowing different kind of effect.
  8365. */
  8366. /**
  8367. * Sets the vignette blend mode allowing different kind of effect.
  8368. */
  8369. vignetteBlendMode: number;
  8370. private _vignetteEnabled;
  8371. /**
  8372. * Gets wether the vignette effect is enabled.
  8373. */
  8374. /**
  8375. * Sets wether the vignette effect is enabled.
  8376. */
  8377. vignetteEnabled: boolean;
  8378. private _applyByPostProcess;
  8379. /**
  8380. * Gets wether the image processing is applied through a post process or not.
  8381. */
  8382. /**
  8383. * Sets wether the image processing is applied through a post process or not.
  8384. */
  8385. applyByPostProcess: boolean;
  8386. private _isEnabled;
  8387. /**
  8388. * Gets wether the image processing is enabled or not.
  8389. */
  8390. /**
  8391. * Sets wether the image processing is enabled or not.
  8392. */
  8393. isEnabled: boolean;
  8394. /**
  8395. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8396. */
  8397. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8398. /**
  8399. * Method called each time the image processing information changes requires to recompile the effect.
  8400. */
  8401. protected _updateParameters(): void;
  8402. /**
  8403. * Gets the current class name.
  8404. * @return "ImageProcessingConfiguration"
  8405. */
  8406. getClassName(): string;
  8407. /**
  8408. * Prepare the list of uniforms associated with the Image Processing effects.
  8409. * @param uniforms The list of uniforms used in the effect
  8410. * @param defines the list of defines currently in use
  8411. */
  8412. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8413. /**
  8414. * Prepare the list of samplers associated with the Image Processing effects.
  8415. * @param samplersList The list of uniforms used in the effect
  8416. * @param defines the list of defines currently in use
  8417. */
  8418. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8419. /**
  8420. * Prepare the list of defines associated to the shader.
  8421. * @param defines the list of defines to complete
  8422. * @param forPostProcess Define if we are currently in post process mode or not
  8423. */
  8424. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8425. /**
  8426. * Returns true if all the image processing information are ready.
  8427. * @returns True if ready, otherwise, false
  8428. */
  8429. isReady(): boolean;
  8430. /**
  8431. * Binds the image processing to the shader.
  8432. * @param effect The effect to bind to
  8433. * @param overrideAspectRatio Override the aspect ratio of the effect
  8434. */
  8435. bind(effect: Effect, overrideAspectRatio?: number): void;
  8436. /**
  8437. * Clones the current image processing instance.
  8438. * @return The cloned image processing
  8439. */
  8440. clone(): ImageProcessingConfiguration;
  8441. /**
  8442. * Serializes the current image processing instance to a json representation.
  8443. * @return a JSON representation
  8444. */
  8445. serialize(): any;
  8446. /**
  8447. * Parses the image processing from a json representation.
  8448. * @param source the JSON source to parse
  8449. * @return The parsed image processing
  8450. */
  8451. static Parse(source: any): ImageProcessingConfiguration;
  8452. private static _VIGNETTEMODE_MULTIPLY;
  8453. private static _VIGNETTEMODE_OPAQUE;
  8454. /**
  8455. * Used to apply the vignette as a mix with the pixel color.
  8456. */
  8457. static readonly VIGNETTEMODE_MULTIPLY: number;
  8458. /**
  8459. * Used to apply the vignette as a replacement of the pixel color.
  8460. */
  8461. static readonly VIGNETTEMODE_OPAQUE: number;
  8462. }
  8463. }
  8464. declare module "babylonjs/Shaders/postprocess.vertex" {
  8465. /** @hidden */
  8466. export var postprocessVertexShader: {
  8467. name: string;
  8468. shader: string;
  8469. };
  8470. }
  8471. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8473. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8474. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8475. module "babylonjs/Engines/thinEngine" {
  8476. interface ThinEngine {
  8477. /**
  8478. * Creates a new render target texture
  8479. * @param size defines the size of the texture
  8480. * @param options defines the options used to create the texture
  8481. * @returns a new render target texture stored in an InternalTexture
  8482. */
  8483. createRenderTargetTexture(size: number | {
  8484. width: number;
  8485. height: number;
  8486. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8487. /**
  8488. * Creates a depth stencil texture.
  8489. * This is only available in WebGL 2 or with the depth texture extension available.
  8490. * @param size The size of face edge in the texture.
  8491. * @param options The options defining the texture.
  8492. * @returns The texture
  8493. */
  8494. createDepthStencilTexture(size: number | {
  8495. width: number;
  8496. height: number;
  8497. }, options: DepthTextureCreationOptions): InternalTexture;
  8498. /** @hidden */
  8499. _createDepthStencilTexture(size: number | {
  8500. width: number;
  8501. height: number;
  8502. }, options: DepthTextureCreationOptions): InternalTexture;
  8503. }
  8504. }
  8505. }
  8506. declare module "babylonjs/Maths/math.axis" {
  8507. import { Vector3 } from "babylonjs/Maths/math.vector";
  8508. /** Defines supported spaces */
  8509. export enum Space {
  8510. /** Local (object) space */
  8511. LOCAL = 0,
  8512. /** World space */
  8513. WORLD = 1,
  8514. /** Bone space */
  8515. BONE = 2
  8516. }
  8517. /** Defines the 3 main axes */
  8518. export class Axis {
  8519. /** X axis */
  8520. static X: Vector3;
  8521. /** Y axis */
  8522. static Y: Vector3;
  8523. /** Z axis */
  8524. static Z: Vector3;
  8525. }
  8526. }
  8527. declare module "babylonjs/Cameras/targetCamera" {
  8528. import { Nullable } from "babylonjs/types";
  8529. import { Camera } from "babylonjs/Cameras/camera";
  8530. import { Scene } from "babylonjs/scene";
  8531. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8532. /**
  8533. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8534. * This is the base of the follow, arc rotate cameras and Free camera
  8535. * @see http://doc.babylonjs.com/features/cameras
  8536. */
  8537. export class TargetCamera extends Camera {
  8538. private static _RigCamTransformMatrix;
  8539. private static _TargetTransformMatrix;
  8540. private static _TargetFocalPoint;
  8541. /**
  8542. * Define the current direction the camera is moving to
  8543. */
  8544. cameraDirection: Vector3;
  8545. /**
  8546. * Define the current rotation the camera is rotating to
  8547. */
  8548. cameraRotation: Vector2;
  8549. /**
  8550. * When set, the up vector of the camera will be updated by the rotation of the camera
  8551. */
  8552. updateUpVectorFromRotation: boolean;
  8553. private _tmpQuaternion;
  8554. /**
  8555. * Define the current rotation of the camera
  8556. */
  8557. rotation: Vector3;
  8558. /**
  8559. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8560. */
  8561. rotationQuaternion: Quaternion;
  8562. /**
  8563. * Define the current speed of the camera
  8564. */
  8565. speed: number;
  8566. /**
  8567. * Add constraint to the camera to prevent it to move freely in all directions and
  8568. * around all axis.
  8569. */
  8570. noRotationConstraint: boolean;
  8571. /**
  8572. * Define the current target of the camera as an object or a position.
  8573. */
  8574. lockedTarget: any;
  8575. /** @hidden */
  8576. _currentTarget: Vector3;
  8577. /** @hidden */
  8578. _initialFocalDistance: number;
  8579. /** @hidden */
  8580. _viewMatrix: Matrix;
  8581. /** @hidden */
  8582. _camMatrix: Matrix;
  8583. /** @hidden */
  8584. _cameraTransformMatrix: Matrix;
  8585. /** @hidden */
  8586. _cameraRotationMatrix: Matrix;
  8587. /** @hidden */
  8588. _referencePoint: Vector3;
  8589. /** @hidden */
  8590. _transformedReferencePoint: Vector3;
  8591. protected _globalCurrentTarget: Vector3;
  8592. protected _globalCurrentUpVector: Vector3;
  8593. /** @hidden */
  8594. _reset: () => void;
  8595. private _defaultUp;
  8596. /**
  8597. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8598. * This is the base of the follow, arc rotate cameras and Free camera
  8599. * @see http://doc.babylonjs.com/features/cameras
  8600. * @param name Defines the name of the camera in the scene
  8601. * @param position Defines the start position of the camera in the scene
  8602. * @param scene Defines the scene the camera belongs to
  8603. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8604. */
  8605. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8606. /**
  8607. * Gets the position in front of the camera at a given distance.
  8608. * @param distance The distance from the camera we want the position to be
  8609. * @returns the position
  8610. */
  8611. getFrontPosition(distance: number): Vector3;
  8612. /** @hidden */
  8613. _getLockedTargetPosition(): Nullable<Vector3>;
  8614. private _storedPosition;
  8615. private _storedRotation;
  8616. private _storedRotationQuaternion;
  8617. /**
  8618. * Store current camera state of the camera (fov, position, rotation, etc..)
  8619. * @returns the camera
  8620. */
  8621. storeState(): Camera;
  8622. /**
  8623. * Restored camera state. You must call storeState() first
  8624. * @returns whether it was successful or not
  8625. * @hidden
  8626. */
  8627. _restoreStateValues(): boolean;
  8628. /** @hidden */
  8629. _initCache(): void;
  8630. /** @hidden */
  8631. _updateCache(ignoreParentClass?: boolean): void;
  8632. /** @hidden */
  8633. _isSynchronizedViewMatrix(): boolean;
  8634. /** @hidden */
  8635. _computeLocalCameraSpeed(): number;
  8636. /**
  8637. * Defines the target the camera should look at.
  8638. * @param target Defines the new target as a Vector or a mesh
  8639. */
  8640. setTarget(target: Vector3): void;
  8641. /**
  8642. * Return the current target position of the camera. This value is expressed in local space.
  8643. * @returns the target position
  8644. */
  8645. getTarget(): Vector3;
  8646. /** @hidden */
  8647. _decideIfNeedsToMove(): boolean;
  8648. /** @hidden */
  8649. _updatePosition(): void;
  8650. /** @hidden */
  8651. _checkInputs(): void;
  8652. protected _updateCameraRotationMatrix(): void;
  8653. /**
  8654. * 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)
  8655. * @returns the current camera
  8656. */
  8657. private _rotateUpVectorWithCameraRotationMatrix;
  8658. private _cachedRotationZ;
  8659. private _cachedQuaternionRotationZ;
  8660. /** @hidden */
  8661. _getViewMatrix(): Matrix;
  8662. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8663. /**
  8664. * @hidden
  8665. */
  8666. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8667. /**
  8668. * @hidden
  8669. */
  8670. _updateRigCameras(): void;
  8671. private _getRigCamPositionAndTarget;
  8672. /**
  8673. * Gets the current object class name.
  8674. * @return the class name
  8675. */
  8676. getClassName(): string;
  8677. }
  8678. }
  8679. declare module "babylonjs/Events/keyboardEvents" {
  8680. /**
  8681. * Gather the list of keyboard event types as constants.
  8682. */
  8683. export class KeyboardEventTypes {
  8684. /**
  8685. * The keydown event is fired when a key becomes active (pressed).
  8686. */
  8687. static readonly KEYDOWN: number;
  8688. /**
  8689. * The keyup event is fired when a key has been released.
  8690. */
  8691. static readonly KEYUP: number;
  8692. }
  8693. /**
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. */
  8696. export class KeyboardInfo {
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number;
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent;
  8705. /**
  8706. * Instantiates a new keyboard info.
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. * @param type Defines the type of event (KeyboardEventTypes)
  8709. * @param event Defines the related dom event
  8710. */
  8711. constructor(
  8712. /**
  8713. * Defines the type of event (KeyboardEventTypes)
  8714. */
  8715. type: number,
  8716. /**
  8717. * Defines the related dom event
  8718. */
  8719. event: KeyboardEvent);
  8720. }
  8721. /**
  8722. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8723. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8724. */
  8725. export class KeyboardInfoPre extends KeyboardInfo {
  8726. /**
  8727. * Defines the type of event (KeyboardEventTypes)
  8728. */
  8729. type: number;
  8730. /**
  8731. * Defines the related dom event
  8732. */
  8733. event: KeyboardEvent;
  8734. /**
  8735. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8736. */
  8737. skipOnPointerObservable: boolean;
  8738. /**
  8739. * Instantiates a new keyboard pre info.
  8740. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8741. * @param type Defines the type of event (KeyboardEventTypes)
  8742. * @param event Defines the related dom event
  8743. */
  8744. constructor(
  8745. /**
  8746. * Defines the type of event (KeyboardEventTypes)
  8747. */
  8748. type: number,
  8749. /**
  8750. * Defines the related dom event
  8751. */
  8752. event: KeyboardEvent);
  8753. }
  8754. }
  8755. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8756. import { Nullable } from "babylonjs/types";
  8757. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8759. /**
  8760. * Manage the keyboard inputs to control the movement of a free camera.
  8761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8762. */
  8763. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8764. /**
  8765. * Defines the camera the input is attached to.
  8766. */
  8767. camera: FreeCamera;
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8770. */
  8771. keysUp: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8774. */
  8775. keysDown: number[];
  8776. /**
  8777. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8778. */
  8779. keysLeft: number[];
  8780. /**
  8781. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8782. */
  8783. keysRight: number[];
  8784. private _keys;
  8785. private _onCanvasBlurObserver;
  8786. private _onKeyboardObserver;
  8787. private _engine;
  8788. private _scene;
  8789. /**
  8790. * Attach the input controls to a specific dom element to get the input from.
  8791. * @param element Defines the element the controls should be listened from
  8792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8793. */
  8794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8795. /**
  8796. * Detach the current controls from the specified dom element.
  8797. * @param element Defines the element to stop listening the inputs from
  8798. */
  8799. detachControl(element: Nullable<HTMLElement>): void;
  8800. /**
  8801. * Update the current camera state depending on the inputs that have been used this frame.
  8802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8803. */
  8804. checkInputs(): void;
  8805. /**
  8806. * Gets the class name of the current intput.
  8807. * @returns the class name
  8808. */
  8809. getClassName(): string;
  8810. /** @hidden */
  8811. _onLostFocus(): void;
  8812. /**
  8813. * Get the friendly name associated with the input class.
  8814. * @returns the input friendly name
  8815. */
  8816. getSimpleName(): string;
  8817. }
  8818. }
  8819. declare module "babylonjs/Lights/shadowLight" {
  8820. import { Camera } from "babylonjs/Cameras/camera";
  8821. import { Scene } from "babylonjs/scene";
  8822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8824. import { Light } from "babylonjs/Lights/light";
  8825. /**
  8826. * Interface describing all the common properties and methods a shadow light needs to implement.
  8827. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8828. * as well as binding the different shadow properties to the effects.
  8829. */
  8830. export interface IShadowLight extends Light {
  8831. /**
  8832. * The light id in the scene (used in scene.findLighById for instance)
  8833. */
  8834. id: string;
  8835. /**
  8836. * The position the shdow will be casted from.
  8837. */
  8838. position: Vector3;
  8839. /**
  8840. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8841. */
  8842. direction: Vector3;
  8843. /**
  8844. * The transformed position. Position of the light in world space taking parenting in account.
  8845. */
  8846. transformedPosition: Vector3;
  8847. /**
  8848. * The transformed direction. Direction of the light in world space taking parenting in account.
  8849. */
  8850. transformedDirection: Vector3;
  8851. /**
  8852. * The friendly name of the light in the scene.
  8853. */
  8854. name: string;
  8855. /**
  8856. * Defines the shadow projection clipping minimum z value.
  8857. */
  8858. shadowMinZ: number;
  8859. /**
  8860. * Defines the shadow projection clipping maximum z value.
  8861. */
  8862. shadowMaxZ: number;
  8863. /**
  8864. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8865. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8866. */
  8867. computeTransformedInformation(): boolean;
  8868. /**
  8869. * Gets the scene the light belongs to.
  8870. * @returns The scene
  8871. */
  8872. getScene(): Scene;
  8873. /**
  8874. * Callback defining a custom Projection Matrix Builder.
  8875. * This can be used to override the default projection matrix computation.
  8876. */
  8877. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8878. /**
  8879. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8880. * @param matrix The materix to updated with the projection information
  8881. * @param viewMatrix The transform matrix of the light
  8882. * @param renderList The list of mesh to render in the map
  8883. * @returns The current light
  8884. */
  8885. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8886. /**
  8887. * Gets the current depth scale used in ESM.
  8888. * @returns The scale
  8889. */
  8890. getDepthScale(): number;
  8891. /**
  8892. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8893. * @returns true if a cube texture needs to be use
  8894. */
  8895. needCube(): boolean;
  8896. /**
  8897. * Detects if the projection matrix requires to be recomputed this frame.
  8898. * @returns true if it requires to be recomputed otherwise, false.
  8899. */
  8900. needProjectionMatrixCompute(): boolean;
  8901. /**
  8902. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8903. */
  8904. forceProjectionMatrixCompute(): void;
  8905. /**
  8906. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8907. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8908. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8909. */
  8910. getShadowDirection(faceIndex?: number): Vector3;
  8911. /**
  8912. * Gets the minZ used for shadow according to both the scene and the light.
  8913. * @param activeCamera The camera we are returning the min for
  8914. * @returns the depth min z
  8915. */
  8916. getDepthMinZ(activeCamera: Camera): number;
  8917. /**
  8918. * Gets the maxZ used for shadow according to both the scene and the light.
  8919. * @param activeCamera The camera we are returning the max for
  8920. * @returns the depth max z
  8921. */
  8922. getDepthMaxZ(activeCamera: Camera): number;
  8923. }
  8924. /**
  8925. * Base implementation IShadowLight
  8926. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8927. */
  8928. export abstract class ShadowLight extends Light implements IShadowLight {
  8929. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8930. protected _position: Vector3;
  8931. protected _setPosition(value: Vector3): void;
  8932. /**
  8933. * Sets the position the shadow will be casted from. Also use as the light position for both
  8934. * point and spot lights.
  8935. */
  8936. /**
  8937. * Sets the position the shadow will be casted from. Also use as the light position for both
  8938. * point and spot lights.
  8939. */
  8940. position: Vector3;
  8941. protected _direction: Vector3;
  8942. protected _setDirection(value: Vector3): void;
  8943. /**
  8944. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8945. * Also use as the light direction on spot and directional lights.
  8946. */
  8947. /**
  8948. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8949. * Also use as the light direction on spot and directional lights.
  8950. */
  8951. direction: Vector3;
  8952. private _shadowMinZ;
  8953. /**
  8954. * Gets the shadow projection clipping minimum z value.
  8955. */
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. shadowMinZ: number;
  8960. private _shadowMaxZ;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. /**
  8965. * Gets the shadow projection clipping maximum z value.
  8966. */
  8967. shadowMaxZ: number;
  8968. /**
  8969. * Callback defining a custom Projection Matrix Builder.
  8970. * This can be used to override the default projection matrix computation.
  8971. */
  8972. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8973. /**
  8974. * The transformed position. Position of the light in world space taking parenting in account.
  8975. */
  8976. transformedPosition: Vector3;
  8977. /**
  8978. * The transformed direction. Direction of the light in world space taking parenting in account.
  8979. */
  8980. transformedDirection: Vector3;
  8981. private _needProjectionMatrixCompute;
  8982. /**
  8983. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8984. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8985. */
  8986. computeTransformedInformation(): boolean;
  8987. /**
  8988. * Return the depth scale used for the shadow map.
  8989. * @returns the depth scale.
  8990. */
  8991. getDepthScale(): number;
  8992. /**
  8993. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8994. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8995. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8996. */
  8997. getShadowDirection(faceIndex?: number): Vector3;
  8998. /**
  8999. * Returns the ShadowLight absolute position in the World.
  9000. * @returns the position vector in world space
  9001. */
  9002. getAbsolutePosition(): Vector3;
  9003. /**
  9004. * Sets the ShadowLight direction toward the passed target.
  9005. * @param target The point to target in local space
  9006. * @returns the updated ShadowLight direction
  9007. */
  9008. setDirectionToTarget(target: Vector3): Vector3;
  9009. /**
  9010. * Returns the light rotation in euler definition.
  9011. * @returns the x y z rotation in local space.
  9012. */
  9013. getRotation(): Vector3;
  9014. /**
  9015. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9016. * @returns true if a cube texture needs to be use
  9017. */
  9018. needCube(): boolean;
  9019. /**
  9020. * Detects if the projection matrix requires to be recomputed this frame.
  9021. * @returns true if it requires to be recomputed otherwise, false.
  9022. */
  9023. needProjectionMatrixCompute(): boolean;
  9024. /**
  9025. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9026. */
  9027. forceProjectionMatrixCompute(): void;
  9028. /** @hidden */
  9029. _initCache(): void;
  9030. /** @hidden */
  9031. _isSynchronized(): boolean;
  9032. /**
  9033. * Computes the world matrix of the node
  9034. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9035. * @returns the world matrix
  9036. */
  9037. computeWorldMatrix(force?: boolean): Matrix;
  9038. /**
  9039. * Gets the minZ used for shadow according to both the scene and the light.
  9040. * @param activeCamera The camera we are returning the min for
  9041. * @returns the depth min z
  9042. */
  9043. getDepthMinZ(activeCamera: Camera): number;
  9044. /**
  9045. * Gets the maxZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the max for
  9047. * @returns the depth max z
  9048. */
  9049. getDepthMaxZ(activeCamera: Camera): number;
  9050. /**
  9051. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9052. * @param matrix The materix to updated with the projection information
  9053. * @param viewMatrix The transform matrix of the light
  9054. * @param renderList The list of mesh to render in the map
  9055. * @returns The current light
  9056. */
  9057. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9058. }
  9059. }
  9060. declare module "babylonjs/Materials/effectFallbacks" {
  9061. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9062. import { Effect } from "babylonjs/Materials/effect";
  9063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9064. /**
  9065. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9066. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9067. */
  9068. export class EffectFallbacks implements IEffectFallbacks {
  9069. private _defines;
  9070. private _currentRank;
  9071. private _maxRank;
  9072. private _mesh;
  9073. /**
  9074. * Removes the fallback from the bound mesh.
  9075. */
  9076. unBindMesh(): void;
  9077. /**
  9078. * Adds a fallback on the specified property.
  9079. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9080. * @param define The name of the define in the shader
  9081. */
  9082. addFallback(rank: number, define: string): void;
  9083. /**
  9084. * Sets the mesh to use CPU skinning when needing to fallback.
  9085. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9086. * @param mesh The mesh to use the fallbacks.
  9087. */
  9088. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9089. /**
  9090. * Checks to see if more fallbacks are still availible.
  9091. */
  9092. readonly hasMoreFallbacks: boolean;
  9093. /**
  9094. * Removes the defines that should be removed when falling back.
  9095. * @param currentDefines defines the current define statements for the shader.
  9096. * @param effect defines the current effect we try to compile
  9097. * @returns The resulting defines with defines of the current rank removed.
  9098. */
  9099. reduce(currentDefines: string, effect: Effect): string;
  9100. }
  9101. }
  9102. declare module "babylonjs/Materials/materialHelper" {
  9103. import { Nullable } from "babylonjs/types";
  9104. import { Scene } from "babylonjs/scene";
  9105. import { Engine } from "babylonjs/Engines/engine";
  9106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9107. import { Light } from "babylonjs/Lights/light";
  9108. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9109. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9111. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9112. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9113. /**
  9114. * "Static Class" containing the most commonly used helper while dealing with material for
  9115. * rendering purpose.
  9116. *
  9117. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9118. *
  9119. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9120. */
  9121. export class MaterialHelper {
  9122. /**
  9123. * Bind the current view position to an effect.
  9124. * @param effect The effect to be bound
  9125. * @param scene The scene the eyes position is used from
  9126. */
  9127. static BindEyePosition(effect: Effect, scene: Scene): void;
  9128. /**
  9129. * Helps preparing the defines values about the UVs in used in the effect.
  9130. * UVs are shared as much as we can accross channels in the shaders.
  9131. * @param texture The texture we are preparing the UVs for
  9132. * @param defines The defines to update
  9133. * @param key The channel key "diffuse", "specular"... used in the shader
  9134. */
  9135. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9136. /**
  9137. * Binds a texture matrix value to its corrsponding uniform
  9138. * @param texture The texture to bind the matrix for
  9139. * @param uniformBuffer The uniform buffer receivin the data
  9140. * @param key The channel key "diffuse", "specular"... used in the shader
  9141. */
  9142. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9143. /**
  9144. * Gets the current status of the fog (should it be enabled?)
  9145. * @param mesh defines the mesh to evaluate for fog support
  9146. * @param scene defines the hosting scene
  9147. * @returns true if fog must be enabled
  9148. */
  9149. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9150. /**
  9151. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9152. * @param mesh defines the current mesh
  9153. * @param scene defines the current scene
  9154. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9155. * @param pointsCloud defines if point cloud rendering has to be turned on
  9156. * @param fogEnabled defines if fog has to be turned on
  9157. * @param alphaTest defines if alpha testing has to be turned on
  9158. * @param defines defines the current list of defines
  9159. */
  9160. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9161. /**
  9162. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9163. * @param scene defines the current scene
  9164. * @param engine defines the current engine
  9165. * @param defines specifies the list of active defines
  9166. * @param useInstances defines if instances have to be turned on
  9167. * @param useClipPlane defines if clip plane have to be turned on
  9168. */
  9169. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9170. /**
  9171. * Prepares the defines for bones
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. */
  9175. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9176. /**
  9177. * Prepares the defines for morph targets
  9178. * @param mesh The mesh containing the geometry data we will draw
  9179. * @param defines The defines to update
  9180. */
  9181. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9182. /**
  9183. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9184. * @param mesh The mesh containing the geometry data we will draw
  9185. * @param defines The defines to update
  9186. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9187. * @param useBones Precise whether bones should be used or not (override mesh info)
  9188. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9189. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9190. * @returns false if defines are considered not dirty and have not been checked
  9191. */
  9192. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9193. /**
  9194. * Prepares the defines related to multiview
  9195. * @param scene The scene we are intending to draw
  9196. * @param defines The defines to update
  9197. */
  9198. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9199. /**
  9200. * Prepares the defines related to the light information passed in parameter
  9201. * @param scene The scene we are intending to draw
  9202. * @param mesh The mesh the effect is compiling for
  9203. * @param light The light the effect is compiling for
  9204. * @param lightIndex The index of the light
  9205. * @param defines The defines to update
  9206. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9207. * @param state Defines the current state regarding what is needed (normals, etc...)
  9208. */
  9209. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9210. needNormals: boolean;
  9211. needRebuild: boolean;
  9212. shadowEnabled: boolean;
  9213. specularEnabled: boolean;
  9214. lightmapMode: boolean;
  9215. }): void;
  9216. /**
  9217. * Prepares the defines related to the light information passed in parameter
  9218. * @param scene The scene we are intending to draw
  9219. * @param mesh The mesh the effect is compiling for
  9220. * @param defines The defines to update
  9221. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9222. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9223. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9224. * @returns true if normals will be required for the rest of the effect
  9225. */
  9226. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9229. * @param lightIndex defines the light index
  9230. * @param uniformsList The uniform list
  9231. * @param samplersList The sampler list
  9232. * @param projectedLightTexture defines if projected texture must be used
  9233. * @param uniformBuffersList defines an optional list of uniform buffers
  9234. */
  9235. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9236. /**
  9237. * Prepares the uniforms and samplers list to be used in the effect
  9238. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9239. * @param samplersList The sampler list
  9240. * @param defines The defines helping in the list generation
  9241. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9242. */
  9243. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9244. /**
  9245. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9246. * @param defines The defines to update while falling back
  9247. * @param fallbacks The authorized effect fallbacks
  9248. * @param maxSimultaneousLights The maximum number of lights allowed
  9249. * @param rank the current rank of the Effect
  9250. * @returns The newly affected rank
  9251. */
  9252. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9253. private static _TmpMorphInfluencers;
  9254. /**
  9255. * Prepares the list of attributes required for morph targets according to the effect defines.
  9256. * @param attribs The current list of supported attribs
  9257. * @param mesh The mesh to prepare the morph targets attributes for
  9258. * @param influencers The number of influencers
  9259. */
  9260. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9261. /**
  9262. * Prepares the list of attributes required for morph targets according to the effect defines.
  9263. * @param attribs The current list of supported attribs
  9264. * @param mesh The mesh to prepare the morph targets attributes for
  9265. * @param defines The current Defines of the effect
  9266. */
  9267. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9268. /**
  9269. * Prepares the list of attributes required for bones according to the effect defines.
  9270. * @param attribs The current list of supported attribs
  9271. * @param mesh The mesh to prepare the bones attributes for
  9272. * @param defines The current Defines of the effect
  9273. * @param fallbacks The current efffect fallback strategy
  9274. */
  9275. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9276. /**
  9277. * Check and prepare the list of attributes required for instances according to the effect defines.
  9278. * @param attribs The current list of supported attribs
  9279. * @param defines The current MaterialDefines of the effect
  9280. */
  9281. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9282. /**
  9283. * Add the list of attributes required for instances to the attribs array.
  9284. * @param attribs The current list of supported attribs
  9285. */
  9286. static PushAttributesForInstances(attribs: string[]): void;
  9287. /**
  9288. * Binds the light information to the effect.
  9289. * @param light The light containing the generator
  9290. * @param effect The effect we are binding the data to
  9291. * @param lightIndex The light index in the effect used to render
  9292. */
  9293. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9294. /**
  9295. * Binds the lights information from the scene to the effect for the given mesh.
  9296. * @param light Light to bind
  9297. * @param lightIndex Light index
  9298. * @param scene The scene where the light belongs to
  9299. * @param effect The effect we are binding the data to
  9300. * @param useSpecular Defines if specular is supported
  9301. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9302. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9303. */
  9304. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9305. /**
  9306. * Binds the lights information from the scene to the effect for the given mesh.
  9307. * @param scene The scene the lights belongs to
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. * @param defines The generated defines for the effect
  9311. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9312. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9313. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9314. */
  9315. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9316. private static _tempFogColor;
  9317. /**
  9318. * Binds the fog information from the scene to the effect for the given mesh.
  9319. * @param scene The scene the lights belongs to
  9320. * @param mesh The mesh we are binding the information to render
  9321. * @param effect The effect we are binding the data to
  9322. * @param linearSpace Defines if the fog effect is applied in linear space
  9323. */
  9324. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9325. /**
  9326. * Binds the bones information from the mesh to the effect.
  9327. * @param mesh The mesh we are binding the information to render
  9328. * @param effect The effect we are binding the data to
  9329. */
  9330. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9331. /**
  9332. * Binds the morph targets information from the mesh to the effect.
  9333. * @param abstractMesh The mesh we are binding the information to render
  9334. * @param effect The effect we are binding the data to
  9335. */
  9336. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9337. /**
  9338. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9339. * @param defines The generated defines used in the effect
  9340. * @param effect The effect we are binding the data to
  9341. * @param scene The scene we are willing to render with logarithmic scale for
  9342. */
  9343. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9344. /**
  9345. * Binds the clip plane information from the scene to the effect.
  9346. * @param scene The scene the clip plane information are extracted from
  9347. * @param effect The effect we are binding the data to
  9348. */
  9349. static BindClipPlane(effect: Effect, scene: Scene): void;
  9350. }
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9353. /** @hidden */
  9354. export var packingFunctions: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9360. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9361. /** @hidden */
  9362. export var shadowMapPixelShader: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9368. /** @hidden */
  9369. export var bonesDeclaration: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9375. /** @hidden */
  9376. export var morphTargetsVertexGlobalDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9382. /** @hidden */
  9383. export var morphTargetsVertexDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9389. /** @hidden */
  9390. export var instancesDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9396. /** @hidden */
  9397. export var helperFunctions: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9403. /** @hidden */
  9404. export var morphTargetsVertex: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9410. /** @hidden */
  9411. export var instancesVertex: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9417. /** @hidden */
  9418. export var bonesVertex: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9430. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9431. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9432. /** @hidden */
  9433. export var shadowMapVertexShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9439. /** @hidden */
  9440. export var depthBoxBlurPixelShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9446. import { Nullable } from "babylonjs/types";
  9447. import { Scene } from "babylonjs/scene";
  9448. import { Matrix } from "babylonjs/Maths/math.vector";
  9449. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9451. import { Mesh } from "babylonjs/Meshes/mesh";
  9452. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9453. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9454. import { Effect } from "babylonjs/Materials/effect";
  9455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9456. import "babylonjs/Shaders/shadowMap.fragment";
  9457. import "babylonjs/Shaders/shadowMap.vertex";
  9458. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9459. import { Observable } from "babylonjs/Misc/observable";
  9460. /**
  9461. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9462. */
  9463. export interface ICustomShaderOptions {
  9464. /**
  9465. * Gets or sets the custom shader name to use
  9466. */
  9467. shaderName: string;
  9468. /**
  9469. * The list of attribute names used in the shader
  9470. */
  9471. attributes?: string[];
  9472. /**
  9473. * The list of unifrom names used in the shader
  9474. */
  9475. uniforms?: string[];
  9476. /**
  9477. * The list of sampler names used in the shader
  9478. */
  9479. samplers?: string[];
  9480. /**
  9481. * The list of defines used in the shader
  9482. */
  9483. defines?: string[];
  9484. }
  9485. /**
  9486. * Interface to implement to create a shadow generator compatible with BJS.
  9487. */
  9488. export interface IShadowGenerator {
  9489. /**
  9490. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9491. * @returns The render target texture if present otherwise, null
  9492. */
  9493. getShadowMap(): Nullable<RenderTargetTexture>;
  9494. /**
  9495. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9496. * @returns The render target texture if the shadow map is present otherwise, null
  9497. */
  9498. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9499. /**
  9500. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9501. * @param subMesh The submesh we want to render in the shadow map
  9502. * @param useInstances Defines wether will draw in the map using instances
  9503. * @returns true if ready otherwise, false
  9504. */
  9505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9506. /**
  9507. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9508. * @param defines Defines of the material we want to update
  9509. * @param lightIndex Index of the light in the enabled light list of the material
  9510. */
  9511. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9512. /**
  9513. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9514. * defined in the generator but impacting the effect).
  9515. * It implies the unifroms available on the materials are the standard BJS ones.
  9516. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9517. * @param effect The effect we are binfing the information for
  9518. */
  9519. bindShadowLight(lightIndex: string, effect: Effect): void;
  9520. /**
  9521. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9522. * (eq to shadow prjection matrix * light transform matrix)
  9523. * @returns The transform matrix used to create the shadow map
  9524. */
  9525. getTransformMatrix(): Matrix;
  9526. /**
  9527. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9528. * Cube and 2D textures for instance.
  9529. */
  9530. recreateShadowMap(): void;
  9531. /**
  9532. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9533. * @param onCompiled Callback triggered at the and of the effects compilation
  9534. * @param options Sets of optional options forcing the compilation with different modes
  9535. */
  9536. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9537. useInstances: boolean;
  9538. }>): void;
  9539. /**
  9540. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9541. * @param options Sets of optional options forcing the compilation with different modes
  9542. * @returns A promise that resolves when the compilation completes
  9543. */
  9544. forceCompilationAsync(options?: Partial<{
  9545. useInstances: boolean;
  9546. }>): Promise<void>;
  9547. /**
  9548. * Serializes the shadow generator setup to a json object.
  9549. * @returns The serialized JSON object
  9550. */
  9551. serialize(): any;
  9552. /**
  9553. * Disposes the Shadow map and related Textures and effects.
  9554. */
  9555. dispose(): void;
  9556. }
  9557. /**
  9558. * Default implementation IShadowGenerator.
  9559. * This is the main object responsible of generating shadows in the framework.
  9560. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9561. */
  9562. export class ShadowGenerator implements IShadowGenerator {
  9563. /**
  9564. * Shadow generator mode None: no filtering applied.
  9565. */
  9566. static readonly FILTER_NONE: number;
  9567. /**
  9568. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9569. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9570. */
  9571. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9572. /**
  9573. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9574. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9575. */
  9576. static readonly FILTER_POISSONSAMPLING: number;
  9577. /**
  9578. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9579. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9580. */
  9581. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9582. /**
  9583. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9584. * edge artifacts on steep falloff.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9590. * edge artifacts on steep falloff.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode PCF: Percentage Closer Filtering
  9596. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9597. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9598. */
  9599. static readonly FILTER_PCF: number;
  9600. /**
  9601. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9603. * Contact Hardening
  9604. */
  9605. static readonly FILTER_PCSS: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Highest Quality.
  9609. *
  9610. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9611. *
  9612. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9613. */
  9614. static readonly QUALITY_HIGH: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * Good tradeoff for quality/perf cross devices
  9618. *
  9619. * Execute PCF on a 3*3 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9622. */
  9623. static readonly QUALITY_MEDIUM: number;
  9624. /**
  9625. * Reserved for PCF and PCSS
  9626. * The lowest quality but the fastest.
  9627. *
  9628. * Execute PCF on a 1*1 kernel.
  9629. *
  9630. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9631. */
  9632. static readonly QUALITY_LOW: number;
  9633. /** Gets or sets the custom shader name to use */
  9634. customShaderOptions: ICustomShaderOptions;
  9635. /**
  9636. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9637. */
  9638. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9639. /**
  9640. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9641. */
  9642. onAfterShadowMapRenderObservable: Observable<Effect>;
  9643. /**
  9644. * Observable triggered before a mesh is rendered in the shadow map.
  9645. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9646. */
  9647. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9648. /**
  9649. * Observable triggered after a mesh is rendered in the shadow map.
  9650. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9651. */
  9652. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9653. private _bias;
  9654. /**
  9655. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9656. */
  9657. /**
  9658. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9659. */
  9660. bias: number;
  9661. private _normalBias;
  9662. /**
  9663. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9664. */
  9665. /**
  9666. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9667. */
  9668. normalBias: number;
  9669. private _blurBoxOffset;
  9670. /**
  9671. * Gets the blur box offset: offset applied during the blur pass.
  9672. * Only useful if useKernelBlur = false
  9673. */
  9674. /**
  9675. * Sets the blur box offset: offset applied during the blur pass.
  9676. * Only useful if useKernelBlur = false
  9677. */
  9678. blurBoxOffset: number;
  9679. private _blurScale;
  9680. /**
  9681. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9682. * 2 means half of the size.
  9683. */
  9684. /**
  9685. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9686. * 2 means half of the size.
  9687. */
  9688. blurScale: number;
  9689. private _blurKernel;
  9690. /**
  9691. * Gets the blur kernel: kernel size of the blur pass.
  9692. * Only useful if useKernelBlur = true
  9693. */
  9694. /**
  9695. * Sets the blur kernel: kernel size of the blur pass.
  9696. * Only useful if useKernelBlur = true
  9697. */
  9698. blurKernel: number;
  9699. private _useKernelBlur;
  9700. /**
  9701. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9702. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9703. */
  9704. /**
  9705. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9706. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9707. */
  9708. useKernelBlur: boolean;
  9709. private _depthScale;
  9710. /**
  9711. * Gets the depth scale used in ESM mode.
  9712. */
  9713. /**
  9714. * Sets the depth scale used in ESM mode.
  9715. * This can override the scale stored on the light.
  9716. */
  9717. depthScale: number;
  9718. private _filter;
  9719. /**
  9720. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9721. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9722. */
  9723. /**
  9724. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9725. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9726. */
  9727. filter: number;
  9728. /**
  9729. * Gets if the current filter is set to Poisson Sampling.
  9730. */
  9731. /**
  9732. * Sets the current filter to Poisson Sampling.
  9733. */
  9734. usePoissonSampling: boolean;
  9735. /**
  9736. * Gets if the current filter is set to ESM.
  9737. */
  9738. /**
  9739. * Sets the current filter is to ESM.
  9740. */
  9741. useExponentialShadowMap: boolean;
  9742. /**
  9743. * Gets if the current filter is set to filtered ESM.
  9744. */
  9745. /**
  9746. * Gets if the current filter is set to filtered ESM.
  9747. */
  9748. useBlurExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9760. * exponential to prevent steep falloff artifacts).
  9761. */
  9762. /**
  9763. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9764. * exponential to prevent steep falloff artifacts).
  9765. */
  9766. useBlurCloseExponentialShadowMap: boolean;
  9767. /**
  9768. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9769. */
  9770. /**
  9771. * Sets the current filter to "PCF" (percentage closer filtering).
  9772. */
  9773. usePercentageCloserFiltering: boolean;
  9774. private _filteringQuality;
  9775. /**
  9776. * Gets the PCF or PCSS Quality.
  9777. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9778. */
  9779. /**
  9780. * Sets the PCF or PCSS Quality.
  9781. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9782. */
  9783. filteringQuality: number;
  9784. /**
  9785. * Gets if the current filter is set to "PCSS" (contact hardening).
  9786. */
  9787. /**
  9788. * Sets the current filter to "PCSS" (contact hardening).
  9789. */
  9790. useContactHardeningShadow: boolean;
  9791. private _contactHardeningLightSizeUVRatio;
  9792. /**
  9793. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. /**
  9802. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9803. * Using a ratio helps keeping shape stability independently of the map size.
  9804. *
  9805. * It does not account for the light projection as it was having too much
  9806. * instability during the light setup or during light position changes.
  9807. *
  9808. * Only valid if useContactHardeningShadow is true.
  9809. */
  9810. contactHardeningLightSizeUVRatio: number;
  9811. private _darkness;
  9812. /** Gets or sets the actual darkness of a shadow */
  9813. darkness: number;
  9814. /**
  9815. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9816. * 0 means strongest and 1 would means no shadow.
  9817. * @returns the darkness.
  9818. */
  9819. getDarkness(): number;
  9820. /**
  9821. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9822. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9823. * @returns the shadow generator allowing fluent coding.
  9824. */
  9825. setDarkness(darkness: number): ShadowGenerator;
  9826. private _transparencyShadow;
  9827. /** Gets or sets the ability to have transparent shadow */
  9828. transparencyShadow: boolean;
  9829. /**
  9830. * Sets the ability to have transparent shadow (boolean).
  9831. * @param transparent True if transparent else False
  9832. * @returns the shadow generator allowing fluent coding
  9833. */
  9834. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9835. private _shadowMap;
  9836. private _shadowMap2;
  9837. /**
  9838. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9839. * @returns The render target texture if present otherwise, null
  9840. */
  9841. getShadowMap(): Nullable<RenderTargetTexture>;
  9842. /**
  9843. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9844. * @returns The render target texture if the shadow map is present otherwise, null
  9845. */
  9846. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9847. /**
  9848. * Gets the class name of that object
  9849. * @returns "ShadowGenerator"
  9850. */
  9851. getClassName(): string;
  9852. /**
  9853. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9854. * @param mesh Mesh to add
  9855. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9856. * @returns the Shadow Generator itself
  9857. */
  9858. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9859. /**
  9860. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9861. * @param mesh Mesh to remove
  9862. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9863. * @returns the Shadow Generator itself
  9864. */
  9865. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9866. /**
  9867. * Controls the extent to which the shadows fade out at the edge of the frustum
  9868. * Used only by directionals and spots
  9869. */
  9870. frustumEdgeFalloff: number;
  9871. private _light;
  9872. /**
  9873. * Returns the associated light object.
  9874. * @returns the light generating the shadow
  9875. */
  9876. getLight(): IShadowLight;
  9877. /**
  9878. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9879. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9880. * It might on the other hand introduce peter panning.
  9881. */
  9882. forceBackFacesOnly: boolean;
  9883. private _scene;
  9884. private _lightDirection;
  9885. private _effect;
  9886. private _viewMatrix;
  9887. private _projectionMatrix;
  9888. private _transformMatrix;
  9889. private _cachedPosition;
  9890. private _cachedDirection;
  9891. private _cachedDefines;
  9892. private _currentRenderID;
  9893. private _boxBlurPostprocess;
  9894. private _kernelBlurXPostprocess;
  9895. private _kernelBlurYPostprocess;
  9896. private _blurPostProcesses;
  9897. private _mapSize;
  9898. private _currentFaceIndex;
  9899. private _currentFaceIndexCache;
  9900. private _textureType;
  9901. private _defaultTextureMatrix;
  9902. private _storedUniqueId;
  9903. /** @hidden */
  9904. static _SceneComponentInitialization: (scene: Scene) => void;
  9905. /**
  9906. * Creates a ShadowGenerator object.
  9907. * A ShadowGenerator is the required tool to use the shadows.
  9908. * Each light casting shadows needs to use its own ShadowGenerator.
  9909. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9910. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9911. * @param light The light object generating the shadows.
  9912. * @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.
  9913. */
  9914. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9915. private _initializeGenerator;
  9916. private _initializeShadowMap;
  9917. private _initializeBlurRTTAndPostProcesses;
  9918. private _renderForShadowMap;
  9919. private _renderSubMeshForShadowMap;
  9920. private _applyFilterValues;
  9921. /**
  9922. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9923. * @param onCompiled Callback triggered at the and of the effects compilation
  9924. * @param options Sets of optional options forcing the compilation with different modes
  9925. */
  9926. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9927. useInstances: boolean;
  9928. }>): void;
  9929. /**
  9930. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9931. * @param options Sets of optional options forcing the compilation with different modes
  9932. * @returns A promise that resolves when the compilation completes
  9933. */
  9934. forceCompilationAsync(options?: Partial<{
  9935. useInstances: boolean;
  9936. }>): Promise<void>;
  9937. /**
  9938. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9939. * @param subMesh The submesh we want to render in the shadow map
  9940. * @param useInstances Defines wether will draw in the map using instances
  9941. * @returns true if ready otherwise, false
  9942. */
  9943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9944. /**
  9945. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9946. * @param defines Defines of the material we want to update
  9947. * @param lightIndex Index of the light in the enabled light list of the material
  9948. */
  9949. prepareDefines(defines: any, lightIndex: number): void;
  9950. /**
  9951. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9952. * defined in the generator but impacting the effect).
  9953. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9954. * @param effect The effect we are binfing the information for
  9955. */
  9956. bindShadowLight(lightIndex: string, effect: Effect): void;
  9957. /**
  9958. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9959. * (eq to shadow prjection matrix * light transform matrix)
  9960. * @returns The transform matrix used to create the shadow map
  9961. */
  9962. getTransformMatrix(): Matrix;
  9963. /**
  9964. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9965. * Cube and 2D textures for instance.
  9966. */
  9967. recreateShadowMap(): void;
  9968. private _disposeBlurPostProcesses;
  9969. private _disposeRTTandPostProcesses;
  9970. /**
  9971. * Disposes the ShadowGenerator.
  9972. * Returns nothing.
  9973. */
  9974. dispose(): void;
  9975. /**
  9976. * Serializes the shadow generator setup to a json object.
  9977. * @returns The serialized JSON object
  9978. */
  9979. serialize(): any;
  9980. /**
  9981. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9982. * @param parsedShadowGenerator The JSON object to parse
  9983. * @param scene The scene to create the shadow map for
  9984. * @returns The parsed shadow generator
  9985. */
  9986. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9987. }
  9988. }
  9989. declare module "babylonjs/Lights/light" {
  9990. import { Nullable } from "babylonjs/types";
  9991. import { Scene } from "babylonjs/scene";
  9992. import { Vector3 } from "babylonjs/Maths/math.vector";
  9993. import { Color3 } from "babylonjs/Maths/math.color";
  9994. import { Node } from "babylonjs/node";
  9995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9996. import { Effect } from "babylonjs/Materials/effect";
  9997. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9998. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9999. /**
  10000. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10001. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10002. * 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.
  10003. */
  10004. export abstract class Light extends Node {
  10005. /**
  10006. * Falloff Default: light is falling off following the material specification:
  10007. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10008. */
  10009. static readonly FALLOFF_DEFAULT: number;
  10010. /**
  10011. * Falloff Physical: light is falling off following the inverse squared distance law.
  10012. */
  10013. static readonly FALLOFF_PHYSICAL: number;
  10014. /**
  10015. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10016. * to enhance interoperability with other engines.
  10017. */
  10018. static readonly FALLOFF_GLTF: number;
  10019. /**
  10020. * Falloff Standard: light is falling off like in the standard material
  10021. * to enhance interoperability with other materials.
  10022. */
  10023. static readonly FALLOFF_STANDARD: number;
  10024. /**
  10025. * If every light affecting the material is in this lightmapMode,
  10026. * material.lightmapTexture adds or multiplies
  10027. * (depends on material.useLightmapAsShadowmap)
  10028. * after every other light calculations.
  10029. */
  10030. static readonly LIGHTMAP_DEFAULT: number;
  10031. /**
  10032. * material.lightmapTexture as only diffuse lighting from this light
  10033. * adds only specular lighting from this light
  10034. * adds dynamic shadows
  10035. */
  10036. static readonly LIGHTMAP_SPECULAR: number;
  10037. /**
  10038. * material.lightmapTexture as only lighting
  10039. * no light calculation from this light
  10040. * only adds dynamic shadows from this light
  10041. */
  10042. static readonly LIGHTMAP_SHADOWSONLY: number;
  10043. /**
  10044. * Each light type uses the default quantity according to its type:
  10045. * point/spot lights use luminous intensity
  10046. * directional lights use illuminance
  10047. */
  10048. static readonly INTENSITYMODE_AUTOMATIC: number;
  10049. /**
  10050. * lumen (lm)
  10051. */
  10052. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10053. /**
  10054. * candela (lm/sr)
  10055. */
  10056. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10057. /**
  10058. * lux (lm/m^2)
  10059. */
  10060. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10061. /**
  10062. * nit (cd/m^2)
  10063. */
  10064. static readonly INTENSITYMODE_LUMINANCE: number;
  10065. /**
  10066. * Light type const id of the point light.
  10067. */
  10068. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10069. /**
  10070. * Light type const id of the directional light.
  10071. */
  10072. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10073. /**
  10074. * Light type const id of the spot light.
  10075. */
  10076. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10077. /**
  10078. * Light type const id of the hemispheric light.
  10079. */
  10080. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10081. /**
  10082. * Diffuse gives the basic color to an object.
  10083. */
  10084. diffuse: Color3;
  10085. /**
  10086. * Specular produces a highlight color on an object.
  10087. * Note: This is note affecting PBR materials.
  10088. */
  10089. specular: Color3;
  10090. /**
  10091. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10092. * falling off base on range or angle.
  10093. * This can be set to any values in Light.FALLOFF_x.
  10094. *
  10095. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10096. * other types of materials.
  10097. */
  10098. falloffType: number;
  10099. /**
  10100. * Strength of the light.
  10101. * Note: By default it is define in the framework own unit.
  10102. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10103. */
  10104. intensity: number;
  10105. private _range;
  10106. protected _inverseSquaredRange: number;
  10107. /**
  10108. * Defines how far from the source the light is impacting in scene units.
  10109. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10110. */
  10111. /**
  10112. * Defines how far from the source the light is impacting in scene units.
  10113. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10114. */
  10115. range: number;
  10116. /**
  10117. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10118. * of light.
  10119. */
  10120. private _photometricScale;
  10121. private _intensityMode;
  10122. /**
  10123. * Gets the photometric scale used to interpret the intensity.
  10124. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10125. */
  10126. /**
  10127. * Sets the photometric scale used to interpret the intensity.
  10128. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10129. */
  10130. intensityMode: number;
  10131. private _radius;
  10132. /**
  10133. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10134. */
  10135. /**
  10136. * sets the light radius used by PBR Materials to simulate soft area lights.
  10137. */
  10138. radius: number;
  10139. private _renderPriority;
  10140. /**
  10141. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10142. * exceeding the number allowed of the materials.
  10143. */
  10144. renderPriority: number;
  10145. private _shadowEnabled;
  10146. /**
  10147. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10148. * the current shadow generator.
  10149. */
  10150. /**
  10151. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10152. * the current shadow generator.
  10153. */
  10154. shadowEnabled: boolean;
  10155. private _includedOnlyMeshes;
  10156. /**
  10157. * Gets the only meshes impacted by this light.
  10158. */
  10159. /**
  10160. * Sets the only meshes impacted by this light.
  10161. */
  10162. includedOnlyMeshes: AbstractMesh[];
  10163. private _excludedMeshes;
  10164. /**
  10165. * Gets the meshes not impacted by this light.
  10166. */
  10167. /**
  10168. * Sets the meshes not impacted by this light.
  10169. */
  10170. excludedMeshes: AbstractMesh[];
  10171. private _excludeWithLayerMask;
  10172. /**
  10173. * Gets the layer id use to find what meshes are not impacted by the light.
  10174. * Inactive if 0
  10175. */
  10176. /**
  10177. * Sets the layer id use to find what meshes are not impacted by the light.
  10178. * Inactive if 0
  10179. */
  10180. excludeWithLayerMask: number;
  10181. private _includeOnlyWithLayerMask;
  10182. /**
  10183. * Gets the layer id use to find what meshes are impacted by the light.
  10184. * Inactive if 0
  10185. */
  10186. /**
  10187. * Sets the layer id use to find what meshes are impacted by the light.
  10188. * Inactive if 0
  10189. */
  10190. includeOnlyWithLayerMask: number;
  10191. private _lightmapMode;
  10192. /**
  10193. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10194. */
  10195. /**
  10196. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10197. */
  10198. lightmapMode: number;
  10199. /**
  10200. * Shadow generator associted to the light.
  10201. * @hidden Internal use only.
  10202. */
  10203. _shadowGenerator: Nullable<IShadowGenerator>;
  10204. /**
  10205. * @hidden Internal use only.
  10206. */
  10207. _excludedMeshesIds: string[];
  10208. /**
  10209. * @hidden Internal use only.
  10210. */
  10211. _includedOnlyMeshesIds: string[];
  10212. /**
  10213. * The current light unifom buffer.
  10214. * @hidden Internal use only.
  10215. */
  10216. _uniformBuffer: UniformBuffer;
  10217. /** @hidden */
  10218. _renderId: number;
  10219. /**
  10220. * Creates a Light object in the scene.
  10221. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10222. * @param name The firendly name of the light
  10223. * @param scene The scene the light belongs too
  10224. */
  10225. constructor(name: string, scene: Scene);
  10226. protected abstract _buildUniformLayout(): void;
  10227. /**
  10228. * Sets the passed Effect "effect" with the Light information.
  10229. * @param effect The effect to update
  10230. * @param lightIndex The index of the light in the effect to update
  10231. * @returns The light
  10232. */
  10233. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10234. /**
  10235. * Sets the passed Effect "effect" with the Light textures.
  10236. * @param effect The effect to update
  10237. * @param lightIndex The index of the light in the effect to update
  10238. * @returns The light
  10239. */
  10240. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10241. /**
  10242. * Binds the lights information from the scene to the effect for the given mesh.
  10243. * @param lightIndex Light index
  10244. * @param scene The scene where the light belongs to
  10245. * @param effect The effect we are binding the data to
  10246. * @param useSpecular Defines if specular is supported
  10247. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10248. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10249. */
  10250. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10251. /**
  10252. * Sets the passed Effect "effect" with the Light information.
  10253. * @param effect The effect to update
  10254. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10255. * @returns The light
  10256. */
  10257. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10258. /**
  10259. * Returns the string "Light".
  10260. * @returns the class name
  10261. */
  10262. getClassName(): string;
  10263. /** @hidden */
  10264. readonly _isLight: boolean;
  10265. /**
  10266. * Converts the light information to a readable string for debug purpose.
  10267. * @param fullDetails Supports for multiple levels of logging within scene loading
  10268. * @returns the human readable light info
  10269. */
  10270. toString(fullDetails?: boolean): string;
  10271. /** @hidden */
  10272. protected _syncParentEnabledState(): void;
  10273. /**
  10274. * Set the enabled state of this node.
  10275. * @param value - the new enabled state
  10276. */
  10277. setEnabled(value: boolean): void;
  10278. /**
  10279. * Returns the Light associated shadow generator if any.
  10280. * @return the associated shadow generator.
  10281. */
  10282. getShadowGenerator(): Nullable<IShadowGenerator>;
  10283. /**
  10284. * Returns a Vector3, the absolute light position in the World.
  10285. * @returns the world space position of the light
  10286. */
  10287. getAbsolutePosition(): Vector3;
  10288. /**
  10289. * Specifies if the light will affect the passed mesh.
  10290. * @param mesh The mesh to test against the light
  10291. * @return true the mesh is affected otherwise, false.
  10292. */
  10293. canAffectMesh(mesh: AbstractMesh): boolean;
  10294. /**
  10295. * Sort function to order lights for rendering.
  10296. * @param a First Light object to compare to second.
  10297. * @param b Second Light object to compare first.
  10298. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10299. */
  10300. static CompareLightsPriority(a: Light, b: Light): number;
  10301. /**
  10302. * Releases resources associated with this node.
  10303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10305. */
  10306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10307. /**
  10308. * Returns the light type ID (integer).
  10309. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10310. */
  10311. getTypeID(): number;
  10312. /**
  10313. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10314. * @returns the scaled intensity in intensity mode unit
  10315. */
  10316. getScaledIntensity(): number;
  10317. /**
  10318. * Returns a new Light object, named "name", from the current one.
  10319. * @param name The name of the cloned light
  10320. * @returns the new created light
  10321. */
  10322. clone(name: string): Nullable<Light>;
  10323. /**
  10324. * Serializes the current light into a Serialization object.
  10325. * @returns the serialized object.
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10330. * This new light is named "name" and added to the passed scene.
  10331. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10332. * @param name The friendly name of the light
  10333. * @param scene The scene the new light will belong to
  10334. * @returns the constructor function
  10335. */
  10336. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10337. /**
  10338. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10339. * @param parsedLight The JSON representation of the light
  10340. * @param scene The scene to create the parsed light in
  10341. * @returns the created light after parsing
  10342. */
  10343. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10344. private _hookArrayForExcluded;
  10345. private _hookArrayForIncludedOnly;
  10346. private _resyncMeshes;
  10347. /**
  10348. * Forces the meshes to update their light related information in their rendering used effects
  10349. * @hidden Internal Use Only
  10350. */
  10351. _markMeshesAsLightDirty(): void;
  10352. /**
  10353. * Recomputes the cached photometric scale if needed.
  10354. */
  10355. private _computePhotometricScale;
  10356. /**
  10357. * Returns the Photometric Scale according to the light type and intensity mode.
  10358. */
  10359. private _getPhotometricScale;
  10360. /**
  10361. * Reorder the light in the scene according to their defined priority.
  10362. * @hidden Internal Use Only
  10363. */
  10364. _reorderLightsInScene(): void;
  10365. /**
  10366. * Prepares the list of defines specific to the light type.
  10367. * @param defines the list of defines
  10368. * @param lightIndex defines the index of the light for the effect
  10369. */
  10370. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10371. }
  10372. }
  10373. declare module "babylonjs/Actions/action" {
  10374. import { Observable } from "babylonjs/Misc/observable";
  10375. import { Condition } from "babylonjs/Actions/condition";
  10376. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10377. import { ActionManager } from "babylonjs/Actions/actionManager";
  10378. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10379. /**
  10380. * Interface used to define Action
  10381. */
  10382. export interface IAction {
  10383. /**
  10384. * Trigger for the action
  10385. */
  10386. trigger: number;
  10387. /** Options of the trigger */
  10388. triggerOptions: any;
  10389. /**
  10390. * Gets the trigger parameters
  10391. * @returns the trigger parameters
  10392. */
  10393. getTriggerParameter(): any;
  10394. /**
  10395. * Internal only - executes current action event
  10396. * @hidden
  10397. */
  10398. _executeCurrent(evt?: ActionEvent): void;
  10399. /**
  10400. * Serialize placeholder for child classes
  10401. * @param parent of child
  10402. * @returns the serialized object
  10403. */
  10404. serialize(parent: any): any;
  10405. /**
  10406. * Internal only
  10407. * @hidden
  10408. */
  10409. _prepare(): void;
  10410. /**
  10411. * Internal only - manager for action
  10412. * @hidden
  10413. */
  10414. _actionManager: AbstractActionManager;
  10415. /**
  10416. * Adds action to chain of actions, may be a DoNothingAction
  10417. * @param action defines the next action to execute
  10418. * @returns The action passed in
  10419. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10420. */
  10421. then(action: IAction): IAction;
  10422. }
  10423. /**
  10424. * The action to be carried out following a trigger
  10425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10426. */
  10427. export class Action implements IAction {
  10428. /** the trigger, with or without parameters, for the action */
  10429. triggerOptions: any;
  10430. /**
  10431. * Trigger for the action
  10432. */
  10433. trigger: number;
  10434. /**
  10435. * Internal only - manager for action
  10436. * @hidden
  10437. */
  10438. _actionManager: ActionManager;
  10439. private _nextActiveAction;
  10440. private _child;
  10441. private _condition?;
  10442. private _triggerParameter;
  10443. /**
  10444. * An event triggered prior to action being executed.
  10445. */
  10446. onBeforeExecuteObservable: Observable<Action>;
  10447. /**
  10448. * Creates a new Action
  10449. * @param triggerOptions the trigger, with or without parameters, for the action
  10450. * @param condition an optional determinant of action
  10451. */
  10452. constructor(
  10453. /** the trigger, with or without parameters, for the action */
  10454. triggerOptions: any, condition?: Condition);
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _prepare(): void;
  10460. /**
  10461. * Gets the trigger parameters
  10462. * @returns the trigger parameters
  10463. */
  10464. getTriggerParameter(): any;
  10465. /**
  10466. * Internal only - executes current action event
  10467. * @hidden
  10468. */
  10469. _executeCurrent(evt?: ActionEvent): void;
  10470. /**
  10471. * Execute placeholder for child classes
  10472. * @param evt optional action event
  10473. */
  10474. execute(evt?: ActionEvent): void;
  10475. /**
  10476. * Skips to next active action
  10477. */
  10478. skipToNextActiveAction(): void;
  10479. /**
  10480. * Adds action to chain of actions, may be a DoNothingAction
  10481. * @param action defines the next action to execute
  10482. * @returns The action passed in
  10483. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10484. */
  10485. then(action: Action): Action;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. _getProperty(propertyPath: string): string;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _getEffectiveTarget(target: any, propertyPath: string): any;
  10496. /**
  10497. * Serialize placeholder for child classes
  10498. * @param parent of child
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. /**
  10503. * Internal only called by serialize
  10504. * @hidden
  10505. */
  10506. protected _serialize(serializedAction: any, parent?: any): any;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */
  10511. static _SerializeValueAsString: (value: any) => string;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */
  10516. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10517. name: string;
  10518. targetType: string;
  10519. value: string;
  10520. };
  10521. }
  10522. }
  10523. declare module "babylonjs/Actions/condition" {
  10524. import { ActionManager } from "babylonjs/Actions/actionManager";
  10525. /**
  10526. * A Condition applied to an Action
  10527. */
  10528. export class Condition {
  10529. /**
  10530. * Internal only - manager for action
  10531. * @hidden
  10532. */
  10533. _actionManager: ActionManager;
  10534. /**
  10535. * Internal only
  10536. * @hidden
  10537. */
  10538. _evaluationId: number;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _currentResult: boolean;
  10544. /**
  10545. * Creates a new Condition
  10546. * @param actionManager the manager of the action the condition is applied to
  10547. */
  10548. constructor(actionManager: ActionManager);
  10549. /**
  10550. * Check if the current condition is valid
  10551. * @returns a boolean
  10552. */
  10553. isValid(): boolean;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. _getProperty(propertyPath: string): string;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. _getEffectiveTarget(target: any, propertyPath: string): any;
  10564. /**
  10565. * Serialize placeholder for child classes
  10566. * @returns the serialized object
  10567. */
  10568. serialize(): any;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. protected _serialize(serializedCondition: any): any;
  10574. }
  10575. /**
  10576. * Defines specific conditional operators as extensions of Condition
  10577. */
  10578. export class ValueCondition extends Condition {
  10579. /** path to specify the property of the target the conditional operator uses */
  10580. propertyPath: string;
  10581. /** the value compared by the conditional operator against the current value of the property */
  10582. value: any;
  10583. /** the conditional operator, default ValueCondition.IsEqual */
  10584. operator: number;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private static _IsEqual;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private static _IsDifferent;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. private static _IsGreater;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private static _IsLesser;
  10605. /**
  10606. * returns the number for IsEqual
  10607. */
  10608. static readonly IsEqual: number;
  10609. /**
  10610. * Returns the number for IsDifferent
  10611. */
  10612. static readonly IsDifferent: number;
  10613. /**
  10614. * Returns the number for IsGreater
  10615. */
  10616. static readonly IsGreater: number;
  10617. /**
  10618. * Returns the number for IsLesser
  10619. */
  10620. static readonly IsLesser: number;
  10621. /**
  10622. * Internal only The action manager for the condition
  10623. * @hidden
  10624. */
  10625. _actionManager: ActionManager;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private _target;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private _effectiveTarget;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private _property;
  10641. /**
  10642. * Creates a new ValueCondition
  10643. * @param actionManager manager for the action the condition applies to
  10644. * @param target for the action
  10645. * @param propertyPath path to specify the property of the target the conditional operator uses
  10646. * @param value the value compared by the conditional operator against the current value of the property
  10647. * @param operator the conditional operator, default ValueCondition.IsEqual
  10648. */
  10649. constructor(actionManager: ActionManager, target: any,
  10650. /** path to specify the property of the target the conditional operator uses */
  10651. propertyPath: string,
  10652. /** the value compared by the conditional operator against the current value of the property */
  10653. value: any,
  10654. /** the conditional operator, default ValueCondition.IsEqual */
  10655. operator?: number);
  10656. /**
  10657. * Compares the given value with the property value for the specified conditional operator
  10658. * @returns the result of the comparison
  10659. */
  10660. isValid(): boolean;
  10661. /**
  10662. * Serialize the ValueCondition into a JSON compatible object
  10663. * @returns serialization object
  10664. */
  10665. serialize(): any;
  10666. /**
  10667. * Gets the name of the conditional operator for the ValueCondition
  10668. * @param operator the conditional operator
  10669. * @returns the name
  10670. */
  10671. static GetOperatorName(operator: number): string;
  10672. }
  10673. /**
  10674. * Defines a predicate condition as an extension of Condition
  10675. */
  10676. export class PredicateCondition extends Condition {
  10677. /** defines the predicate function used to validate the condition */
  10678. predicate: () => boolean;
  10679. /**
  10680. * Internal only - manager for action
  10681. * @hidden
  10682. */
  10683. _actionManager: ActionManager;
  10684. /**
  10685. * Creates a new PredicateCondition
  10686. * @param actionManager manager for the action the condition applies to
  10687. * @param predicate defines the predicate function used to validate the condition
  10688. */
  10689. constructor(actionManager: ActionManager,
  10690. /** defines the predicate function used to validate the condition */
  10691. predicate: () => boolean);
  10692. /**
  10693. * @returns the validity of the predicate condition
  10694. */
  10695. isValid(): boolean;
  10696. }
  10697. /**
  10698. * Defines a state condition as an extension of Condition
  10699. */
  10700. export class StateCondition extends Condition {
  10701. /** Value to compare with target state */
  10702. value: string;
  10703. /**
  10704. * Internal only - manager for action
  10705. * @hidden
  10706. */
  10707. _actionManager: ActionManager;
  10708. /**
  10709. * Internal only
  10710. * @hidden
  10711. */
  10712. private _target;
  10713. /**
  10714. * Creates a new StateCondition
  10715. * @param actionManager manager for the action the condition applies to
  10716. * @param target of the condition
  10717. * @param value to compare with target state
  10718. */
  10719. constructor(actionManager: ActionManager, target: any,
  10720. /** Value to compare with target state */
  10721. value: string);
  10722. /**
  10723. * Gets a boolean indicating if the current condition is met
  10724. * @returns the validity of the state
  10725. */
  10726. isValid(): boolean;
  10727. /**
  10728. * Serialize the StateCondition into a JSON compatible object
  10729. * @returns serialization object
  10730. */
  10731. serialize(): any;
  10732. }
  10733. }
  10734. declare module "babylonjs/Actions/directActions" {
  10735. import { Action } from "babylonjs/Actions/action";
  10736. import { Condition } from "babylonjs/Actions/condition";
  10737. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10738. /**
  10739. * This defines an action responsible to toggle a boolean once triggered.
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10741. */
  10742. export class SwitchBooleanAction extends Action {
  10743. /**
  10744. * The path to the boolean property in the target object
  10745. */
  10746. propertyPath: string;
  10747. private _target;
  10748. private _effectiveTarget;
  10749. private _property;
  10750. /**
  10751. * Instantiate the action
  10752. * @param triggerOptions defines the trigger options
  10753. * @param target defines the object containing the boolean
  10754. * @param propertyPath defines the path to the boolean property in the target object
  10755. * @param condition defines the trigger related conditions
  10756. */
  10757. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10758. /** @hidden */
  10759. _prepare(): void;
  10760. /**
  10761. * Execute the action toggle the boolean value.
  10762. */
  10763. execute(): void;
  10764. /**
  10765. * Serializes the actions and its related information.
  10766. * @param parent defines the object to serialize in
  10767. * @returns the serialized object
  10768. */
  10769. serialize(parent: any): any;
  10770. }
  10771. /**
  10772. * This defines an action responsible to set a the state field of the target
  10773. * to a desired value once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class SetStateAction extends Action {
  10777. /**
  10778. * The value to store in the state field.
  10779. */
  10780. value: string;
  10781. private _target;
  10782. /**
  10783. * Instantiate the action
  10784. * @param triggerOptions defines the trigger options
  10785. * @param target defines the object containing the state property
  10786. * @param value defines the value to store in the state field
  10787. * @param condition defines the trigger related conditions
  10788. */
  10789. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10790. /**
  10791. * Execute the action and store the value on the target state property.
  10792. */
  10793. execute(): void;
  10794. /**
  10795. * Serializes the actions and its related information.
  10796. * @param parent defines the object to serialize in
  10797. * @returns the serialized object
  10798. */
  10799. serialize(parent: any): any;
  10800. }
  10801. /**
  10802. * This defines an action responsible to set a property of the target
  10803. * to a desired value once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class SetValueAction extends Action {
  10807. /**
  10808. * The path of the property to set in the target.
  10809. */
  10810. propertyPath: string;
  10811. /**
  10812. * The value to set in the property
  10813. */
  10814. value: any;
  10815. private _target;
  10816. private _effectiveTarget;
  10817. private _property;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the object containing the property
  10822. * @param propertyPath defines the path of the property to set in the target
  10823. * @param value defines the value to set in the property
  10824. * @param condition defines the trigger related conditions
  10825. */
  10826. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10827. /** @hidden */
  10828. _prepare(): void;
  10829. /**
  10830. * Execute the action and set the targetted property to the desired value.
  10831. */
  10832. execute(): void;
  10833. /**
  10834. * Serializes the actions and its related information.
  10835. * @param parent defines the object to serialize in
  10836. * @returns the serialized object
  10837. */
  10838. serialize(parent: any): any;
  10839. }
  10840. /**
  10841. * This defines an action responsible to increment the target value
  10842. * to a desired value once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class IncrementValueAction extends Action {
  10846. /**
  10847. * The path of the property to increment in the target.
  10848. */
  10849. propertyPath: string;
  10850. /**
  10851. * The value we should increment the property by.
  10852. */
  10853. value: any;
  10854. private _target;
  10855. private _effectiveTarget;
  10856. private _property;
  10857. /**
  10858. * Instantiate the action
  10859. * @param triggerOptions defines the trigger options
  10860. * @param target defines the object containing the property
  10861. * @param propertyPath defines the path of the property to increment in the target
  10862. * @param value defines the value value we should increment the property by
  10863. * @param condition defines the trigger related conditions
  10864. */
  10865. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10866. /** @hidden */
  10867. _prepare(): void;
  10868. /**
  10869. * Execute the action and increment the target of the value amount.
  10870. */
  10871. execute(): void;
  10872. /**
  10873. * Serializes the actions and its related information.
  10874. * @param parent defines the object to serialize in
  10875. * @returns the serialized object
  10876. */
  10877. serialize(parent: any): any;
  10878. }
  10879. /**
  10880. * This defines an action responsible to start an animation once triggered.
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10882. */
  10883. export class PlayAnimationAction extends Action {
  10884. /**
  10885. * Where the animation should start (animation frame)
  10886. */
  10887. from: number;
  10888. /**
  10889. * Where the animation should stop (animation frame)
  10890. */
  10891. to: number;
  10892. /**
  10893. * Define if the animation should loop or stop after the first play.
  10894. */
  10895. loop?: boolean;
  10896. private _target;
  10897. /**
  10898. * Instantiate the action
  10899. * @param triggerOptions defines the trigger options
  10900. * @param target defines the target animation or animation name
  10901. * @param from defines from where the animation should start (animation frame)
  10902. * @param end defines where the animation should stop (animation frame)
  10903. * @param loop defines if the animation should loop or stop after the first play
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and play the animation.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to stop an animation once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class StopAnimationAction extends Action {
  10925. private _target;
  10926. /**
  10927. * Instantiate the action
  10928. * @param triggerOptions defines the trigger options
  10929. * @param target defines the target animation or animation name
  10930. * @param condition defines the trigger related conditions
  10931. */
  10932. constructor(triggerOptions: any, target: any, condition?: Condition);
  10933. /** @hidden */
  10934. _prepare(): void;
  10935. /**
  10936. * Execute the action and stop the animation.
  10937. */
  10938. execute(): void;
  10939. /**
  10940. * Serializes the actions and its related information.
  10941. * @param parent defines the object to serialize in
  10942. * @returns the serialized object
  10943. */
  10944. serialize(parent: any): any;
  10945. }
  10946. /**
  10947. * This defines an action responsible that does nothing once triggered.
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10949. */
  10950. export class DoNothingAction extends Action {
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param condition defines the trigger related conditions
  10955. */
  10956. constructor(triggerOptions?: any, condition?: Condition);
  10957. /**
  10958. * Execute the action and do nothing.
  10959. */
  10960. execute(): void;
  10961. /**
  10962. * Serializes the actions and its related information.
  10963. * @param parent defines the object to serialize in
  10964. * @returns the serialized object
  10965. */
  10966. serialize(parent: any): any;
  10967. }
  10968. /**
  10969. * This defines an action responsible to trigger several actions once triggered.
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10971. */
  10972. export class CombineAction extends Action {
  10973. /**
  10974. * The list of aggregated animations to run.
  10975. */
  10976. children: Action[];
  10977. /**
  10978. * Instantiate the action
  10979. * @param triggerOptions defines the trigger options
  10980. * @param children defines the list of aggregated animations to run
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and executes all the aggregated actions.
  10988. */
  10989. execute(evt: ActionEvent): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to run code (external event) once triggered.
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11000. */
  11001. export class ExecuteCodeAction extends Action {
  11002. /**
  11003. * The callback function to run.
  11004. */
  11005. func: (evt: ActionEvent) => void;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param func defines the callback function to run
  11010. * @param condition defines the trigger related conditions
  11011. */
  11012. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11013. /**
  11014. * Execute the action and run the attached code.
  11015. */
  11016. execute(evt: ActionEvent): void;
  11017. }
  11018. /**
  11019. * This defines an action responsible to set the parent property of the target once triggered.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11021. */
  11022. export class SetParentAction extends Action {
  11023. private _parent;
  11024. private _target;
  11025. /**
  11026. * Instantiate the action
  11027. * @param triggerOptions defines the trigger options
  11028. * @param target defines the target containing the parent property
  11029. * @param parent defines from where the animation should start (animation frame)
  11030. * @param condition defines the trigger related conditions
  11031. */
  11032. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11033. /** @hidden */
  11034. _prepare(): void;
  11035. /**
  11036. * Execute the action and set the parent property.
  11037. */
  11038. execute(): void;
  11039. /**
  11040. * Serializes the actions and its related information.
  11041. * @param parent defines the object to serialize in
  11042. * @returns the serialized object
  11043. */
  11044. serialize(parent: any): any;
  11045. }
  11046. }
  11047. declare module "babylonjs/Actions/actionManager" {
  11048. import { Nullable } from "babylonjs/types";
  11049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11050. import { Scene } from "babylonjs/scene";
  11051. import { IAction } from "babylonjs/Actions/action";
  11052. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11053. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11054. /**
  11055. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11056. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11058. */
  11059. export class ActionManager extends AbstractActionManager {
  11060. /**
  11061. * Nothing
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly NothingTrigger: number;
  11065. /**
  11066. * On pick
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickTrigger: number;
  11070. /**
  11071. * On left pick
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnLeftPickTrigger: number;
  11075. /**
  11076. * On right pick
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnRightPickTrigger: number;
  11080. /**
  11081. * On center pick
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnCenterPickTrigger: number;
  11085. /**
  11086. * On pick down
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPickDownTrigger: number;
  11090. /**
  11091. * On double pick
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnDoublePickTrigger: number;
  11095. /**
  11096. * On pick up
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnPickUpTrigger: number;
  11100. /**
  11101. * On pick out.
  11102. * This trigger will only be raised if you also declared a OnPickDown
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnPickOutTrigger: number;
  11106. /**
  11107. * On long press
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnLongPressTrigger: number;
  11111. /**
  11112. * On pointer over
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnPointerOverTrigger: number;
  11116. /**
  11117. * On pointer out
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnPointerOutTrigger: number;
  11121. /**
  11122. * On every frame
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnEveryFrameTrigger: number;
  11126. /**
  11127. * On intersection enter
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnIntersectionEnterTrigger: number;
  11131. /**
  11132. * On intersection exit
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnIntersectionExitTrigger: number;
  11136. /**
  11137. * On key down
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11139. */
  11140. static readonly OnKeyDownTrigger: number;
  11141. /**
  11142. * On key up
  11143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11144. */
  11145. static readonly OnKeyUpTrigger: number;
  11146. private _scene;
  11147. /**
  11148. * Creates a new action manager
  11149. * @param scene defines the hosting scene
  11150. */
  11151. constructor(scene: Scene);
  11152. /**
  11153. * Releases all associated resources
  11154. */
  11155. dispose(): void;
  11156. /**
  11157. * Gets hosting scene
  11158. * @returns the hosting scene
  11159. */
  11160. getScene(): Scene;
  11161. /**
  11162. * Does this action manager handles actions of any of the given triggers
  11163. * @param triggers defines the triggers to be tested
  11164. * @return a boolean indicating whether one (or more) of the triggers is handled
  11165. */
  11166. hasSpecificTriggers(triggers: number[]): boolean;
  11167. /**
  11168. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11169. * speed.
  11170. * @param triggerA defines the trigger to be tested
  11171. * @param triggerB defines the trigger to be tested
  11172. * @return a boolean indicating whether one (or more) of the triggers is handled
  11173. */
  11174. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11175. /**
  11176. * Does this action manager handles actions of a given trigger
  11177. * @param trigger defines the trigger to be tested
  11178. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11179. * @return whether the trigger is handled
  11180. */
  11181. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11182. /**
  11183. * Does this action manager has pointer triggers
  11184. */
  11185. readonly hasPointerTriggers: boolean;
  11186. /**
  11187. * Does this action manager has pick triggers
  11188. */
  11189. readonly hasPickTriggers: boolean;
  11190. /**
  11191. * Registers an action to this action manager
  11192. * @param action defines the action to be registered
  11193. * @return the action amended (prepared) after registration
  11194. */
  11195. registerAction(action: IAction): Nullable<IAction>;
  11196. /**
  11197. * Unregisters an action to this action manager
  11198. * @param action defines the action to be unregistered
  11199. * @return a boolean indicating whether the action has been unregistered
  11200. */
  11201. unregisterAction(action: IAction): Boolean;
  11202. /**
  11203. * Process a specific trigger
  11204. * @param trigger defines the trigger to process
  11205. * @param evt defines the event details to be processed
  11206. */
  11207. processTrigger(trigger: number, evt?: IActionEvent): void;
  11208. /** @hidden */
  11209. _getEffectiveTarget(target: any, propertyPath: string): any;
  11210. /** @hidden */
  11211. _getProperty(propertyPath: string): string;
  11212. /**
  11213. * Serialize this manager to a JSON object
  11214. * @param name defines the property name to store this manager
  11215. * @returns a JSON representation of this manager
  11216. */
  11217. serialize(name: string): any;
  11218. /**
  11219. * Creates a new ActionManager from a JSON data
  11220. * @param parsedActions defines the JSON data to read from
  11221. * @param object defines the hosting mesh
  11222. * @param scene defines the hosting scene
  11223. */
  11224. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11225. /**
  11226. * Get a trigger name by index
  11227. * @param trigger defines the trigger index
  11228. * @returns a trigger name
  11229. */
  11230. static GetTriggerName(trigger: number): string;
  11231. }
  11232. }
  11233. declare module "babylonjs/Culling/ray" {
  11234. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11235. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11237. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11238. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11239. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11240. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11241. import { Plane } from "babylonjs/Maths/math.plane";
  11242. /**
  11243. * Class representing a ray with position and direction
  11244. */
  11245. export class Ray {
  11246. /** origin point */
  11247. origin: Vector3;
  11248. /** direction */
  11249. direction: Vector3;
  11250. /** length of the ray */
  11251. length: number;
  11252. private static readonly TmpVector3;
  11253. private _tmpRay;
  11254. /**
  11255. * Creates a new ray
  11256. * @param origin origin point
  11257. * @param direction direction
  11258. * @param length length of the ray
  11259. */
  11260. constructor(
  11261. /** origin point */
  11262. origin: Vector3,
  11263. /** direction */
  11264. direction: Vector3,
  11265. /** length of the ray */
  11266. length?: number);
  11267. /**
  11268. * Checks if the ray intersects a box
  11269. * @param minimum bound of the box
  11270. * @param maximum bound of the box
  11271. * @param intersectionTreshold extra extend to be added to the box in all direction
  11272. * @returns if the box was hit
  11273. */
  11274. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11275. /**
  11276. * Checks if the ray intersects a box
  11277. * @param box the bounding box to check
  11278. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11279. * @returns if the box was hit
  11280. */
  11281. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11282. /**
  11283. * If the ray hits a sphere
  11284. * @param sphere the bounding sphere to check
  11285. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11286. * @returns true if it hits the sphere
  11287. */
  11288. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11289. /**
  11290. * If the ray hits a triange
  11291. * @param vertex0 triangle vertex
  11292. * @param vertex1 triangle vertex
  11293. * @param vertex2 triangle vertex
  11294. * @returns intersection information if hit
  11295. */
  11296. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11297. /**
  11298. * Checks if ray intersects a plane
  11299. * @param plane the plane to check
  11300. * @returns the distance away it was hit
  11301. */
  11302. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11303. /**
  11304. * Calculate the intercept of a ray on a given axis
  11305. * @param axis to check 'x' | 'y' | 'z'
  11306. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11307. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11308. */
  11309. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11310. /**
  11311. * Checks if ray intersects a mesh
  11312. * @param mesh the mesh to check
  11313. * @param fastCheck if only the bounding box should checked
  11314. * @returns picking info of the intersecton
  11315. */
  11316. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11317. /**
  11318. * Checks if ray intersects a mesh
  11319. * @param meshes the meshes to check
  11320. * @param fastCheck if only the bounding box should checked
  11321. * @param results array to store result in
  11322. * @returns Array of picking infos
  11323. */
  11324. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11325. private _comparePickingInfo;
  11326. private static smallnum;
  11327. private static rayl;
  11328. /**
  11329. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11330. * @param sega the first point of the segment to test the intersection against
  11331. * @param segb the second point of the segment to test the intersection against
  11332. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11333. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11334. */
  11335. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11336. /**
  11337. * Update the ray from viewport position
  11338. * @param x position
  11339. * @param y y position
  11340. * @param viewportWidth viewport width
  11341. * @param viewportHeight viewport height
  11342. * @param world world matrix
  11343. * @param view view matrix
  11344. * @param projection projection matrix
  11345. * @returns this ray updated
  11346. */
  11347. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11348. /**
  11349. * Creates a ray with origin and direction of 0,0,0
  11350. * @returns the new ray
  11351. */
  11352. static Zero(): Ray;
  11353. /**
  11354. * Creates a new ray from screen space and viewport
  11355. * @param x position
  11356. * @param y y position
  11357. * @param viewportWidth viewport width
  11358. * @param viewportHeight viewport height
  11359. * @param world world matrix
  11360. * @param view view matrix
  11361. * @param projection projection matrix
  11362. * @returns new ray
  11363. */
  11364. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11365. /**
  11366. * 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
  11367. * transformed to the given world matrix.
  11368. * @param origin The origin point
  11369. * @param end The end point
  11370. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11371. * @returns the new ray
  11372. */
  11373. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11374. /**
  11375. * Transforms a ray by a matrix
  11376. * @param ray ray to transform
  11377. * @param matrix matrix to apply
  11378. * @returns the resulting new ray
  11379. */
  11380. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11381. /**
  11382. * Transforms a ray by a matrix
  11383. * @param ray ray to transform
  11384. * @param matrix matrix to apply
  11385. * @param result ray to store result in
  11386. */
  11387. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11388. /**
  11389. * Unproject a ray from screen space to object space
  11390. * @param sourceX defines the screen space x coordinate to use
  11391. * @param sourceY defines the screen space y coordinate to use
  11392. * @param viewportWidth defines the current width of the viewport
  11393. * @param viewportHeight defines the current height of the viewport
  11394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11395. * @param view defines the view matrix to use
  11396. * @param projection defines the projection matrix to use
  11397. */
  11398. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11399. }
  11400. /**
  11401. * Type used to define predicate used to select faces when a mesh intersection is detected
  11402. */
  11403. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11404. module "babylonjs/scene" {
  11405. interface Scene {
  11406. /** @hidden */
  11407. _tempPickingRay: Nullable<Ray>;
  11408. /** @hidden */
  11409. _cachedRayForTransform: Ray;
  11410. /** @hidden */
  11411. _pickWithRayInverseMatrix: Matrix;
  11412. /** @hidden */
  11413. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11414. /** @hidden */
  11415. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11416. }
  11417. }
  11418. }
  11419. declare module "babylonjs/sceneComponent" {
  11420. import { Scene } from "babylonjs/scene";
  11421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11422. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11423. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11424. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11425. import { Nullable } from "babylonjs/types";
  11426. import { Camera } from "babylonjs/Cameras/camera";
  11427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11429. import { AbstractScene } from "babylonjs/abstractScene";
  11430. import { Mesh } from "babylonjs/Meshes/mesh";
  11431. /**
  11432. * Groups all the scene component constants in one place to ease maintenance.
  11433. * @hidden
  11434. */
  11435. export class SceneComponentConstants {
  11436. static readonly NAME_EFFECTLAYER: string;
  11437. static readonly NAME_LAYER: string;
  11438. static readonly NAME_LENSFLARESYSTEM: string;
  11439. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11440. static readonly NAME_PARTICLESYSTEM: string;
  11441. static readonly NAME_GAMEPAD: string;
  11442. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11443. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11444. static readonly NAME_DEPTHRENDERER: string;
  11445. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11446. static readonly NAME_SPRITE: string;
  11447. static readonly NAME_OUTLINERENDERER: string;
  11448. static readonly NAME_PROCEDURALTEXTURE: string;
  11449. static readonly NAME_SHADOWGENERATOR: string;
  11450. static readonly NAME_OCTREE: string;
  11451. static readonly NAME_PHYSICSENGINE: string;
  11452. static readonly NAME_AUDIO: string;
  11453. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11454. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11455. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11456. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11457. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11458. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11459. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11460. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11461. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11462. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11463. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11464. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11465. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11466. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11467. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11468. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11469. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11470. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11471. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11472. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11473. static readonly STEP_AFTERRENDER_AUDIO: number;
  11474. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11475. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11476. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11477. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11478. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11479. static readonly STEP_POINTERMOVE_SPRITE: number;
  11480. static readonly STEP_POINTERDOWN_SPRITE: number;
  11481. static readonly STEP_POINTERUP_SPRITE: number;
  11482. }
  11483. /**
  11484. * This represents a scene component.
  11485. *
  11486. * This is used to decouple the dependency the scene is having on the different workloads like
  11487. * layers, post processes...
  11488. */
  11489. export interface ISceneComponent {
  11490. /**
  11491. * The name of the component. Each component must have a unique name.
  11492. */
  11493. name: string;
  11494. /**
  11495. * The scene the component belongs to.
  11496. */
  11497. scene: Scene;
  11498. /**
  11499. * Register the component to one instance of a scene.
  11500. */
  11501. register(): void;
  11502. /**
  11503. * Rebuilds the elements related to this component in case of
  11504. * context lost for instance.
  11505. */
  11506. rebuild(): void;
  11507. /**
  11508. * Disposes the component and the associated ressources.
  11509. */
  11510. dispose(): void;
  11511. }
  11512. /**
  11513. * This represents a SERIALIZABLE scene component.
  11514. *
  11515. * This extends Scene Component to add Serialization methods on top.
  11516. */
  11517. export interface ISceneSerializableComponent extends ISceneComponent {
  11518. /**
  11519. * Adds all the elements from the container to the scene
  11520. * @param container the container holding the elements
  11521. */
  11522. addFromContainer(container: AbstractScene): void;
  11523. /**
  11524. * Removes all the elements in the container from the scene
  11525. * @param container contains the elements to remove
  11526. * @param dispose if the removed element should be disposed (default: false)
  11527. */
  11528. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11529. /**
  11530. * Serializes the component data to the specified json object
  11531. * @param serializationObject The object to serialize to
  11532. */
  11533. serialize(serializationObject: any): void;
  11534. }
  11535. /**
  11536. * Strong typing of a Mesh related stage step action
  11537. */
  11538. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11539. /**
  11540. * Strong typing of a Evaluate Sub Mesh related stage step action
  11541. */
  11542. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11543. /**
  11544. * Strong typing of a Active Mesh related stage step action
  11545. */
  11546. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11547. /**
  11548. * Strong typing of a Camera related stage step action
  11549. */
  11550. export type CameraStageAction = (camera: Camera) => void;
  11551. /**
  11552. * Strong typing of a Camera Frame buffer related stage step action
  11553. */
  11554. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11555. /**
  11556. * Strong typing of a Render Target related stage step action
  11557. */
  11558. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11559. /**
  11560. * Strong typing of a RenderingGroup related stage step action
  11561. */
  11562. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11563. /**
  11564. * Strong typing of a Mesh Render related stage step action
  11565. */
  11566. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11567. /**
  11568. * Strong typing of a simple stage step action
  11569. */
  11570. export type SimpleStageAction = () => void;
  11571. /**
  11572. * Strong typing of a render target action.
  11573. */
  11574. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11575. /**
  11576. * Strong typing of a pointer move action.
  11577. */
  11578. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11579. /**
  11580. * Strong typing of a pointer up/down action.
  11581. */
  11582. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11583. /**
  11584. * Representation of a stage in the scene (Basically a list of ordered steps)
  11585. * @hidden
  11586. */
  11587. export class Stage<T extends Function> extends Array<{
  11588. index: number;
  11589. component: ISceneComponent;
  11590. action: T;
  11591. }> {
  11592. /**
  11593. * Hide ctor from the rest of the world.
  11594. * @param items The items to add.
  11595. */
  11596. private constructor();
  11597. /**
  11598. * Creates a new Stage.
  11599. * @returns A new instance of a Stage
  11600. */
  11601. static Create<T extends Function>(): Stage<T>;
  11602. /**
  11603. * Registers a step in an ordered way in the targeted stage.
  11604. * @param index Defines the position to register the step in
  11605. * @param component Defines the component attached to the step
  11606. * @param action Defines the action to launch during the step
  11607. */
  11608. registerStep(index: number, component: ISceneComponent, action: T): void;
  11609. /**
  11610. * Clears all the steps from the stage.
  11611. */
  11612. clear(): void;
  11613. }
  11614. }
  11615. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11616. import { Nullable } from "babylonjs/types";
  11617. import { Observable } from "babylonjs/Misc/observable";
  11618. import { Scene } from "babylonjs/scene";
  11619. import { Sprite } from "babylonjs/Sprites/sprite";
  11620. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11621. import { Ray } from "babylonjs/Culling/ray";
  11622. import { Camera } from "babylonjs/Cameras/camera";
  11623. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11624. import { ISceneComponent } from "babylonjs/sceneComponent";
  11625. module "babylonjs/scene" {
  11626. interface Scene {
  11627. /** @hidden */
  11628. _pointerOverSprite: Nullable<Sprite>;
  11629. /** @hidden */
  11630. _pickedDownSprite: Nullable<Sprite>;
  11631. /** @hidden */
  11632. _tempSpritePickingRay: Nullable<Ray>;
  11633. /**
  11634. * All of the sprite managers added to this scene
  11635. * @see http://doc.babylonjs.com/babylon101/sprites
  11636. */
  11637. spriteManagers: Array<ISpriteManager>;
  11638. /**
  11639. * An event triggered when sprites rendering is about to start
  11640. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11641. */
  11642. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11643. /**
  11644. * An event triggered when sprites rendering is done
  11645. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11646. */
  11647. onAfterSpritesRenderingObservable: Observable<Scene>;
  11648. /** @hidden */
  11649. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11650. /** Launch a ray to try to pick a sprite in the scene
  11651. * @param x position on screen
  11652. * @param y position on screen
  11653. * @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
  11654. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11655. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11656. * @returns a PickingInfo
  11657. */
  11658. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11659. /** Use the given ray to pick a sprite in the scene
  11660. * @param ray The ray (in world space) to use to pick meshes
  11661. * @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
  11662. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11663. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11664. * @returns a PickingInfo
  11665. */
  11666. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11667. /** @hidden */
  11668. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11669. /** Launch a ray to try to pick sprites in the scene
  11670. * @param x position on screen
  11671. * @param y position on screen
  11672. * @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
  11673. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11674. * @returns a PickingInfo array
  11675. */
  11676. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11677. /** Use the given ray to pick sprites in the scene
  11678. * @param ray The ray (in world space) to use to pick meshes
  11679. * @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
  11680. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11681. * @returns a PickingInfo array
  11682. */
  11683. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11684. /**
  11685. * Force the sprite under the pointer
  11686. * @param sprite defines the sprite to use
  11687. */
  11688. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11689. /**
  11690. * Gets the sprite under the pointer
  11691. * @returns a Sprite or null if no sprite is under the pointer
  11692. */
  11693. getPointerOverSprite(): Nullable<Sprite>;
  11694. }
  11695. }
  11696. /**
  11697. * Defines the sprite scene component responsible to manage sprites
  11698. * in a given scene.
  11699. */
  11700. export class SpriteSceneComponent implements ISceneComponent {
  11701. /**
  11702. * The component name helpfull to identify the component in the list of scene components.
  11703. */
  11704. readonly name: string;
  11705. /**
  11706. * The scene the component belongs to.
  11707. */
  11708. scene: Scene;
  11709. /** @hidden */
  11710. private _spritePredicate;
  11711. /**
  11712. * Creates a new instance of the component for the given scene
  11713. * @param scene Defines the scene to register the component in
  11714. */
  11715. constructor(scene: Scene);
  11716. /**
  11717. * Registers the component in a given scene
  11718. */
  11719. register(): void;
  11720. /**
  11721. * Rebuilds the elements related to this component in case of
  11722. * context lost for instance.
  11723. */
  11724. rebuild(): void;
  11725. /**
  11726. * Disposes the component and the associated ressources.
  11727. */
  11728. dispose(): void;
  11729. private _pickSpriteButKeepRay;
  11730. private _pointerMove;
  11731. private _pointerDown;
  11732. private _pointerUp;
  11733. }
  11734. }
  11735. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11736. /** @hidden */
  11737. export var fogFragmentDeclaration: {
  11738. name: string;
  11739. shader: string;
  11740. };
  11741. }
  11742. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11743. /** @hidden */
  11744. export var fogFragment: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/sprites.fragment" {
  11750. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11751. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11752. /** @hidden */
  11753. export var spritesPixelShader: {
  11754. name: string;
  11755. shader: string;
  11756. };
  11757. }
  11758. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11759. /** @hidden */
  11760. export var fogVertexDeclaration: {
  11761. name: string;
  11762. shader: string;
  11763. };
  11764. }
  11765. declare module "babylonjs/Shaders/sprites.vertex" {
  11766. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11767. /** @hidden */
  11768. export var spritesVertexShader: {
  11769. name: string;
  11770. shader: string;
  11771. };
  11772. }
  11773. declare module "babylonjs/Sprites/spriteManager" {
  11774. import { IDisposable, Scene } from "babylonjs/scene";
  11775. import { Nullable } from "babylonjs/types";
  11776. import { Observable } from "babylonjs/Misc/observable";
  11777. import { Sprite } from "babylonjs/Sprites/sprite";
  11778. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11779. import { Camera } from "babylonjs/Cameras/camera";
  11780. import { Texture } from "babylonjs/Materials/Textures/texture";
  11781. import "babylonjs/Shaders/sprites.fragment";
  11782. import "babylonjs/Shaders/sprites.vertex";
  11783. import { Ray } from "babylonjs/Culling/ray";
  11784. /**
  11785. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11786. */
  11787. export interface ISpriteManager extends IDisposable {
  11788. /**
  11789. * Restricts the camera to viewing objects with the same layerMask.
  11790. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11791. */
  11792. layerMask: number;
  11793. /**
  11794. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11795. */
  11796. isPickable: boolean;
  11797. /**
  11798. * Specifies the rendering group id for this mesh (0 by default)
  11799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11800. */
  11801. renderingGroupId: number;
  11802. /**
  11803. * Defines the list of sprites managed by the manager.
  11804. */
  11805. sprites: Array<Sprite>;
  11806. /**
  11807. * Tests the intersection of a sprite with a specific ray.
  11808. * @param ray The ray we are sending to test the collision
  11809. * @param camera The camera space we are sending rays in
  11810. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11811. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11812. * @returns picking info or null.
  11813. */
  11814. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11815. /**
  11816. * Intersects the sprites with a ray
  11817. * @param ray defines the ray to intersect with
  11818. * @param camera defines the current active camera
  11819. * @param predicate defines a predicate used to select candidate sprites
  11820. * @returns null if no hit or a PickingInfo array
  11821. */
  11822. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11823. /**
  11824. * Renders the list of sprites on screen.
  11825. */
  11826. render(): void;
  11827. }
  11828. /**
  11829. * Class used to manage multiple sprites on the same spritesheet
  11830. * @see http://doc.babylonjs.com/babylon101/sprites
  11831. */
  11832. export class SpriteManager implements ISpriteManager {
  11833. /** defines the manager's name */
  11834. name: string;
  11835. /** Gets the list of sprites */
  11836. sprites: Sprite[];
  11837. /** Gets or sets the rendering group id (0 by default) */
  11838. renderingGroupId: number;
  11839. /** Gets or sets camera layer mask */
  11840. layerMask: number;
  11841. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11842. fogEnabled: boolean;
  11843. /** Gets or sets a boolean indicating if the sprites are pickable */
  11844. isPickable: boolean;
  11845. /** Defines the default width of a cell in the spritesheet */
  11846. cellWidth: number;
  11847. /** Defines the default height of a cell in the spritesheet */
  11848. cellHeight: number;
  11849. /** Associative array from JSON sprite data file */
  11850. private _cellData;
  11851. /** Array of sprite names from JSON sprite data file */
  11852. private _spriteMap;
  11853. /** True when packed cell data from JSON file is ready*/
  11854. private _packedAndReady;
  11855. /**
  11856. * An event triggered when the manager is disposed.
  11857. */
  11858. onDisposeObservable: Observable<SpriteManager>;
  11859. private _onDisposeObserver;
  11860. /**
  11861. * Callback called when the manager is disposed
  11862. */
  11863. onDispose: () => void;
  11864. private _capacity;
  11865. private _fromPacked;
  11866. private _spriteTexture;
  11867. private _epsilon;
  11868. private _scene;
  11869. private _vertexData;
  11870. private _buffer;
  11871. private _vertexBuffers;
  11872. private _indexBuffer;
  11873. private _effectBase;
  11874. private _effectFog;
  11875. /**
  11876. * Gets or sets the spritesheet texture
  11877. */
  11878. texture: Texture;
  11879. /**
  11880. * Creates a new sprite manager
  11881. * @param name defines the manager's name
  11882. * @param imgUrl defines the sprite sheet url
  11883. * @param capacity defines the maximum allowed number of sprites
  11884. * @param cellSize defines the size of a sprite cell
  11885. * @param scene defines the hosting scene
  11886. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11887. * @param samplingMode defines the smapling mode to use with spritesheet
  11888. * @param fromPacked set to false; do not alter
  11889. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11890. */
  11891. constructor(
  11892. /** defines the manager's name */
  11893. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11894. private _makePacked;
  11895. private _appendSpriteVertex;
  11896. /**
  11897. * Intersects the sprites with a ray
  11898. * @param ray defines the ray to intersect with
  11899. * @param camera defines the current active camera
  11900. * @param predicate defines a predicate used to select candidate sprites
  11901. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11902. * @returns null if no hit or a PickingInfo
  11903. */
  11904. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11905. /**
  11906. * Intersects the sprites with a ray
  11907. * @param ray defines the ray to intersect with
  11908. * @param camera defines the current active camera
  11909. * @param predicate defines a predicate used to select candidate sprites
  11910. * @returns null if no hit or a PickingInfo array
  11911. */
  11912. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11913. /**
  11914. * Render all child sprites
  11915. */
  11916. render(): void;
  11917. /**
  11918. * Release associated resources
  11919. */
  11920. dispose(): void;
  11921. }
  11922. }
  11923. declare module "babylonjs/Sprites/sprite" {
  11924. import { Vector3 } from "babylonjs/Maths/math.vector";
  11925. import { Nullable } from "babylonjs/types";
  11926. import { ActionManager } from "babylonjs/Actions/actionManager";
  11927. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11928. import { Color4 } from "babylonjs/Maths/math.color";
  11929. /**
  11930. * Class used to represent a sprite
  11931. * @see http://doc.babylonjs.com/babylon101/sprites
  11932. */
  11933. export class Sprite {
  11934. /** defines the name */
  11935. name: string;
  11936. /** Gets or sets the current world position */
  11937. position: Vector3;
  11938. /** Gets or sets the main color */
  11939. color: Color4;
  11940. /** Gets or sets the width */
  11941. width: number;
  11942. /** Gets or sets the height */
  11943. height: number;
  11944. /** Gets or sets rotation angle */
  11945. angle: number;
  11946. /** Gets or sets the cell index in the sprite sheet */
  11947. cellIndex: number;
  11948. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11949. cellRef: string;
  11950. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11951. invertU: number;
  11952. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11953. invertV: number;
  11954. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11955. disposeWhenFinishedAnimating: boolean;
  11956. /** Gets the list of attached animations */
  11957. animations: Animation[];
  11958. /** Gets or sets a boolean indicating if the sprite can be picked */
  11959. isPickable: boolean;
  11960. /**
  11961. * Gets or sets the associated action manager
  11962. */
  11963. actionManager: Nullable<ActionManager>;
  11964. private _animationStarted;
  11965. private _loopAnimation;
  11966. private _fromIndex;
  11967. private _toIndex;
  11968. private _delay;
  11969. private _direction;
  11970. private _manager;
  11971. private _time;
  11972. private _onAnimationEnd;
  11973. /**
  11974. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11975. */
  11976. isVisible: boolean;
  11977. /**
  11978. * Gets or sets the sprite size
  11979. */
  11980. size: number;
  11981. /**
  11982. * Creates a new Sprite
  11983. * @param name defines the name
  11984. * @param manager defines the manager
  11985. */
  11986. constructor(
  11987. /** defines the name */
  11988. name: string, manager: ISpriteManager);
  11989. /**
  11990. * Starts an animation
  11991. * @param from defines the initial key
  11992. * @param to defines the end key
  11993. * @param loop defines if the animation must loop
  11994. * @param delay defines the start delay (in ms)
  11995. * @param onAnimationEnd defines a callback to call when animation ends
  11996. */
  11997. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11998. /** Stops current animation (if any) */
  11999. stopAnimation(): void;
  12000. /** @hidden */
  12001. _animate(deltaTime: number): void;
  12002. /** Release associated resources */
  12003. dispose(): void;
  12004. }
  12005. }
  12006. declare module "babylonjs/Collisions/pickingInfo" {
  12007. import { Nullable } from "babylonjs/types";
  12008. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12010. import { Sprite } from "babylonjs/Sprites/sprite";
  12011. import { Ray } from "babylonjs/Culling/ray";
  12012. /**
  12013. * Information about the result of picking within a scene
  12014. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12015. */
  12016. export class PickingInfo {
  12017. /** @hidden */
  12018. _pickingUnavailable: boolean;
  12019. /**
  12020. * If the pick collided with an object
  12021. */
  12022. hit: boolean;
  12023. /**
  12024. * Distance away where the pick collided
  12025. */
  12026. distance: number;
  12027. /**
  12028. * The location of pick collision
  12029. */
  12030. pickedPoint: Nullable<Vector3>;
  12031. /**
  12032. * The mesh corresponding the the pick collision
  12033. */
  12034. pickedMesh: Nullable<AbstractMesh>;
  12035. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12036. bu: number;
  12037. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12038. bv: number;
  12039. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12040. faceId: number;
  12041. /** Id of the the submesh that was picked */
  12042. subMeshId: number;
  12043. /** If a sprite was picked, this will be the sprite the pick collided with */
  12044. pickedSprite: Nullable<Sprite>;
  12045. /**
  12046. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12047. */
  12048. originMesh: Nullable<AbstractMesh>;
  12049. /**
  12050. * The ray that was used to perform the picking.
  12051. */
  12052. ray: Nullable<Ray>;
  12053. /**
  12054. * Gets the normal correspodning to the face the pick collided with
  12055. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12056. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12057. * @returns The normal correspodning to the face the pick collided with
  12058. */
  12059. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12060. /**
  12061. * Gets the texture coordinates of where the pick occured
  12062. * @returns the vector containing the coordnates of the texture
  12063. */
  12064. getTextureCoordinates(): Nullable<Vector2>;
  12065. }
  12066. }
  12067. declare module "babylonjs/Events/pointerEvents" {
  12068. import { Nullable } from "babylonjs/types";
  12069. import { Vector2 } from "babylonjs/Maths/math.vector";
  12070. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12071. import { Ray } from "babylonjs/Culling/ray";
  12072. /**
  12073. * Gather the list of pointer event types as constants.
  12074. */
  12075. export class PointerEventTypes {
  12076. /**
  12077. * 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.
  12078. */
  12079. static readonly POINTERDOWN: number;
  12080. /**
  12081. * The pointerup event is fired when a pointer is no longer active.
  12082. */
  12083. static readonly POINTERUP: number;
  12084. /**
  12085. * The pointermove event is fired when a pointer changes coordinates.
  12086. */
  12087. static readonly POINTERMOVE: number;
  12088. /**
  12089. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12090. */
  12091. static readonly POINTERWHEEL: number;
  12092. /**
  12093. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12094. */
  12095. static readonly POINTERPICK: number;
  12096. /**
  12097. * The pointertap event is fired when a the object has been touched and released without drag.
  12098. */
  12099. static readonly POINTERTAP: number;
  12100. /**
  12101. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12102. */
  12103. static readonly POINTERDOUBLETAP: number;
  12104. }
  12105. /**
  12106. * Base class of pointer info types.
  12107. */
  12108. export class PointerInfoBase {
  12109. /**
  12110. * Defines the type of event (PointerEventTypes)
  12111. */
  12112. type: number;
  12113. /**
  12114. * Defines the related dom event
  12115. */
  12116. event: PointerEvent | MouseWheelEvent;
  12117. /**
  12118. * Instantiates the base class of pointers info.
  12119. * @param type Defines the type of event (PointerEventTypes)
  12120. * @param event Defines the related dom event
  12121. */
  12122. constructor(
  12123. /**
  12124. * Defines the type of event (PointerEventTypes)
  12125. */
  12126. type: number,
  12127. /**
  12128. * Defines the related dom event
  12129. */
  12130. event: PointerEvent | MouseWheelEvent);
  12131. }
  12132. /**
  12133. * This class is used to store pointer related info for the onPrePointerObservable event.
  12134. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12135. */
  12136. export class PointerInfoPre extends PointerInfoBase {
  12137. /**
  12138. * Ray from a pointer if availible (eg. 6dof controller)
  12139. */
  12140. ray: Nullable<Ray>;
  12141. /**
  12142. * Defines the local position of the pointer on the canvas.
  12143. */
  12144. localPosition: Vector2;
  12145. /**
  12146. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12147. */
  12148. skipOnPointerObservable: boolean;
  12149. /**
  12150. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12151. * @param type Defines the type of event (PointerEventTypes)
  12152. * @param event Defines the related dom event
  12153. * @param localX Defines the local x coordinates of the pointer when the event occured
  12154. * @param localY Defines the local y coordinates of the pointer when the event occured
  12155. */
  12156. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12157. }
  12158. /**
  12159. * This type contains all the data related to a pointer event in Babylon.js.
  12160. * 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.
  12161. */
  12162. export class PointerInfo extends PointerInfoBase {
  12163. /**
  12164. * Defines the picking info associated to the info (if any)\
  12165. */
  12166. pickInfo: Nullable<PickingInfo>;
  12167. /**
  12168. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12169. * @param type Defines the type of event (PointerEventTypes)
  12170. * @param event Defines the related dom event
  12171. * @param pickInfo Defines the picking info associated to the info (if any)\
  12172. */
  12173. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12174. /**
  12175. * Defines the picking info associated to the info (if any)\
  12176. */
  12177. pickInfo: Nullable<PickingInfo>);
  12178. }
  12179. /**
  12180. * Data relating to a touch event on the screen.
  12181. */
  12182. export interface PointerTouch {
  12183. /**
  12184. * X coordinate of touch.
  12185. */
  12186. x: number;
  12187. /**
  12188. * Y coordinate of touch.
  12189. */
  12190. y: number;
  12191. /**
  12192. * Id of touch. Unique for each finger.
  12193. */
  12194. pointerId: number;
  12195. /**
  12196. * Event type passed from DOM.
  12197. */
  12198. type: any;
  12199. }
  12200. }
  12201. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12202. import { Observable } from "babylonjs/Misc/observable";
  12203. import { Nullable } from "babylonjs/types";
  12204. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12206. /**
  12207. * Manage the mouse inputs to control the movement of a free camera.
  12208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12209. */
  12210. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12211. /**
  12212. * Define if touch is enabled in the mouse input
  12213. */
  12214. touchEnabled: boolean;
  12215. /**
  12216. * Defines the camera the input is attached to.
  12217. */
  12218. camera: FreeCamera;
  12219. /**
  12220. * Defines the buttons associated with the input to handle camera move.
  12221. */
  12222. buttons: number[];
  12223. /**
  12224. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12225. */
  12226. angularSensibility: number;
  12227. private _pointerInput;
  12228. private _onMouseMove;
  12229. private _observer;
  12230. private previousPosition;
  12231. /**
  12232. * Observable for when a pointer move event occurs containing the move offset
  12233. */
  12234. onPointerMovedObservable: Observable<{
  12235. offsetX: number;
  12236. offsetY: number;
  12237. }>;
  12238. /**
  12239. * @hidden
  12240. * If the camera should be rotated automatically based on pointer movement
  12241. */
  12242. _allowCameraRotation: boolean;
  12243. /**
  12244. * Manage the mouse inputs to control the movement of a free camera.
  12245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12246. * @param touchEnabled Defines if touch is enabled or not
  12247. */
  12248. constructor(
  12249. /**
  12250. * Define if touch is enabled in the mouse input
  12251. */
  12252. touchEnabled?: boolean);
  12253. /**
  12254. * Attach the input controls to a specific dom element to get the input from.
  12255. * @param element Defines the element the controls should be listened from
  12256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12257. */
  12258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12259. /**
  12260. * Called on JS contextmenu event.
  12261. * Override this method to provide functionality.
  12262. */
  12263. protected onContextMenu(evt: PointerEvent): void;
  12264. /**
  12265. * Detach the current controls from the specified dom element.
  12266. * @param element Defines the element to stop listening the inputs from
  12267. */
  12268. detachControl(element: Nullable<HTMLElement>): void;
  12269. /**
  12270. * Gets the class name of the current intput.
  12271. * @returns the class name
  12272. */
  12273. getClassName(): string;
  12274. /**
  12275. * Get the friendly name associated with the input class.
  12276. * @returns the input friendly name
  12277. */
  12278. getSimpleName(): string;
  12279. }
  12280. }
  12281. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12282. import { Nullable } from "babylonjs/types";
  12283. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12284. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12285. /**
  12286. * Manage the touch inputs to control the movement of a free camera.
  12287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12288. */
  12289. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12290. /**
  12291. * Defines the camera the input is attached to.
  12292. */
  12293. camera: FreeCamera;
  12294. /**
  12295. * Defines the touch sensibility for rotation.
  12296. * The higher the faster.
  12297. */
  12298. touchAngularSensibility: number;
  12299. /**
  12300. * Defines the touch sensibility for move.
  12301. * The higher the faster.
  12302. */
  12303. touchMoveSensibility: number;
  12304. private _offsetX;
  12305. private _offsetY;
  12306. private _pointerPressed;
  12307. private _pointerInput;
  12308. private _observer;
  12309. private _onLostFocus;
  12310. /**
  12311. * Attach the input controls to a specific dom element to get the input from.
  12312. * @param element Defines the element the controls should be listened from
  12313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12314. */
  12315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12316. /**
  12317. * Detach the current controls from the specified dom element.
  12318. * @param element Defines the element to stop listening the inputs from
  12319. */
  12320. detachControl(element: Nullable<HTMLElement>): void;
  12321. /**
  12322. * Update the current camera state depending on the inputs that have been used this frame.
  12323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12324. */
  12325. checkInputs(): void;
  12326. /**
  12327. * Gets the class name of the current intput.
  12328. * @returns the class name
  12329. */
  12330. getClassName(): string;
  12331. /**
  12332. * Get the friendly name associated with the input class.
  12333. * @returns the input friendly name
  12334. */
  12335. getSimpleName(): string;
  12336. }
  12337. }
  12338. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12339. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12340. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12341. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12342. import { Nullable } from "babylonjs/types";
  12343. /**
  12344. * Default Inputs manager for the FreeCamera.
  12345. * It groups all the default supported inputs for ease of use.
  12346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12347. */
  12348. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12349. /**
  12350. * @hidden
  12351. */
  12352. _mouseInput: Nullable<FreeCameraMouseInput>;
  12353. /**
  12354. * Instantiates a new FreeCameraInputsManager.
  12355. * @param camera Defines the camera the inputs belong to
  12356. */
  12357. constructor(camera: FreeCamera);
  12358. /**
  12359. * Add keyboard input support to the input manager.
  12360. * @returns the current input manager
  12361. */
  12362. addKeyboard(): FreeCameraInputsManager;
  12363. /**
  12364. * Add mouse input support to the input manager.
  12365. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12366. * @returns the current input manager
  12367. */
  12368. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12369. /**
  12370. * Removes the mouse input support from the manager
  12371. * @returns the current input manager
  12372. */
  12373. removeMouse(): FreeCameraInputsManager;
  12374. /**
  12375. * Add touch input support to the input manager.
  12376. * @returns the current input manager
  12377. */
  12378. addTouch(): FreeCameraInputsManager;
  12379. /**
  12380. * Remove all attached input methods from a camera
  12381. */
  12382. clear(): void;
  12383. }
  12384. }
  12385. declare module "babylonjs/Cameras/freeCamera" {
  12386. import { Vector3 } from "babylonjs/Maths/math.vector";
  12387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12388. import { Scene } from "babylonjs/scene";
  12389. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12390. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12391. /**
  12392. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12393. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12394. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12395. */
  12396. export class FreeCamera extends TargetCamera {
  12397. /**
  12398. * Define the collision ellipsoid of the camera.
  12399. * This is helpful to simulate a camera body like the player body around the camera
  12400. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12401. */
  12402. ellipsoid: Vector3;
  12403. /**
  12404. * Define an offset for the position of the ellipsoid around the camera.
  12405. * This can be helpful to determine the center of the body near the gravity center of the body
  12406. * instead of its head.
  12407. */
  12408. ellipsoidOffset: Vector3;
  12409. /**
  12410. * Enable or disable collisions of the camera with the rest of the scene objects.
  12411. */
  12412. checkCollisions: boolean;
  12413. /**
  12414. * Enable or disable gravity on the camera.
  12415. */
  12416. applyGravity: boolean;
  12417. /**
  12418. * Define the input manager associated to the camera.
  12419. */
  12420. inputs: FreeCameraInputsManager;
  12421. /**
  12422. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12423. * Higher values reduce sensitivity.
  12424. */
  12425. /**
  12426. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12427. * Higher values reduce sensitivity.
  12428. */
  12429. angularSensibility: number;
  12430. /**
  12431. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12432. */
  12433. keysUp: number[];
  12434. /**
  12435. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12436. */
  12437. keysDown: number[];
  12438. /**
  12439. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12440. */
  12441. keysLeft: number[];
  12442. /**
  12443. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12444. */
  12445. keysRight: number[];
  12446. /**
  12447. * Event raised when the camera collide with a mesh in the scene.
  12448. */
  12449. onCollide: (collidedMesh: AbstractMesh) => void;
  12450. private _collider;
  12451. private _needMoveForGravity;
  12452. private _oldPosition;
  12453. private _diffPosition;
  12454. private _newPosition;
  12455. /** @hidden */
  12456. _localDirection: Vector3;
  12457. /** @hidden */
  12458. _transformedDirection: Vector3;
  12459. /**
  12460. * Instantiates a Free Camera.
  12461. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12462. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12464. * @param name Define the name of the camera in the scene
  12465. * @param position Define the start position of the camera in the scene
  12466. * @param scene Define the scene the camera belongs to
  12467. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12468. */
  12469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12470. /**
  12471. * Attached controls to the current camera.
  12472. * @param element Defines the element the controls should be listened from
  12473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12474. */
  12475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12476. /**
  12477. * Detach the current controls from the camera.
  12478. * The camera will stop reacting to inputs.
  12479. * @param element Defines the element to stop listening the inputs from
  12480. */
  12481. detachControl(element: HTMLElement): void;
  12482. private _collisionMask;
  12483. /**
  12484. * Define a collision mask to limit the list of object the camera can collide with
  12485. */
  12486. collisionMask: number;
  12487. /** @hidden */
  12488. _collideWithWorld(displacement: Vector3): void;
  12489. private _onCollisionPositionChange;
  12490. /** @hidden */
  12491. _checkInputs(): void;
  12492. /** @hidden */
  12493. _decideIfNeedsToMove(): boolean;
  12494. /** @hidden */
  12495. _updatePosition(): void;
  12496. /**
  12497. * Destroy the camera and release the current resources hold by it.
  12498. */
  12499. dispose(): void;
  12500. /**
  12501. * Gets the current object class name.
  12502. * @return the class name
  12503. */
  12504. getClassName(): string;
  12505. }
  12506. }
  12507. declare module "babylonjs/Gamepads/gamepad" {
  12508. import { Observable } from "babylonjs/Misc/observable";
  12509. /**
  12510. * Represents a gamepad control stick position
  12511. */
  12512. export class StickValues {
  12513. /**
  12514. * The x component of the control stick
  12515. */
  12516. x: number;
  12517. /**
  12518. * The y component of the control stick
  12519. */
  12520. y: number;
  12521. /**
  12522. * Initializes the gamepad x and y control stick values
  12523. * @param x The x component of the gamepad control stick value
  12524. * @param y The y component of the gamepad control stick value
  12525. */
  12526. constructor(
  12527. /**
  12528. * The x component of the control stick
  12529. */
  12530. x: number,
  12531. /**
  12532. * The y component of the control stick
  12533. */
  12534. y: number);
  12535. }
  12536. /**
  12537. * An interface which manages callbacks for gamepad button changes
  12538. */
  12539. export interface GamepadButtonChanges {
  12540. /**
  12541. * Called when a gamepad has been changed
  12542. */
  12543. changed: boolean;
  12544. /**
  12545. * Called when a gamepad press event has been triggered
  12546. */
  12547. pressChanged: boolean;
  12548. /**
  12549. * Called when a touch event has been triggered
  12550. */
  12551. touchChanged: boolean;
  12552. /**
  12553. * Called when a value has changed
  12554. */
  12555. valueChanged: boolean;
  12556. }
  12557. /**
  12558. * Represents a gamepad
  12559. */
  12560. export class Gamepad {
  12561. /**
  12562. * The id of the gamepad
  12563. */
  12564. id: string;
  12565. /**
  12566. * The index of the gamepad
  12567. */
  12568. index: number;
  12569. /**
  12570. * The browser gamepad
  12571. */
  12572. browserGamepad: any;
  12573. /**
  12574. * Specifies what type of gamepad this represents
  12575. */
  12576. type: number;
  12577. private _leftStick;
  12578. private _rightStick;
  12579. /** @hidden */
  12580. _isConnected: boolean;
  12581. private _leftStickAxisX;
  12582. private _leftStickAxisY;
  12583. private _rightStickAxisX;
  12584. private _rightStickAxisY;
  12585. /**
  12586. * Triggered when the left control stick has been changed
  12587. */
  12588. private _onleftstickchanged;
  12589. /**
  12590. * Triggered when the right control stick has been changed
  12591. */
  12592. private _onrightstickchanged;
  12593. /**
  12594. * Represents a gamepad controller
  12595. */
  12596. static GAMEPAD: number;
  12597. /**
  12598. * Represents a generic controller
  12599. */
  12600. static GENERIC: number;
  12601. /**
  12602. * Represents an XBox controller
  12603. */
  12604. static XBOX: number;
  12605. /**
  12606. * Represents a pose-enabled controller
  12607. */
  12608. static POSE_ENABLED: number;
  12609. /**
  12610. * Represents an Dual Shock controller
  12611. */
  12612. static DUALSHOCK: number;
  12613. /**
  12614. * Specifies whether the left control stick should be Y-inverted
  12615. */
  12616. protected _invertLeftStickY: boolean;
  12617. /**
  12618. * Specifies if the gamepad has been connected
  12619. */
  12620. readonly isConnected: boolean;
  12621. /**
  12622. * Initializes the gamepad
  12623. * @param id The id of the gamepad
  12624. * @param index The index of the gamepad
  12625. * @param browserGamepad The browser gamepad
  12626. * @param leftStickX The x component of the left joystick
  12627. * @param leftStickY The y component of the left joystick
  12628. * @param rightStickX The x component of the right joystick
  12629. * @param rightStickY The y component of the right joystick
  12630. */
  12631. constructor(
  12632. /**
  12633. * The id of the gamepad
  12634. */
  12635. id: string,
  12636. /**
  12637. * The index of the gamepad
  12638. */
  12639. index: number,
  12640. /**
  12641. * The browser gamepad
  12642. */
  12643. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12644. /**
  12645. * Callback triggered when the left joystick has changed
  12646. * @param callback
  12647. */
  12648. onleftstickchanged(callback: (values: StickValues) => void): void;
  12649. /**
  12650. * Callback triggered when the right joystick has changed
  12651. * @param callback
  12652. */
  12653. onrightstickchanged(callback: (values: StickValues) => void): void;
  12654. /**
  12655. * Gets the left joystick
  12656. */
  12657. /**
  12658. * Sets the left joystick values
  12659. */
  12660. leftStick: StickValues;
  12661. /**
  12662. * Gets the right joystick
  12663. */
  12664. /**
  12665. * Sets the right joystick value
  12666. */
  12667. rightStick: StickValues;
  12668. /**
  12669. * Updates the gamepad joystick positions
  12670. */
  12671. update(): void;
  12672. /**
  12673. * Disposes the gamepad
  12674. */
  12675. dispose(): void;
  12676. }
  12677. /**
  12678. * Represents a generic gamepad
  12679. */
  12680. export class GenericPad extends Gamepad {
  12681. private _buttons;
  12682. private _onbuttondown;
  12683. private _onbuttonup;
  12684. /**
  12685. * Observable triggered when a button has been pressed
  12686. */
  12687. onButtonDownObservable: Observable<number>;
  12688. /**
  12689. * Observable triggered when a button has been released
  12690. */
  12691. onButtonUpObservable: Observable<number>;
  12692. /**
  12693. * Callback triggered when a button has been pressed
  12694. * @param callback Called when a button has been pressed
  12695. */
  12696. onbuttondown(callback: (buttonPressed: number) => void): void;
  12697. /**
  12698. * Callback triggered when a button has been released
  12699. * @param callback Called when a button has been released
  12700. */
  12701. onbuttonup(callback: (buttonReleased: number) => void): void;
  12702. /**
  12703. * Initializes the generic gamepad
  12704. * @param id The id of the generic gamepad
  12705. * @param index The index of the generic gamepad
  12706. * @param browserGamepad The browser gamepad
  12707. */
  12708. constructor(id: string, index: number, browserGamepad: any);
  12709. private _setButtonValue;
  12710. /**
  12711. * Updates the generic gamepad
  12712. */
  12713. update(): void;
  12714. /**
  12715. * Disposes the generic gamepad
  12716. */
  12717. dispose(): void;
  12718. }
  12719. }
  12720. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12721. import { Nullable } from "babylonjs/types";
  12722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12723. import { Scene } from "babylonjs/scene";
  12724. module "babylonjs/Engines/engine" {
  12725. interface Engine {
  12726. /**
  12727. * Creates a raw texture
  12728. * @param data defines the data to store in the texture
  12729. * @param width defines the width of the texture
  12730. * @param height defines the height of the texture
  12731. * @param format defines the format of the data
  12732. * @param generateMipMaps defines if the engine should generate the mip levels
  12733. * @param invertY defines if data must be stored with Y axis inverted
  12734. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12735. * @param compression defines the compression used (null by default)
  12736. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12737. * @returns the raw texture inside an InternalTexture
  12738. */
  12739. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12740. /**
  12741. * Update a raw texture
  12742. * @param texture defines the texture to update
  12743. * @param data defines the data to store in the texture
  12744. * @param format defines the format of the data
  12745. * @param invertY defines if data must be stored with Y axis inverted
  12746. */
  12747. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12748. /**
  12749. * Update a raw texture
  12750. * @param texture defines the texture to update
  12751. * @param data defines the data to store in the texture
  12752. * @param format defines the format of the data
  12753. * @param invertY defines if data must be stored with Y axis inverted
  12754. * @param compression defines the compression used (null by default)
  12755. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12756. */
  12757. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12758. /**
  12759. * Creates a new raw cube texture
  12760. * @param data defines the array of data to use to create each face
  12761. * @param size defines the size of the textures
  12762. * @param format defines the format of the data
  12763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12764. * @param generateMipMaps defines if the engine should generate the mip levels
  12765. * @param invertY defines if data must be stored with Y axis inverted
  12766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12767. * @param compression defines the compression used (null by default)
  12768. * @returns the cube texture as an InternalTexture
  12769. */
  12770. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12771. /**
  12772. * Update a raw cube texture
  12773. * @param texture defines the texture to udpdate
  12774. * @param data defines the data to store
  12775. * @param format defines the data format
  12776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12777. * @param invertY defines if data must be stored with Y axis inverted
  12778. */
  12779. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12780. /**
  12781. * Update a raw cube texture
  12782. * @param texture defines the texture to udpdate
  12783. * @param data defines the data to store
  12784. * @param format defines the data format
  12785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12786. * @param invertY defines if data must be stored with Y axis inverted
  12787. * @param compression defines the compression used (null by default)
  12788. */
  12789. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12790. /**
  12791. * Update a raw cube texture
  12792. * @param texture defines the texture to udpdate
  12793. * @param data defines the data to store
  12794. * @param format defines the data format
  12795. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12796. * @param invertY defines if data must be stored with Y axis inverted
  12797. * @param compression defines the compression used (null by default)
  12798. * @param level defines which level of the texture to update
  12799. */
  12800. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12801. /**
  12802. * Creates a new raw cube texture from a specified url
  12803. * @param url defines the url where the data is located
  12804. * @param scene defines the current scene
  12805. * @param size defines the size of the textures
  12806. * @param format defines the format of the data
  12807. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12808. * @param noMipmap defines if the engine should avoid generating the mip levels
  12809. * @param callback defines a callback used to extract texture data from loaded data
  12810. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12811. * @param onLoad defines a callback called when texture is loaded
  12812. * @param onError defines a callback called if there is an error
  12813. * @returns the cube texture as an InternalTexture
  12814. */
  12815. 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;
  12816. /**
  12817. * Creates a new raw cube texture from a specified url
  12818. * @param url defines the url where the data is located
  12819. * @param scene defines the current scene
  12820. * @param size defines the size of the textures
  12821. * @param format defines the format of the data
  12822. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12823. * @param noMipmap defines if the engine should avoid generating the mip levels
  12824. * @param callback defines a callback used to extract texture data from loaded data
  12825. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12826. * @param onLoad defines a callback called when texture is loaded
  12827. * @param onError defines a callback called if there is an error
  12828. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12829. * @param invertY defines if data must be stored with Y axis inverted
  12830. * @returns the cube texture as an InternalTexture
  12831. */
  12832. 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;
  12833. /**
  12834. * Creates a new raw 3D texture
  12835. * @param data defines the data used to create the texture
  12836. * @param width defines the width of the texture
  12837. * @param height defines the height of the texture
  12838. * @param depth defines the depth of the texture
  12839. * @param format defines the format of the texture
  12840. * @param generateMipMaps defines if the engine must generate mip levels
  12841. * @param invertY defines if data must be stored with Y axis inverted
  12842. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12843. * @param compression defines the compressed used (can be null)
  12844. * @param textureType defines the compressed used (can be null)
  12845. * @returns a new raw 3D texture (stored in an InternalTexture)
  12846. */
  12847. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12848. /**
  12849. * Update a raw 3D texture
  12850. * @param texture defines the texture to update
  12851. * @param data defines the data to store
  12852. * @param format defines the data format
  12853. * @param invertY defines if data must be stored with Y axis inverted
  12854. */
  12855. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12856. /**
  12857. * Update a raw 3D texture
  12858. * @param texture defines the texture to update
  12859. * @param data defines the data to store
  12860. * @param format defines the data format
  12861. * @param invertY defines if data must be stored with Y axis inverted
  12862. * @param compression defines the used compression (can be null)
  12863. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12864. */
  12865. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12866. /**
  12867. * Creates a new raw 2D array texture
  12868. * @param data defines the data used to create the texture
  12869. * @param width defines the width of the texture
  12870. * @param height defines the height of the texture
  12871. * @param depth defines the number of layers of the texture
  12872. * @param format defines the format of the texture
  12873. * @param generateMipMaps defines if the engine must generate mip levels
  12874. * @param invertY defines if data must be stored with Y axis inverted
  12875. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12876. * @param compression defines the compressed used (can be null)
  12877. * @param textureType defines the compressed used (can be null)
  12878. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12879. */
  12880. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12881. /**
  12882. * Update a raw 2D array texture
  12883. * @param texture defines the texture to update
  12884. * @param data defines the data to store
  12885. * @param format defines the data format
  12886. * @param invertY defines if data must be stored with Y axis inverted
  12887. */
  12888. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12889. /**
  12890. * Update a raw 2D array texture
  12891. * @param texture defines the texture to update
  12892. * @param data defines the data to store
  12893. * @param format defines the data format
  12894. * @param invertY defines if data must be stored with Y axis inverted
  12895. * @param compression defines the used compression (can be null)
  12896. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12897. */
  12898. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12899. }
  12900. }
  12901. }
  12902. declare module "babylonjs/Materials/Textures/rawTexture" {
  12903. import { Scene } from "babylonjs/scene";
  12904. import { Texture } from "babylonjs/Materials/Textures/texture";
  12905. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12906. /**
  12907. * Raw texture can help creating a texture directly from an array of data.
  12908. * This can be super useful if you either get the data from an uncompressed source or
  12909. * if you wish to create your texture pixel by pixel.
  12910. */
  12911. export class RawTexture extends Texture {
  12912. /**
  12913. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12914. */
  12915. format: number;
  12916. private _engine;
  12917. /**
  12918. * Instantiates a new RawTexture.
  12919. * Raw texture can help creating a texture directly from an array of data.
  12920. * This can be super useful if you either get the data from an uncompressed source or
  12921. * if you wish to create your texture pixel by pixel.
  12922. * @param data define the array of data to use to create the texture
  12923. * @param width define the width of the texture
  12924. * @param height define the height of the texture
  12925. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12926. * @param scene define the scene the texture belongs to
  12927. * @param generateMipMaps define whether mip maps should be generated or not
  12928. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12929. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12930. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12931. */
  12932. constructor(data: ArrayBufferView, width: number, height: number,
  12933. /**
  12934. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12935. */
  12936. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12937. /**
  12938. * Updates the texture underlying data.
  12939. * @param data Define the new data of the texture
  12940. */
  12941. update(data: ArrayBufferView): void;
  12942. /**
  12943. * Creates a luminance texture from some data.
  12944. * @param data Define the texture data
  12945. * @param width Define the width of the texture
  12946. * @param height Define the height of the texture
  12947. * @param scene Define the scene the texture belongs to
  12948. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12949. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12950. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12951. * @returns the luminance texture
  12952. */
  12953. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12954. /**
  12955. * Creates a luminance alpha texture from some data.
  12956. * @param data Define the texture data
  12957. * @param width Define the width of the texture
  12958. * @param height Define the height of the texture
  12959. * @param scene Define the scene the texture belongs to
  12960. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12961. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12962. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12963. * @returns the luminance alpha texture
  12964. */
  12965. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12966. /**
  12967. * Creates an alpha texture from some data.
  12968. * @param data Define the texture data
  12969. * @param width Define the width of the texture
  12970. * @param height Define the height of the texture
  12971. * @param scene Define the scene the texture belongs to
  12972. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12973. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12974. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12975. * @returns the alpha texture
  12976. */
  12977. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12978. /**
  12979. * Creates a RGB texture from some data.
  12980. * @param data Define the texture data
  12981. * @param width Define the width of the texture
  12982. * @param height Define the height of the texture
  12983. * @param scene Define the scene the texture belongs to
  12984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12988. * @returns the RGB alpha texture
  12989. */
  12990. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12991. /**
  12992. * Creates a RGBA texture from some data.
  12993. * @param data Define the texture data
  12994. * @param width Define the width of the texture
  12995. * @param height Define the height of the texture
  12996. * @param scene Define the scene the texture belongs to
  12997. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12998. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12999. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13000. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13001. * @returns the RGBA texture
  13002. */
  13003. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13004. /**
  13005. * Creates a R texture from some data.
  13006. * @param data Define the texture data
  13007. * @param width Define the width of the texture
  13008. * @param height Define the height of the texture
  13009. * @param scene Define the scene the texture belongs to
  13010. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13011. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13012. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13013. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13014. * @returns the R texture
  13015. */
  13016. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13017. }
  13018. }
  13019. declare module "babylonjs/Maths/math.size" {
  13020. /**
  13021. * Interface for the size containing width and height
  13022. */
  13023. export interface ISize {
  13024. /**
  13025. * Width
  13026. */
  13027. width: number;
  13028. /**
  13029. * Heighht
  13030. */
  13031. height: number;
  13032. }
  13033. /**
  13034. * Size containing widht and height
  13035. */
  13036. export class Size implements ISize {
  13037. /**
  13038. * Width
  13039. */
  13040. width: number;
  13041. /**
  13042. * Height
  13043. */
  13044. height: number;
  13045. /**
  13046. * Creates a Size object from the given width and height (floats).
  13047. * @param width width of the new size
  13048. * @param height height of the new size
  13049. */
  13050. constructor(width: number, height: number);
  13051. /**
  13052. * Returns a string with the Size width and height
  13053. * @returns a string with the Size width and height
  13054. */
  13055. toString(): string;
  13056. /**
  13057. * "Size"
  13058. * @returns the string "Size"
  13059. */
  13060. getClassName(): string;
  13061. /**
  13062. * Returns the Size hash code.
  13063. * @returns a hash code for a unique width and height
  13064. */
  13065. getHashCode(): number;
  13066. /**
  13067. * Updates the current size from the given one.
  13068. * @param src the given size
  13069. */
  13070. copyFrom(src: Size): void;
  13071. /**
  13072. * Updates in place the current Size from the given floats.
  13073. * @param width width of the new size
  13074. * @param height height of the new size
  13075. * @returns the updated Size.
  13076. */
  13077. copyFromFloats(width: number, height: number): Size;
  13078. /**
  13079. * Updates in place the current Size from the given floats.
  13080. * @param width width to set
  13081. * @param height height to set
  13082. * @returns the updated Size.
  13083. */
  13084. set(width: number, height: number): Size;
  13085. /**
  13086. * Multiplies the width and height by numbers
  13087. * @param w factor to multiple the width by
  13088. * @param h factor to multiple the height by
  13089. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13090. */
  13091. multiplyByFloats(w: number, h: number): Size;
  13092. /**
  13093. * Clones the size
  13094. * @returns a new Size copied from the given one.
  13095. */
  13096. clone(): Size;
  13097. /**
  13098. * True if the current Size and the given one width and height are strictly equal.
  13099. * @param other the other size to compare against
  13100. * @returns True if the current Size and the given one width and height are strictly equal.
  13101. */
  13102. equals(other: Size): boolean;
  13103. /**
  13104. * The surface of the Size : width * height (float).
  13105. */
  13106. readonly surface: number;
  13107. /**
  13108. * Create a new size of zero
  13109. * @returns a new Size set to (0.0, 0.0)
  13110. */
  13111. static Zero(): Size;
  13112. /**
  13113. * Sums the width and height of two sizes
  13114. * @param otherSize size to add to this size
  13115. * @returns a new Size set as the addition result of the current Size and the given one.
  13116. */
  13117. add(otherSize: Size): Size;
  13118. /**
  13119. * Subtracts the width and height of two
  13120. * @param otherSize size to subtract to this size
  13121. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13122. */
  13123. subtract(otherSize: Size): Size;
  13124. /**
  13125. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13126. * @param start starting size to lerp between
  13127. * @param end end size to lerp between
  13128. * @param amount amount to lerp between the start and end values
  13129. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13130. */
  13131. static Lerp(start: Size, end: Size, amount: number): Size;
  13132. }
  13133. }
  13134. declare module "babylonjs/Animations/runtimeAnimation" {
  13135. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13136. import { Animatable } from "babylonjs/Animations/animatable";
  13137. import { Scene } from "babylonjs/scene";
  13138. /**
  13139. * Defines a runtime animation
  13140. */
  13141. export class RuntimeAnimation {
  13142. private _events;
  13143. /**
  13144. * The current frame of the runtime animation
  13145. */
  13146. private _currentFrame;
  13147. /**
  13148. * The animation used by the runtime animation
  13149. */
  13150. private _animation;
  13151. /**
  13152. * The target of the runtime animation
  13153. */
  13154. private _target;
  13155. /**
  13156. * The initiating animatable
  13157. */
  13158. private _host;
  13159. /**
  13160. * The original value of the runtime animation
  13161. */
  13162. private _originalValue;
  13163. /**
  13164. * The original blend value of the runtime animation
  13165. */
  13166. private _originalBlendValue;
  13167. /**
  13168. * The offsets cache of the runtime animation
  13169. */
  13170. private _offsetsCache;
  13171. /**
  13172. * The high limits cache of the runtime animation
  13173. */
  13174. private _highLimitsCache;
  13175. /**
  13176. * Specifies if the runtime animation has been stopped
  13177. */
  13178. private _stopped;
  13179. /**
  13180. * The blending factor of the runtime animation
  13181. */
  13182. private _blendingFactor;
  13183. /**
  13184. * The BabylonJS scene
  13185. */
  13186. private _scene;
  13187. /**
  13188. * The current value of the runtime animation
  13189. */
  13190. private _currentValue;
  13191. /** @hidden */
  13192. _animationState: _IAnimationState;
  13193. /**
  13194. * The active target of the runtime animation
  13195. */
  13196. private _activeTargets;
  13197. private _currentActiveTarget;
  13198. private _directTarget;
  13199. /**
  13200. * The target path of the runtime animation
  13201. */
  13202. private _targetPath;
  13203. /**
  13204. * The weight of the runtime animation
  13205. */
  13206. private _weight;
  13207. /**
  13208. * The ratio offset of the runtime animation
  13209. */
  13210. private _ratioOffset;
  13211. /**
  13212. * The previous delay of the runtime animation
  13213. */
  13214. private _previousDelay;
  13215. /**
  13216. * The previous ratio of the runtime animation
  13217. */
  13218. private _previousRatio;
  13219. private _enableBlending;
  13220. private _keys;
  13221. private _minFrame;
  13222. private _maxFrame;
  13223. private _minValue;
  13224. private _maxValue;
  13225. private _targetIsArray;
  13226. /**
  13227. * Gets the current frame of the runtime animation
  13228. */
  13229. readonly currentFrame: number;
  13230. /**
  13231. * Gets the weight of the runtime animation
  13232. */
  13233. readonly weight: number;
  13234. /**
  13235. * Gets the current value of the runtime animation
  13236. */
  13237. readonly currentValue: any;
  13238. /**
  13239. * Gets the target path of the runtime animation
  13240. */
  13241. readonly targetPath: string;
  13242. /**
  13243. * Gets the actual target of the runtime animation
  13244. */
  13245. readonly target: any;
  13246. /** @hidden */
  13247. _onLoop: () => void;
  13248. /**
  13249. * Create a new RuntimeAnimation object
  13250. * @param target defines the target of the animation
  13251. * @param animation defines the source animation object
  13252. * @param scene defines the hosting scene
  13253. * @param host defines the initiating Animatable
  13254. */
  13255. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13256. private _preparePath;
  13257. /**
  13258. * Gets the animation from the runtime animation
  13259. */
  13260. readonly animation: Animation;
  13261. /**
  13262. * Resets the runtime animation to the beginning
  13263. * @param restoreOriginal defines whether to restore the target property to the original value
  13264. */
  13265. reset(restoreOriginal?: boolean): void;
  13266. /**
  13267. * Specifies if the runtime animation is stopped
  13268. * @returns Boolean specifying if the runtime animation is stopped
  13269. */
  13270. isStopped(): boolean;
  13271. /**
  13272. * Disposes of the runtime animation
  13273. */
  13274. dispose(): void;
  13275. /**
  13276. * Apply the interpolated value to the target
  13277. * @param currentValue defines the value computed by the animation
  13278. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13279. */
  13280. setValue(currentValue: any, weight: number): void;
  13281. private _getOriginalValues;
  13282. private _setValue;
  13283. /**
  13284. * Gets the loop pmode of the runtime animation
  13285. * @returns Loop Mode
  13286. */
  13287. private _getCorrectLoopMode;
  13288. /**
  13289. * Move the current animation to a given frame
  13290. * @param frame defines the frame to move to
  13291. */
  13292. goToFrame(frame: number): void;
  13293. /**
  13294. * @hidden Internal use only
  13295. */
  13296. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13297. /**
  13298. * Execute the current animation
  13299. * @param delay defines the delay to add to the current frame
  13300. * @param from defines the lower bound of the animation range
  13301. * @param to defines the upper bound of the animation range
  13302. * @param loop defines if the current animation must loop
  13303. * @param speedRatio defines the current speed ratio
  13304. * @param weight defines the weight of the animation (default is -1 so no weight)
  13305. * @param onLoop optional callback called when animation loops
  13306. * @returns a boolean indicating if the animation is running
  13307. */
  13308. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13309. }
  13310. }
  13311. declare module "babylonjs/Animations/animatable" {
  13312. import { Animation } from "babylonjs/Animations/animation";
  13313. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13314. import { Nullable } from "babylonjs/types";
  13315. import { Observable } from "babylonjs/Misc/observable";
  13316. import { Scene } from "babylonjs/scene";
  13317. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13318. import { Node } from "babylonjs/node";
  13319. /**
  13320. * Class used to store an actual running animation
  13321. */
  13322. export class Animatable {
  13323. /** defines the target object */
  13324. target: any;
  13325. /** defines the starting frame number (default is 0) */
  13326. fromFrame: number;
  13327. /** defines the ending frame number (default is 100) */
  13328. toFrame: number;
  13329. /** defines if the animation must loop (default is false) */
  13330. loopAnimation: boolean;
  13331. /** defines a callback to call when animation ends if it is not looping */
  13332. onAnimationEnd?: (() => void) | null | undefined;
  13333. /** defines a callback to call when animation loops */
  13334. onAnimationLoop?: (() => void) | null | undefined;
  13335. private _localDelayOffset;
  13336. private _pausedDelay;
  13337. private _runtimeAnimations;
  13338. private _paused;
  13339. private _scene;
  13340. private _speedRatio;
  13341. private _weight;
  13342. private _syncRoot;
  13343. /**
  13344. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13345. * This will only apply for non looping animation (default is true)
  13346. */
  13347. disposeOnEnd: boolean;
  13348. /**
  13349. * Gets a boolean indicating if the animation has started
  13350. */
  13351. animationStarted: boolean;
  13352. /**
  13353. * Observer raised when the animation ends
  13354. */
  13355. onAnimationEndObservable: Observable<Animatable>;
  13356. /**
  13357. * Observer raised when the animation loops
  13358. */
  13359. onAnimationLoopObservable: Observable<Animatable>;
  13360. /**
  13361. * Gets the root Animatable used to synchronize and normalize animations
  13362. */
  13363. readonly syncRoot: Nullable<Animatable>;
  13364. /**
  13365. * Gets the current frame of the first RuntimeAnimation
  13366. * Used to synchronize Animatables
  13367. */
  13368. readonly masterFrame: number;
  13369. /**
  13370. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13371. */
  13372. weight: number;
  13373. /**
  13374. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13375. */
  13376. speedRatio: number;
  13377. /**
  13378. * Creates a new Animatable
  13379. * @param scene defines the hosting scene
  13380. * @param target defines the target object
  13381. * @param fromFrame defines the starting frame number (default is 0)
  13382. * @param toFrame defines the ending frame number (default is 100)
  13383. * @param loopAnimation defines if the animation must loop (default is false)
  13384. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13385. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13386. * @param animations defines a group of animation to add to the new Animatable
  13387. * @param onAnimationLoop defines a callback to call when animation loops
  13388. */
  13389. constructor(scene: Scene,
  13390. /** defines the target object */
  13391. target: any,
  13392. /** defines the starting frame number (default is 0) */
  13393. fromFrame?: number,
  13394. /** defines the ending frame number (default is 100) */
  13395. toFrame?: number,
  13396. /** defines if the animation must loop (default is false) */
  13397. loopAnimation?: boolean, speedRatio?: number,
  13398. /** defines a callback to call when animation ends if it is not looping */
  13399. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13400. /** defines a callback to call when animation loops */
  13401. onAnimationLoop?: (() => void) | null | undefined);
  13402. /**
  13403. * Synchronize and normalize current Animatable with a source Animatable
  13404. * This is useful when using animation weights and when animations are not of the same length
  13405. * @param root defines the root Animatable to synchronize with
  13406. * @returns the current Animatable
  13407. */
  13408. syncWith(root: Animatable): Animatable;
  13409. /**
  13410. * Gets the list of runtime animations
  13411. * @returns an array of RuntimeAnimation
  13412. */
  13413. getAnimations(): RuntimeAnimation[];
  13414. /**
  13415. * Adds more animations to the current animatable
  13416. * @param target defines the target of the animations
  13417. * @param animations defines the new animations to add
  13418. */
  13419. appendAnimations(target: any, animations: Animation[]): void;
  13420. /**
  13421. * Gets the source animation for a specific property
  13422. * @param property defines the propertyu to look for
  13423. * @returns null or the source animation for the given property
  13424. */
  13425. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13426. /**
  13427. * Gets the runtime animation for a specific property
  13428. * @param property defines the propertyu to look for
  13429. * @returns null or the runtime animation for the given property
  13430. */
  13431. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13432. /**
  13433. * Resets the animatable to its original state
  13434. */
  13435. reset(): void;
  13436. /**
  13437. * Allows the animatable to blend with current running animations
  13438. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13439. * @param blendingSpeed defines the blending speed to use
  13440. */
  13441. enableBlending(blendingSpeed: number): void;
  13442. /**
  13443. * Disable animation blending
  13444. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13445. */
  13446. disableBlending(): void;
  13447. /**
  13448. * Jump directly to a given frame
  13449. * @param frame defines the frame to jump to
  13450. */
  13451. goToFrame(frame: number): void;
  13452. /**
  13453. * Pause the animation
  13454. */
  13455. pause(): void;
  13456. /**
  13457. * Restart the animation
  13458. */
  13459. restart(): void;
  13460. private _raiseOnAnimationEnd;
  13461. /**
  13462. * Stop and delete the current animation
  13463. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13464. * @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)
  13465. */
  13466. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13467. /**
  13468. * Wait asynchronously for the animation to end
  13469. * @returns a promise which will be fullfilled when the animation ends
  13470. */
  13471. waitAsync(): Promise<Animatable>;
  13472. /** @hidden */
  13473. _animate(delay: number): boolean;
  13474. }
  13475. module "babylonjs/scene" {
  13476. interface Scene {
  13477. /** @hidden */
  13478. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13479. /** @hidden */
  13480. _processLateAnimationBindingsForMatrices(holder: {
  13481. totalWeight: number;
  13482. animations: RuntimeAnimation[];
  13483. originalValue: Matrix;
  13484. }): any;
  13485. /** @hidden */
  13486. _processLateAnimationBindingsForQuaternions(holder: {
  13487. totalWeight: number;
  13488. animations: RuntimeAnimation[];
  13489. originalValue: Quaternion;
  13490. }, refQuaternion: Quaternion): Quaternion;
  13491. /** @hidden */
  13492. _processLateAnimationBindings(): void;
  13493. /**
  13494. * Will start the animation sequence of a given target
  13495. * @param target defines the target
  13496. * @param from defines from which frame should animation start
  13497. * @param to defines until which frame should animation run.
  13498. * @param weight defines the weight to apply to the animation (1.0 by default)
  13499. * @param loop defines if the animation loops
  13500. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13501. * @param onAnimationEnd defines the function to be executed when the animation ends
  13502. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13503. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13504. * @param onAnimationLoop defines the callback to call when an animation loops
  13505. * @returns the animatable object created for this animation
  13506. */
  13507. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13508. /**
  13509. * Will start the animation sequence of a given target
  13510. * @param target defines the target
  13511. * @param from defines from which frame should animation start
  13512. * @param to defines until which frame should animation run.
  13513. * @param loop defines if the animation loops
  13514. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13515. * @param onAnimationEnd defines the function to be executed when the animation ends
  13516. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13517. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13518. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13519. * @param onAnimationLoop defines the callback to call when an animation loops
  13520. * @returns the animatable object created for this animation
  13521. */
  13522. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13523. /**
  13524. * Will start the animation sequence of a given target and its hierarchy
  13525. * @param target defines the target
  13526. * @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.
  13527. * @param from defines from which frame should animation start
  13528. * @param to defines until which frame should animation run.
  13529. * @param loop defines if the animation loops
  13530. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13531. * @param onAnimationEnd defines the function to be executed when the animation ends
  13532. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13533. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13534. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13535. * @param onAnimationLoop defines the callback to call when an animation loops
  13536. * @returns the list of created animatables
  13537. */
  13538. 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[];
  13539. /**
  13540. * Begin a new animation on a given node
  13541. * @param target defines the target where the animation will take place
  13542. * @param animations defines the list of animations to start
  13543. * @param from defines the initial value
  13544. * @param to defines the final value
  13545. * @param loop defines if you want animation to loop (off by default)
  13546. * @param speedRatio defines the speed ratio to apply to all animations
  13547. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13548. * @param onAnimationLoop defines the callback to call when an animation loops
  13549. * @returns the list of created animatables
  13550. */
  13551. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13552. /**
  13553. * Begin a new animation on a given node and its hierarchy
  13554. * @param target defines the root node where the animation will take place
  13555. * @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.
  13556. * @param animations defines the list of animations to start
  13557. * @param from defines the initial value
  13558. * @param to defines the final value
  13559. * @param loop defines if you want animation to loop (off by default)
  13560. * @param speedRatio defines the speed ratio to apply to all animations
  13561. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13562. * @param onAnimationLoop defines the callback to call when an animation loops
  13563. * @returns the list of animatables created for all nodes
  13564. */
  13565. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13566. /**
  13567. * Gets the animatable associated with a specific target
  13568. * @param target defines the target of the animatable
  13569. * @returns the required animatable if found
  13570. */
  13571. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13572. /**
  13573. * Gets all animatables associated with a given target
  13574. * @param target defines the target to look animatables for
  13575. * @returns an array of Animatables
  13576. */
  13577. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13578. /**
  13579. * Stops and removes all animations that have been applied to the scene
  13580. */
  13581. stopAllAnimations(): void;
  13582. /**
  13583. * Gets the current delta time used by animation engine
  13584. */
  13585. deltaTime: number;
  13586. }
  13587. }
  13588. module "babylonjs/Bones/bone" {
  13589. interface Bone {
  13590. /**
  13591. * Copy an animation range from another bone
  13592. * @param source defines the source bone
  13593. * @param rangeName defines the range name to copy
  13594. * @param frameOffset defines the frame offset
  13595. * @param rescaleAsRequired defines if rescaling must be applied if required
  13596. * @param skelDimensionsRatio defines the scaling ratio
  13597. * @returns true if operation was successful
  13598. */
  13599. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13600. }
  13601. }
  13602. }
  13603. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13604. /**
  13605. * Class used to override all child animations of a given target
  13606. */
  13607. export class AnimationPropertiesOverride {
  13608. /**
  13609. * Gets or sets a value indicating if animation blending must be used
  13610. */
  13611. enableBlending: boolean;
  13612. /**
  13613. * Gets or sets the blending speed to use when enableBlending is true
  13614. */
  13615. blendingSpeed: number;
  13616. /**
  13617. * Gets or sets the default loop mode to use
  13618. */
  13619. loopMode: number;
  13620. }
  13621. }
  13622. declare module "babylonjs/Bones/skeleton" {
  13623. import { Bone } from "babylonjs/Bones/bone";
  13624. import { Observable } from "babylonjs/Misc/observable";
  13625. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13626. import { Scene } from "babylonjs/scene";
  13627. import { Nullable } from "babylonjs/types";
  13628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13629. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13630. import { Animatable } from "babylonjs/Animations/animatable";
  13631. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13632. import { Animation } from "babylonjs/Animations/animation";
  13633. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13634. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13636. /**
  13637. * Class used to handle skinning animations
  13638. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13639. */
  13640. export class Skeleton implements IAnimatable {
  13641. /** defines the skeleton name */
  13642. name: string;
  13643. /** defines the skeleton Id */
  13644. id: string;
  13645. /**
  13646. * Defines the list of child bones
  13647. */
  13648. bones: Bone[];
  13649. /**
  13650. * Defines an estimate of the dimension of the skeleton at rest
  13651. */
  13652. dimensionsAtRest: Vector3;
  13653. /**
  13654. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13655. */
  13656. needInitialSkinMatrix: boolean;
  13657. /**
  13658. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13659. */
  13660. overrideMesh: Nullable<AbstractMesh>;
  13661. /**
  13662. * Gets the list of animations attached to this skeleton
  13663. */
  13664. animations: Array<Animation>;
  13665. private _scene;
  13666. private _isDirty;
  13667. private _transformMatrices;
  13668. private _transformMatrixTexture;
  13669. private _meshesWithPoseMatrix;
  13670. private _animatables;
  13671. private _identity;
  13672. private _synchronizedWithMesh;
  13673. private _ranges;
  13674. private _lastAbsoluteTransformsUpdateId;
  13675. private _canUseTextureForBones;
  13676. private _uniqueId;
  13677. /** @hidden */
  13678. _numBonesWithLinkedTransformNode: number;
  13679. /** @hidden */
  13680. _hasWaitingData: Nullable<boolean>;
  13681. /**
  13682. * Specifies if the skeleton should be serialized
  13683. */
  13684. doNotSerialize: boolean;
  13685. private _useTextureToStoreBoneMatrices;
  13686. /**
  13687. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13688. * Please note that this option is not available if the hardware does not support it
  13689. */
  13690. useTextureToStoreBoneMatrices: boolean;
  13691. private _animationPropertiesOverride;
  13692. /**
  13693. * Gets or sets the animation properties override
  13694. */
  13695. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13696. /**
  13697. * List of inspectable custom properties (used by the Inspector)
  13698. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13699. */
  13700. inspectableCustomProperties: IInspectable[];
  13701. /**
  13702. * An observable triggered before computing the skeleton's matrices
  13703. */
  13704. onBeforeComputeObservable: Observable<Skeleton>;
  13705. /**
  13706. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13707. */
  13708. readonly isUsingTextureForMatrices: boolean;
  13709. /**
  13710. * Gets the unique ID of this skeleton
  13711. */
  13712. readonly uniqueId: number;
  13713. /**
  13714. * Creates a new skeleton
  13715. * @param name defines the skeleton name
  13716. * @param id defines the skeleton Id
  13717. * @param scene defines the hosting scene
  13718. */
  13719. constructor(
  13720. /** defines the skeleton name */
  13721. name: string,
  13722. /** defines the skeleton Id */
  13723. id: string, scene: Scene);
  13724. /**
  13725. * Gets the current object class name.
  13726. * @return the class name
  13727. */
  13728. getClassName(): string;
  13729. /**
  13730. * Returns an array containing the root bones
  13731. * @returns an array containing the root bones
  13732. */
  13733. getChildren(): Array<Bone>;
  13734. /**
  13735. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13736. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13737. * @returns a Float32Array containing matrices data
  13738. */
  13739. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13740. /**
  13741. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13742. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13743. * @returns a raw texture containing the data
  13744. */
  13745. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13746. /**
  13747. * Gets the current hosting scene
  13748. * @returns a scene object
  13749. */
  13750. getScene(): Scene;
  13751. /**
  13752. * Gets a string representing the current skeleton data
  13753. * @param fullDetails defines a boolean indicating if we want a verbose version
  13754. * @returns a string representing the current skeleton data
  13755. */
  13756. toString(fullDetails?: boolean): string;
  13757. /**
  13758. * Get bone's index searching by name
  13759. * @param name defines bone's name to search for
  13760. * @return the indice of the bone. Returns -1 if not found
  13761. */
  13762. getBoneIndexByName(name: string): number;
  13763. /**
  13764. * Creater a new animation range
  13765. * @param name defines the name of the range
  13766. * @param from defines the start key
  13767. * @param to defines the end key
  13768. */
  13769. createAnimationRange(name: string, from: number, to: number): void;
  13770. /**
  13771. * Delete a specific animation range
  13772. * @param name defines the name of the range
  13773. * @param deleteFrames defines if frames must be removed as well
  13774. */
  13775. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13776. /**
  13777. * Gets a specific animation range
  13778. * @param name defines the name of the range to look for
  13779. * @returns the requested animation range or null if not found
  13780. */
  13781. getAnimationRange(name: string): Nullable<AnimationRange>;
  13782. /**
  13783. * Gets the list of all animation ranges defined on this skeleton
  13784. * @returns an array
  13785. */
  13786. getAnimationRanges(): Nullable<AnimationRange>[];
  13787. /**
  13788. * Copy animation range from a source skeleton.
  13789. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13790. * @param source defines the source skeleton
  13791. * @param name defines the name of the range to copy
  13792. * @param rescaleAsRequired defines if rescaling must be applied if required
  13793. * @returns true if operation was successful
  13794. */
  13795. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13796. /**
  13797. * Forces the skeleton to go to rest pose
  13798. */
  13799. returnToRest(): void;
  13800. private _getHighestAnimationFrame;
  13801. /**
  13802. * Begin a specific animation range
  13803. * @param name defines the name of the range to start
  13804. * @param loop defines if looping must be turned on (false by default)
  13805. * @param speedRatio defines the speed ratio to apply (1 by default)
  13806. * @param onAnimationEnd defines a callback which will be called when animation will end
  13807. * @returns a new animatable
  13808. */
  13809. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13810. /** @hidden */
  13811. _markAsDirty(): void;
  13812. /** @hidden */
  13813. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13814. /** @hidden */
  13815. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13816. private _computeTransformMatrices;
  13817. /**
  13818. * Build all resources required to render a skeleton
  13819. */
  13820. prepare(): void;
  13821. /**
  13822. * Gets the list of animatables currently running for this skeleton
  13823. * @returns an array of animatables
  13824. */
  13825. getAnimatables(): IAnimatable[];
  13826. /**
  13827. * Clone the current skeleton
  13828. * @param name defines the name of the new skeleton
  13829. * @param id defines the id of the new skeleton
  13830. * @returns the new skeleton
  13831. */
  13832. clone(name: string, id?: string): Skeleton;
  13833. /**
  13834. * Enable animation blending for this skeleton
  13835. * @param blendingSpeed defines the blending speed to apply
  13836. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13837. */
  13838. enableBlending(blendingSpeed?: number): void;
  13839. /**
  13840. * Releases all resources associated with the current skeleton
  13841. */
  13842. dispose(): void;
  13843. /**
  13844. * Serialize the skeleton in a JSON object
  13845. * @returns a JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Creates a new skeleton from serialized data
  13850. * @param parsedSkeleton defines the serialized data
  13851. * @param scene defines the hosting scene
  13852. * @returns a new skeleton
  13853. */
  13854. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13855. /**
  13856. * Compute all node absolute transforms
  13857. * @param forceUpdate defines if computation must be done even if cache is up to date
  13858. */
  13859. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13860. /**
  13861. * Gets the root pose matrix
  13862. * @returns a matrix
  13863. */
  13864. getPoseMatrix(): Nullable<Matrix>;
  13865. /**
  13866. * Sorts bones per internal index
  13867. */
  13868. sortBones(): void;
  13869. private _sortBones;
  13870. }
  13871. }
  13872. declare module "babylonjs/Bones/bone" {
  13873. import { Skeleton } from "babylonjs/Bones/skeleton";
  13874. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13875. import { Nullable } from "babylonjs/types";
  13876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13878. import { Node } from "babylonjs/node";
  13879. import { Space } from "babylonjs/Maths/math.axis";
  13880. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13881. /**
  13882. * Class used to store bone information
  13883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13884. */
  13885. export class Bone extends Node {
  13886. /**
  13887. * defines the bone name
  13888. */
  13889. name: string;
  13890. private static _tmpVecs;
  13891. private static _tmpQuat;
  13892. private static _tmpMats;
  13893. /**
  13894. * Gets the list of child bones
  13895. */
  13896. children: Bone[];
  13897. /** Gets the animations associated with this bone */
  13898. animations: import("babylonjs/Animations/animation").Animation[];
  13899. /**
  13900. * Gets or sets bone length
  13901. */
  13902. length: number;
  13903. /**
  13904. * @hidden Internal only
  13905. * Set this value to map this bone to a different index in the transform matrices
  13906. * Set this value to -1 to exclude the bone from the transform matrices
  13907. */
  13908. _index: Nullable<number>;
  13909. private _skeleton;
  13910. private _localMatrix;
  13911. private _restPose;
  13912. private _baseMatrix;
  13913. private _absoluteTransform;
  13914. private _invertedAbsoluteTransform;
  13915. private _parent;
  13916. private _scalingDeterminant;
  13917. private _worldTransform;
  13918. private _localScaling;
  13919. private _localRotation;
  13920. private _localPosition;
  13921. private _needToDecompose;
  13922. private _needToCompose;
  13923. /** @hidden */
  13924. _linkedTransformNode: Nullable<TransformNode>;
  13925. /** @hidden */
  13926. _waitingTransformNodeId: Nullable<string>;
  13927. /** @hidden */
  13928. /** @hidden */
  13929. _matrix: Matrix;
  13930. /**
  13931. * Create a new bone
  13932. * @param name defines the bone name
  13933. * @param skeleton defines the parent skeleton
  13934. * @param parentBone defines the parent (can be null if the bone is the root)
  13935. * @param localMatrix defines the local matrix
  13936. * @param restPose defines the rest pose matrix
  13937. * @param baseMatrix defines the base matrix
  13938. * @param index defines index of the bone in the hiearchy
  13939. */
  13940. constructor(
  13941. /**
  13942. * defines the bone name
  13943. */
  13944. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13945. /**
  13946. * Gets the current object class name.
  13947. * @return the class name
  13948. */
  13949. getClassName(): string;
  13950. /**
  13951. * Gets the parent skeleton
  13952. * @returns a skeleton
  13953. */
  13954. getSkeleton(): Skeleton;
  13955. /**
  13956. * Gets parent bone
  13957. * @returns a bone or null if the bone is the root of the bone hierarchy
  13958. */
  13959. getParent(): Nullable<Bone>;
  13960. /**
  13961. * Returns an array containing the root bones
  13962. * @returns an array containing the root bones
  13963. */
  13964. getChildren(): Array<Bone>;
  13965. /**
  13966. * Gets the node index in matrix array generated for rendering
  13967. * @returns the node index
  13968. */
  13969. getIndex(): number;
  13970. /**
  13971. * Sets the parent bone
  13972. * @param parent defines the parent (can be null if the bone is the root)
  13973. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13974. */
  13975. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13976. /**
  13977. * Gets the local matrix
  13978. * @returns a matrix
  13979. */
  13980. getLocalMatrix(): Matrix;
  13981. /**
  13982. * Gets the base matrix (initial matrix which remains unchanged)
  13983. * @returns a matrix
  13984. */
  13985. getBaseMatrix(): Matrix;
  13986. /**
  13987. * Gets the rest pose matrix
  13988. * @returns a matrix
  13989. */
  13990. getRestPose(): Matrix;
  13991. /**
  13992. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13993. */
  13994. getWorldMatrix(): Matrix;
  13995. /**
  13996. * Sets the local matrix to rest pose matrix
  13997. */
  13998. returnToRest(): void;
  13999. /**
  14000. * Gets the inverse of the absolute transform matrix.
  14001. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14002. * @returns a matrix
  14003. */
  14004. getInvertedAbsoluteTransform(): Matrix;
  14005. /**
  14006. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14007. * @returns a matrix
  14008. */
  14009. getAbsoluteTransform(): Matrix;
  14010. /**
  14011. * Links with the given transform node.
  14012. * The local matrix of this bone is copied from the transform node every frame.
  14013. * @param transformNode defines the transform node to link to
  14014. */
  14015. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14016. /**
  14017. * Gets the node used to drive the bone's transformation
  14018. * @returns a transform node or null
  14019. */
  14020. getTransformNode(): Nullable<TransformNode>;
  14021. /** Gets or sets current position (in local space) */
  14022. position: Vector3;
  14023. /** Gets or sets current rotation (in local space) */
  14024. rotation: Vector3;
  14025. /** Gets or sets current rotation quaternion (in local space) */
  14026. rotationQuaternion: Quaternion;
  14027. /** Gets or sets current scaling (in local space) */
  14028. scaling: Vector3;
  14029. /**
  14030. * Gets the animation properties override
  14031. */
  14032. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14033. private _decompose;
  14034. private _compose;
  14035. /**
  14036. * Update the base and local matrices
  14037. * @param matrix defines the new base or local matrix
  14038. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14039. * @param updateLocalMatrix defines if the local matrix should be updated
  14040. */
  14041. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14042. /** @hidden */
  14043. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14044. /**
  14045. * Flag the bone as dirty (Forcing it to update everything)
  14046. */
  14047. markAsDirty(): void;
  14048. /** @hidden */
  14049. _markAsDirtyAndCompose(): void;
  14050. private _markAsDirtyAndDecompose;
  14051. /**
  14052. * Translate the bone in local or world space
  14053. * @param vec The amount to translate the bone
  14054. * @param space The space that the translation is in
  14055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14056. */
  14057. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14058. /**
  14059. * Set the postion of the bone in local or world space
  14060. * @param position The position to set the bone
  14061. * @param space The space that the position is in
  14062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14063. */
  14064. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14065. /**
  14066. * Set the absolute position of the bone (world space)
  14067. * @param position The position to set the bone
  14068. * @param mesh The mesh that this bone is attached to
  14069. */
  14070. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14071. /**
  14072. * Scale the bone on the x, y and z axes (in local space)
  14073. * @param x The amount to scale the bone on the x axis
  14074. * @param y The amount to scale the bone on the y axis
  14075. * @param z The amount to scale the bone on the z axis
  14076. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14077. */
  14078. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14079. /**
  14080. * Set the bone scaling in local space
  14081. * @param scale defines the scaling vector
  14082. */
  14083. setScale(scale: Vector3): void;
  14084. /**
  14085. * Gets the current scaling in local space
  14086. * @returns the current scaling vector
  14087. */
  14088. getScale(): Vector3;
  14089. /**
  14090. * Gets the current scaling in local space and stores it in a target vector
  14091. * @param result defines the target vector
  14092. */
  14093. getScaleToRef(result: Vector3): void;
  14094. /**
  14095. * Set the yaw, pitch, and roll of the bone in local or world space
  14096. * @param yaw The rotation of the bone on the y axis
  14097. * @param pitch The rotation of the bone on the x axis
  14098. * @param roll The rotation of the bone on the z axis
  14099. * @param space The space that the axes of rotation are in
  14100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14101. */
  14102. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14103. /**
  14104. * Add a rotation to the bone on an axis in local or world space
  14105. * @param axis The axis to rotate the bone on
  14106. * @param amount The amount to rotate the bone
  14107. * @param space The space that the axis is in
  14108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14109. */
  14110. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14111. /**
  14112. * Set the rotation of the bone to a particular axis angle in local or world space
  14113. * @param axis The axis to rotate the bone on
  14114. * @param angle The angle that the bone should be rotated to
  14115. * @param space The space that the axis is in
  14116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14117. */
  14118. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14119. /**
  14120. * Set the euler rotation of the bone in local of world space
  14121. * @param rotation The euler rotation that the bone should be set to
  14122. * @param space The space that the rotation is in
  14123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14124. */
  14125. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14126. /**
  14127. * Set the quaternion rotation of the bone in local of world space
  14128. * @param quat The quaternion rotation that the bone should be set to
  14129. * @param space The space that the rotation is in
  14130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14131. */
  14132. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14133. /**
  14134. * Set the rotation matrix of the bone in local of world space
  14135. * @param rotMat The rotation matrix that the bone should be set to
  14136. * @param space The space that the rotation is in
  14137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14138. */
  14139. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14140. private _rotateWithMatrix;
  14141. private _getNegativeRotationToRef;
  14142. /**
  14143. * Get the position of the bone in local or world space
  14144. * @param space The space that the returned position is in
  14145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14146. * @returns The position of the bone
  14147. */
  14148. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14149. /**
  14150. * Copy the position of the bone to a vector3 in local or world space
  14151. * @param space The space that the returned position is in
  14152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14153. * @param result The vector3 to copy the position to
  14154. */
  14155. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14156. /**
  14157. * Get the absolute position of the bone (world space)
  14158. * @param mesh The mesh that this bone is attached to
  14159. * @returns The absolute position of the bone
  14160. */
  14161. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14162. /**
  14163. * Copy the absolute position of the bone (world space) to the result param
  14164. * @param mesh The mesh that this bone is attached to
  14165. * @param result The vector3 to copy the absolute position to
  14166. */
  14167. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14168. /**
  14169. * Compute the absolute transforms of this bone and its children
  14170. */
  14171. computeAbsoluteTransforms(): void;
  14172. /**
  14173. * Get the world direction from an axis that is in the local space of the bone
  14174. * @param localAxis The local direction that is used to compute the world direction
  14175. * @param mesh The mesh that this bone is attached to
  14176. * @returns The world direction
  14177. */
  14178. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14179. /**
  14180. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14181. * @param localAxis The local direction that is used to compute the world direction
  14182. * @param mesh The mesh that this bone is attached to
  14183. * @param result The vector3 that the world direction will be copied to
  14184. */
  14185. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14186. /**
  14187. * Get the euler rotation of the bone in local or world space
  14188. * @param space The space that the rotation should be in
  14189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14190. * @returns The euler rotation
  14191. */
  14192. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14193. /**
  14194. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14195. * @param space The space that the rotation should be in
  14196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14197. * @param result The vector3 that the rotation should be copied to
  14198. */
  14199. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14200. /**
  14201. * Get the quaternion rotation of the bone in either local or world space
  14202. * @param space The space that the rotation should be in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. * @returns The quaternion rotation
  14205. */
  14206. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14207. /**
  14208. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14209. * @param space The space that the rotation should be in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. * @param result The quaternion that the rotation should be copied to
  14212. */
  14213. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14214. /**
  14215. * Get the rotation matrix of the bone in local or world space
  14216. * @param space The space that the rotation should be in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. * @returns The rotation matrix
  14219. */
  14220. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14221. /**
  14222. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14223. * @param space The space that the rotation should be in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. * @param result The quaternion that the rotation should be copied to
  14226. */
  14227. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14228. /**
  14229. * Get the world position of a point that is in the local space of the bone
  14230. * @param position The local position
  14231. * @param mesh The mesh that this bone is attached to
  14232. * @returns The world position
  14233. */
  14234. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14235. /**
  14236. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14237. * @param position The local position
  14238. * @param mesh The mesh that this bone is attached to
  14239. * @param result The vector3 that the world position should be copied to
  14240. */
  14241. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14242. /**
  14243. * Get the local position of a point that is in world space
  14244. * @param position The world position
  14245. * @param mesh The mesh that this bone is attached to
  14246. * @returns The local position
  14247. */
  14248. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14249. /**
  14250. * Get the local position of a point that is in world space and copy it to the result param
  14251. * @param position The world position
  14252. * @param mesh The mesh that this bone is attached to
  14253. * @param result The vector3 that the local position should be copied to
  14254. */
  14255. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14256. }
  14257. }
  14258. declare module "babylonjs/Meshes/transformNode" {
  14259. import { DeepImmutable } from "babylonjs/types";
  14260. import { Observable } from "babylonjs/Misc/observable";
  14261. import { Nullable } from "babylonjs/types";
  14262. import { Camera } from "babylonjs/Cameras/camera";
  14263. import { Scene } from "babylonjs/scene";
  14264. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14265. import { Node } from "babylonjs/node";
  14266. import { Bone } from "babylonjs/Bones/bone";
  14267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14268. import { Space } from "babylonjs/Maths/math.axis";
  14269. /**
  14270. * 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.
  14271. * @see https://doc.babylonjs.com/how_to/transformnode
  14272. */
  14273. export class TransformNode extends Node {
  14274. /**
  14275. * Object will not rotate to face the camera
  14276. */
  14277. static BILLBOARDMODE_NONE: number;
  14278. /**
  14279. * Object will rotate to face the camera but only on the x axis
  14280. */
  14281. static BILLBOARDMODE_X: number;
  14282. /**
  14283. * Object will rotate to face the camera but only on the y axis
  14284. */
  14285. static BILLBOARDMODE_Y: number;
  14286. /**
  14287. * Object will rotate to face the camera but only on the z axis
  14288. */
  14289. static BILLBOARDMODE_Z: number;
  14290. /**
  14291. * Object will rotate to face the camera
  14292. */
  14293. static BILLBOARDMODE_ALL: number;
  14294. /**
  14295. * Object will rotate to face the camera's position instead of orientation
  14296. */
  14297. static BILLBOARDMODE_USE_POSITION: number;
  14298. private _forward;
  14299. private _forwardInverted;
  14300. private _up;
  14301. private _right;
  14302. private _rightInverted;
  14303. private _position;
  14304. private _rotation;
  14305. private _rotationQuaternion;
  14306. protected _scaling: Vector3;
  14307. protected _isDirty: boolean;
  14308. private _transformToBoneReferal;
  14309. private _isAbsoluteSynced;
  14310. private _billboardMode;
  14311. /**
  14312. * Gets or sets the billboard mode. Default is 0.
  14313. *
  14314. * | Value | Type | Description |
  14315. * | --- | --- | --- |
  14316. * | 0 | BILLBOARDMODE_NONE | |
  14317. * | 1 | BILLBOARDMODE_X | |
  14318. * | 2 | BILLBOARDMODE_Y | |
  14319. * | 4 | BILLBOARDMODE_Z | |
  14320. * | 7 | BILLBOARDMODE_ALL | |
  14321. *
  14322. */
  14323. billboardMode: number;
  14324. private _preserveParentRotationForBillboard;
  14325. /**
  14326. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14327. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14328. */
  14329. preserveParentRotationForBillboard: boolean;
  14330. /**
  14331. * 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
  14332. */
  14333. scalingDeterminant: number;
  14334. private _infiniteDistance;
  14335. /**
  14336. * Gets or sets the distance of the object to max, often used by skybox
  14337. */
  14338. infiniteDistance: boolean;
  14339. /**
  14340. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14341. * By default the system will update normals to compensate
  14342. */
  14343. ignoreNonUniformScaling: boolean;
  14344. /**
  14345. * 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
  14346. */
  14347. reIntegrateRotationIntoRotationQuaternion: boolean;
  14348. /** @hidden */
  14349. _poseMatrix: Nullable<Matrix>;
  14350. /** @hidden */
  14351. _localMatrix: Matrix;
  14352. private _usePivotMatrix;
  14353. private _absolutePosition;
  14354. private _absoluteScaling;
  14355. private _absoluteRotationQuaternion;
  14356. private _pivotMatrix;
  14357. private _pivotMatrixInverse;
  14358. protected _postMultiplyPivotMatrix: boolean;
  14359. protected _isWorldMatrixFrozen: boolean;
  14360. /** @hidden */
  14361. _indexInSceneTransformNodesArray: number;
  14362. /**
  14363. * An event triggered after the world matrix is updated
  14364. */
  14365. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14366. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14367. /**
  14368. * Gets a string identifying the name of the class
  14369. * @returns "TransformNode" string
  14370. */
  14371. getClassName(): string;
  14372. /**
  14373. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14374. */
  14375. position: Vector3;
  14376. /**
  14377. * 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)).
  14378. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14379. */
  14380. rotation: Vector3;
  14381. /**
  14382. * 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)).
  14383. */
  14384. scaling: Vector3;
  14385. /**
  14386. * 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).
  14387. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14388. */
  14389. rotationQuaternion: Nullable<Quaternion>;
  14390. /**
  14391. * The forward direction of that transform in world space.
  14392. */
  14393. readonly forward: Vector3;
  14394. /**
  14395. * The up direction of that transform in world space.
  14396. */
  14397. readonly up: Vector3;
  14398. /**
  14399. * The right direction of that transform in world space.
  14400. */
  14401. readonly right: Vector3;
  14402. /**
  14403. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14404. * @param matrix the matrix to copy the pose from
  14405. * @returns this TransformNode.
  14406. */
  14407. updatePoseMatrix(matrix: Matrix): TransformNode;
  14408. /**
  14409. * Returns the mesh Pose matrix.
  14410. * @returns the pose matrix
  14411. */
  14412. getPoseMatrix(): Matrix;
  14413. /** @hidden */
  14414. _isSynchronized(): boolean;
  14415. /** @hidden */
  14416. _initCache(): void;
  14417. /**
  14418. * Flag the transform node as dirty (Forcing it to update everything)
  14419. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14420. * @returns this transform node
  14421. */
  14422. markAsDirty(property: string): TransformNode;
  14423. /**
  14424. * Returns the current mesh absolute position.
  14425. * Returns a Vector3.
  14426. */
  14427. readonly absolutePosition: Vector3;
  14428. /**
  14429. * Returns the current mesh absolute scaling.
  14430. * Returns a Vector3.
  14431. */
  14432. readonly absoluteScaling: Vector3;
  14433. /**
  14434. * Returns the current mesh absolute rotation.
  14435. * Returns a Quaternion.
  14436. */
  14437. readonly absoluteRotationQuaternion: Quaternion;
  14438. /**
  14439. * Sets a new matrix to apply before all other transformation
  14440. * @param matrix defines the transform matrix
  14441. * @returns the current TransformNode
  14442. */
  14443. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14444. /**
  14445. * Sets a new pivot matrix to the current node
  14446. * @param matrix defines the new pivot matrix to use
  14447. * @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
  14448. * @returns the current TransformNode
  14449. */
  14450. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14451. /**
  14452. * Returns the mesh pivot matrix.
  14453. * Default : Identity.
  14454. * @returns the matrix
  14455. */
  14456. getPivotMatrix(): Matrix;
  14457. /**
  14458. * Instantiate (when possible) or clone that node with its hierarchy
  14459. * @param newParent defines the new parent to use for the instance (or clone)
  14460. * @param options defines options to configure how copy is done
  14461. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14462. * @returns an instance (or a clone) of the current node with its hiearchy
  14463. */
  14464. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14465. doNotInstantiate: boolean;
  14466. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14467. /**
  14468. * Prevents the World matrix to be computed any longer
  14469. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14470. * @returns the TransformNode.
  14471. */
  14472. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14473. /**
  14474. * Allows back the World matrix computation.
  14475. * @returns the TransformNode.
  14476. */
  14477. unfreezeWorldMatrix(): this;
  14478. /**
  14479. * True if the World matrix has been frozen.
  14480. */
  14481. readonly isWorldMatrixFrozen: boolean;
  14482. /**
  14483. * Retuns the mesh absolute position in the World.
  14484. * @returns a Vector3.
  14485. */
  14486. getAbsolutePosition(): Vector3;
  14487. /**
  14488. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14489. * @param absolutePosition the absolute position to set
  14490. * @returns the TransformNode.
  14491. */
  14492. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14493. /**
  14494. * Sets the mesh position in its local space.
  14495. * @param vector3 the position to set in localspace
  14496. * @returns the TransformNode.
  14497. */
  14498. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14499. /**
  14500. * Returns the mesh position in the local space from the current World matrix values.
  14501. * @returns a new Vector3.
  14502. */
  14503. getPositionExpressedInLocalSpace(): Vector3;
  14504. /**
  14505. * Translates the mesh along the passed Vector3 in its local space.
  14506. * @param vector3 the distance to translate in localspace
  14507. * @returns the TransformNode.
  14508. */
  14509. locallyTranslate(vector3: Vector3): TransformNode;
  14510. private static _lookAtVectorCache;
  14511. /**
  14512. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14513. * @param targetPoint the position (must be in same space as current mesh) to look at
  14514. * @param yawCor optional yaw (y-axis) correction in radians
  14515. * @param pitchCor optional pitch (x-axis) correction in radians
  14516. * @param rollCor optional roll (z-axis) correction in radians
  14517. * @param space the choosen space of the target
  14518. * @returns the TransformNode.
  14519. */
  14520. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14521. /**
  14522. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14523. * This Vector3 is expressed in the World space.
  14524. * @param localAxis axis to rotate
  14525. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14526. */
  14527. getDirection(localAxis: Vector3): Vector3;
  14528. /**
  14529. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14530. * localAxis is expressed in the mesh local space.
  14531. * result is computed in the Wordl space from the mesh World matrix.
  14532. * @param localAxis axis to rotate
  14533. * @param result the resulting transformnode
  14534. * @returns this TransformNode.
  14535. */
  14536. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14537. /**
  14538. * Sets this transform node rotation to the given local axis.
  14539. * @param localAxis the axis in local space
  14540. * @param yawCor optional yaw (y-axis) correction in radians
  14541. * @param pitchCor optional pitch (x-axis) correction in radians
  14542. * @param rollCor optional roll (z-axis) correction in radians
  14543. * @returns this TransformNode
  14544. */
  14545. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14546. /**
  14547. * Sets a new pivot point to the current node
  14548. * @param point defines the new pivot point to use
  14549. * @param space defines if the point is in world or local space (local by default)
  14550. * @returns the current TransformNode
  14551. */
  14552. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14553. /**
  14554. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14555. * @returns the pivot point
  14556. */
  14557. getPivotPoint(): Vector3;
  14558. /**
  14559. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14560. * @param result the vector3 to store the result
  14561. * @returns this TransformNode.
  14562. */
  14563. getPivotPointToRef(result: Vector3): TransformNode;
  14564. /**
  14565. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14566. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14567. */
  14568. getAbsolutePivotPoint(): Vector3;
  14569. /**
  14570. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14571. * @param result vector3 to store the result
  14572. * @returns this TransformNode.
  14573. */
  14574. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14575. /**
  14576. * Defines the passed node as the parent of the current node.
  14577. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14578. * @see https://doc.babylonjs.com/how_to/parenting
  14579. * @param node the node ot set as the parent
  14580. * @returns this TransformNode.
  14581. */
  14582. setParent(node: Nullable<Node>): TransformNode;
  14583. private _nonUniformScaling;
  14584. /**
  14585. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14586. */
  14587. readonly nonUniformScaling: boolean;
  14588. /** @hidden */
  14589. _updateNonUniformScalingState(value: boolean): boolean;
  14590. /**
  14591. * Attach the current TransformNode to another TransformNode associated with a bone
  14592. * @param bone Bone affecting the TransformNode
  14593. * @param affectedTransformNode TransformNode associated with the bone
  14594. * @returns this object
  14595. */
  14596. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14597. /**
  14598. * Detach the transform node if its associated with a bone
  14599. * @returns this object
  14600. */
  14601. detachFromBone(): TransformNode;
  14602. private static _rotationAxisCache;
  14603. /**
  14604. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14605. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14606. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14607. * The passed axis is also normalized.
  14608. * @param axis the axis to rotate around
  14609. * @param amount the amount to rotate in radians
  14610. * @param space Space to rotate in (Default: local)
  14611. * @returns the TransformNode.
  14612. */
  14613. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14614. /**
  14615. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14616. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14617. * The passed axis is also normalized. .
  14618. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14619. * @param point the point to rotate around
  14620. * @param axis the axis to rotate around
  14621. * @param amount the amount to rotate in radians
  14622. * @returns the TransformNode
  14623. */
  14624. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14625. /**
  14626. * Translates the mesh along the axis vector for the passed distance in the given space.
  14627. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14628. * @param axis the axis to translate in
  14629. * @param distance the distance to translate
  14630. * @param space Space to rotate in (Default: local)
  14631. * @returns the TransformNode.
  14632. */
  14633. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14634. /**
  14635. * Adds a rotation step to the mesh current rotation.
  14636. * x, y, z are Euler angles expressed in radians.
  14637. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14638. * This means this rotation is made in the mesh local space only.
  14639. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14640. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14641. * ```javascript
  14642. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14643. * ```
  14644. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14645. * 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.
  14646. * @param x Rotation to add
  14647. * @param y Rotation to add
  14648. * @param z Rotation to add
  14649. * @returns the TransformNode.
  14650. */
  14651. addRotation(x: number, y: number, z: number): TransformNode;
  14652. /**
  14653. * @hidden
  14654. */
  14655. protected _getEffectiveParent(): Nullable<Node>;
  14656. /**
  14657. * Computes the world matrix of the node
  14658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14659. * @returns the world matrix
  14660. */
  14661. computeWorldMatrix(force?: boolean): Matrix;
  14662. protected _afterComputeWorldMatrix(): void;
  14663. /**
  14664. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14665. * @param func callback function to add
  14666. *
  14667. * @returns the TransformNode.
  14668. */
  14669. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14670. /**
  14671. * Removes a registered callback function.
  14672. * @param func callback function to remove
  14673. * @returns the TransformNode.
  14674. */
  14675. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14676. /**
  14677. * Gets the position of the current mesh in camera space
  14678. * @param camera defines the camera to use
  14679. * @returns a position
  14680. */
  14681. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14682. /**
  14683. * Returns the distance from the mesh to the active camera
  14684. * @param camera defines the camera to use
  14685. * @returns the distance
  14686. */
  14687. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14688. /**
  14689. * Clone the current transform node
  14690. * @param name Name of the new clone
  14691. * @param newParent New parent for the clone
  14692. * @param doNotCloneChildren Do not clone children hierarchy
  14693. * @returns the new transform node
  14694. */
  14695. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14696. /**
  14697. * Serializes the objects information.
  14698. * @param currentSerializationObject defines the object to serialize in
  14699. * @returns the serialized object
  14700. */
  14701. serialize(currentSerializationObject?: any): any;
  14702. /**
  14703. * Returns a new TransformNode object parsed from the source provided.
  14704. * @param parsedTransformNode is the source.
  14705. * @param scene the scne the object belongs to
  14706. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14707. * @returns a new TransformNode object parsed from the source provided.
  14708. */
  14709. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14710. /**
  14711. * Get all child-transformNodes of this node
  14712. * @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
  14713. * @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
  14714. * @returns an array of TransformNode
  14715. */
  14716. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14717. /**
  14718. * Releases resources associated with this transform node.
  14719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14721. */
  14722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14723. /**
  14724. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14725. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14726. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14727. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14728. * @returns the current mesh
  14729. */
  14730. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14731. private _syncAbsoluteScalingAndRotation;
  14732. }
  14733. }
  14734. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14735. import { Observable } from "babylonjs/Misc/observable";
  14736. import { Nullable } from "babylonjs/types";
  14737. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14740. import { Ray } from "babylonjs/Culling/ray";
  14741. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14742. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14743. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14744. /**
  14745. * Defines the types of pose enabled controllers that are supported
  14746. */
  14747. export enum PoseEnabledControllerType {
  14748. /**
  14749. * HTC Vive
  14750. */
  14751. VIVE = 0,
  14752. /**
  14753. * Oculus Rift
  14754. */
  14755. OCULUS = 1,
  14756. /**
  14757. * Windows mixed reality
  14758. */
  14759. WINDOWS = 2,
  14760. /**
  14761. * Samsung gear VR
  14762. */
  14763. GEAR_VR = 3,
  14764. /**
  14765. * Google Daydream
  14766. */
  14767. DAYDREAM = 4,
  14768. /**
  14769. * Generic
  14770. */
  14771. GENERIC = 5
  14772. }
  14773. /**
  14774. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14775. */
  14776. export interface MutableGamepadButton {
  14777. /**
  14778. * Value of the button/trigger
  14779. */
  14780. value: number;
  14781. /**
  14782. * If the button/trigger is currently touched
  14783. */
  14784. touched: boolean;
  14785. /**
  14786. * If the button/trigger is currently pressed
  14787. */
  14788. pressed: boolean;
  14789. }
  14790. /**
  14791. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14792. * @hidden
  14793. */
  14794. export interface ExtendedGamepadButton extends GamepadButton {
  14795. /**
  14796. * If the button/trigger is currently pressed
  14797. */
  14798. readonly pressed: boolean;
  14799. /**
  14800. * If the button/trigger is currently touched
  14801. */
  14802. readonly touched: boolean;
  14803. /**
  14804. * Value of the button/trigger
  14805. */
  14806. readonly value: number;
  14807. }
  14808. /** @hidden */
  14809. export interface _GamePadFactory {
  14810. /**
  14811. * Returns wether or not the current gamepad can be created for this type of controller.
  14812. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14813. * @returns true if it can be created, otherwise false
  14814. */
  14815. canCreate(gamepadInfo: any): boolean;
  14816. /**
  14817. * Creates a new instance of the Gamepad.
  14818. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14819. * @returns the new gamepad instance
  14820. */
  14821. create(gamepadInfo: any): Gamepad;
  14822. }
  14823. /**
  14824. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14825. */
  14826. export class PoseEnabledControllerHelper {
  14827. /** @hidden */
  14828. static _ControllerFactories: _GamePadFactory[];
  14829. /** @hidden */
  14830. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14831. /**
  14832. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14833. * @param vrGamepad the gamepad to initialized
  14834. * @returns a vr controller of the type the gamepad identified as
  14835. */
  14836. static InitiateController(vrGamepad: any): Gamepad;
  14837. }
  14838. /**
  14839. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14840. */
  14841. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14842. /**
  14843. * If the controller is used in a webXR session
  14844. */
  14845. isXR: boolean;
  14846. private _deviceRoomPosition;
  14847. private _deviceRoomRotationQuaternion;
  14848. /**
  14849. * The device position in babylon space
  14850. */
  14851. devicePosition: Vector3;
  14852. /**
  14853. * The device rotation in babylon space
  14854. */
  14855. deviceRotationQuaternion: Quaternion;
  14856. /**
  14857. * The scale factor of the device in babylon space
  14858. */
  14859. deviceScaleFactor: number;
  14860. /**
  14861. * (Likely devicePosition should be used instead) The device position in its room space
  14862. */
  14863. position: Vector3;
  14864. /**
  14865. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14866. */
  14867. rotationQuaternion: Quaternion;
  14868. /**
  14869. * The type of controller (Eg. Windows mixed reality)
  14870. */
  14871. controllerType: PoseEnabledControllerType;
  14872. protected _calculatedPosition: Vector3;
  14873. private _calculatedRotation;
  14874. /**
  14875. * The raw pose from the device
  14876. */
  14877. rawPose: DevicePose;
  14878. private _trackPosition;
  14879. private _maxRotationDistFromHeadset;
  14880. private _draggedRoomRotation;
  14881. /**
  14882. * @hidden
  14883. */
  14884. _disableTrackPosition(fixedPosition: Vector3): void;
  14885. /**
  14886. * Internal, the mesh attached to the controller
  14887. * @hidden
  14888. */
  14889. _mesh: Nullable<AbstractMesh>;
  14890. private _poseControlledCamera;
  14891. private _leftHandSystemQuaternion;
  14892. /**
  14893. * Internal, matrix used to convert room space to babylon space
  14894. * @hidden
  14895. */
  14896. _deviceToWorld: Matrix;
  14897. /**
  14898. * Node to be used when casting a ray from the controller
  14899. * @hidden
  14900. */
  14901. _pointingPoseNode: Nullable<TransformNode>;
  14902. /**
  14903. * Name of the child mesh that can be used to cast a ray from the controller
  14904. */
  14905. static readonly POINTING_POSE: string;
  14906. /**
  14907. * Creates a new PoseEnabledController from a gamepad
  14908. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14909. */
  14910. constructor(browserGamepad: any);
  14911. private _workingMatrix;
  14912. /**
  14913. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14914. */
  14915. update(): void;
  14916. /**
  14917. * Updates only the pose device and mesh without doing any button event checking
  14918. */
  14919. protected _updatePoseAndMesh(): void;
  14920. /**
  14921. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14922. * @param poseData raw pose fromthe device
  14923. */
  14924. updateFromDevice(poseData: DevicePose): void;
  14925. /**
  14926. * @hidden
  14927. */
  14928. _meshAttachedObservable: Observable<AbstractMesh>;
  14929. /**
  14930. * Attaches a mesh to the controller
  14931. * @param mesh the mesh to be attached
  14932. */
  14933. attachToMesh(mesh: AbstractMesh): void;
  14934. /**
  14935. * Attaches the controllers mesh to a camera
  14936. * @param camera the camera the mesh should be attached to
  14937. */
  14938. attachToPoseControlledCamera(camera: TargetCamera): void;
  14939. /**
  14940. * Disposes of the controller
  14941. */
  14942. dispose(): void;
  14943. /**
  14944. * The mesh that is attached to the controller
  14945. */
  14946. readonly mesh: Nullable<AbstractMesh>;
  14947. /**
  14948. * Gets the ray of the controller in the direction the controller is pointing
  14949. * @param length the length the resulting ray should be
  14950. * @returns a ray in the direction the controller is pointing
  14951. */
  14952. getForwardRay(length?: number): Ray;
  14953. }
  14954. }
  14955. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14956. import { Observable } from "babylonjs/Misc/observable";
  14957. import { Scene } from "babylonjs/scene";
  14958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14959. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14960. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14961. import { Nullable } from "babylonjs/types";
  14962. /**
  14963. * Defines the WebVRController object that represents controllers tracked in 3D space
  14964. */
  14965. export abstract class WebVRController extends PoseEnabledController {
  14966. /**
  14967. * Internal, the default controller model for the controller
  14968. */
  14969. protected _defaultModel: Nullable<AbstractMesh>;
  14970. /**
  14971. * Fired when the trigger state has changed
  14972. */
  14973. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14974. /**
  14975. * Fired when the main button state has changed
  14976. */
  14977. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14978. /**
  14979. * Fired when the secondary button state has changed
  14980. */
  14981. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14982. /**
  14983. * Fired when the pad state has changed
  14984. */
  14985. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14986. /**
  14987. * Fired when controllers stick values have changed
  14988. */
  14989. onPadValuesChangedObservable: Observable<StickValues>;
  14990. /**
  14991. * Array of button availible on the controller
  14992. */
  14993. protected _buttons: Array<MutableGamepadButton>;
  14994. private _onButtonStateChange;
  14995. /**
  14996. * Fired when a controller button's state has changed
  14997. * @param callback the callback containing the button that was modified
  14998. */
  14999. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15000. /**
  15001. * X and Y axis corresponding to the controllers joystick
  15002. */
  15003. pad: StickValues;
  15004. /**
  15005. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15006. */
  15007. hand: string;
  15008. /**
  15009. * The default controller model for the controller
  15010. */
  15011. readonly defaultModel: Nullable<AbstractMesh>;
  15012. /**
  15013. * Creates a new WebVRController from a gamepad
  15014. * @param vrGamepad the gamepad that the WebVRController should be created from
  15015. */
  15016. constructor(vrGamepad: any);
  15017. /**
  15018. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15019. */
  15020. update(): void;
  15021. /**
  15022. * Function to be called when a button is modified
  15023. */
  15024. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15025. /**
  15026. * Loads a mesh and attaches it to the controller
  15027. * @param scene the scene the mesh should be added to
  15028. * @param meshLoaded callback for when the mesh has been loaded
  15029. */
  15030. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15031. private _setButtonValue;
  15032. private _changes;
  15033. private _checkChanges;
  15034. /**
  15035. * Disposes of th webVRCOntroller
  15036. */
  15037. dispose(): void;
  15038. }
  15039. }
  15040. declare module "babylonjs/Lights/hemisphericLight" {
  15041. import { Nullable } from "babylonjs/types";
  15042. import { Scene } from "babylonjs/scene";
  15043. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15044. import { Color3 } from "babylonjs/Maths/math.color";
  15045. import { Effect } from "babylonjs/Materials/effect";
  15046. import { Light } from "babylonjs/Lights/light";
  15047. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15048. /**
  15049. * The HemisphericLight simulates the ambient environment light,
  15050. * so the passed direction is the light reflection direction, not the incoming direction.
  15051. */
  15052. export class HemisphericLight extends Light {
  15053. /**
  15054. * The groundColor is the light in the opposite direction to the one specified during creation.
  15055. * 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.
  15056. */
  15057. groundColor: Color3;
  15058. /**
  15059. * The light reflection direction, not the incoming direction.
  15060. */
  15061. direction: Vector3;
  15062. /**
  15063. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15064. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15065. * The HemisphericLight can't cast shadows.
  15066. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15067. * @param name The friendly name of the light
  15068. * @param direction The direction of the light reflection
  15069. * @param scene The scene the light belongs to
  15070. */
  15071. constructor(name: string, direction: Vector3, scene: Scene);
  15072. protected _buildUniformLayout(): void;
  15073. /**
  15074. * Returns the string "HemisphericLight".
  15075. * @return The class name
  15076. */
  15077. getClassName(): string;
  15078. /**
  15079. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15080. * Returns the updated direction.
  15081. * @param target The target the direction should point to
  15082. * @return The computed direction
  15083. */
  15084. setDirectionToTarget(target: Vector3): Vector3;
  15085. /**
  15086. * Returns the shadow generator associated to the light.
  15087. * @returns Always null for hemispheric lights because it does not support shadows.
  15088. */
  15089. getShadowGenerator(): Nullable<IShadowGenerator>;
  15090. /**
  15091. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15092. * @param effect The effect to update
  15093. * @param lightIndex The index of the light in the effect to update
  15094. * @returns The hemispheric light
  15095. */
  15096. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15097. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15098. /**
  15099. * Computes the world matrix of the node
  15100. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15101. * @param useWasUpdatedFlag defines a reserved property
  15102. * @returns the world matrix
  15103. */
  15104. computeWorldMatrix(): Matrix;
  15105. /**
  15106. * Returns the integer 3.
  15107. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15108. */
  15109. getTypeID(): number;
  15110. /**
  15111. * Prepares the list of defines specific to the light type.
  15112. * @param defines the list of defines
  15113. * @param lightIndex defines the index of the light for the effect
  15114. */
  15115. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15116. }
  15117. }
  15118. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15119. /** @hidden */
  15120. export var vrMultiviewToSingleviewPixelShader: {
  15121. name: string;
  15122. shader: string;
  15123. };
  15124. }
  15125. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15127. import { Scene } from "babylonjs/scene";
  15128. /**
  15129. * Renders to multiple views with a single draw call
  15130. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15131. */
  15132. export class MultiviewRenderTarget extends RenderTargetTexture {
  15133. /**
  15134. * Creates a multiview render target
  15135. * @param scene scene used with the render target
  15136. * @param size the size of the render target (used for each view)
  15137. */
  15138. constructor(scene: Scene, size?: number | {
  15139. width: number;
  15140. height: number;
  15141. } | {
  15142. ratio: number;
  15143. });
  15144. /**
  15145. * @hidden
  15146. * @param faceIndex the face index, if its a cube texture
  15147. */
  15148. _bindFrameBuffer(faceIndex?: number): void;
  15149. /**
  15150. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15151. * @returns the view count
  15152. */
  15153. getViewCount(): number;
  15154. }
  15155. }
  15156. declare module "babylonjs/Maths/math.frustum" {
  15157. import { Matrix } from "babylonjs/Maths/math.vector";
  15158. import { DeepImmutable } from "babylonjs/types";
  15159. import { Plane } from "babylonjs/Maths/math.plane";
  15160. /**
  15161. * Represents a camera frustum
  15162. */
  15163. export class Frustum {
  15164. /**
  15165. * Gets the planes representing the frustum
  15166. * @param transform matrix to be applied to the returned planes
  15167. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15168. */
  15169. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15170. /**
  15171. * Gets the near frustum plane transformed by the transform matrix
  15172. * @param transform transformation matrix to be applied to the resulting frustum plane
  15173. * @param frustumPlane the resuling frustum plane
  15174. */
  15175. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15176. /**
  15177. * Gets the far frustum plane transformed by the transform matrix
  15178. * @param transform transformation matrix to be applied to the resulting frustum plane
  15179. * @param frustumPlane the resuling frustum plane
  15180. */
  15181. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15182. /**
  15183. * Gets the left frustum plane transformed by the transform matrix
  15184. * @param transform transformation matrix to be applied to the resulting frustum plane
  15185. * @param frustumPlane the resuling frustum plane
  15186. */
  15187. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15188. /**
  15189. * Gets the right frustum plane transformed by the transform matrix
  15190. * @param transform transformation matrix to be applied to the resulting frustum plane
  15191. * @param frustumPlane the resuling frustum plane
  15192. */
  15193. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15194. /**
  15195. * Gets the top frustum plane transformed by the transform matrix
  15196. * @param transform transformation matrix to be applied to the resulting frustum plane
  15197. * @param frustumPlane the resuling frustum plane
  15198. */
  15199. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15200. /**
  15201. * Gets the bottom frustum plane transformed by the transform matrix
  15202. * @param transform transformation matrix to be applied to the resulting frustum plane
  15203. * @param frustumPlane the resuling frustum plane
  15204. */
  15205. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15206. /**
  15207. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15208. * @param transform transformation matrix to be applied to the resulting frustum planes
  15209. * @param frustumPlanes the resuling frustum planes
  15210. */
  15211. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15212. }
  15213. }
  15214. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15215. import { Camera } from "babylonjs/Cameras/camera";
  15216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15217. import { Nullable } from "babylonjs/types";
  15218. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15219. import { Matrix } from "babylonjs/Maths/math.vector";
  15220. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15221. module "babylonjs/Engines/engine" {
  15222. interface Engine {
  15223. /**
  15224. * Creates a new multiview render target
  15225. * @param width defines the width of the texture
  15226. * @param height defines the height of the texture
  15227. * @returns the created multiview texture
  15228. */
  15229. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15230. /**
  15231. * Binds a multiview framebuffer to be drawn to
  15232. * @param multiviewTexture texture to bind
  15233. */
  15234. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15235. }
  15236. }
  15237. module "babylonjs/Cameras/camera" {
  15238. interface Camera {
  15239. /**
  15240. * @hidden
  15241. * 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)
  15242. */
  15243. _useMultiviewToSingleView: boolean;
  15244. /**
  15245. * @hidden
  15246. * 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)
  15247. */
  15248. _multiviewTexture: Nullable<RenderTargetTexture>;
  15249. /**
  15250. * @hidden
  15251. * ensures the multiview texture of the camera exists and has the specified width/height
  15252. * @param width height to set on the multiview texture
  15253. * @param height width to set on the multiview texture
  15254. */
  15255. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15256. }
  15257. }
  15258. module "babylonjs/scene" {
  15259. interface Scene {
  15260. /** @hidden */
  15261. _transformMatrixR: Matrix;
  15262. /** @hidden */
  15263. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15264. /** @hidden */
  15265. _createMultiviewUbo(): void;
  15266. /** @hidden */
  15267. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15268. /** @hidden */
  15269. _renderMultiviewToSingleView(camera: Camera): void;
  15270. }
  15271. }
  15272. }
  15273. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15274. import { Camera } from "babylonjs/Cameras/camera";
  15275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15276. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15277. import "babylonjs/Engines/Extensions/engine.multiview";
  15278. /**
  15279. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15280. * This will not be used for webXR as it supports displaying texture arrays directly
  15281. */
  15282. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15283. /**
  15284. * Initializes a VRMultiviewToSingleview
  15285. * @param name name of the post process
  15286. * @param camera camera to be applied to
  15287. * @param scaleFactor scaling factor to the size of the output texture
  15288. */
  15289. constructor(name: string, camera: Camera, scaleFactor: number);
  15290. }
  15291. }
  15292. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15293. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15294. import { Nullable } from "babylonjs/types";
  15295. import { Size } from "babylonjs/Maths/math.size";
  15296. import { Observable } from "babylonjs/Misc/observable";
  15297. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15298. /**
  15299. * Interface used to define additional presentation attributes
  15300. */
  15301. export interface IVRPresentationAttributes {
  15302. /**
  15303. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15304. */
  15305. highRefreshRate: boolean;
  15306. /**
  15307. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15308. */
  15309. foveationLevel: number;
  15310. }
  15311. module "babylonjs/Engines/engine" {
  15312. interface Engine {
  15313. /** @hidden */
  15314. _vrDisplay: any;
  15315. /** @hidden */
  15316. _vrSupported: boolean;
  15317. /** @hidden */
  15318. _oldSize: Size;
  15319. /** @hidden */
  15320. _oldHardwareScaleFactor: number;
  15321. /** @hidden */
  15322. _vrExclusivePointerMode: boolean;
  15323. /** @hidden */
  15324. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15325. /** @hidden */
  15326. _onVRDisplayPointerRestricted: () => void;
  15327. /** @hidden */
  15328. _onVRDisplayPointerUnrestricted: () => void;
  15329. /** @hidden */
  15330. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15331. /** @hidden */
  15332. _onVrDisplayDisconnect: Nullable<() => void>;
  15333. /** @hidden */
  15334. _onVrDisplayPresentChange: Nullable<() => void>;
  15335. /**
  15336. * Observable signaled when VR display mode changes
  15337. */
  15338. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15339. /**
  15340. * Observable signaled when VR request present is complete
  15341. */
  15342. onVRRequestPresentComplete: Observable<boolean>;
  15343. /**
  15344. * Observable signaled when VR request present starts
  15345. */
  15346. onVRRequestPresentStart: Observable<Engine>;
  15347. /**
  15348. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15349. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15350. */
  15351. isInVRExclusivePointerMode: boolean;
  15352. /**
  15353. * Gets a boolean indicating if a webVR device was detected
  15354. * @returns true if a webVR device was detected
  15355. */
  15356. isVRDevicePresent(): boolean;
  15357. /**
  15358. * Gets the current webVR device
  15359. * @returns the current webVR device (or null)
  15360. */
  15361. getVRDevice(): any;
  15362. /**
  15363. * Initializes a webVR display and starts listening to display change events
  15364. * The onVRDisplayChangedObservable will be notified upon these changes
  15365. * @returns A promise containing a VRDisplay and if vr is supported
  15366. */
  15367. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15368. /** @hidden */
  15369. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15370. /**
  15371. * Gets or sets the presentation attributes used to configure VR rendering
  15372. */
  15373. vrPresentationAttributes?: IVRPresentationAttributes;
  15374. /**
  15375. * Call this function to switch to webVR mode
  15376. * Will do nothing if webVR is not supported or if there is no webVR device
  15377. * @param options the webvr options provided to the camera. mainly used for multiview
  15378. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15379. */
  15380. enableVR(options: WebVROptions): void;
  15381. /** @hidden */
  15382. _onVRFullScreenTriggered(): void;
  15383. }
  15384. }
  15385. }
  15386. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15387. import { Nullable } from "babylonjs/types";
  15388. import { Observable } from "babylonjs/Misc/observable";
  15389. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15390. import { Scene } from "babylonjs/scene";
  15391. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15392. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15393. import { Node } from "babylonjs/node";
  15394. import { Ray } from "babylonjs/Culling/ray";
  15395. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15396. import "babylonjs/Engines/Extensions/engine.webVR";
  15397. /**
  15398. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15399. * IMPORTANT!! The data is right-hand data.
  15400. * @export
  15401. * @interface DevicePose
  15402. */
  15403. export interface DevicePose {
  15404. /**
  15405. * The position of the device, values in array are [x,y,z].
  15406. */
  15407. readonly position: Nullable<Float32Array>;
  15408. /**
  15409. * The linearVelocity of the device, values in array are [x,y,z].
  15410. */
  15411. readonly linearVelocity: Nullable<Float32Array>;
  15412. /**
  15413. * The linearAcceleration of the device, values in array are [x,y,z].
  15414. */
  15415. readonly linearAcceleration: Nullable<Float32Array>;
  15416. /**
  15417. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15418. */
  15419. readonly orientation: Nullable<Float32Array>;
  15420. /**
  15421. * The angularVelocity of the device, values in array are [x,y,z].
  15422. */
  15423. readonly angularVelocity: Nullable<Float32Array>;
  15424. /**
  15425. * The angularAcceleration of the device, values in array are [x,y,z].
  15426. */
  15427. readonly angularAcceleration: Nullable<Float32Array>;
  15428. }
  15429. /**
  15430. * Interface representing a pose controlled object in Babylon.
  15431. * A pose controlled object has both regular pose values as well as pose values
  15432. * from an external device such as a VR head mounted display
  15433. */
  15434. export interface PoseControlled {
  15435. /**
  15436. * The position of the object in babylon space.
  15437. */
  15438. position: Vector3;
  15439. /**
  15440. * The rotation quaternion of the object in babylon space.
  15441. */
  15442. rotationQuaternion: Quaternion;
  15443. /**
  15444. * The position of the device in babylon space.
  15445. */
  15446. devicePosition?: Vector3;
  15447. /**
  15448. * The rotation quaternion of the device in babylon space.
  15449. */
  15450. deviceRotationQuaternion: Quaternion;
  15451. /**
  15452. * The raw pose coming from the device.
  15453. */
  15454. rawPose: Nullable<DevicePose>;
  15455. /**
  15456. * The scale of the device to be used when translating from device space to babylon space.
  15457. */
  15458. deviceScaleFactor: number;
  15459. /**
  15460. * Updates the poseControlled values based on the input device pose.
  15461. * @param poseData the pose data to update the object with
  15462. */
  15463. updateFromDevice(poseData: DevicePose): void;
  15464. }
  15465. /**
  15466. * Set of options to customize the webVRCamera
  15467. */
  15468. export interface WebVROptions {
  15469. /**
  15470. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15471. */
  15472. trackPosition?: boolean;
  15473. /**
  15474. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15475. */
  15476. positionScale?: number;
  15477. /**
  15478. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15479. */
  15480. displayName?: string;
  15481. /**
  15482. * Should the native controller meshes be initialized. (default: true)
  15483. */
  15484. controllerMeshes?: boolean;
  15485. /**
  15486. * Creating a default HemiLight only on controllers. (default: true)
  15487. */
  15488. defaultLightingOnControllers?: boolean;
  15489. /**
  15490. * If you don't want to use the default VR button of the helper. (default: false)
  15491. */
  15492. useCustomVRButton?: boolean;
  15493. /**
  15494. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15495. */
  15496. customVRButton?: HTMLButtonElement;
  15497. /**
  15498. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15499. */
  15500. rayLength?: number;
  15501. /**
  15502. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15503. */
  15504. defaultHeight?: number;
  15505. /**
  15506. * If multiview should be used if availible (default: false)
  15507. */
  15508. useMultiview?: boolean;
  15509. }
  15510. /**
  15511. * This represents a WebVR camera.
  15512. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15513. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15514. */
  15515. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15516. private webVROptions;
  15517. /**
  15518. * @hidden
  15519. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15520. */
  15521. _vrDevice: any;
  15522. /**
  15523. * The rawPose of the vrDevice.
  15524. */
  15525. rawPose: Nullable<DevicePose>;
  15526. private _onVREnabled;
  15527. private _specsVersion;
  15528. private _attached;
  15529. private _frameData;
  15530. protected _descendants: Array<Node>;
  15531. private _deviceRoomPosition;
  15532. /** @hidden */
  15533. _deviceRoomRotationQuaternion: Quaternion;
  15534. private _standingMatrix;
  15535. /**
  15536. * Represents device position in babylon space.
  15537. */
  15538. devicePosition: Vector3;
  15539. /**
  15540. * Represents device rotation in babylon space.
  15541. */
  15542. deviceRotationQuaternion: Quaternion;
  15543. /**
  15544. * The scale of the device to be used when translating from device space to babylon space.
  15545. */
  15546. deviceScaleFactor: number;
  15547. private _deviceToWorld;
  15548. private _worldToDevice;
  15549. /**
  15550. * References to the webVR controllers for the vrDevice.
  15551. */
  15552. controllers: Array<WebVRController>;
  15553. /**
  15554. * Emits an event when a controller is attached.
  15555. */
  15556. onControllersAttachedObservable: Observable<WebVRController[]>;
  15557. /**
  15558. * Emits an event when a controller's mesh has been loaded;
  15559. */
  15560. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15561. /**
  15562. * Emits an event when the HMD's pose has been updated.
  15563. */
  15564. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15565. private _poseSet;
  15566. /**
  15567. * If the rig cameras be used as parent instead of this camera.
  15568. */
  15569. rigParenting: boolean;
  15570. private _lightOnControllers;
  15571. private _defaultHeight?;
  15572. /**
  15573. * Instantiates a WebVRFreeCamera.
  15574. * @param name The name of the WebVRFreeCamera
  15575. * @param position The starting anchor position for the camera
  15576. * @param scene The scene the camera belongs to
  15577. * @param webVROptions a set of customizable options for the webVRCamera
  15578. */
  15579. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15580. /**
  15581. * Gets the device distance from the ground in meters.
  15582. * @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.
  15583. */
  15584. deviceDistanceToRoomGround(): number;
  15585. /**
  15586. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15587. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15588. */
  15589. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15590. /**
  15591. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15592. * @returns A promise with a boolean set to if the standing matrix is supported.
  15593. */
  15594. useStandingMatrixAsync(): Promise<boolean>;
  15595. /**
  15596. * Disposes the camera
  15597. */
  15598. dispose(): void;
  15599. /**
  15600. * Gets a vrController by name.
  15601. * @param name The name of the controller to retreive
  15602. * @returns the controller matching the name specified or null if not found
  15603. */
  15604. getControllerByName(name: string): Nullable<WebVRController>;
  15605. private _leftController;
  15606. /**
  15607. * The controller corresponding to the users left hand.
  15608. */
  15609. readonly leftController: Nullable<WebVRController>;
  15610. private _rightController;
  15611. /**
  15612. * The controller corresponding to the users right hand.
  15613. */
  15614. readonly rightController: Nullable<WebVRController>;
  15615. /**
  15616. * Casts a ray forward from the vrCamera's gaze.
  15617. * @param length Length of the ray (default: 100)
  15618. * @returns the ray corresponding to the gaze
  15619. */
  15620. getForwardRay(length?: number): Ray;
  15621. /**
  15622. * @hidden
  15623. * Updates the camera based on device's frame data
  15624. */
  15625. _checkInputs(): void;
  15626. /**
  15627. * Updates the poseControlled values based on the input device pose.
  15628. * @param poseData Pose coming from the device
  15629. */
  15630. updateFromDevice(poseData: DevicePose): void;
  15631. private _htmlElementAttached;
  15632. private _detachIfAttached;
  15633. /**
  15634. * WebVR's attach control will start broadcasting frames to the device.
  15635. * Note that in certain browsers (chrome for example) this function must be called
  15636. * within a user-interaction callback. Example:
  15637. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15638. *
  15639. * @param element html element to attach the vrDevice to
  15640. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15641. */
  15642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15643. /**
  15644. * Detaches the camera from the html element and disables VR
  15645. *
  15646. * @param element html element to detach from
  15647. */
  15648. detachControl(element: HTMLElement): void;
  15649. /**
  15650. * @returns the name of this class
  15651. */
  15652. getClassName(): string;
  15653. /**
  15654. * Calls resetPose on the vrDisplay
  15655. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15656. */
  15657. resetToCurrentRotation(): void;
  15658. /**
  15659. * @hidden
  15660. * Updates the rig cameras (left and right eye)
  15661. */
  15662. _updateRigCameras(): void;
  15663. private _workingVector;
  15664. private _oneVector;
  15665. private _workingMatrix;
  15666. private updateCacheCalled;
  15667. private _correctPositionIfNotTrackPosition;
  15668. /**
  15669. * @hidden
  15670. * Updates the cached values of the camera
  15671. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15672. */
  15673. _updateCache(ignoreParentClass?: boolean): void;
  15674. /**
  15675. * @hidden
  15676. * Get current device position in babylon world
  15677. */
  15678. _computeDevicePosition(): void;
  15679. /**
  15680. * Updates the current device position and rotation in the babylon world
  15681. */
  15682. update(): void;
  15683. /**
  15684. * @hidden
  15685. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15686. * @returns an identity matrix
  15687. */
  15688. _getViewMatrix(): Matrix;
  15689. private _tmpMatrix;
  15690. /**
  15691. * This function is called by the two RIG cameras.
  15692. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15693. * @hidden
  15694. */
  15695. _getWebVRViewMatrix(): Matrix;
  15696. /** @hidden */
  15697. _getWebVRProjectionMatrix(): Matrix;
  15698. private _onGamepadConnectedObserver;
  15699. private _onGamepadDisconnectedObserver;
  15700. private _updateCacheWhenTrackingDisabledObserver;
  15701. /**
  15702. * Initializes the controllers and their meshes
  15703. */
  15704. initControllers(): void;
  15705. }
  15706. }
  15707. declare module "babylonjs/PostProcesses/postProcess" {
  15708. import { Nullable } from "babylonjs/types";
  15709. import { SmartArray } from "babylonjs/Misc/smartArray";
  15710. import { Observable } from "babylonjs/Misc/observable";
  15711. import { Vector2 } from "babylonjs/Maths/math.vector";
  15712. import { Camera } from "babylonjs/Cameras/camera";
  15713. import { Effect } from "babylonjs/Materials/effect";
  15714. import "babylonjs/Shaders/postprocess.vertex";
  15715. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15716. import { Engine } from "babylonjs/Engines/engine";
  15717. import { Color4 } from "babylonjs/Maths/math.color";
  15718. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15720. /**
  15721. * Size options for a post process
  15722. */
  15723. export type PostProcessOptions = {
  15724. width: number;
  15725. height: number;
  15726. };
  15727. /**
  15728. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15729. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15730. */
  15731. export class PostProcess {
  15732. /** Name of the PostProcess. */
  15733. name: string;
  15734. /**
  15735. * Gets or sets the unique id of the post process
  15736. */
  15737. uniqueId: number;
  15738. /**
  15739. * Width of the texture to apply the post process on
  15740. */
  15741. width: number;
  15742. /**
  15743. * Height of the texture to apply the post process on
  15744. */
  15745. height: number;
  15746. /**
  15747. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15748. * @hidden
  15749. */
  15750. _outputTexture: Nullable<InternalTexture>;
  15751. /**
  15752. * Sampling mode used by the shader
  15753. * See https://doc.babylonjs.com/classes/3.1/texture
  15754. */
  15755. renderTargetSamplingMode: number;
  15756. /**
  15757. * Clear color to use when screen clearing
  15758. */
  15759. clearColor: Color4;
  15760. /**
  15761. * If the buffer needs to be cleared before applying the post process. (default: true)
  15762. * Should be set to false if shader will overwrite all previous pixels.
  15763. */
  15764. autoClear: boolean;
  15765. /**
  15766. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15767. */
  15768. alphaMode: number;
  15769. /**
  15770. * Sets the setAlphaBlendConstants of the babylon engine
  15771. */
  15772. alphaConstants: Color4;
  15773. /**
  15774. * Animations to be used for the post processing
  15775. */
  15776. animations: import("babylonjs/Animations/animation").Animation[];
  15777. /**
  15778. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15779. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15780. */
  15781. enablePixelPerfectMode: boolean;
  15782. /**
  15783. * Force the postprocess to be applied without taking in account viewport
  15784. */
  15785. forceFullscreenViewport: boolean;
  15786. /**
  15787. * List of inspectable custom properties (used by the Inspector)
  15788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15789. */
  15790. inspectableCustomProperties: IInspectable[];
  15791. /**
  15792. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15793. *
  15794. * | Value | Type | Description |
  15795. * | ----- | ----------------------------------- | ----------- |
  15796. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15797. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15798. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15799. *
  15800. */
  15801. scaleMode: number;
  15802. /**
  15803. * Force textures to be a power of two (default: false)
  15804. */
  15805. alwaysForcePOT: boolean;
  15806. private _samples;
  15807. /**
  15808. * Number of sample textures (default: 1)
  15809. */
  15810. samples: number;
  15811. /**
  15812. * Modify the scale of the post process to be the same as the viewport (default: false)
  15813. */
  15814. adaptScaleToCurrentViewport: boolean;
  15815. private _camera;
  15816. private _scene;
  15817. private _engine;
  15818. private _options;
  15819. private _reusable;
  15820. private _textureType;
  15821. /**
  15822. * Smart array of input and output textures for the post process.
  15823. * @hidden
  15824. */
  15825. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15826. /**
  15827. * The index in _textures that corresponds to the output texture.
  15828. * @hidden
  15829. */
  15830. _currentRenderTextureInd: number;
  15831. private _effect;
  15832. private _samplers;
  15833. private _fragmentUrl;
  15834. private _vertexUrl;
  15835. private _parameters;
  15836. private _scaleRatio;
  15837. protected _indexParameters: any;
  15838. private _shareOutputWithPostProcess;
  15839. private _texelSize;
  15840. private _forcedOutputTexture;
  15841. /**
  15842. * Returns the fragment url or shader name used in the post process.
  15843. * @returns the fragment url or name in the shader store.
  15844. */
  15845. getEffectName(): string;
  15846. /**
  15847. * An event triggered when the postprocess is activated.
  15848. */
  15849. onActivateObservable: Observable<Camera>;
  15850. private _onActivateObserver;
  15851. /**
  15852. * A function that is added to the onActivateObservable
  15853. */
  15854. onActivate: Nullable<(camera: Camera) => void>;
  15855. /**
  15856. * An event triggered when the postprocess changes its size.
  15857. */
  15858. onSizeChangedObservable: Observable<PostProcess>;
  15859. private _onSizeChangedObserver;
  15860. /**
  15861. * A function that is added to the onSizeChangedObservable
  15862. */
  15863. onSizeChanged: (postProcess: PostProcess) => void;
  15864. /**
  15865. * An event triggered when the postprocess applies its effect.
  15866. */
  15867. onApplyObservable: Observable<Effect>;
  15868. private _onApplyObserver;
  15869. /**
  15870. * A function that is added to the onApplyObservable
  15871. */
  15872. onApply: (effect: Effect) => void;
  15873. /**
  15874. * An event triggered before rendering the postprocess
  15875. */
  15876. onBeforeRenderObservable: Observable<Effect>;
  15877. private _onBeforeRenderObserver;
  15878. /**
  15879. * A function that is added to the onBeforeRenderObservable
  15880. */
  15881. onBeforeRender: (effect: Effect) => void;
  15882. /**
  15883. * An event triggered after rendering the postprocess
  15884. */
  15885. onAfterRenderObservable: Observable<Effect>;
  15886. private _onAfterRenderObserver;
  15887. /**
  15888. * A function that is added to the onAfterRenderObservable
  15889. */
  15890. onAfterRender: (efect: Effect) => void;
  15891. /**
  15892. * 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
  15893. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15894. */
  15895. inputTexture: InternalTexture;
  15896. /**
  15897. * Gets the camera which post process is applied to.
  15898. * @returns The camera the post process is applied to.
  15899. */
  15900. getCamera(): Camera;
  15901. /**
  15902. * Gets the texel size of the postprocess.
  15903. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15904. */
  15905. readonly texelSize: Vector2;
  15906. /**
  15907. * Creates a new instance PostProcess
  15908. * @param name The name of the PostProcess.
  15909. * @param fragmentUrl The url of the fragment shader to be used.
  15910. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15911. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15912. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15913. * @param camera The camera to apply the render pass to.
  15914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15915. * @param engine The engine which the post process will be applied. (default: current engine)
  15916. * @param reusable If the post process can be reused on the same frame. (default: false)
  15917. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15918. * @param textureType Type of textures used when performing the post process. (default: 0)
  15919. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15920. * @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
  15921. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15922. */
  15923. constructor(
  15924. /** Name of the PostProcess. */
  15925. 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);
  15926. /**
  15927. * Gets a string idenfifying the name of the class
  15928. * @returns "PostProcess" string
  15929. */
  15930. getClassName(): string;
  15931. /**
  15932. * Gets the engine which this post process belongs to.
  15933. * @returns The engine the post process was enabled with.
  15934. */
  15935. getEngine(): Engine;
  15936. /**
  15937. * The effect that is created when initializing the post process.
  15938. * @returns The created effect corresponding the the postprocess.
  15939. */
  15940. getEffect(): Effect;
  15941. /**
  15942. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15943. * @param postProcess The post process to share the output with.
  15944. * @returns This post process.
  15945. */
  15946. shareOutputWith(postProcess: PostProcess): PostProcess;
  15947. /**
  15948. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15949. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15950. */
  15951. useOwnOutput(): void;
  15952. /**
  15953. * Updates the effect with the current post process compile time values and recompiles the shader.
  15954. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15955. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15956. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15957. * @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
  15958. * @param onCompiled Called when the shader has been compiled.
  15959. * @param onError Called if there is an error when compiling a shader.
  15960. */
  15961. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15962. /**
  15963. * The post process is reusable if it can be used multiple times within one frame.
  15964. * @returns If the post process is reusable
  15965. */
  15966. isReusable(): boolean;
  15967. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15968. markTextureDirty(): void;
  15969. /**
  15970. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15971. * 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.
  15972. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15973. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15974. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15975. * @returns The target texture that was bound to be written to.
  15976. */
  15977. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15978. /**
  15979. * If the post process is supported.
  15980. */
  15981. readonly isSupported: boolean;
  15982. /**
  15983. * The aspect ratio of the output texture.
  15984. */
  15985. readonly aspectRatio: number;
  15986. /**
  15987. * Get a value indicating if the post-process is ready to be used
  15988. * @returns true if the post-process is ready (shader is compiled)
  15989. */
  15990. isReady(): boolean;
  15991. /**
  15992. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15993. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15994. */
  15995. apply(): Nullable<Effect>;
  15996. private _disposeTextures;
  15997. /**
  15998. * Disposes the post process.
  15999. * @param camera The camera to dispose the post process on.
  16000. */
  16001. dispose(camera?: Camera): void;
  16002. }
  16003. }
  16004. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16005. /** @hidden */
  16006. export var kernelBlurVaryingDeclaration: {
  16007. name: string;
  16008. shader: string;
  16009. };
  16010. }
  16011. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16012. /** @hidden */
  16013. export var kernelBlurFragment: {
  16014. name: string;
  16015. shader: string;
  16016. };
  16017. }
  16018. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16019. /** @hidden */
  16020. export var kernelBlurFragment2: {
  16021. name: string;
  16022. shader: string;
  16023. };
  16024. }
  16025. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16026. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16027. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16028. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16029. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16030. /** @hidden */
  16031. export var kernelBlurPixelShader: {
  16032. name: string;
  16033. shader: string;
  16034. };
  16035. }
  16036. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16037. /** @hidden */
  16038. export var kernelBlurVertex: {
  16039. name: string;
  16040. shader: string;
  16041. };
  16042. }
  16043. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16044. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16045. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16046. /** @hidden */
  16047. export var kernelBlurVertexShader: {
  16048. name: string;
  16049. shader: string;
  16050. };
  16051. }
  16052. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16053. import { Vector2 } from "babylonjs/Maths/math.vector";
  16054. import { Nullable } from "babylonjs/types";
  16055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16056. import { Camera } from "babylonjs/Cameras/camera";
  16057. import { Effect } from "babylonjs/Materials/effect";
  16058. import { Engine } from "babylonjs/Engines/engine";
  16059. import "babylonjs/Shaders/kernelBlur.fragment";
  16060. import "babylonjs/Shaders/kernelBlur.vertex";
  16061. /**
  16062. * The Blur Post Process which blurs an image based on a kernel and direction.
  16063. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16064. */
  16065. export class BlurPostProcess extends PostProcess {
  16066. /** The direction in which to blur the image. */
  16067. direction: Vector2;
  16068. private blockCompilation;
  16069. protected _kernel: number;
  16070. protected _idealKernel: number;
  16071. protected _packedFloat: boolean;
  16072. private _staticDefines;
  16073. /**
  16074. * Sets the length in pixels of the blur sample region
  16075. */
  16076. /**
  16077. * Gets the length in pixels of the blur sample region
  16078. */
  16079. kernel: number;
  16080. /**
  16081. * Sets wether or not the blur needs to unpack/repack floats
  16082. */
  16083. /**
  16084. * Gets wether or not the blur is unpacking/repacking floats
  16085. */
  16086. packedFloat: boolean;
  16087. /**
  16088. * Creates a new instance BlurPostProcess
  16089. * @param name The name of the effect.
  16090. * @param direction The direction in which to blur the image.
  16091. * @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.
  16092. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16093. * @param camera The camera to apply the render pass to.
  16094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16095. * @param engine The engine which the post process will be applied. (default: current engine)
  16096. * @param reusable If the post process can be reused on the same frame. (default: false)
  16097. * @param textureType Type of textures used when performing the post process. (default: 0)
  16098. * @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)
  16099. */
  16100. constructor(name: string,
  16101. /** The direction in which to blur the image. */
  16102. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16103. /**
  16104. * Updates the effect with the current post process compile time values and recompiles the shader.
  16105. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16106. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16107. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16108. * @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
  16109. * @param onCompiled Called when the shader has been compiled.
  16110. * @param onError Called if there is an error when compiling a shader.
  16111. */
  16112. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16113. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16114. /**
  16115. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16116. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16117. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16118. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16119. * The gaps between physical kernels are compensated for in the weighting of the samples
  16120. * @param idealKernel Ideal blur kernel.
  16121. * @return Nearest best kernel.
  16122. */
  16123. protected _nearestBestKernel(idealKernel: number): number;
  16124. /**
  16125. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16126. * @param x The point on the Gaussian distribution to sample.
  16127. * @return the value of the Gaussian function at x.
  16128. */
  16129. protected _gaussianWeight(x: number): number;
  16130. /**
  16131. * Generates a string that can be used as a floating point number in GLSL.
  16132. * @param x Value to print.
  16133. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16134. * @return GLSL float string.
  16135. */
  16136. protected _glslFloat(x: number, decimalFigures?: number): string;
  16137. }
  16138. }
  16139. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16140. import { Scene } from "babylonjs/scene";
  16141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16142. import { Plane } from "babylonjs/Maths/math.plane";
  16143. /**
  16144. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16145. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16146. * You can then easily use it as a reflectionTexture on a flat surface.
  16147. * In case the surface is not a plane, please consider relying on reflection probes.
  16148. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16149. */
  16150. export class MirrorTexture extends RenderTargetTexture {
  16151. private scene;
  16152. /**
  16153. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16154. * 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.
  16155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16156. */
  16157. mirrorPlane: Plane;
  16158. /**
  16159. * Define the blur ratio used to blur the reflection if needed.
  16160. */
  16161. blurRatio: number;
  16162. /**
  16163. * Define the adaptive blur kernel used to blur the reflection if needed.
  16164. * This will autocompute the closest best match for the `blurKernel`
  16165. */
  16166. adaptiveBlurKernel: number;
  16167. /**
  16168. * Define the blur kernel used to blur the reflection if needed.
  16169. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16170. */
  16171. blurKernel: number;
  16172. /**
  16173. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16174. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16175. */
  16176. blurKernelX: number;
  16177. /**
  16178. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16179. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16180. */
  16181. blurKernelY: number;
  16182. private _autoComputeBlurKernel;
  16183. protected _onRatioRescale(): void;
  16184. private _updateGammaSpace;
  16185. private _imageProcessingConfigChangeObserver;
  16186. private _transformMatrix;
  16187. private _mirrorMatrix;
  16188. private _savedViewMatrix;
  16189. private _blurX;
  16190. private _blurY;
  16191. private _adaptiveBlurKernel;
  16192. private _blurKernelX;
  16193. private _blurKernelY;
  16194. private _blurRatio;
  16195. /**
  16196. * Instantiates a Mirror Texture.
  16197. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16198. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16199. * You can then easily use it as a reflectionTexture on a flat surface.
  16200. * In case the surface is not a plane, please consider relying on reflection probes.
  16201. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16202. * @param name
  16203. * @param size
  16204. * @param scene
  16205. * @param generateMipMaps
  16206. * @param type
  16207. * @param samplingMode
  16208. * @param generateDepthBuffer
  16209. */
  16210. constructor(name: string, size: number | {
  16211. width: number;
  16212. height: number;
  16213. } | {
  16214. ratio: number;
  16215. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16216. private _preparePostProcesses;
  16217. /**
  16218. * Clone the mirror texture.
  16219. * @returns the cloned texture
  16220. */
  16221. clone(): MirrorTexture;
  16222. /**
  16223. * Serialize the texture to a JSON representation you could use in Parse later on
  16224. * @returns the serialized JSON representation
  16225. */
  16226. serialize(): any;
  16227. /**
  16228. * Dispose the texture and release its associated resources.
  16229. */
  16230. dispose(): void;
  16231. }
  16232. }
  16233. declare module "babylonjs/Materials/Textures/texture" {
  16234. import { Observable } from "babylonjs/Misc/observable";
  16235. import { Nullable } from "babylonjs/types";
  16236. import { Matrix } from "babylonjs/Maths/math.vector";
  16237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16238. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16239. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16240. import { Scene } from "babylonjs/scene";
  16241. /**
  16242. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16243. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16244. */
  16245. export class Texture extends BaseTexture {
  16246. /**
  16247. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16248. */
  16249. static SerializeBuffers: boolean;
  16250. /** @hidden */
  16251. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16252. /** @hidden */
  16253. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16254. /** @hidden */
  16255. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16256. /** nearest is mag = nearest and min = nearest and mip = linear */
  16257. static readonly NEAREST_SAMPLINGMODE: number;
  16258. /** nearest is mag = nearest and min = nearest and mip = linear */
  16259. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16260. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16261. static readonly BILINEAR_SAMPLINGMODE: number;
  16262. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16263. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16264. /** Trilinear is mag = linear and min = linear and mip = linear */
  16265. static readonly TRILINEAR_SAMPLINGMODE: number;
  16266. /** Trilinear is mag = linear and min = linear and mip = linear */
  16267. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16268. /** mag = nearest and min = nearest and mip = nearest */
  16269. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16270. /** mag = nearest and min = linear and mip = nearest */
  16271. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16272. /** mag = nearest and min = linear and mip = linear */
  16273. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16274. /** mag = nearest and min = linear and mip = none */
  16275. static readonly NEAREST_LINEAR: number;
  16276. /** mag = nearest and min = nearest and mip = none */
  16277. static readonly NEAREST_NEAREST: number;
  16278. /** mag = linear and min = nearest and mip = nearest */
  16279. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16280. /** mag = linear and min = nearest and mip = linear */
  16281. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16282. /** mag = linear and min = linear and mip = none */
  16283. static readonly LINEAR_LINEAR: number;
  16284. /** mag = linear and min = nearest and mip = none */
  16285. static readonly LINEAR_NEAREST: number;
  16286. /** Explicit coordinates mode */
  16287. static readonly EXPLICIT_MODE: number;
  16288. /** Spherical coordinates mode */
  16289. static readonly SPHERICAL_MODE: number;
  16290. /** Planar coordinates mode */
  16291. static readonly PLANAR_MODE: number;
  16292. /** Cubic coordinates mode */
  16293. static readonly CUBIC_MODE: number;
  16294. /** Projection coordinates mode */
  16295. static readonly PROJECTION_MODE: number;
  16296. /** Inverse Cubic coordinates mode */
  16297. static readonly SKYBOX_MODE: number;
  16298. /** Inverse Cubic coordinates mode */
  16299. static readonly INVCUBIC_MODE: number;
  16300. /** Equirectangular coordinates mode */
  16301. static readonly EQUIRECTANGULAR_MODE: number;
  16302. /** Equirectangular Fixed coordinates mode */
  16303. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16304. /** Equirectangular Fixed Mirrored coordinates mode */
  16305. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16306. /** Texture is not repeating outside of 0..1 UVs */
  16307. static readonly CLAMP_ADDRESSMODE: number;
  16308. /** Texture is repeating outside of 0..1 UVs */
  16309. static readonly WRAP_ADDRESSMODE: number;
  16310. /** Texture is repeating and mirrored */
  16311. static readonly MIRROR_ADDRESSMODE: number;
  16312. /**
  16313. * 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
  16314. */
  16315. static UseSerializedUrlIfAny: boolean;
  16316. /**
  16317. * Define the url of the texture.
  16318. */
  16319. url: Nullable<string>;
  16320. /**
  16321. * Define an offset on the texture to offset the u coordinates of the UVs
  16322. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16323. */
  16324. uOffset: number;
  16325. /**
  16326. * Define an offset on the texture to offset the v coordinates of the UVs
  16327. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16328. */
  16329. vOffset: number;
  16330. /**
  16331. * Define an offset on the texture to scale the u coordinates of the UVs
  16332. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16333. */
  16334. uScale: number;
  16335. /**
  16336. * Define an offset on the texture to scale the v coordinates of the UVs
  16337. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16338. */
  16339. vScale: number;
  16340. /**
  16341. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16342. * @see http://doc.babylonjs.com/how_to/more_materials
  16343. */
  16344. uAng: number;
  16345. /**
  16346. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16347. * @see http://doc.babylonjs.com/how_to/more_materials
  16348. */
  16349. vAng: number;
  16350. /**
  16351. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16352. * @see http://doc.babylonjs.com/how_to/more_materials
  16353. */
  16354. wAng: number;
  16355. /**
  16356. * Defines the center of rotation (U)
  16357. */
  16358. uRotationCenter: number;
  16359. /**
  16360. * Defines the center of rotation (V)
  16361. */
  16362. vRotationCenter: number;
  16363. /**
  16364. * Defines the center of rotation (W)
  16365. */
  16366. wRotationCenter: number;
  16367. /**
  16368. * Are mip maps generated for this texture or not.
  16369. */
  16370. readonly noMipmap: boolean;
  16371. /**
  16372. * List of inspectable custom properties (used by the Inspector)
  16373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16374. */
  16375. inspectableCustomProperties: Nullable<IInspectable[]>;
  16376. private _noMipmap;
  16377. /** @hidden */
  16378. _invertY: boolean;
  16379. private _rowGenerationMatrix;
  16380. private _cachedTextureMatrix;
  16381. private _projectionModeMatrix;
  16382. private _t0;
  16383. private _t1;
  16384. private _t2;
  16385. private _cachedUOffset;
  16386. private _cachedVOffset;
  16387. private _cachedUScale;
  16388. private _cachedVScale;
  16389. private _cachedUAng;
  16390. private _cachedVAng;
  16391. private _cachedWAng;
  16392. private _cachedProjectionMatrixId;
  16393. private _cachedCoordinatesMode;
  16394. /** @hidden */
  16395. protected _initialSamplingMode: number;
  16396. /** @hidden */
  16397. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16398. private _deleteBuffer;
  16399. protected _format: Nullable<number>;
  16400. private _delayedOnLoad;
  16401. private _delayedOnError;
  16402. private _mimeType?;
  16403. /**
  16404. * Observable triggered once the texture has been loaded.
  16405. */
  16406. onLoadObservable: Observable<Texture>;
  16407. protected _isBlocking: boolean;
  16408. /**
  16409. * Is the texture preventing material to render while loading.
  16410. * If false, a default texture will be used instead of the loading one during the preparation step.
  16411. */
  16412. isBlocking: boolean;
  16413. /**
  16414. * Get the current sampling mode associated with the texture.
  16415. */
  16416. readonly samplingMode: number;
  16417. /**
  16418. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16419. */
  16420. readonly invertY: boolean;
  16421. /**
  16422. * Instantiates a new texture.
  16423. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16424. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16425. * @param url defines the url of the picture to load as a texture
  16426. * @param scene defines the scene or engine the texture will belong to
  16427. * @param noMipmap defines if the texture will require mip maps or not
  16428. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16429. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16430. * @param onLoad defines a callback triggered when the texture has been loaded
  16431. * @param onError defines a callback triggered when an error occurred during the loading session
  16432. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16433. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16434. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16435. * @param mimeType defines an optional mime type information
  16436. */
  16437. 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);
  16438. /**
  16439. * Update the url (and optional buffer) of this texture if url was null during construction.
  16440. * @param url the url of the texture
  16441. * @param buffer the buffer of the texture (defaults to null)
  16442. * @param onLoad callback called when the texture is loaded (defaults to null)
  16443. */
  16444. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16445. /**
  16446. * Finish the loading sequence of a texture flagged as delayed load.
  16447. * @hidden
  16448. */
  16449. delayLoad(): void;
  16450. private _prepareRowForTextureGeneration;
  16451. /**
  16452. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16453. * @returns the transform matrix of the texture.
  16454. */
  16455. getTextureMatrix(uBase?: number): Matrix;
  16456. /**
  16457. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16458. * @returns The reflection texture transform
  16459. */
  16460. getReflectionTextureMatrix(): Matrix;
  16461. /**
  16462. * Clones the texture.
  16463. * @returns the cloned texture
  16464. */
  16465. clone(): Texture;
  16466. /**
  16467. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16468. * @returns The JSON representation of the texture
  16469. */
  16470. serialize(): any;
  16471. /**
  16472. * Get the current class name of the texture useful for serialization or dynamic coding.
  16473. * @returns "Texture"
  16474. */
  16475. getClassName(): string;
  16476. /**
  16477. * Dispose the texture and release its associated resources.
  16478. */
  16479. dispose(): void;
  16480. /**
  16481. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16482. * @param parsedTexture Define the JSON representation of the texture
  16483. * @param scene Define the scene the parsed texture should be instantiated in
  16484. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16485. * @returns The parsed texture if successful
  16486. */
  16487. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16488. /**
  16489. * Creates a texture from its base 64 representation.
  16490. * @param data Define the base64 payload without the data: prefix
  16491. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16492. * @param scene Define the scene the texture should belong to
  16493. * @param noMipmap Forces the texture to not create mip map information if true
  16494. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16495. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16496. * @param onLoad define a callback triggered when the texture has been loaded
  16497. * @param onError define a callback triggered when an error occurred during the loading session
  16498. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16499. * @returns the created texture
  16500. */
  16501. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16502. /**
  16503. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16504. * @param data Define the base64 payload without the data: prefix
  16505. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16506. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16507. * @param scene Define the scene the texture should belong to
  16508. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16509. * @param noMipmap Forces the texture to not create mip map information if true
  16510. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16511. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16512. * @param onLoad define a callback triggered when the texture has been loaded
  16513. * @param onError define a callback triggered when an error occurred during the loading session
  16514. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16515. * @returns the created texture
  16516. */
  16517. 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;
  16518. }
  16519. }
  16520. declare module "babylonjs/PostProcesses/postProcessManager" {
  16521. import { Nullable } from "babylonjs/types";
  16522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16523. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16524. import { Scene } from "babylonjs/scene";
  16525. /**
  16526. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16527. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16528. */
  16529. export class PostProcessManager {
  16530. private _scene;
  16531. private _indexBuffer;
  16532. private _vertexBuffers;
  16533. /**
  16534. * Creates a new instance PostProcess
  16535. * @param scene The scene that the post process is associated with.
  16536. */
  16537. constructor(scene: Scene);
  16538. private _prepareBuffers;
  16539. private _buildIndexBuffer;
  16540. /**
  16541. * Rebuilds the vertex buffers of the manager.
  16542. * @hidden
  16543. */
  16544. _rebuild(): void;
  16545. /**
  16546. * Prepares a frame to be run through a post process.
  16547. * @param sourceTexture The input texture to the post procesess. (default: null)
  16548. * @param postProcesses An array of post processes to be run. (default: null)
  16549. * @returns True if the post processes were able to be run.
  16550. * @hidden
  16551. */
  16552. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16553. /**
  16554. * Manually render a set of post processes to a texture.
  16555. * @param postProcesses An array of post processes to be run.
  16556. * @param targetTexture The target texture to render to.
  16557. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16558. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16559. * @param lodLevel defines which lod of the texture to render to
  16560. */
  16561. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16562. /**
  16563. * Finalize the result of the output of the postprocesses.
  16564. * @param doNotPresent If true the result will not be displayed to the screen.
  16565. * @param targetTexture The target texture to render to.
  16566. * @param faceIndex The index of the face to bind the target texture to.
  16567. * @param postProcesses The array of post processes to render.
  16568. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16569. * @hidden
  16570. */
  16571. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16572. /**
  16573. * Disposes of the post process manager.
  16574. */
  16575. dispose(): void;
  16576. }
  16577. }
  16578. declare module "babylonjs/Misc/gradients" {
  16579. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16580. /** Interface used by value gradients (color, factor, ...) */
  16581. export interface IValueGradient {
  16582. /**
  16583. * Gets or sets the gradient value (between 0 and 1)
  16584. */
  16585. gradient: number;
  16586. }
  16587. /** Class used to store color4 gradient */
  16588. export class ColorGradient implements IValueGradient {
  16589. /**
  16590. * Gets or sets the gradient value (between 0 and 1)
  16591. */
  16592. gradient: number;
  16593. /**
  16594. * Gets or sets first associated color
  16595. */
  16596. color1: Color4;
  16597. /**
  16598. * Gets or sets second associated color
  16599. */
  16600. color2?: Color4;
  16601. /**
  16602. * Will get a color picked randomly between color1 and color2.
  16603. * If color2 is undefined then color1 will be used
  16604. * @param result defines the target Color4 to store the result in
  16605. */
  16606. getColorToRef(result: Color4): void;
  16607. }
  16608. /** Class used to store color 3 gradient */
  16609. export class Color3Gradient implements IValueGradient {
  16610. /**
  16611. * Gets or sets the gradient value (between 0 and 1)
  16612. */
  16613. gradient: number;
  16614. /**
  16615. * Gets or sets the associated color
  16616. */
  16617. color: Color3;
  16618. }
  16619. /** Class used to store factor gradient */
  16620. export class FactorGradient implements IValueGradient {
  16621. /**
  16622. * Gets or sets the gradient value (between 0 and 1)
  16623. */
  16624. gradient: number;
  16625. /**
  16626. * Gets or sets first associated factor
  16627. */
  16628. factor1: number;
  16629. /**
  16630. * Gets or sets second associated factor
  16631. */
  16632. factor2?: number;
  16633. /**
  16634. * Will get a number picked randomly between factor1 and factor2.
  16635. * If factor2 is undefined then factor1 will be used
  16636. * @returns the picked number
  16637. */
  16638. getFactor(): number;
  16639. }
  16640. /**
  16641. * Helper used to simplify some generic gradient tasks
  16642. */
  16643. export class GradientHelper {
  16644. /**
  16645. * Gets the current gradient from an array of IValueGradient
  16646. * @param ratio defines the current ratio to get
  16647. * @param gradients defines the array of IValueGradient
  16648. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16649. */
  16650. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16651. }
  16652. }
  16653. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16655. import { Nullable } from "babylonjs/types";
  16656. module "babylonjs/Engines/thinEngine" {
  16657. interface ThinEngine {
  16658. /**
  16659. * Creates a dynamic texture
  16660. * @param width defines the width of the texture
  16661. * @param height defines the height of the texture
  16662. * @param generateMipMaps defines if the engine should generate the mip levels
  16663. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16664. * @returns the dynamic texture inside an InternalTexture
  16665. */
  16666. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16667. /**
  16668. * Update the content of a dynamic texture
  16669. * @param texture defines the texture to update
  16670. * @param canvas defines the canvas containing the source
  16671. * @param invertY defines if data must be stored with Y axis inverted
  16672. * @param premulAlpha defines if alpha is stored as premultiplied
  16673. * @param format defines the format of the data
  16674. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16675. */
  16676. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16677. }
  16678. }
  16679. }
  16680. declare module "babylonjs/Misc/canvasGenerator" {
  16681. /**
  16682. * Helper class used to generate a canvas to manipulate images
  16683. */
  16684. export class CanvasGenerator {
  16685. /**
  16686. * Create a new canvas (or offscreen canvas depending on the context)
  16687. * @param width defines the expected width
  16688. * @param height defines the expected height
  16689. * @return a new canvas or offscreen canvas
  16690. */
  16691. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16692. }
  16693. }
  16694. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16695. import { Scene } from "babylonjs/scene";
  16696. import { Texture } from "babylonjs/Materials/Textures/texture";
  16697. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16698. /**
  16699. * A class extending Texture allowing drawing on a texture
  16700. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16701. */
  16702. export class DynamicTexture extends Texture {
  16703. private _generateMipMaps;
  16704. private _canvas;
  16705. private _context;
  16706. private _engine;
  16707. /**
  16708. * Creates a DynamicTexture
  16709. * @param name defines the name of the texture
  16710. * @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
  16711. * @param scene defines the scene where you want the texture
  16712. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16713. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16714. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16715. */
  16716. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16717. /**
  16718. * Get the current class name of the texture useful for serialization or dynamic coding.
  16719. * @returns "DynamicTexture"
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * Gets the current state of canRescale
  16724. */
  16725. readonly canRescale: boolean;
  16726. private _recreate;
  16727. /**
  16728. * Scales the texture
  16729. * @param ratio the scale factor to apply to both width and height
  16730. */
  16731. scale(ratio: number): void;
  16732. /**
  16733. * Resizes the texture
  16734. * @param width the new width
  16735. * @param height the new height
  16736. */
  16737. scaleTo(width: number, height: number): void;
  16738. /**
  16739. * Gets the context of the canvas used by the texture
  16740. * @returns the canvas context of the dynamic texture
  16741. */
  16742. getContext(): CanvasRenderingContext2D;
  16743. /**
  16744. * Clears the texture
  16745. */
  16746. clear(): void;
  16747. /**
  16748. * Updates the texture
  16749. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16750. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16751. */
  16752. update(invertY?: boolean, premulAlpha?: boolean): void;
  16753. /**
  16754. * Draws text onto the texture
  16755. * @param text defines the text to be drawn
  16756. * @param x defines the placement of the text from the left
  16757. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16758. * @param font defines the font to be used with font-style, font-size, font-name
  16759. * @param color defines the color used for the text
  16760. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16761. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16762. * @param update defines whether texture is immediately update (default is true)
  16763. */
  16764. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16765. /**
  16766. * Clones the texture
  16767. * @returns the clone of the texture.
  16768. */
  16769. clone(): DynamicTexture;
  16770. /**
  16771. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16772. * @returns a serialized dynamic texture object
  16773. */
  16774. serialize(): any;
  16775. /** @hidden */
  16776. _rebuild(): void;
  16777. }
  16778. }
  16779. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16780. import { Scene } from "babylonjs/scene";
  16781. import { ISceneComponent } from "babylonjs/sceneComponent";
  16782. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16783. module "babylonjs/abstractScene" {
  16784. interface AbstractScene {
  16785. /**
  16786. * The list of procedural textures added to the scene
  16787. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16788. */
  16789. proceduralTextures: Array<ProceduralTexture>;
  16790. }
  16791. }
  16792. /**
  16793. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16794. * in a given scene.
  16795. */
  16796. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16797. /**
  16798. * The component name helpfull to identify the component in the list of scene components.
  16799. */
  16800. readonly name: string;
  16801. /**
  16802. * The scene the component belongs to.
  16803. */
  16804. scene: Scene;
  16805. /**
  16806. * Creates a new instance of the component for the given scene
  16807. * @param scene Defines the scene to register the component in
  16808. */
  16809. constructor(scene: Scene);
  16810. /**
  16811. * Registers the component in a given scene
  16812. */
  16813. register(): void;
  16814. /**
  16815. * Rebuilds the elements related to this component in case of
  16816. * context lost for instance.
  16817. */
  16818. rebuild(): void;
  16819. /**
  16820. * Disposes the component and the associated ressources.
  16821. */
  16822. dispose(): void;
  16823. private _beforeClear;
  16824. }
  16825. }
  16826. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16827. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16828. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16829. module "babylonjs/Engines/thinEngine" {
  16830. interface ThinEngine {
  16831. /**
  16832. * Creates a new render target cube texture
  16833. * @param size defines the size of the texture
  16834. * @param options defines the options used to create the texture
  16835. * @returns a new render target cube texture stored in an InternalTexture
  16836. */
  16837. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16838. }
  16839. }
  16840. }
  16841. declare module "babylonjs/Shaders/procedural.vertex" {
  16842. /** @hidden */
  16843. export var proceduralVertexShader: {
  16844. name: string;
  16845. shader: string;
  16846. };
  16847. }
  16848. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16849. import { Observable } from "babylonjs/Misc/observable";
  16850. import { Nullable } from "babylonjs/types";
  16851. import { Scene } from "babylonjs/scene";
  16852. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16853. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16854. import { Effect } from "babylonjs/Materials/effect";
  16855. import { Texture } from "babylonjs/Materials/Textures/texture";
  16856. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16857. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16858. import "babylonjs/Shaders/procedural.vertex";
  16859. /**
  16860. * 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.
  16861. * This is the base class of any Procedural texture and contains most of the shareable code.
  16862. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16863. */
  16864. export class ProceduralTexture extends Texture {
  16865. isCube: boolean;
  16866. /**
  16867. * Define if the texture is enabled or not (disabled texture will not render)
  16868. */
  16869. isEnabled: boolean;
  16870. /**
  16871. * Define if the texture must be cleared before rendering (default is true)
  16872. */
  16873. autoClear: boolean;
  16874. /**
  16875. * Callback called when the texture is generated
  16876. */
  16877. onGenerated: () => void;
  16878. /**
  16879. * Event raised when the texture is generated
  16880. */
  16881. onGeneratedObservable: Observable<ProceduralTexture>;
  16882. /** @hidden */
  16883. _generateMipMaps: boolean;
  16884. /** @hidden **/
  16885. _effect: Effect;
  16886. /** @hidden */
  16887. _textures: {
  16888. [key: string]: Texture;
  16889. };
  16890. private _size;
  16891. private _currentRefreshId;
  16892. private _refreshRate;
  16893. private _vertexBuffers;
  16894. private _indexBuffer;
  16895. private _uniforms;
  16896. private _samplers;
  16897. private _fragment;
  16898. private _floats;
  16899. private _ints;
  16900. private _floatsArrays;
  16901. private _colors3;
  16902. private _colors4;
  16903. private _vectors2;
  16904. private _vectors3;
  16905. private _matrices;
  16906. private _fallbackTexture;
  16907. private _fallbackTextureUsed;
  16908. private _engine;
  16909. private _cachedDefines;
  16910. private _contentUpdateId;
  16911. private _contentData;
  16912. /**
  16913. * Instantiates a new procedural texture.
  16914. * 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.
  16915. * This is the base class of any Procedural texture and contains most of the shareable code.
  16916. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16917. * @param name Define the name of the texture
  16918. * @param size Define the size of the texture to create
  16919. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16920. * @param scene Define the scene the texture belongs to
  16921. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16922. * @param generateMipMaps Define if the texture should creates mip maps or not
  16923. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16924. */
  16925. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16926. /**
  16927. * The effect that is created when initializing the post process.
  16928. * @returns The created effect corresponding the the postprocess.
  16929. */
  16930. getEffect(): Effect;
  16931. /**
  16932. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16933. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16934. */
  16935. getContent(): Nullable<ArrayBufferView>;
  16936. private _createIndexBuffer;
  16937. /** @hidden */
  16938. _rebuild(): void;
  16939. /**
  16940. * Resets the texture in order to recreate its associated resources.
  16941. * This can be called in case of context loss
  16942. */
  16943. reset(): void;
  16944. protected _getDefines(): string;
  16945. /**
  16946. * Is the texture ready to be used ? (rendered at least once)
  16947. * @returns true if ready, otherwise, false.
  16948. */
  16949. isReady(): boolean;
  16950. /**
  16951. * Resets the refresh counter of the texture and start bak from scratch.
  16952. * Could be useful to regenerate the texture if it is setup to render only once.
  16953. */
  16954. resetRefreshCounter(): void;
  16955. /**
  16956. * Set the fragment shader to use in order to render the texture.
  16957. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16958. */
  16959. setFragment(fragment: any): void;
  16960. /**
  16961. * Define the refresh rate of the texture or the rendering frequency.
  16962. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16963. */
  16964. refreshRate: number;
  16965. /** @hidden */
  16966. _shouldRender(): boolean;
  16967. /**
  16968. * Get the size the texture is rendering at.
  16969. * @returns the size (texture is always squared)
  16970. */
  16971. getRenderSize(): number;
  16972. /**
  16973. * Resize the texture to new value.
  16974. * @param size Define the new size the texture should have
  16975. * @param generateMipMaps Define whether the new texture should create mip maps
  16976. */
  16977. resize(size: number, generateMipMaps: boolean): void;
  16978. private _checkUniform;
  16979. /**
  16980. * Set a texture in the shader program used to render.
  16981. * @param name Define the name of the uniform samplers as defined in the shader
  16982. * @param texture Define the texture to bind to this sampler
  16983. * @return the texture itself allowing "fluent" like uniform updates
  16984. */
  16985. setTexture(name: string, texture: Texture): ProceduralTexture;
  16986. /**
  16987. * Set a float in the shader.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the texture itself allowing "fluent" like uniform updates
  16991. */
  16992. setFloat(name: string, value: number): ProceduralTexture;
  16993. /**
  16994. * Set a int in the shader.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the texture itself allowing "fluent" like uniform updates
  16998. */
  16999. setInt(name: string, value: number): ProceduralTexture;
  17000. /**
  17001. * Set an array of floats in the shader.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the texture itself allowing "fluent" like uniform updates
  17005. */
  17006. setFloats(name: string, value: number[]): ProceduralTexture;
  17007. /**
  17008. * Set a vec3 in the shader from a Color3.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the texture itself allowing "fluent" like uniform updates
  17012. */
  17013. setColor3(name: string, value: Color3): ProceduralTexture;
  17014. /**
  17015. * Set a vec4 in the shader from a Color4.
  17016. * @param name Define the name of the uniform as defined in the shader
  17017. * @param value Define the value to give to the uniform
  17018. * @return the texture itself allowing "fluent" like uniform updates
  17019. */
  17020. setColor4(name: string, value: Color4): ProceduralTexture;
  17021. /**
  17022. * Set a vec2 in the shader from a Vector2.
  17023. * @param name Define the name of the uniform as defined in the shader
  17024. * @param value Define the value to give to the uniform
  17025. * @return the texture itself allowing "fluent" like uniform updates
  17026. */
  17027. setVector2(name: string, value: Vector2): ProceduralTexture;
  17028. /**
  17029. * Set a vec3 in the shader from a Vector3.
  17030. * @param name Define the name of the uniform as defined in the shader
  17031. * @param value Define the value to give to the uniform
  17032. * @return the texture itself allowing "fluent" like uniform updates
  17033. */
  17034. setVector3(name: string, value: Vector3): ProceduralTexture;
  17035. /**
  17036. * Set a mat4 in the shader from a MAtrix.
  17037. * @param name Define the name of the uniform as defined in the shader
  17038. * @param value Define the value to give to the uniform
  17039. * @return the texture itself allowing "fluent" like uniform updates
  17040. */
  17041. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17042. /**
  17043. * Render the texture to its associated render target.
  17044. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17045. */
  17046. render(useCameraPostProcess?: boolean): void;
  17047. /**
  17048. * Clone the texture.
  17049. * @returns the cloned texture
  17050. */
  17051. clone(): ProceduralTexture;
  17052. /**
  17053. * Dispose the texture and release its asoociated resources.
  17054. */
  17055. dispose(): void;
  17056. }
  17057. }
  17058. declare module "babylonjs/Particles/baseParticleSystem" {
  17059. import { Nullable } from "babylonjs/types";
  17060. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17062. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17063. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17064. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17065. import { Scene } from "babylonjs/scene";
  17066. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17067. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17068. import { Texture } from "babylonjs/Materials/Textures/texture";
  17069. import { Color4 } from "babylonjs/Maths/math.color";
  17070. import { Animation } from "babylonjs/Animations/animation";
  17071. /**
  17072. * This represents the base class for particle system in Babylon.
  17073. * 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.
  17074. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17075. * @example https://doc.babylonjs.com/babylon101/particles
  17076. */
  17077. export class BaseParticleSystem {
  17078. /**
  17079. * Source color is added to the destination color without alpha affecting the result
  17080. */
  17081. static BLENDMODE_ONEONE: number;
  17082. /**
  17083. * Blend current color and particle color using particle’s alpha
  17084. */
  17085. static BLENDMODE_STANDARD: number;
  17086. /**
  17087. * Add current color and particle color multiplied by particle’s alpha
  17088. */
  17089. static BLENDMODE_ADD: number;
  17090. /**
  17091. * Multiply current color with particle color
  17092. */
  17093. static BLENDMODE_MULTIPLY: number;
  17094. /**
  17095. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17096. */
  17097. static BLENDMODE_MULTIPLYADD: number;
  17098. /**
  17099. * List of animations used by the particle system.
  17100. */
  17101. animations: Animation[];
  17102. /**
  17103. * The id of the Particle system.
  17104. */
  17105. id: string;
  17106. /**
  17107. * The friendly name of the Particle system.
  17108. */
  17109. name: string;
  17110. /**
  17111. * The rendering group used by the Particle system to chose when to render.
  17112. */
  17113. renderingGroupId: number;
  17114. /**
  17115. * The emitter represents the Mesh or position we are attaching the particle system to.
  17116. */
  17117. emitter: Nullable<AbstractMesh | Vector3>;
  17118. /**
  17119. * The maximum number of particles to emit per frame
  17120. */
  17121. emitRate: number;
  17122. /**
  17123. * If you want to launch only a few particles at once, that can be done, as well.
  17124. */
  17125. manualEmitCount: number;
  17126. /**
  17127. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17128. */
  17129. updateSpeed: number;
  17130. /**
  17131. * The amount of time the particle system is running (depends of the overall update speed).
  17132. */
  17133. targetStopDuration: number;
  17134. /**
  17135. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17136. */
  17137. disposeOnStop: boolean;
  17138. /**
  17139. * Minimum power of emitting particles.
  17140. */
  17141. minEmitPower: number;
  17142. /**
  17143. * Maximum power of emitting particles.
  17144. */
  17145. maxEmitPower: number;
  17146. /**
  17147. * Minimum life time of emitting particles.
  17148. */
  17149. minLifeTime: number;
  17150. /**
  17151. * Maximum life time of emitting particles.
  17152. */
  17153. maxLifeTime: number;
  17154. /**
  17155. * Minimum Size of emitting particles.
  17156. */
  17157. minSize: number;
  17158. /**
  17159. * Maximum Size of emitting particles.
  17160. */
  17161. maxSize: number;
  17162. /**
  17163. * Minimum scale of emitting particles on X axis.
  17164. */
  17165. minScaleX: number;
  17166. /**
  17167. * Maximum scale of emitting particles on X axis.
  17168. */
  17169. maxScaleX: number;
  17170. /**
  17171. * Minimum scale of emitting particles on Y axis.
  17172. */
  17173. minScaleY: number;
  17174. /**
  17175. * Maximum scale of emitting particles on Y axis.
  17176. */
  17177. maxScaleY: number;
  17178. /**
  17179. * Gets or sets the minimal initial rotation in radians.
  17180. */
  17181. minInitialRotation: number;
  17182. /**
  17183. * Gets or sets the maximal initial rotation in radians.
  17184. */
  17185. maxInitialRotation: number;
  17186. /**
  17187. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17188. */
  17189. minAngularSpeed: number;
  17190. /**
  17191. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17192. */
  17193. maxAngularSpeed: number;
  17194. /**
  17195. * The texture used to render each particle. (this can be a spritesheet)
  17196. */
  17197. particleTexture: Nullable<Texture>;
  17198. /**
  17199. * The layer mask we are rendering the particles through.
  17200. */
  17201. layerMask: number;
  17202. /**
  17203. * This can help using your own shader to render the particle system.
  17204. * The according effect will be created
  17205. */
  17206. customShader: any;
  17207. /**
  17208. * By default particle system starts as soon as they are created. This prevents the
  17209. * automatic start to happen and let you decide when to start emitting particles.
  17210. */
  17211. preventAutoStart: boolean;
  17212. private _noiseTexture;
  17213. /**
  17214. * Gets or sets a texture used to add random noise to particle positions
  17215. */
  17216. noiseTexture: Nullable<ProceduralTexture>;
  17217. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17218. noiseStrength: Vector3;
  17219. /**
  17220. * Callback triggered when the particle animation is ending.
  17221. */
  17222. onAnimationEnd: Nullable<() => void>;
  17223. /**
  17224. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17225. */
  17226. blendMode: number;
  17227. /**
  17228. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17229. * to override the particles.
  17230. */
  17231. forceDepthWrite: boolean;
  17232. /** 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 */
  17233. preWarmCycles: number;
  17234. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17235. preWarmStepOffset: number;
  17236. /**
  17237. * 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)
  17238. */
  17239. spriteCellChangeSpeed: number;
  17240. /**
  17241. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17242. */
  17243. startSpriteCellID: number;
  17244. /**
  17245. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17246. */
  17247. endSpriteCellID: number;
  17248. /**
  17249. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17250. */
  17251. spriteCellWidth: number;
  17252. /**
  17253. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17254. */
  17255. spriteCellHeight: number;
  17256. /**
  17257. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17258. */
  17259. spriteRandomStartCell: boolean;
  17260. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17261. translationPivot: Vector2;
  17262. /** @hidden */
  17263. protected _isAnimationSheetEnabled: boolean;
  17264. /**
  17265. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17266. */
  17267. beginAnimationOnStart: boolean;
  17268. /**
  17269. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17270. */
  17271. beginAnimationFrom: number;
  17272. /**
  17273. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17274. */
  17275. beginAnimationTo: number;
  17276. /**
  17277. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17278. */
  17279. beginAnimationLoop: boolean;
  17280. /**
  17281. * Gets or sets a world offset applied to all particles
  17282. */
  17283. worldOffset: Vector3;
  17284. /**
  17285. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17286. */
  17287. isAnimationSheetEnabled: boolean;
  17288. /**
  17289. * Get hosting scene
  17290. * @returns the scene
  17291. */
  17292. getScene(): Scene;
  17293. /**
  17294. * You can use gravity if you want to give an orientation to your particles.
  17295. */
  17296. gravity: Vector3;
  17297. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17298. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17299. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17300. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17301. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17302. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17303. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17304. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17305. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17306. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17307. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17308. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17309. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17310. /**
  17311. * Defines the delay in milliseconds before starting the system (0 by default)
  17312. */
  17313. startDelay: number;
  17314. /**
  17315. * Gets the current list of drag gradients.
  17316. * You must use addDragGradient and removeDragGradient to udpate this list
  17317. * @returns the list of drag gradients
  17318. */
  17319. getDragGradients(): Nullable<Array<FactorGradient>>;
  17320. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17321. limitVelocityDamping: number;
  17322. /**
  17323. * Gets the current list of limit velocity gradients.
  17324. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17325. * @returns the list of limit velocity gradients
  17326. */
  17327. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17328. /**
  17329. * Gets the current list of color gradients.
  17330. * You must use addColorGradient and removeColorGradient to udpate this list
  17331. * @returns the list of color gradients
  17332. */
  17333. getColorGradients(): Nullable<Array<ColorGradient>>;
  17334. /**
  17335. * Gets the current list of size gradients.
  17336. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17337. * @returns the list of size gradients
  17338. */
  17339. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17340. /**
  17341. * Gets the current list of color remap gradients.
  17342. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17343. * @returns the list of color remap gradients
  17344. */
  17345. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17346. /**
  17347. * Gets the current list of alpha remap gradients.
  17348. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17349. * @returns the list of alpha remap gradients
  17350. */
  17351. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17352. /**
  17353. * Gets the current list of life time gradients.
  17354. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17355. * @returns the list of life time gradients
  17356. */
  17357. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17358. /**
  17359. * Gets the current list of angular speed gradients.
  17360. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17361. * @returns the list of angular speed gradients
  17362. */
  17363. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17364. /**
  17365. * Gets the current list of velocity gradients.
  17366. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17367. * @returns the list of velocity gradients
  17368. */
  17369. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17370. /**
  17371. * Gets the current list of start size gradients.
  17372. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17373. * @returns the list of start size gradients
  17374. */
  17375. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17376. /**
  17377. * Gets the current list of emit rate gradients.
  17378. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17379. * @returns the list of emit rate gradients
  17380. */
  17381. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17382. /**
  17383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17384. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17385. */
  17386. direction1: Vector3;
  17387. /**
  17388. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17389. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17390. */
  17391. direction2: Vector3;
  17392. /**
  17393. * 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.
  17394. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17395. */
  17396. minEmitBox: Vector3;
  17397. /**
  17398. * 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.
  17399. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17400. */
  17401. maxEmitBox: Vector3;
  17402. /**
  17403. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17404. */
  17405. color1: Color4;
  17406. /**
  17407. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17408. */
  17409. color2: Color4;
  17410. /**
  17411. * Color the particle will have at the end of its lifetime
  17412. */
  17413. colorDead: Color4;
  17414. /**
  17415. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17416. */
  17417. textureMask: Color4;
  17418. /**
  17419. * The particle emitter type defines the emitter used by the particle system.
  17420. * It can be for example box, sphere, or cone...
  17421. */
  17422. particleEmitterType: IParticleEmitterType;
  17423. /** @hidden */
  17424. _isSubEmitter: boolean;
  17425. /**
  17426. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17427. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17428. */
  17429. billboardMode: number;
  17430. protected _isBillboardBased: boolean;
  17431. /**
  17432. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17433. */
  17434. isBillboardBased: boolean;
  17435. /**
  17436. * The scene the particle system belongs to.
  17437. */
  17438. protected _scene: Scene;
  17439. /**
  17440. * Local cache of defines for image processing.
  17441. */
  17442. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17443. /**
  17444. * Default configuration related to image processing available in the standard Material.
  17445. */
  17446. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17447. /**
  17448. * Gets the image processing configuration used either in this material.
  17449. */
  17450. /**
  17451. * Sets the Default image processing configuration used either in the this material.
  17452. *
  17453. * If sets to null, the scene one is in use.
  17454. */
  17455. imageProcessingConfiguration: ImageProcessingConfiguration;
  17456. /**
  17457. * Attaches a new image processing configuration to the Standard Material.
  17458. * @param configuration
  17459. */
  17460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17461. /** @hidden */
  17462. protected _reset(): void;
  17463. /** @hidden */
  17464. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17465. /**
  17466. * Instantiates a particle system.
  17467. * 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.
  17468. * @param name The name of the particle system
  17469. */
  17470. constructor(name: string);
  17471. /**
  17472. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17475. * @returns the emitter
  17476. */
  17477. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17478. /**
  17479. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17480. * @param radius The radius of the hemisphere to emit from
  17481. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17482. * @returns the emitter
  17483. */
  17484. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17485. /**
  17486. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17487. * @param radius The radius of the sphere to emit from
  17488. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17489. * @returns the emitter
  17490. */
  17491. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17492. /**
  17493. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17494. * @param radius The radius of the sphere to emit from
  17495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17497. * @returns the emitter
  17498. */
  17499. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17500. /**
  17501. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17502. * @param radius The radius of the emission cylinder
  17503. * @param height The height of the emission cylinder
  17504. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17505. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17506. * @returns the emitter
  17507. */
  17508. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17509. /**
  17510. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17511. * @param radius The radius of the cylinder to emit from
  17512. * @param height The height of the emission cylinder
  17513. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17516. * @returns the emitter
  17517. */
  17518. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17519. /**
  17520. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17521. * @param radius The radius of the cone to emit from
  17522. * @param angle The base angle of the cone
  17523. * @returns the emitter
  17524. */
  17525. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17526. /**
  17527. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17530. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17531. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17532. * @returns the emitter
  17533. */
  17534. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17535. }
  17536. }
  17537. declare module "babylonjs/Particles/subEmitter" {
  17538. import { Scene } from "babylonjs/scene";
  17539. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17540. /**
  17541. * Type of sub emitter
  17542. */
  17543. export enum SubEmitterType {
  17544. /**
  17545. * Attached to the particle over it's lifetime
  17546. */
  17547. ATTACHED = 0,
  17548. /**
  17549. * Created when the particle dies
  17550. */
  17551. END = 1
  17552. }
  17553. /**
  17554. * Sub emitter class used to emit particles from an existing particle
  17555. */
  17556. export class SubEmitter {
  17557. /**
  17558. * the particle system to be used by the sub emitter
  17559. */
  17560. particleSystem: ParticleSystem;
  17561. /**
  17562. * Type of the submitter (Default: END)
  17563. */
  17564. type: SubEmitterType;
  17565. /**
  17566. * 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)
  17567. * Note: This only is supported when using an emitter of type Mesh
  17568. */
  17569. inheritDirection: boolean;
  17570. /**
  17571. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17572. */
  17573. inheritedVelocityAmount: number;
  17574. /**
  17575. * Creates a sub emitter
  17576. * @param particleSystem the particle system to be used by the sub emitter
  17577. */
  17578. constructor(
  17579. /**
  17580. * the particle system to be used by the sub emitter
  17581. */
  17582. particleSystem: ParticleSystem);
  17583. /**
  17584. * Clones the sub emitter
  17585. * @returns the cloned sub emitter
  17586. */
  17587. clone(): SubEmitter;
  17588. /**
  17589. * Serialize current object to a JSON object
  17590. * @returns the serialized object
  17591. */
  17592. serialize(): any;
  17593. /** @hidden */
  17594. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17595. /**
  17596. * Creates a new SubEmitter from a serialized JSON version
  17597. * @param serializationObject defines the JSON object to read from
  17598. * @param scene defines the hosting scene
  17599. * @param rootUrl defines the rootUrl for data loading
  17600. * @returns a new SubEmitter
  17601. */
  17602. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17603. /** Release associated resources */
  17604. dispose(): void;
  17605. }
  17606. }
  17607. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17608. /** @hidden */
  17609. export var clipPlaneFragmentDeclaration: {
  17610. name: string;
  17611. shader: string;
  17612. };
  17613. }
  17614. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17615. /** @hidden */
  17616. export var imageProcessingDeclaration: {
  17617. name: string;
  17618. shader: string;
  17619. };
  17620. }
  17621. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17622. /** @hidden */
  17623. export var imageProcessingFunctions: {
  17624. name: string;
  17625. shader: string;
  17626. };
  17627. }
  17628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17629. /** @hidden */
  17630. export var clipPlaneFragment: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Shaders/particles.fragment" {
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17637. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17639. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17640. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17641. /** @hidden */
  17642. export var particlesPixelShader: {
  17643. name: string;
  17644. shader: string;
  17645. };
  17646. }
  17647. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17648. /** @hidden */
  17649. export var clipPlaneVertexDeclaration: {
  17650. name: string;
  17651. shader: string;
  17652. };
  17653. }
  17654. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17655. /** @hidden */
  17656. export var clipPlaneVertex: {
  17657. name: string;
  17658. shader: string;
  17659. };
  17660. }
  17661. declare module "babylonjs/Shaders/particles.vertex" {
  17662. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17663. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17664. /** @hidden */
  17665. export var particlesVertexShader: {
  17666. name: string;
  17667. shader: string;
  17668. };
  17669. }
  17670. declare module "babylonjs/Particles/particleSystem" {
  17671. import { Nullable } from "babylonjs/types";
  17672. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17673. import { Observable } from "babylonjs/Misc/observable";
  17674. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17675. import { Effect } from "babylonjs/Materials/effect";
  17676. import { Scene, IDisposable } from "babylonjs/scene";
  17677. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17678. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17679. import { Particle } from "babylonjs/Particles/particle";
  17680. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17681. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17682. import "babylonjs/Shaders/particles.fragment";
  17683. import "babylonjs/Shaders/particles.vertex";
  17684. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17685. /**
  17686. * This represents a particle system in Babylon.
  17687. * 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.
  17688. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17689. * @example https://doc.babylonjs.com/babylon101/particles
  17690. */
  17691. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17692. /**
  17693. * Billboard mode will only apply to Y axis
  17694. */
  17695. static readonly BILLBOARDMODE_Y: number;
  17696. /**
  17697. * Billboard mode will apply to all axes
  17698. */
  17699. static readonly BILLBOARDMODE_ALL: number;
  17700. /**
  17701. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17702. */
  17703. static readonly BILLBOARDMODE_STRETCHED: number;
  17704. /**
  17705. * This function can be defined to provide custom update for active particles.
  17706. * This function will be called instead of regular update (age, position, color, etc.).
  17707. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17708. */
  17709. updateFunction: (particles: Particle[]) => void;
  17710. private _emitterWorldMatrix;
  17711. /**
  17712. * This function can be defined to specify initial direction for every new particle.
  17713. * It by default use the emitterType defined function
  17714. */
  17715. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17716. /**
  17717. * This function can be defined to specify initial position for every new particle.
  17718. * It by default use the emitterType defined function
  17719. */
  17720. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17721. /**
  17722. * @hidden
  17723. */
  17724. _inheritedVelocityOffset: Vector3;
  17725. /**
  17726. * An event triggered when the system is disposed
  17727. */
  17728. onDisposeObservable: Observable<ParticleSystem>;
  17729. private _onDisposeObserver;
  17730. /**
  17731. * Sets a callback that will be triggered when the system is disposed
  17732. */
  17733. onDispose: () => void;
  17734. private _particles;
  17735. private _epsilon;
  17736. private _capacity;
  17737. private _stockParticles;
  17738. private _newPartsExcess;
  17739. private _vertexData;
  17740. private _vertexBuffer;
  17741. private _vertexBuffers;
  17742. private _spriteBuffer;
  17743. private _indexBuffer;
  17744. private _effect;
  17745. private _customEffect;
  17746. private _cachedDefines;
  17747. private _scaledColorStep;
  17748. private _colorDiff;
  17749. private _scaledDirection;
  17750. private _scaledGravity;
  17751. private _currentRenderId;
  17752. private _alive;
  17753. private _useInstancing;
  17754. private _started;
  17755. private _stopped;
  17756. private _actualFrame;
  17757. private _scaledUpdateSpeed;
  17758. private _vertexBufferSize;
  17759. /** @hidden */
  17760. _currentEmitRateGradient: Nullable<FactorGradient>;
  17761. /** @hidden */
  17762. _currentEmitRate1: number;
  17763. /** @hidden */
  17764. _currentEmitRate2: number;
  17765. /** @hidden */
  17766. _currentStartSizeGradient: Nullable<FactorGradient>;
  17767. /** @hidden */
  17768. _currentStartSize1: number;
  17769. /** @hidden */
  17770. _currentStartSize2: number;
  17771. private readonly _rawTextureWidth;
  17772. private _rampGradientsTexture;
  17773. private _useRampGradients;
  17774. /** Gets or sets a boolean indicating that ramp gradients must be used
  17775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17776. */
  17777. useRampGradients: boolean;
  17778. /**
  17779. * 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.
  17780. * 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: [])
  17781. */
  17782. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17783. private _subEmitters;
  17784. /**
  17785. * @hidden
  17786. * If the particle systems emitter should be disposed when the particle system is disposed
  17787. */
  17788. _disposeEmitterOnDispose: boolean;
  17789. /**
  17790. * The current active Sub-systems, this property is used by the root particle system only.
  17791. */
  17792. activeSubSystems: Array<ParticleSystem>;
  17793. private _rootParticleSystem;
  17794. /**
  17795. * Gets the current list of active particles
  17796. */
  17797. readonly particles: Particle[];
  17798. /**
  17799. * Returns the string "ParticleSystem"
  17800. * @returns a string containing the class name
  17801. */
  17802. getClassName(): string;
  17803. /**
  17804. * Instantiates a particle system.
  17805. * 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.
  17806. * @param name The name of the particle system
  17807. * @param capacity The max number of particles alive at the same time
  17808. * @param scene The scene the particle system belongs to
  17809. * @param customEffect a custom effect used to change the way particles are rendered by default
  17810. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17811. * @param epsilon Offset used to render the particles
  17812. */
  17813. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17814. private _addFactorGradient;
  17815. private _removeFactorGradient;
  17816. /**
  17817. * Adds a new life time gradient
  17818. * @param gradient defines the gradient to use (between 0 and 1)
  17819. * @param factor defines the life time factor to affect to the specified gradient
  17820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17821. * @returns the current particle system
  17822. */
  17823. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17824. /**
  17825. * Remove a specific life time gradient
  17826. * @param gradient defines the gradient to remove
  17827. * @returns the current particle system
  17828. */
  17829. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17830. /**
  17831. * Adds a new size gradient
  17832. * @param gradient defines the gradient to use (between 0 and 1)
  17833. * @param factor defines the size factor to affect to the specified gradient
  17834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17835. * @returns the current particle system
  17836. */
  17837. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17838. /**
  17839. * Remove a specific size gradient
  17840. * @param gradient defines the gradient to remove
  17841. * @returns the current particle system
  17842. */
  17843. removeSizeGradient(gradient: number): IParticleSystem;
  17844. /**
  17845. * Adds a new color remap gradient
  17846. * @param gradient defines the gradient to use (between 0 and 1)
  17847. * @param min defines the color remap minimal range
  17848. * @param max defines the color remap maximal range
  17849. * @returns the current particle system
  17850. */
  17851. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17852. /**
  17853. * Remove a specific color remap gradient
  17854. * @param gradient defines the gradient to remove
  17855. * @returns the current particle system
  17856. */
  17857. removeColorRemapGradient(gradient: number): IParticleSystem;
  17858. /**
  17859. * Adds a new alpha remap gradient
  17860. * @param gradient defines the gradient to use (between 0 and 1)
  17861. * @param min defines the alpha remap minimal range
  17862. * @param max defines the alpha remap maximal range
  17863. * @returns the current particle system
  17864. */
  17865. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17866. /**
  17867. * Remove a specific alpha remap gradient
  17868. * @param gradient defines the gradient to remove
  17869. * @returns the current particle system
  17870. */
  17871. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17872. /**
  17873. * Adds a new angular speed gradient
  17874. * @param gradient defines the gradient to use (between 0 and 1)
  17875. * @param factor defines the angular speed to affect to the specified gradient
  17876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17877. * @returns the current particle system
  17878. */
  17879. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17880. /**
  17881. * Remove a specific angular speed gradient
  17882. * @param gradient defines the gradient to remove
  17883. * @returns the current particle system
  17884. */
  17885. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17886. /**
  17887. * Adds a new velocity gradient
  17888. * @param gradient defines the gradient to use (between 0 and 1)
  17889. * @param factor defines the velocity to affect to the specified gradient
  17890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17891. * @returns the current particle system
  17892. */
  17893. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17894. /**
  17895. * Remove a specific velocity gradient
  17896. * @param gradient defines the gradient to remove
  17897. * @returns the current particle system
  17898. */
  17899. removeVelocityGradient(gradient: number): IParticleSystem;
  17900. /**
  17901. * Adds a new limit velocity gradient
  17902. * @param gradient defines the gradient to use (between 0 and 1)
  17903. * @param factor defines the limit velocity value to affect to the specified gradient
  17904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17905. * @returns the current particle system
  17906. */
  17907. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17908. /**
  17909. * Remove a specific limit velocity gradient
  17910. * @param gradient defines the gradient to remove
  17911. * @returns the current particle system
  17912. */
  17913. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17914. /**
  17915. * Adds a new drag gradient
  17916. * @param gradient defines the gradient to use (between 0 and 1)
  17917. * @param factor defines the drag value to affect to the specified gradient
  17918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17919. * @returns the current particle system
  17920. */
  17921. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17922. /**
  17923. * Remove a specific drag gradient
  17924. * @param gradient defines the gradient to remove
  17925. * @returns the current particle system
  17926. */
  17927. removeDragGradient(gradient: number): IParticleSystem;
  17928. /**
  17929. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17930. * @param gradient defines the gradient to use (between 0 and 1)
  17931. * @param factor defines the emit rate value to affect to the specified gradient
  17932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17933. * @returns the current particle system
  17934. */
  17935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17936. /**
  17937. * Remove a specific emit rate gradient
  17938. * @param gradient defines the gradient to remove
  17939. * @returns the current particle system
  17940. */
  17941. removeEmitRateGradient(gradient: number): IParticleSystem;
  17942. /**
  17943. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17944. * @param gradient defines the gradient to use (between 0 and 1)
  17945. * @param factor defines the start size value to affect to the specified gradient
  17946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17947. * @returns the current particle system
  17948. */
  17949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17950. /**
  17951. * Remove a specific start size gradient
  17952. * @param gradient defines the gradient to remove
  17953. * @returns the current particle system
  17954. */
  17955. removeStartSizeGradient(gradient: number): IParticleSystem;
  17956. private _createRampGradientTexture;
  17957. /**
  17958. * Gets the current list of ramp gradients.
  17959. * You must use addRampGradient and removeRampGradient to udpate this list
  17960. * @returns the list of ramp gradients
  17961. */
  17962. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17963. /**
  17964. * Adds a new ramp gradient used to remap particle colors
  17965. * @param gradient defines the gradient to use (between 0 and 1)
  17966. * @param color defines the color to affect to the specified gradient
  17967. * @returns the current particle system
  17968. */
  17969. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17970. /**
  17971. * Remove a specific ramp gradient
  17972. * @param gradient defines the gradient to remove
  17973. * @returns the current particle system
  17974. */
  17975. removeRampGradient(gradient: number): ParticleSystem;
  17976. /**
  17977. * Adds a new color gradient
  17978. * @param gradient defines the gradient to use (between 0 and 1)
  17979. * @param color1 defines the color to affect to the specified gradient
  17980. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17981. * @returns this particle system
  17982. */
  17983. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17984. /**
  17985. * Remove a specific color gradient
  17986. * @param gradient defines the gradient to remove
  17987. * @returns this particle system
  17988. */
  17989. removeColorGradient(gradient: number): IParticleSystem;
  17990. private _fetchR;
  17991. protected _reset(): void;
  17992. private _resetEffect;
  17993. private _createVertexBuffers;
  17994. private _createIndexBuffer;
  17995. /**
  17996. * Gets the maximum number of particles active at the same time.
  17997. * @returns The max number of active particles.
  17998. */
  17999. getCapacity(): number;
  18000. /**
  18001. * Gets whether there are still active particles in the system.
  18002. * @returns True if it is alive, otherwise false.
  18003. */
  18004. isAlive(): boolean;
  18005. /**
  18006. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18007. * @returns True if it has been started, otherwise false.
  18008. */
  18009. isStarted(): boolean;
  18010. private _prepareSubEmitterInternalArray;
  18011. /**
  18012. * Starts the particle system and begins to emit
  18013. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18014. */
  18015. start(delay?: number): void;
  18016. /**
  18017. * Stops the particle system.
  18018. * @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.
  18019. */
  18020. stop(stopSubEmitters?: boolean): void;
  18021. /**
  18022. * Remove all active particles
  18023. */
  18024. reset(): void;
  18025. /**
  18026. * @hidden (for internal use only)
  18027. */
  18028. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18029. /**
  18030. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18031. * Its lifetime will start back at 0.
  18032. */
  18033. recycleParticle: (particle: Particle) => void;
  18034. private _stopSubEmitters;
  18035. private _createParticle;
  18036. private _removeFromRoot;
  18037. private _emitFromParticle;
  18038. private _update;
  18039. /** @hidden */
  18040. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18041. /** @hidden */
  18042. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18043. /** @hidden */
  18044. private _getEffect;
  18045. /**
  18046. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18047. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18048. */
  18049. animate(preWarmOnly?: boolean): void;
  18050. private _appendParticleVertices;
  18051. /**
  18052. * Rebuilds the particle system.
  18053. */
  18054. rebuild(): void;
  18055. /**
  18056. * Is this system ready to be used/rendered
  18057. * @return true if the system is ready
  18058. */
  18059. isReady(): boolean;
  18060. private _render;
  18061. /**
  18062. * Renders the particle system in its current state.
  18063. * @returns the current number of particles
  18064. */
  18065. render(): number;
  18066. /**
  18067. * Disposes the particle system and free the associated resources
  18068. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18069. */
  18070. dispose(disposeTexture?: boolean): void;
  18071. /**
  18072. * Clones the particle system.
  18073. * @param name The name of the cloned object
  18074. * @param newEmitter The new emitter to use
  18075. * @returns the cloned particle system
  18076. */
  18077. clone(name: string, newEmitter: any): ParticleSystem;
  18078. /**
  18079. * Serializes the particle system to a JSON object.
  18080. * @returns the JSON object
  18081. */
  18082. serialize(): any;
  18083. /** @hidden */
  18084. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18085. /** @hidden */
  18086. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18087. /**
  18088. * Parses a JSON object to create a particle system.
  18089. * @param parsedParticleSystem The JSON object to parse
  18090. * @param scene The scene to create the particle system in
  18091. * @param rootUrl The root url to use to load external dependencies like texture
  18092. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18093. * @returns the Parsed particle system
  18094. */
  18095. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18096. }
  18097. }
  18098. declare module "babylonjs/Particles/particle" {
  18099. import { Nullable } from "babylonjs/types";
  18100. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18101. import { Color4 } from "babylonjs/Maths/math.color";
  18102. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18103. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18104. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18105. /**
  18106. * A particle represents one of the element emitted by a particle system.
  18107. * This is mainly define by its coordinates, direction, velocity and age.
  18108. */
  18109. export class Particle {
  18110. /**
  18111. * The particle system the particle belongs to.
  18112. */
  18113. particleSystem: ParticleSystem;
  18114. private static _Count;
  18115. /**
  18116. * Unique ID of the particle
  18117. */
  18118. id: number;
  18119. /**
  18120. * The world position of the particle in the scene.
  18121. */
  18122. position: Vector3;
  18123. /**
  18124. * The world direction of the particle in the scene.
  18125. */
  18126. direction: Vector3;
  18127. /**
  18128. * The color of the particle.
  18129. */
  18130. color: Color4;
  18131. /**
  18132. * The color change of the particle per step.
  18133. */
  18134. colorStep: Color4;
  18135. /**
  18136. * Defines how long will the life of the particle be.
  18137. */
  18138. lifeTime: number;
  18139. /**
  18140. * The current age of the particle.
  18141. */
  18142. age: number;
  18143. /**
  18144. * The current size of the particle.
  18145. */
  18146. size: number;
  18147. /**
  18148. * The current scale of the particle.
  18149. */
  18150. scale: Vector2;
  18151. /**
  18152. * The current angle of the particle.
  18153. */
  18154. angle: number;
  18155. /**
  18156. * Defines how fast is the angle changing.
  18157. */
  18158. angularSpeed: number;
  18159. /**
  18160. * Defines the cell index used by the particle to be rendered from a sprite.
  18161. */
  18162. cellIndex: number;
  18163. /**
  18164. * The information required to support color remapping
  18165. */
  18166. remapData: Vector4;
  18167. /** @hidden */
  18168. _randomCellOffset?: number;
  18169. /** @hidden */
  18170. _initialDirection: Nullable<Vector3>;
  18171. /** @hidden */
  18172. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18173. /** @hidden */
  18174. _initialStartSpriteCellID: number;
  18175. /** @hidden */
  18176. _initialEndSpriteCellID: number;
  18177. /** @hidden */
  18178. _currentColorGradient: Nullable<ColorGradient>;
  18179. /** @hidden */
  18180. _currentColor1: Color4;
  18181. /** @hidden */
  18182. _currentColor2: Color4;
  18183. /** @hidden */
  18184. _currentSizeGradient: Nullable<FactorGradient>;
  18185. /** @hidden */
  18186. _currentSize1: number;
  18187. /** @hidden */
  18188. _currentSize2: number;
  18189. /** @hidden */
  18190. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18191. /** @hidden */
  18192. _currentAngularSpeed1: number;
  18193. /** @hidden */
  18194. _currentAngularSpeed2: number;
  18195. /** @hidden */
  18196. _currentVelocityGradient: Nullable<FactorGradient>;
  18197. /** @hidden */
  18198. _currentVelocity1: number;
  18199. /** @hidden */
  18200. _currentVelocity2: number;
  18201. /** @hidden */
  18202. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18203. /** @hidden */
  18204. _currentLimitVelocity1: number;
  18205. /** @hidden */
  18206. _currentLimitVelocity2: number;
  18207. /** @hidden */
  18208. _currentDragGradient: Nullable<FactorGradient>;
  18209. /** @hidden */
  18210. _currentDrag1: number;
  18211. /** @hidden */
  18212. _currentDrag2: number;
  18213. /** @hidden */
  18214. _randomNoiseCoordinates1: Vector3;
  18215. /** @hidden */
  18216. _randomNoiseCoordinates2: Vector3;
  18217. /**
  18218. * Creates a new instance Particle
  18219. * @param particleSystem the particle system the particle belongs to
  18220. */
  18221. constructor(
  18222. /**
  18223. * The particle system the particle belongs to.
  18224. */
  18225. particleSystem: ParticleSystem);
  18226. private updateCellInfoFromSystem;
  18227. /**
  18228. * Defines how the sprite cell index is updated for the particle
  18229. */
  18230. updateCellIndex(): void;
  18231. /** @hidden */
  18232. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18233. /** @hidden */
  18234. _inheritParticleInfoToSubEmitters(): void;
  18235. /** @hidden */
  18236. _reset(): void;
  18237. /**
  18238. * Copy the properties of particle to another one.
  18239. * @param other the particle to copy the information to.
  18240. */
  18241. copyTo(other: Particle): void;
  18242. }
  18243. }
  18244. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18245. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18246. import { Effect } from "babylonjs/Materials/effect";
  18247. import { Particle } from "babylonjs/Particles/particle";
  18248. /**
  18249. * Particle emitter represents a volume emitting particles.
  18250. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18251. */
  18252. export interface IParticleEmitterType {
  18253. /**
  18254. * Called by the particle System when the direction is computed for the created particle.
  18255. * @param worldMatrix is the world matrix of the particle system
  18256. * @param directionToUpdate is the direction vector to update with the result
  18257. * @param particle is the particle we are computed the direction for
  18258. */
  18259. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18260. /**
  18261. * Called by the particle System when the position is computed for the created particle.
  18262. * @param worldMatrix is the world matrix of the particle system
  18263. * @param positionToUpdate is the position vector to update with the result
  18264. * @param particle is the particle we are computed the position for
  18265. */
  18266. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18267. /**
  18268. * Clones the current emitter and returns a copy of it
  18269. * @returns the new emitter
  18270. */
  18271. clone(): IParticleEmitterType;
  18272. /**
  18273. * Called by the GPUParticleSystem to setup the update shader
  18274. * @param effect defines the update shader
  18275. */
  18276. applyToShader(effect: Effect): void;
  18277. /**
  18278. * Returns a string to use to update the GPU particles update shader
  18279. * @returns the effect defines string
  18280. */
  18281. getEffectDefines(): string;
  18282. /**
  18283. * Returns a string representing the class name
  18284. * @returns a string containing the class name
  18285. */
  18286. getClassName(): string;
  18287. /**
  18288. * Serializes the particle system to a JSON object.
  18289. * @returns the JSON object
  18290. */
  18291. serialize(): any;
  18292. /**
  18293. * Parse properties from a JSON object
  18294. * @param serializationObject defines the JSON object
  18295. */
  18296. parse(serializationObject: any): void;
  18297. }
  18298. }
  18299. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18300. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18301. import { Effect } from "babylonjs/Materials/effect";
  18302. import { Particle } from "babylonjs/Particles/particle";
  18303. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18304. /**
  18305. * Particle emitter emitting particles from the inside of a box.
  18306. * It emits the particles randomly between 2 given directions.
  18307. */
  18308. export class BoxParticleEmitter implements IParticleEmitterType {
  18309. /**
  18310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18311. */
  18312. direction1: Vector3;
  18313. /**
  18314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18315. */
  18316. direction2: Vector3;
  18317. /**
  18318. * 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.
  18319. */
  18320. minEmitBox: Vector3;
  18321. /**
  18322. * 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.
  18323. */
  18324. maxEmitBox: Vector3;
  18325. /**
  18326. * Creates a new instance BoxParticleEmitter
  18327. */
  18328. constructor();
  18329. /**
  18330. * Called by the particle System when the direction is computed for the created particle.
  18331. * @param worldMatrix is the world matrix of the particle system
  18332. * @param directionToUpdate is the direction vector to update with the result
  18333. * @param particle is the particle we are computed the direction for
  18334. */
  18335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18336. /**
  18337. * Called by the particle System when the position is computed for the created particle.
  18338. * @param worldMatrix is the world matrix of the particle system
  18339. * @param positionToUpdate is the position vector to update with the result
  18340. * @param particle is the particle we are computed the position for
  18341. */
  18342. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18343. /**
  18344. * Clones the current emitter and returns a copy of it
  18345. * @returns the new emitter
  18346. */
  18347. clone(): BoxParticleEmitter;
  18348. /**
  18349. * Called by the GPUParticleSystem to setup the update shader
  18350. * @param effect defines the update shader
  18351. */
  18352. applyToShader(effect: Effect): void;
  18353. /**
  18354. * Returns a string to use to update the GPU particles update shader
  18355. * @returns a string containng the defines string
  18356. */
  18357. getEffectDefines(): string;
  18358. /**
  18359. * Returns the string "BoxParticleEmitter"
  18360. * @returns a string containing the class name
  18361. */
  18362. getClassName(): string;
  18363. /**
  18364. * Serializes the particle system to a JSON object.
  18365. * @returns the JSON object
  18366. */
  18367. serialize(): any;
  18368. /**
  18369. * Parse properties from a JSON object
  18370. * @param serializationObject defines the JSON object
  18371. */
  18372. parse(serializationObject: any): void;
  18373. }
  18374. }
  18375. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18376. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18377. import { Effect } from "babylonjs/Materials/effect";
  18378. import { Particle } from "babylonjs/Particles/particle";
  18379. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18380. /**
  18381. * Particle emitter emitting particles from the inside of a cone.
  18382. * It emits the particles alongside the cone volume from the base to the particle.
  18383. * The emission direction might be randomized.
  18384. */
  18385. export class ConeParticleEmitter implements IParticleEmitterType {
  18386. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18387. directionRandomizer: number;
  18388. private _radius;
  18389. private _angle;
  18390. private _height;
  18391. /**
  18392. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18393. */
  18394. radiusRange: number;
  18395. /**
  18396. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18397. */
  18398. heightRange: number;
  18399. /**
  18400. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18401. */
  18402. emitFromSpawnPointOnly: boolean;
  18403. /**
  18404. * Gets or sets the radius of the emission cone
  18405. */
  18406. radius: number;
  18407. /**
  18408. * Gets or sets the angle of the emission cone
  18409. */
  18410. angle: number;
  18411. private _buildHeight;
  18412. /**
  18413. * Creates a new instance ConeParticleEmitter
  18414. * @param radius the radius of the emission cone (1 by default)
  18415. * @param angle the cone base angle (PI by default)
  18416. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18417. */
  18418. constructor(radius?: number, angle?: number,
  18419. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18420. directionRandomizer?: number);
  18421. /**
  18422. * Called by the particle System when the direction is computed for the created particle.
  18423. * @param worldMatrix is the world matrix of the particle system
  18424. * @param directionToUpdate is the direction vector to update with the result
  18425. * @param particle is the particle we are computed the direction for
  18426. */
  18427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18428. /**
  18429. * Called by the particle System when the position is computed for the created particle.
  18430. * @param worldMatrix is the world matrix of the particle system
  18431. * @param positionToUpdate is the position vector to update with the result
  18432. * @param particle is the particle we are computed the position for
  18433. */
  18434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18435. /**
  18436. * Clones the current emitter and returns a copy of it
  18437. * @returns the new emitter
  18438. */
  18439. clone(): ConeParticleEmitter;
  18440. /**
  18441. * Called by the GPUParticleSystem to setup the update shader
  18442. * @param effect defines the update shader
  18443. */
  18444. applyToShader(effect: Effect): void;
  18445. /**
  18446. * Returns a string to use to update the GPU particles update shader
  18447. * @returns a string containng the defines string
  18448. */
  18449. getEffectDefines(): string;
  18450. /**
  18451. * Returns the string "ConeParticleEmitter"
  18452. * @returns a string containing the class name
  18453. */
  18454. getClassName(): string;
  18455. /**
  18456. * Serializes the particle system to a JSON object.
  18457. * @returns the JSON object
  18458. */
  18459. serialize(): any;
  18460. /**
  18461. * Parse properties from a JSON object
  18462. * @param serializationObject defines the JSON object
  18463. */
  18464. parse(serializationObject: any): void;
  18465. }
  18466. }
  18467. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18468. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18469. import { Effect } from "babylonjs/Materials/effect";
  18470. import { Particle } from "babylonjs/Particles/particle";
  18471. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18472. /**
  18473. * Particle emitter emitting particles from the inside of a cylinder.
  18474. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18475. */
  18476. export class CylinderParticleEmitter implements IParticleEmitterType {
  18477. /**
  18478. * The radius of the emission cylinder.
  18479. */
  18480. radius: number;
  18481. /**
  18482. * The height of the emission cylinder.
  18483. */
  18484. height: number;
  18485. /**
  18486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18487. */
  18488. radiusRange: number;
  18489. /**
  18490. * How much to randomize the particle direction [0-1].
  18491. */
  18492. directionRandomizer: number;
  18493. /**
  18494. * Creates a new instance CylinderParticleEmitter
  18495. * @param radius the radius of the emission cylinder (1 by default)
  18496. * @param height the height of the emission cylinder (1 by default)
  18497. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18499. */
  18500. constructor(
  18501. /**
  18502. * The radius of the emission cylinder.
  18503. */
  18504. radius?: number,
  18505. /**
  18506. * The height of the emission cylinder.
  18507. */
  18508. height?: number,
  18509. /**
  18510. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18511. */
  18512. radiusRange?: number,
  18513. /**
  18514. * How much to randomize the particle direction [0-1].
  18515. */
  18516. directionRandomizer?: number);
  18517. /**
  18518. * Called by the particle System when the direction is computed for the created particle.
  18519. * @param worldMatrix is the world matrix of the particle system
  18520. * @param directionToUpdate is the direction vector to update with the result
  18521. * @param particle is the particle we are computed the direction for
  18522. */
  18523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18524. /**
  18525. * Called by the particle System when the position is computed for the created particle.
  18526. * @param worldMatrix is the world matrix of the particle system
  18527. * @param positionToUpdate is the position vector to update with the result
  18528. * @param particle is the particle we are computed the position for
  18529. */
  18530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18531. /**
  18532. * Clones the current emitter and returns a copy of it
  18533. * @returns the new emitter
  18534. */
  18535. clone(): CylinderParticleEmitter;
  18536. /**
  18537. * Called by the GPUParticleSystem to setup the update shader
  18538. * @param effect defines the update shader
  18539. */
  18540. applyToShader(effect: Effect): void;
  18541. /**
  18542. * Returns a string to use to update the GPU particles update shader
  18543. * @returns a string containng the defines string
  18544. */
  18545. getEffectDefines(): string;
  18546. /**
  18547. * Returns the string "CylinderParticleEmitter"
  18548. * @returns a string containing the class name
  18549. */
  18550. getClassName(): string;
  18551. /**
  18552. * Serializes the particle system to a JSON object.
  18553. * @returns the JSON object
  18554. */
  18555. serialize(): any;
  18556. /**
  18557. * Parse properties from a JSON object
  18558. * @param serializationObject defines the JSON object
  18559. */
  18560. parse(serializationObject: any): void;
  18561. }
  18562. /**
  18563. * Particle emitter emitting particles from the inside of a cylinder.
  18564. * It emits the particles randomly between two vectors.
  18565. */
  18566. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18567. /**
  18568. * The min limit of the emission direction.
  18569. */
  18570. direction1: Vector3;
  18571. /**
  18572. * The max limit of the emission direction.
  18573. */
  18574. direction2: Vector3;
  18575. /**
  18576. * Creates a new instance CylinderDirectedParticleEmitter
  18577. * @param radius the radius of the emission cylinder (1 by default)
  18578. * @param height the height of the emission cylinder (1 by default)
  18579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18580. * @param direction1 the min limit of the emission direction (up vector by default)
  18581. * @param direction2 the max limit of the emission direction (up vector by default)
  18582. */
  18583. constructor(radius?: number, height?: number, radiusRange?: number,
  18584. /**
  18585. * The min limit of the emission direction.
  18586. */
  18587. direction1?: Vector3,
  18588. /**
  18589. * The max limit of the emission direction.
  18590. */
  18591. direction2?: Vector3);
  18592. /**
  18593. * Called by the particle System when the direction is computed for the created particle.
  18594. * @param worldMatrix is the world matrix of the particle system
  18595. * @param directionToUpdate is the direction vector to update with the result
  18596. * @param particle is the particle we are computed the direction for
  18597. */
  18598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18599. /**
  18600. * Clones the current emitter and returns a copy of it
  18601. * @returns the new emitter
  18602. */
  18603. clone(): CylinderDirectedParticleEmitter;
  18604. /**
  18605. * Called by the GPUParticleSystem to setup the update shader
  18606. * @param effect defines the update shader
  18607. */
  18608. applyToShader(effect: Effect): void;
  18609. /**
  18610. * Returns a string to use to update the GPU particles update shader
  18611. * @returns a string containng the defines string
  18612. */
  18613. getEffectDefines(): string;
  18614. /**
  18615. * Returns the string "CylinderDirectedParticleEmitter"
  18616. * @returns a string containing the class name
  18617. */
  18618. getClassName(): string;
  18619. /**
  18620. * Serializes the particle system to a JSON object.
  18621. * @returns the JSON object
  18622. */
  18623. serialize(): any;
  18624. /**
  18625. * Parse properties from a JSON object
  18626. * @param serializationObject defines the JSON object
  18627. */
  18628. parse(serializationObject: any): void;
  18629. }
  18630. }
  18631. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18633. import { Effect } from "babylonjs/Materials/effect";
  18634. import { Particle } from "babylonjs/Particles/particle";
  18635. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18636. /**
  18637. * Particle emitter emitting particles from the inside of a hemisphere.
  18638. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18639. */
  18640. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18641. /**
  18642. * The radius of the emission hemisphere.
  18643. */
  18644. radius: number;
  18645. /**
  18646. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18647. */
  18648. radiusRange: number;
  18649. /**
  18650. * How much to randomize the particle direction [0-1].
  18651. */
  18652. directionRandomizer: number;
  18653. /**
  18654. * Creates a new instance HemisphericParticleEmitter
  18655. * @param radius the radius of the emission hemisphere (1 by default)
  18656. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18657. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18658. */
  18659. constructor(
  18660. /**
  18661. * The radius of the emission hemisphere.
  18662. */
  18663. radius?: number,
  18664. /**
  18665. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18666. */
  18667. radiusRange?: number,
  18668. /**
  18669. * How much to randomize the particle direction [0-1].
  18670. */
  18671. directionRandomizer?: number);
  18672. /**
  18673. * Called by the particle System when the direction is computed for the created particle.
  18674. * @param worldMatrix is the world matrix of the particle system
  18675. * @param directionToUpdate is the direction vector to update with the result
  18676. * @param particle is the particle we are computed the direction for
  18677. */
  18678. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18679. /**
  18680. * Called by the particle System when the position is computed for the created particle.
  18681. * @param worldMatrix is the world matrix of the particle system
  18682. * @param positionToUpdate is the position vector to update with the result
  18683. * @param particle is the particle we are computed the position for
  18684. */
  18685. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18686. /**
  18687. * Clones the current emitter and returns a copy of it
  18688. * @returns the new emitter
  18689. */
  18690. clone(): HemisphericParticleEmitter;
  18691. /**
  18692. * Called by the GPUParticleSystem to setup the update shader
  18693. * @param effect defines the update shader
  18694. */
  18695. applyToShader(effect: Effect): void;
  18696. /**
  18697. * Returns a string to use to update the GPU particles update shader
  18698. * @returns a string containng the defines string
  18699. */
  18700. getEffectDefines(): string;
  18701. /**
  18702. * Returns the string "HemisphericParticleEmitter"
  18703. * @returns a string containing the class name
  18704. */
  18705. getClassName(): string;
  18706. /**
  18707. * Serializes the particle system to a JSON object.
  18708. * @returns the JSON object
  18709. */
  18710. serialize(): any;
  18711. /**
  18712. * Parse properties from a JSON object
  18713. * @param serializationObject defines the JSON object
  18714. */
  18715. parse(serializationObject: any): void;
  18716. }
  18717. }
  18718. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18719. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18720. import { Effect } from "babylonjs/Materials/effect";
  18721. import { Particle } from "babylonjs/Particles/particle";
  18722. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18723. /**
  18724. * Particle emitter emitting particles from a point.
  18725. * It emits the particles randomly between 2 given directions.
  18726. */
  18727. export class PointParticleEmitter implements IParticleEmitterType {
  18728. /**
  18729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18730. */
  18731. direction1: Vector3;
  18732. /**
  18733. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18734. */
  18735. direction2: Vector3;
  18736. /**
  18737. * Creates a new instance PointParticleEmitter
  18738. */
  18739. constructor();
  18740. /**
  18741. * Called by the particle System when the direction is computed for the created particle.
  18742. * @param worldMatrix is the world matrix of the particle system
  18743. * @param directionToUpdate is the direction vector to update with the result
  18744. * @param particle is the particle we are computed the direction for
  18745. */
  18746. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18747. /**
  18748. * Called by the particle System when the position is computed for the created particle.
  18749. * @param worldMatrix is the world matrix of the particle system
  18750. * @param positionToUpdate is the position vector to update with the result
  18751. * @param particle is the particle we are computed the position for
  18752. */
  18753. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18754. /**
  18755. * Clones the current emitter and returns a copy of it
  18756. * @returns the new emitter
  18757. */
  18758. clone(): PointParticleEmitter;
  18759. /**
  18760. * Called by the GPUParticleSystem to setup the update shader
  18761. * @param effect defines the update shader
  18762. */
  18763. applyToShader(effect: Effect): void;
  18764. /**
  18765. * Returns a string to use to update the GPU particles update shader
  18766. * @returns a string containng the defines string
  18767. */
  18768. getEffectDefines(): string;
  18769. /**
  18770. * Returns the string "PointParticleEmitter"
  18771. * @returns a string containing the class name
  18772. */
  18773. getClassName(): string;
  18774. /**
  18775. * Serializes the particle system to a JSON object.
  18776. * @returns the JSON object
  18777. */
  18778. serialize(): any;
  18779. /**
  18780. * Parse properties from a JSON object
  18781. * @param serializationObject defines the JSON object
  18782. */
  18783. parse(serializationObject: any): void;
  18784. }
  18785. }
  18786. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18788. import { Effect } from "babylonjs/Materials/effect";
  18789. import { Particle } from "babylonjs/Particles/particle";
  18790. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18791. /**
  18792. * Particle emitter emitting particles from the inside of a sphere.
  18793. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18794. */
  18795. export class SphereParticleEmitter implements IParticleEmitterType {
  18796. /**
  18797. * The radius of the emission sphere.
  18798. */
  18799. radius: number;
  18800. /**
  18801. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18802. */
  18803. radiusRange: number;
  18804. /**
  18805. * How much to randomize the particle direction [0-1].
  18806. */
  18807. directionRandomizer: number;
  18808. /**
  18809. * Creates a new instance SphereParticleEmitter
  18810. * @param radius the radius of the emission sphere (1 by default)
  18811. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18812. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18813. */
  18814. constructor(
  18815. /**
  18816. * The radius of the emission sphere.
  18817. */
  18818. radius?: number,
  18819. /**
  18820. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18821. */
  18822. radiusRange?: number,
  18823. /**
  18824. * How much to randomize the particle direction [0-1].
  18825. */
  18826. directionRandomizer?: number);
  18827. /**
  18828. * Called by the particle System when the direction is computed for the created particle.
  18829. * @param worldMatrix is the world matrix of the particle system
  18830. * @param directionToUpdate is the direction vector to update with the result
  18831. * @param particle is the particle we are computed the direction for
  18832. */
  18833. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18834. /**
  18835. * Called by the particle System when the position is computed for the created particle.
  18836. * @param worldMatrix is the world matrix of the particle system
  18837. * @param positionToUpdate is the position vector to update with the result
  18838. * @param particle is the particle we are computed the position for
  18839. */
  18840. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18841. /**
  18842. * Clones the current emitter and returns a copy of it
  18843. * @returns the new emitter
  18844. */
  18845. clone(): SphereParticleEmitter;
  18846. /**
  18847. * Called by the GPUParticleSystem to setup the update shader
  18848. * @param effect defines the update shader
  18849. */
  18850. applyToShader(effect: Effect): void;
  18851. /**
  18852. * Returns a string to use to update the GPU particles update shader
  18853. * @returns a string containng the defines string
  18854. */
  18855. getEffectDefines(): string;
  18856. /**
  18857. * Returns the string "SphereParticleEmitter"
  18858. * @returns a string containing the class name
  18859. */
  18860. getClassName(): string;
  18861. /**
  18862. * Serializes the particle system to a JSON object.
  18863. * @returns the JSON object
  18864. */
  18865. serialize(): any;
  18866. /**
  18867. * Parse properties from a JSON object
  18868. * @param serializationObject defines the JSON object
  18869. */
  18870. parse(serializationObject: any): void;
  18871. }
  18872. /**
  18873. * Particle emitter emitting particles from the inside of a sphere.
  18874. * It emits the particles randomly between two vectors.
  18875. */
  18876. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18877. /**
  18878. * The min limit of the emission direction.
  18879. */
  18880. direction1: Vector3;
  18881. /**
  18882. * The max limit of the emission direction.
  18883. */
  18884. direction2: Vector3;
  18885. /**
  18886. * Creates a new instance SphereDirectedParticleEmitter
  18887. * @param radius the radius of the emission sphere (1 by default)
  18888. * @param direction1 the min limit of the emission direction (up vector by default)
  18889. * @param direction2 the max limit of the emission direction (up vector by default)
  18890. */
  18891. constructor(radius?: number,
  18892. /**
  18893. * The min limit of the emission direction.
  18894. */
  18895. direction1?: Vector3,
  18896. /**
  18897. * The max limit of the emission direction.
  18898. */
  18899. direction2?: Vector3);
  18900. /**
  18901. * Called by the particle System when the direction is computed for the created particle.
  18902. * @param worldMatrix is the world matrix of the particle system
  18903. * @param directionToUpdate is the direction vector to update with the result
  18904. * @param particle is the particle we are computed the direction for
  18905. */
  18906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18907. /**
  18908. * Clones the current emitter and returns a copy of it
  18909. * @returns the new emitter
  18910. */
  18911. clone(): SphereDirectedParticleEmitter;
  18912. /**
  18913. * Called by the GPUParticleSystem to setup the update shader
  18914. * @param effect defines the update shader
  18915. */
  18916. applyToShader(effect: Effect): void;
  18917. /**
  18918. * Returns a string to use to update the GPU particles update shader
  18919. * @returns a string containng the defines string
  18920. */
  18921. getEffectDefines(): string;
  18922. /**
  18923. * Returns the string "SphereDirectedParticleEmitter"
  18924. * @returns a string containing the class name
  18925. */
  18926. getClassName(): string;
  18927. /**
  18928. * Serializes the particle system to a JSON object.
  18929. * @returns the JSON object
  18930. */
  18931. serialize(): any;
  18932. /**
  18933. * Parse properties from a JSON object
  18934. * @param serializationObject defines the JSON object
  18935. */
  18936. parse(serializationObject: any): void;
  18937. }
  18938. }
  18939. declare module "babylonjs/Particles/EmitterTypes/index" {
  18940. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18941. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18942. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18943. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18944. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18945. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18946. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18947. }
  18948. declare module "babylonjs/Particles/IParticleSystem" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18951. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18954. import { Texture } from "babylonjs/Materials/Textures/texture";
  18955. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18956. import { Scene } from "babylonjs/scene";
  18957. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18958. import { Animation } from "babylonjs/Animations/animation";
  18959. /**
  18960. * Interface representing a particle system in Babylon.js.
  18961. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18962. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18963. */
  18964. export interface IParticleSystem {
  18965. /**
  18966. * List of animations used by the particle system.
  18967. */
  18968. animations: Animation[];
  18969. /**
  18970. * The id of the Particle system.
  18971. */
  18972. id: string;
  18973. /**
  18974. * The name of the Particle system.
  18975. */
  18976. name: string;
  18977. /**
  18978. * The emitter represents the Mesh or position we are attaching the particle system to.
  18979. */
  18980. emitter: Nullable<AbstractMesh | Vector3>;
  18981. /**
  18982. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18983. */
  18984. isBillboardBased: boolean;
  18985. /**
  18986. * The rendering group used by the Particle system to chose when to render.
  18987. */
  18988. renderingGroupId: number;
  18989. /**
  18990. * The layer mask we are rendering the particles through.
  18991. */
  18992. layerMask: number;
  18993. /**
  18994. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18995. */
  18996. updateSpeed: number;
  18997. /**
  18998. * The amount of time the particle system is running (depends of the overall update speed).
  18999. */
  19000. targetStopDuration: number;
  19001. /**
  19002. * The texture used to render each particle. (this can be a spritesheet)
  19003. */
  19004. particleTexture: Nullable<Texture>;
  19005. /**
  19006. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19007. */
  19008. blendMode: number;
  19009. /**
  19010. * Minimum life time of emitting particles.
  19011. */
  19012. minLifeTime: number;
  19013. /**
  19014. * Maximum life time of emitting particles.
  19015. */
  19016. maxLifeTime: number;
  19017. /**
  19018. * Minimum Size of emitting particles.
  19019. */
  19020. minSize: number;
  19021. /**
  19022. * Maximum Size of emitting particles.
  19023. */
  19024. maxSize: number;
  19025. /**
  19026. * Minimum scale of emitting particles on X axis.
  19027. */
  19028. minScaleX: number;
  19029. /**
  19030. * Maximum scale of emitting particles on X axis.
  19031. */
  19032. maxScaleX: number;
  19033. /**
  19034. * Minimum scale of emitting particles on Y axis.
  19035. */
  19036. minScaleY: number;
  19037. /**
  19038. * Maximum scale of emitting particles on Y axis.
  19039. */
  19040. maxScaleY: number;
  19041. /**
  19042. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19043. */
  19044. color1: Color4;
  19045. /**
  19046. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19047. */
  19048. color2: Color4;
  19049. /**
  19050. * Color the particle will have at the end of its lifetime.
  19051. */
  19052. colorDead: Color4;
  19053. /**
  19054. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19055. */
  19056. emitRate: number;
  19057. /**
  19058. * You can use gravity if you want to give an orientation to your particles.
  19059. */
  19060. gravity: Vector3;
  19061. /**
  19062. * Minimum power of emitting particles.
  19063. */
  19064. minEmitPower: number;
  19065. /**
  19066. * Maximum power of emitting particles.
  19067. */
  19068. maxEmitPower: number;
  19069. /**
  19070. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19071. */
  19072. minAngularSpeed: number;
  19073. /**
  19074. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19075. */
  19076. maxAngularSpeed: number;
  19077. /**
  19078. * Gets or sets the minimal initial rotation in radians.
  19079. */
  19080. minInitialRotation: number;
  19081. /**
  19082. * Gets or sets the maximal initial rotation in radians.
  19083. */
  19084. maxInitialRotation: number;
  19085. /**
  19086. * The particle emitter type defines the emitter used by the particle system.
  19087. * It can be for example box, sphere, or cone...
  19088. */
  19089. particleEmitterType: Nullable<IParticleEmitterType>;
  19090. /**
  19091. * Defines the delay in milliseconds before starting the system (0 by default)
  19092. */
  19093. startDelay: number;
  19094. /**
  19095. * 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
  19096. */
  19097. preWarmCycles: number;
  19098. /**
  19099. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19100. */
  19101. preWarmStepOffset: number;
  19102. /**
  19103. * 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)
  19104. */
  19105. spriteCellChangeSpeed: number;
  19106. /**
  19107. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19108. */
  19109. startSpriteCellID: number;
  19110. /**
  19111. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19112. */
  19113. endSpriteCellID: number;
  19114. /**
  19115. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19116. */
  19117. spriteCellWidth: number;
  19118. /**
  19119. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19120. */
  19121. spriteCellHeight: number;
  19122. /**
  19123. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19124. */
  19125. spriteRandomStartCell: boolean;
  19126. /**
  19127. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19128. */
  19129. isAnimationSheetEnabled: boolean;
  19130. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19131. translationPivot: Vector2;
  19132. /**
  19133. * Gets or sets a texture used to add random noise to particle positions
  19134. */
  19135. noiseTexture: Nullable<BaseTexture>;
  19136. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19137. noiseStrength: Vector3;
  19138. /**
  19139. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19140. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19141. */
  19142. billboardMode: number;
  19143. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19144. limitVelocityDamping: number;
  19145. /**
  19146. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19147. */
  19148. beginAnimationOnStart: boolean;
  19149. /**
  19150. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19151. */
  19152. beginAnimationFrom: number;
  19153. /**
  19154. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19155. */
  19156. beginAnimationTo: number;
  19157. /**
  19158. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19159. */
  19160. beginAnimationLoop: boolean;
  19161. /**
  19162. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19163. */
  19164. disposeOnStop: boolean;
  19165. /**
  19166. * Gets the maximum number of particles active at the same time.
  19167. * @returns The max number of active particles.
  19168. */
  19169. getCapacity(): number;
  19170. /**
  19171. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19172. * @returns True if it has been started, otherwise false.
  19173. */
  19174. isStarted(): boolean;
  19175. /**
  19176. * Animates the particle system for this frame.
  19177. */
  19178. animate(): void;
  19179. /**
  19180. * Renders the particle system in its current state.
  19181. * @returns the current number of particles
  19182. */
  19183. render(): number;
  19184. /**
  19185. * Dispose the particle system and frees its associated resources.
  19186. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19187. */
  19188. dispose(disposeTexture?: boolean): void;
  19189. /**
  19190. * Clones the particle system.
  19191. * @param name The name of the cloned object
  19192. * @param newEmitter The new emitter to use
  19193. * @returns the cloned particle system
  19194. */
  19195. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19196. /**
  19197. * Serializes the particle system to a JSON object.
  19198. * @returns the JSON object
  19199. */
  19200. serialize(): any;
  19201. /**
  19202. * Rebuild the particle system
  19203. */
  19204. rebuild(): void;
  19205. /**
  19206. * Starts the particle system and begins to emit
  19207. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19208. */
  19209. start(delay?: number): void;
  19210. /**
  19211. * Stops the particle system.
  19212. */
  19213. stop(): void;
  19214. /**
  19215. * Remove all active particles
  19216. */
  19217. reset(): void;
  19218. /**
  19219. * Is this system ready to be used/rendered
  19220. * @return true if the system is ready
  19221. */
  19222. isReady(): boolean;
  19223. /**
  19224. * Adds a new color gradient
  19225. * @param gradient defines the gradient to use (between 0 and 1)
  19226. * @param color1 defines the color to affect to the specified gradient
  19227. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19228. * @returns the current particle system
  19229. */
  19230. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19231. /**
  19232. * Remove a specific color gradient
  19233. * @param gradient defines the gradient to remove
  19234. * @returns the current particle system
  19235. */
  19236. removeColorGradient(gradient: number): IParticleSystem;
  19237. /**
  19238. * Adds a new size gradient
  19239. * @param gradient defines the gradient to use (between 0 and 1)
  19240. * @param factor defines the size factor to affect to the specified gradient
  19241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19242. * @returns the current particle system
  19243. */
  19244. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19245. /**
  19246. * Remove a specific size gradient
  19247. * @param gradient defines the gradient to remove
  19248. * @returns the current particle system
  19249. */
  19250. removeSizeGradient(gradient: number): IParticleSystem;
  19251. /**
  19252. * Gets the current list of color gradients.
  19253. * You must use addColorGradient and removeColorGradient to udpate this list
  19254. * @returns the list of color gradients
  19255. */
  19256. getColorGradients(): Nullable<Array<ColorGradient>>;
  19257. /**
  19258. * Gets the current list of size gradients.
  19259. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19260. * @returns the list of size gradients
  19261. */
  19262. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Gets the current list of angular speed gradients.
  19265. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19266. * @returns the list of angular speed gradients
  19267. */
  19268. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19269. /**
  19270. * Adds a new angular speed gradient
  19271. * @param gradient defines the gradient to use (between 0 and 1)
  19272. * @param factor defines the angular speed to affect to the specified gradient
  19273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19274. * @returns the current particle system
  19275. */
  19276. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19277. /**
  19278. * Remove a specific angular speed gradient
  19279. * @param gradient defines the gradient to remove
  19280. * @returns the current particle system
  19281. */
  19282. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19283. /**
  19284. * Gets the current list of velocity gradients.
  19285. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19286. * @returns the list of velocity gradients
  19287. */
  19288. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19289. /**
  19290. * Adds a new velocity gradient
  19291. * @param gradient defines the gradient to use (between 0 and 1)
  19292. * @param factor defines the velocity to affect to the specified gradient
  19293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19294. * @returns the current particle system
  19295. */
  19296. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19297. /**
  19298. * Remove a specific velocity gradient
  19299. * @param gradient defines the gradient to remove
  19300. * @returns the current particle system
  19301. */
  19302. removeVelocityGradient(gradient: number): IParticleSystem;
  19303. /**
  19304. * Gets the current list of limit velocity gradients.
  19305. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19306. * @returns the list of limit velocity gradients
  19307. */
  19308. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19309. /**
  19310. * Adds a new limit velocity gradient
  19311. * @param gradient defines the gradient to use (between 0 and 1)
  19312. * @param factor defines the limit velocity to affect to the specified gradient
  19313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19314. * @returns the current particle system
  19315. */
  19316. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19317. /**
  19318. * Remove a specific limit velocity gradient
  19319. * @param gradient defines the gradient to remove
  19320. * @returns the current particle system
  19321. */
  19322. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19323. /**
  19324. * Adds a new drag gradient
  19325. * @param gradient defines the gradient to use (between 0 and 1)
  19326. * @param factor defines the drag to affect to the specified gradient
  19327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19328. * @returns the current particle system
  19329. */
  19330. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19331. /**
  19332. * Remove a specific drag gradient
  19333. * @param gradient defines the gradient to remove
  19334. * @returns the current particle system
  19335. */
  19336. removeDragGradient(gradient: number): IParticleSystem;
  19337. /**
  19338. * Gets the current list of drag gradients.
  19339. * You must use addDragGradient and removeDragGradient to udpate this list
  19340. * @returns the list of drag gradients
  19341. */
  19342. getDragGradients(): Nullable<Array<FactorGradient>>;
  19343. /**
  19344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19345. * @param gradient defines the gradient to use (between 0 and 1)
  19346. * @param factor defines the emit rate to affect to the specified gradient
  19347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19348. * @returns the current particle system
  19349. */
  19350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19351. /**
  19352. * Remove a specific emit rate gradient
  19353. * @param gradient defines the gradient to remove
  19354. * @returns the current particle system
  19355. */
  19356. removeEmitRateGradient(gradient: number): IParticleSystem;
  19357. /**
  19358. * Gets the current list of emit rate gradients.
  19359. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19360. * @returns the list of emit rate gradients
  19361. */
  19362. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19363. /**
  19364. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19365. * @param gradient defines the gradient to use (between 0 and 1)
  19366. * @param factor defines the start size to affect to the specified gradient
  19367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19368. * @returns the current particle system
  19369. */
  19370. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19371. /**
  19372. * Remove a specific start size gradient
  19373. * @param gradient defines the gradient to remove
  19374. * @returns the current particle system
  19375. */
  19376. removeStartSizeGradient(gradient: number): IParticleSystem;
  19377. /**
  19378. * Gets the current list of start size gradients.
  19379. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19380. * @returns the list of start size gradients
  19381. */
  19382. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19383. /**
  19384. * Adds a new life time gradient
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param factor defines the life time factor to affect to the specified gradient
  19387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19388. * @returns the current particle system
  19389. */
  19390. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19391. /**
  19392. * Remove a specific life time gradient
  19393. * @param gradient defines the gradient to remove
  19394. * @returns the current particle system
  19395. */
  19396. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19397. /**
  19398. * Gets the current list of life time gradients.
  19399. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19400. * @returns the list of life time gradients
  19401. */
  19402. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19403. /**
  19404. * Gets the current list of color gradients.
  19405. * You must use addColorGradient and removeColorGradient to udpate this list
  19406. * @returns the list of color gradients
  19407. */
  19408. getColorGradients(): Nullable<Array<ColorGradient>>;
  19409. /**
  19410. * Adds a new ramp gradient used to remap particle colors
  19411. * @param gradient defines the gradient to use (between 0 and 1)
  19412. * @param color defines the color to affect to the specified gradient
  19413. * @returns the current particle system
  19414. */
  19415. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19416. /**
  19417. * Gets the current list of ramp gradients.
  19418. * You must use addRampGradient and removeRampGradient to udpate this list
  19419. * @returns the list of ramp gradients
  19420. */
  19421. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19422. /** Gets or sets a boolean indicating that ramp gradients must be used
  19423. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19424. */
  19425. useRampGradients: boolean;
  19426. /**
  19427. * Adds a new color remap gradient
  19428. * @param gradient defines the gradient to use (between 0 and 1)
  19429. * @param min defines the color remap minimal range
  19430. * @param max defines the color remap maximal range
  19431. * @returns the current particle system
  19432. */
  19433. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19434. /**
  19435. * Gets the current list of color remap gradients.
  19436. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19437. * @returns the list of color remap gradients
  19438. */
  19439. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19440. /**
  19441. * Adds a new alpha remap gradient
  19442. * @param gradient defines the gradient to use (between 0 and 1)
  19443. * @param min defines the alpha remap minimal range
  19444. * @param max defines the alpha remap maximal range
  19445. * @returns the current particle system
  19446. */
  19447. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19448. /**
  19449. * Gets the current list of alpha remap gradients.
  19450. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19451. * @returns the list of alpha remap gradients
  19452. */
  19453. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19454. /**
  19455. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19458. * @returns the emitter
  19459. */
  19460. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19461. /**
  19462. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19463. * @param radius The radius of the hemisphere to emit from
  19464. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19465. * @returns the emitter
  19466. */
  19467. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19468. /**
  19469. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19470. * @param radius The radius of the sphere to emit from
  19471. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19472. * @returns the emitter
  19473. */
  19474. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19475. /**
  19476. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19477. * @param radius The radius of the sphere to emit from
  19478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19480. * @returns the emitter
  19481. */
  19482. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19483. /**
  19484. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19485. * @param radius The radius of the emission cylinder
  19486. * @param height The height of the emission cylinder
  19487. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19488. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19489. * @returns the emitter
  19490. */
  19491. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19492. /**
  19493. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19494. * @param radius The radius of the cylinder to emit from
  19495. * @param height The height of the emission cylinder
  19496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19497. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19498. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19499. * @returns the emitter
  19500. */
  19501. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19502. /**
  19503. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19504. * @param radius The radius of the cone to emit from
  19505. * @param angle The base angle of the cone
  19506. * @returns the emitter
  19507. */
  19508. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19509. /**
  19510. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19513. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19514. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19515. * @returns the emitter
  19516. */
  19517. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19518. /**
  19519. * Get hosting scene
  19520. * @returns the scene
  19521. */
  19522. getScene(): Scene;
  19523. }
  19524. }
  19525. declare module "babylonjs/Meshes/instancedMesh" {
  19526. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19527. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19528. import { Camera } from "babylonjs/Cameras/camera";
  19529. import { Node } from "babylonjs/node";
  19530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19531. import { Mesh } from "babylonjs/Meshes/mesh";
  19532. import { Material } from "babylonjs/Materials/material";
  19533. import { Skeleton } from "babylonjs/Bones/skeleton";
  19534. import { Light } from "babylonjs/Lights/light";
  19535. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19536. /**
  19537. * Creates an instance based on a source mesh.
  19538. */
  19539. export class InstancedMesh extends AbstractMesh {
  19540. private _sourceMesh;
  19541. private _currentLOD;
  19542. /** @hidden */
  19543. _indexInSourceMeshInstanceArray: number;
  19544. constructor(name: string, source: Mesh);
  19545. /**
  19546. * Returns the string "InstancedMesh".
  19547. */
  19548. getClassName(): string;
  19549. /** Gets the list of lights affecting that mesh */
  19550. readonly lightSources: Light[];
  19551. _resyncLightSources(): void;
  19552. _resyncLightSource(light: Light): void;
  19553. _removeLightSource(light: Light, dispose: boolean): void;
  19554. /**
  19555. * If the source mesh receives shadows
  19556. */
  19557. readonly receiveShadows: boolean;
  19558. /**
  19559. * The material of the source mesh
  19560. */
  19561. readonly material: Nullable<Material>;
  19562. /**
  19563. * Visibility of the source mesh
  19564. */
  19565. readonly visibility: number;
  19566. /**
  19567. * Skeleton of the source mesh
  19568. */
  19569. readonly skeleton: Nullable<Skeleton>;
  19570. /**
  19571. * Rendering ground id of the source mesh
  19572. */
  19573. renderingGroupId: number;
  19574. /**
  19575. * Returns the total number of vertices (integer).
  19576. */
  19577. getTotalVertices(): number;
  19578. /**
  19579. * Returns a positive integer : the total number of indices in this mesh geometry.
  19580. * @returns the numner of indices or zero if the mesh has no geometry.
  19581. */
  19582. getTotalIndices(): number;
  19583. /**
  19584. * The source mesh of the instance
  19585. */
  19586. readonly sourceMesh: Mesh;
  19587. /**
  19588. * Is this node ready to be used/rendered
  19589. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19590. * @return {boolean} is it ready
  19591. */
  19592. isReady(completeCheck?: boolean): boolean;
  19593. /**
  19594. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19595. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19596. * @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.
  19597. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19598. */
  19599. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19600. /**
  19601. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19602. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19603. * The `data` are either a numeric array either a Float32Array.
  19604. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19605. * 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).
  19606. * Note that a new underlying VertexBuffer object is created each call.
  19607. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19608. *
  19609. * Possible `kind` values :
  19610. * - VertexBuffer.PositionKind
  19611. * - VertexBuffer.UVKind
  19612. * - VertexBuffer.UV2Kind
  19613. * - VertexBuffer.UV3Kind
  19614. * - VertexBuffer.UV4Kind
  19615. * - VertexBuffer.UV5Kind
  19616. * - VertexBuffer.UV6Kind
  19617. * - VertexBuffer.ColorKind
  19618. * - VertexBuffer.MatricesIndicesKind
  19619. * - VertexBuffer.MatricesIndicesExtraKind
  19620. * - VertexBuffer.MatricesWeightsKind
  19621. * - VertexBuffer.MatricesWeightsExtraKind
  19622. *
  19623. * Returns the Mesh.
  19624. */
  19625. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19626. /**
  19627. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19628. * If the mesh has no geometry, it is simply returned as it is.
  19629. * The `data` are either a numeric array either a Float32Array.
  19630. * No new underlying VertexBuffer object is created.
  19631. * 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.
  19632. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19633. *
  19634. * Possible `kind` values :
  19635. * - VertexBuffer.PositionKind
  19636. * - VertexBuffer.UVKind
  19637. * - VertexBuffer.UV2Kind
  19638. * - VertexBuffer.UV3Kind
  19639. * - VertexBuffer.UV4Kind
  19640. * - VertexBuffer.UV5Kind
  19641. * - VertexBuffer.UV6Kind
  19642. * - VertexBuffer.ColorKind
  19643. * - VertexBuffer.MatricesIndicesKind
  19644. * - VertexBuffer.MatricesIndicesExtraKind
  19645. * - VertexBuffer.MatricesWeightsKind
  19646. * - VertexBuffer.MatricesWeightsExtraKind
  19647. *
  19648. * Returns the Mesh.
  19649. */
  19650. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19651. /**
  19652. * Sets the mesh indices.
  19653. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19654. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19655. * This method creates a new index buffer each call.
  19656. * Returns the Mesh.
  19657. */
  19658. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19659. /**
  19660. * Boolean : True if the mesh owns the requested kind of data.
  19661. */
  19662. isVerticesDataPresent(kind: string): boolean;
  19663. /**
  19664. * Returns an array of indices (IndicesArray).
  19665. */
  19666. getIndices(): Nullable<IndicesArray>;
  19667. readonly _positions: Nullable<Vector3[]>;
  19668. /**
  19669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19670. * This means the mesh underlying bounding box and sphere are recomputed.
  19671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19672. * @returns the current mesh
  19673. */
  19674. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19675. /** @hidden */
  19676. _preActivate(): InstancedMesh;
  19677. /** @hidden */
  19678. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19679. /** @hidden */
  19680. _postActivate(): void;
  19681. getWorldMatrix(): Matrix;
  19682. readonly isAnInstance: boolean;
  19683. /**
  19684. * Returns the current associated LOD AbstractMesh.
  19685. */
  19686. getLOD(camera: Camera): AbstractMesh;
  19687. /** @hidden */
  19688. _syncSubMeshes(): InstancedMesh;
  19689. /** @hidden */
  19690. _generatePointsArray(): boolean;
  19691. /**
  19692. * Creates a new InstancedMesh from the current mesh.
  19693. * - name (string) : the cloned mesh name
  19694. * - newParent (optional Node) : the optional Node to parent the clone to.
  19695. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19696. *
  19697. * Returns the clone.
  19698. */
  19699. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19700. /**
  19701. * Disposes the InstancedMesh.
  19702. * Returns nothing.
  19703. */
  19704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19705. }
  19706. module "babylonjs/Meshes/mesh" {
  19707. interface Mesh {
  19708. /**
  19709. * Register a custom buffer that will be instanced
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19711. * @param kind defines the buffer kind
  19712. * @param stride defines the stride in floats
  19713. */
  19714. registerInstancedBuffer(kind: string, stride: number): void;
  19715. /** @hidden */
  19716. _userInstancedBuffersStorage: {
  19717. data: {
  19718. [key: string]: Float32Array;
  19719. };
  19720. sizes: {
  19721. [key: string]: number;
  19722. };
  19723. vertexBuffers: {
  19724. [key: string]: Nullable<VertexBuffer>;
  19725. };
  19726. strides: {
  19727. [key: string]: number;
  19728. };
  19729. };
  19730. }
  19731. }
  19732. module "babylonjs/Meshes/abstractMesh" {
  19733. interface AbstractMesh {
  19734. /**
  19735. * Object used to store instanced buffers defined by user
  19736. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19737. */
  19738. instancedBuffers: {
  19739. [key: string]: any;
  19740. };
  19741. }
  19742. }
  19743. }
  19744. declare module "babylonjs/Materials/shaderMaterial" {
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19748. import { Mesh } from "babylonjs/Meshes/mesh";
  19749. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19751. import { Texture } from "babylonjs/Materials/Textures/texture";
  19752. import { Material } from "babylonjs/Materials/material";
  19753. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19754. /**
  19755. * Defines the options associated with the creation of a shader material.
  19756. */
  19757. export interface IShaderMaterialOptions {
  19758. /**
  19759. * Does the material work in alpha blend mode
  19760. */
  19761. needAlphaBlending: boolean;
  19762. /**
  19763. * Does the material work in alpha test mode
  19764. */
  19765. needAlphaTesting: boolean;
  19766. /**
  19767. * The list of attribute names used in the shader
  19768. */
  19769. attributes: string[];
  19770. /**
  19771. * The list of unifrom names used in the shader
  19772. */
  19773. uniforms: string[];
  19774. /**
  19775. * The list of UBO names used in the shader
  19776. */
  19777. uniformBuffers: string[];
  19778. /**
  19779. * The list of sampler names used in the shader
  19780. */
  19781. samplers: string[];
  19782. /**
  19783. * The list of defines used in the shader
  19784. */
  19785. defines: string[];
  19786. }
  19787. /**
  19788. * 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.
  19789. *
  19790. * This returned material effects how the mesh will look based on the code in the shaders.
  19791. *
  19792. * @see http://doc.babylonjs.com/how_to/shader_material
  19793. */
  19794. export class ShaderMaterial extends Material {
  19795. private _shaderPath;
  19796. private _options;
  19797. private _textures;
  19798. private _textureArrays;
  19799. private _floats;
  19800. private _ints;
  19801. private _floatsArrays;
  19802. private _colors3;
  19803. private _colors3Arrays;
  19804. private _colors4;
  19805. private _colors4Arrays;
  19806. private _vectors2;
  19807. private _vectors3;
  19808. private _vectors4;
  19809. private _matrices;
  19810. private _matrixArrays;
  19811. private _matrices3x3;
  19812. private _matrices2x2;
  19813. private _vectors2Arrays;
  19814. private _vectors3Arrays;
  19815. private _vectors4Arrays;
  19816. private _cachedWorldViewMatrix;
  19817. private _cachedWorldViewProjectionMatrix;
  19818. private _renderId;
  19819. private _multiview;
  19820. /**
  19821. * Instantiate a new shader material.
  19822. * 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.
  19823. * This returned material effects how the mesh will look based on the code in the shaders.
  19824. * @see http://doc.babylonjs.com/how_to/shader_material
  19825. * @param name Define the name of the material in the scene
  19826. * @param scene Define the scene the material belongs to
  19827. * @param shaderPath Defines the route to the shader code in one of three ways:
  19828. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19829. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19830. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19831. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19832. * @param options Define the options used to create the shader
  19833. */
  19834. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19835. /**
  19836. * Gets the shader path used to define the shader code
  19837. * It can be modified to trigger a new compilation
  19838. */
  19839. /**
  19840. * Sets the shader path used to define the shader code
  19841. * It can be modified to trigger a new compilation
  19842. */
  19843. shaderPath: any;
  19844. /**
  19845. * Gets the options used to compile the shader.
  19846. * They can be modified to trigger a new compilation
  19847. */
  19848. readonly options: IShaderMaterialOptions;
  19849. /**
  19850. * Gets the current class name of the material e.g. "ShaderMaterial"
  19851. * Mainly use in serialization.
  19852. * @returns the class name
  19853. */
  19854. getClassName(): string;
  19855. /**
  19856. * Specifies if the material will require alpha blending
  19857. * @returns a boolean specifying if alpha blending is needed
  19858. */
  19859. needAlphaBlending(): boolean;
  19860. /**
  19861. * Specifies if this material should be rendered in alpha test mode
  19862. * @returns a boolean specifying if an alpha test is needed.
  19863. */
  19864. needAlphaTesting(): boolean;
  19865. private _checkUniform;
  19866. /**
  19867. * Set a texture in the shader.
  19868. * @param name Define the name of the uniform samplers as defined in the shader
  19869. * @param texture Define the texture to bind to this sampler
  19870. * @return the material itself allowing "fluent" like uniform updates
  19871. */
  19872. setTexture(name: string, texture: Texture): ShaderMaterial;
  19873. /**
  19874. * Set a texture array in the shader.
  19875. * @param name Define the name of the uniform sampler array as defined in the shader
  19876. * @param textures Define the list of textures to bind to this sampler
  19877. * @return the material itself allowing "fluent" like uniform updates
  19878. */
  19879. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19880. /**
  19881. * Set a float in the shader.
  19882. * @param name Define the name of the uniform as defined in the shader
  19883. * @param value Define the value to give to the uniform
  19884. * @return the material itself allowing "fluent" like uniform updates
  19885. */
  19886. setFloat(name: string, value: number): ShaderMaterial;
  19887. /**
  19888. * Set a int in the shader.
  19889. * @param name Define the name of the uniform as defined in the shader
  19890. * @param value Define the value to give to the uniform
  19891. * @return the material itself allowing "fluent" like uniform updates
  19892. */
  19893. setInt(name: string, value: number): ShaderMaterial;
  19894. /**
  19895. * Set an array of floats in the shader.
  19896. * @param name Define the name of the uniform as defined in the shader
  19897. * @param value Define the value to give to the uniform
  19898. * @return the material itself allowing "fluent" like uniform updates
  19899. */
  19900. setFloats(name: string, value: number[]): ShaderMaterial;
  19901. /**
  19902. * Set a vec3 in the shader from a Color3.
  19903. * @param name Define the name of the uniform as defined in the shader
  19904. * @param value Define the value to give to the uniform
  19905. * @return the material itself allowing "fluent" like uniform updates
  19906. */
  19907. setColor3(name: string, value: Color3): ShaderMaterial;
  19908. /**
  19909. * Set a vec3 array in the shader from a Color3 array.
  19910. * @param name Define the name of the uniform as defined in the shader
  19911. * @param value Define the value to give to the uniform
  19912. * @return the material itself allowing "fluent" like uniform updates
  19913. */
  19914. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19915. /**
  19916. * Set a vec4 in the shader from a Color4.
  19917. * @param name Define the name of the uniform as defined in the shader
  19918. * @param value Define the value to give to the uniform
  19919. * @return the material itself allowing "fluent" like uniform updates
  19920. */
  19921. setColor4(name: string, value: Color4): ShaderMaterial;
  19922. /**
  19923. * Set a vec4 array in the shader from a Color4 array.
  19924. * @param name Define the name of the uniform as defined in the shader
  19925. * @param value Define the value to give to the uniform
  19926. * @return the material itself allowing "fluent" like uniform updates
  19927. */
  19928. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19929. /**
  19930. * Set a vec2 in the shader from a Vector2.
  19931. * @param name Define the name of the uniform as defined in the shader
  19932. * @param value Define the value to give to the uniform
  19933. * @return the material itself allowing "fluent" like uniform updates
  19934. */
  19935. setVector2(name: string, value: Vector2): ShaderMaterial;
  19936. /**
  19937. * Set a vec3 in the shader from a Vector3.
  19938. * @param name Define the name of the uniform as defined in the shader
  19939. * @param value Define the value to give to the uniform
  19940. * @return the material itself allowing "fluent" like uniform updates
  19941. */
  19942. setVector3(name: string, value: Vector3): ShaderMaterial;
  19943. /**
  19944. * Set a vec4 in the shader from a Vector4.
  19945. * @param name Define the name of the uniform as defined in the shader
  19946. * @param value Define the value to give to the uniform
  19947. * @return the material itself allowing "fluent" like uniform updates
  19948. */
  19949. setVector4(name: string, value: Vector4): ShaderMaterial;
  19950. /**
  19951. * Set a mat4 in the shader from a Matrix.
  19952. * @param name Define the name of the uniform as defined in the shader
  19953. * @param value Define the value to give to the uniform
  19954. * @return the material itself allowing "fluent" like uniform updates
  19955. */
  19956. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19957. /**
  19958. * Set a float32Array in the shader from a matrix array.
  19959. * @param name Define the name of the uniform as defined in the shader
  19960. * @param value Define the value to give to the uniform
  19961. * @return the material itself allowing "fluent" like uniform updates
  19962. */
  19963. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19964. /**
  19965. * Set a mat3 in the shader from a Float32Array.
  19966. * @param name Define the name of the uniform as defined in the shader
  19967. * @param value Define the value to give to the uniform
  19968. * @return the material itself allowing "fluent" like uniform updates
  19969. */
  19970. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19971. /**
  19972. * Set a mat2 in the shader from a Float32Array.
  19973. * @param name Define the name of the uniform as defined in the shader
  19974. * @param value Define the value to give to the uniform
  19975. * @return the material itself allowing "fluent" like uniform updates
  19976. */
  19977. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19978. /**
  19979. * Set a vec2 array in the shader from a number array.
  19980. * @param name Define the name of the uniform as defined in the shader
  19981. * @param value Define the value to give to the uniform
  19982. * @return the material itself allowing "fluent" like uniform updates
  19983. */
  19984. setArray2(name: string, value: number[]): ShaderMaterial;
  19985. /**
  19986. * Set a vec3 array in the shader from a number array.
  19987. * @param name Define the name of the uniform as defined in the shader
  19988. * @param value Define the value to give to the uniform
  19989. * @return the material itself allowing "fluent" like uniform updates
  19990. */
  19991. setArray3(name: string, value: number[]): ShaderMaterial;
  19992. /**
  19993. * Set a vec4 array in the shader from a number array.
  19994. * @param name Define the name of the uniform as defined in the shader
  19995. * @param value Define the value to give to the uniform
  19996. * @return the material itself allowing "fluent" like uniform updates
  19997. */
  19998. setArray4(name: string, value: number[]): ShaderMaterial;
  19999. private _checkCache;
  20000. /**
  20001. * Specifies that the submesh is ready to be used
  20002. * @param mesh defines the mesh to check
  20003. * @param subMesh defines which submesh to check
  20004. * @param useInstances specifies that instances should be used
  20005. * @returns a boolean indicating that the submesh is ready or not
  20006. */
  20007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20008. /**
  20009. * Checks if the material is ready to render the requested mesh
  20010. * @param mesh Define the mesh to render
  20011. * @param useInstances Define whether or not the material is used with instances
  20012. * @returns true if ready, otherwise false
  20013. */
  20014. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20015. /**
  20016. * Binds the world matrix to the material
  20017. * @param world defines the world transformation matrix
  20018. */
  20019. bindOnlyWorldMatrix(world: Matrix): void;
  20020. /**
  20021. * Binds the material to the mesh
  20022. * @param world defines the world transformation matrix
  20023. * @param mesh defines the mesh to bind the material to
  20024. */
  20025. bind(world: Matrix, mesh?: Mesh): void;
  20026. /**
  20027. * Gets the active textures from the material
  20028. * @returns an array of textures
  20029. */
  20030. getActiveTextures(): BaseTexture[];
  20031. /**
  20032. * Specifies if the material uses a texture
  20033. * @param texture defines the texture to check against the material
  20034. * @returns a boolean specifying if the material uses the texture
  20035. */
  20036. hasTexture(texture: BaseTexture): boolean;
  20037. /**
  20038. * Makes a duplicate of the material, and gives it a new name
  20039. * @param name defines the new name for the duplicated material
  20040. * @returns the cloned material
  20041. */
  20042. clone(name: string): ShaderMaterial;
  20043. /**
  20044. * Disposes the material
  20045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20048. */
  20049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20050. /**
  20051. * Serializes this material in a JSON representation
  20052. * @returns the serialized material object
  20053. */
  20054. serialize(): any;
  20055. /**
  20056. * Creates a shader material from parsed shader material data
  20057. * @param source defines the JSON represnetation of the material
  20058. * @param scene defines the hosting scene
  20059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20060. * @returns a new material
  20061. */
  20062. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20063. }
  20064. }
  20065. declare module "babylonjs/Shaders/color.fragment" {
  20066. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20068. /** @hidden */
  20069. export var colorPixelShader: {
  20070. name: string;
  20071. shader: string;
  20072. };
  20073. }
  20074. declare module "babylonjs/Shaders/color.vertex" {
  20075. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20076. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20077. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20078. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20079. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20080. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20081. /** @hidden */
  20082. export var colorVertexShader: {
  20083. name: string;
  20084. shader: string;
  20085. };
  20086. }
  20087. declare module "babylonjs/Meshes/linesMesh" {
  20088. import { Nullable } from "babylonjs/types";
  20089. import { Scene } from "babylonjs/scene";
  20090. import { Color3 } from "babylonjs/Maths/math.color";
  20091. import { Node } from "babylonjs/node";
  20092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20093. import { Mesh } from "babylonjs/Meshes/mesh";
  20094. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20095. import { Effect } from "babylonjs/Materials/effect";
  20096. import { Material } from "babylonjs/Materials/material";
  20097. import "babylonjs/Shaders/color.fragment";
  20098. import "babylonjs/Shaders/color.vertex";
  20099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20100. /**
  20101. * Line mesh
  20102. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20103. */
  20104. export class LinesMesh extends Mesh {
  20105. /**
  20106. * If vertex color should be applied to the mesh
  20107. */
  20108. readonly useVertexColor?: boolean | undefined;
  20109. /**
  20110. * If vertex alpha should be applied to the mesh
  20111. */
  20112. readonly useVertexAlpha?: boolean | undefined;
  20113. /**
  20114. * Color of the line (Default: White)
  20115. */
  20116. color: Color3;
  20117. /**
  20118. * Alpha of the line (Default: 1)
  20119. */
  20120. alpha: number;
  20121. /**
  20122. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20123. * This margin is expressed in world space coordinates, so its value may vary.
  20124. * Default value is 0.1
  20125. */
  20126. intersectionThreshold: number;
  20127. private _colorShader;
  20128. private color4;
  20129. /**
  20130. * Creates a new LinesMesh
  20131. * @param name defines the name
  20132. * @param scene defines the hosting scene
  20133. * @param parent defines the parent mesh if any
  20134. * @param source defines the optional source LinesMesh used to clone data from
  20135. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20136. * When false, achieved by calling a clone(), also passing False.
  20137. * This will make creation of children, recursive.
  20138. * @param useVertexColor defines if this LinesMesh supports vertex color
  20139. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20140. */
  20141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20142. /**
  20143. * If vertex color should be applied to the mesh
  20144. */
  20145. useVertexColor?: boolean | undefined,
  20146. /**
  20147. * If vertex alpha should be applied to the mesh
  20148. */
  20149. useVertexAlpha?: boolean | undefined);
  20150. private _addClipPlaneDefine;
  20151. private _removeClipPlaneDefine;
  20152. isReady(): boolean;
  20153. /**
  20154. * Returns the string "LineMesh"
  20155. */
  20156. getClassName(): string;
  20157. /**
  20158. * @hidden
  20159. */
  20160. /**
  20161. * @hidden
  20162. */
  20163. material: Material;
  20164. /**
  20165. * @hidden
  20166. */
  20167. readonly checkCollisions: boolean;
  20168. /** @hidden */
  20169. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20170. /** @hidden */
  20171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20172. /**
  20173. * Disposes of the line mesh
  20174. * @param doNotRecurse If children should be disposed
  20175. */
  20176. dispose(doNotRecurse?: boolean): void;
  20177. /**
  20178. * Returns a new LineMesh object cloned from the current one.
  20179. */
  20180. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20181. /**
  20182. * Creates a new InstancedLinesMesh object from the mesh model.
  20183. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20184. * @param name defines the name of the new instance
  20185. * @returns a new InstancedLinesMesh
  20186. */
  20187. createInstance(name: string): InstancedLinesMesh;
  20188. }
  20189. /**
  20190. * Creates an instance based on a source LinesMesh
  20191. */
  20192. export class InstancedLinesMesh extends InstancedMesh {
  20193. /**
  20194. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20195. * This margin is expressed in world space coordinates, so its value may vary.
  20196. * Initilized with the intersectionThreshold value of the source LinesMesh
  20197. */
  20198. intersectionThreshold: number;
  20199. constructor(name: string, source: LinesMesh);
  20200. /**
  20201. * Returns the string "InstancedLinesMesh".
  20202. */
  20203. getClassName(): string;
  20204. }
  20205. }
  20206. declare module "babylonjs/Shaders/line.fragment" {
  20207. /** @hidden */
  20208. export var linePixelShader: {
  20209. name: string;
  20210. shader: string;
  20211. };
  20212. }
  20213. declare module "babylonjs/Shaders/line.vertex" {
  20214. /** @hidden */
  20215. export var lineVertexShader: {
  20216. name: string;
  20217. shader: string;
  20218. };
  20219. }
  20220. declare module "babylonjs/Rendering/edgesRenderer" {
  20221. import { Nullable } from "babylonjs/types";
  20222. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20224. import { Vector3 } from "babylonjs/Maths/math.vector";
  20225. import { IDisposable } from "babylonjs/scene";
  20226. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20227. import "babylonjs/Shaders/line.fragment";
  20228. import "babylonjs/Shaders/line.vertex";
  20229. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20230. module "babylonjs/Meshes/abstractMesh" {
  20231. interface AbstractMesh {
  20232. /**
  20233. * Gets the edgesRenderer associated with the mesh
  20234. */
  20235. edgesRenderer: Nullable<EdgesRenderer>;
  20236. }
  20237. }
  20238. module "babylonjs/Meshes/linesMesh" {
  20239. interface LinesMesh {
  20240. /**
  20241. * Enables the edge rendering mode on the mesh.
  20242. * This mode makes the mesh edges visible
  20243. * @param epsilon defines the maximal distance between two angles to detect a face
  20244. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20245. * @returns the currentAbstractMesh
  20246. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20247. */
  20248. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20249. }
  20250. }
  20251. module "babylonjs/Meshes/linesMesh" {
  20252. interface InstancedLinesMesh {
  20253. /**
  20254. * Enables the edge rendering mode on the mesh.
  20255. * This mode makes the mesh edges visible
  20256. * @param epsilon defines the maximal distance between two angles to detect a face
  20257. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20258. * @returns the current InstancedLinesMesh
  20259. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20260. */
  20261. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20262. }
  20263. }
  20264. /**
  20265. * Defines the minimum contract an Edges renderer should follow.
  20266. */
  20267. export interface IEdgesRenderer extends IDisposable {
  20268. /**
  20269. * Gets or sets a boolean indicating if the edgesRenderer is active
  20270. */
  20271. isEnabled: boolean;
  20272. /**
  20273. * Renders the edges of the attached mesh,
  20274. */
  20275. render(): void;
  20276. /**
  20277. * Checks wether or not the edges renderer is ready to render.
  20278. * @return true if ready, otherwise false.
  20279. */
  20280. isReady(): boolean;
  20281. }
  20282. /**
  20283. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20284. */
  20285. export class EdgesRenderer implements IEdgesRenderer {
  20286. /**
  20287. * Define the size of the edges with an orthographic camera
  20288. */
  20289. edgesWidthScalerForOrthographic: number;
  20290. /**
  20291. * Define the size of the edges with a perspective camera
  20292. */
  20293. edgesWidthScalerForPerspective: number;
  20294. protected _source: AbstractMesh;
  20295. protected _linesPositions: number[];
  20296. protected _linesNormals: number[];
  20297. protected _linesIndices: number[];
  20298. protected _epsilon: number;
  20299. protected _indicesCount: number;
  20300. protected _lineShader: ShaderMaterial;
  20301. protected _ib: DataBuffer;
  20302. protected _buffers: {
  20303. [key: string]: Nullable<VertexBuffer>;
  20304. };
  20305. protected _checkVerticesInsteadOfIndices: boolean;
  20306. private _meshRebuildObserver;
  20307. private _meshDisposeObserver;
  20308. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20309. isEnabled: boolean;
  20310. /**
  20311. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20312. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20313. * @param source Mesh used to create edges
  20314. * @param epsilon sum of angles in adjacency to check for edge
  20315. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20316. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20317. */
  20318. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20319. protected _prepareRessources(): void;
  20320. /** @hidden */
  20321. _rebuild(): void;
  20322. /**
  20323. * Releases the required resources for the edges renderer
  20324. */
  20325. dispose(): void;
  20326. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20327. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20328. /**
  20329. * Checks if the pair of p0 and p1 is en edge
  20330. * @param faceIndex
  20331. * @param edge
  20332. * @param faceNormals
  20333. * @param p0
  20334. * @param p1
  20335. * @private
  20336. */
  20337. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20338. /**
  20339. * push line into the position, normal and index buffer
  20340. * @protected
  20341. */
  20342. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20343. /**
  20344. * Generates lines edges from adjacencjes
  20345. * @private
  20346. */
  20347. _generateEdgesLines(): void;
  20348. /**
  20349. * Checks wether or not the edges renderer is ready to render.
  20350. * @return true if ready, otherwise false.
  20351. */
  20352. isReady(): boolean;
  20353. /**
  20354. * Renders the edges of the attached mesh,
  20355. */
  20356. render(): void;
  20357. }
  20358. /**
  20359. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20360. */
  20361. export class LineEdgesRenderer extends EdgesRenderer {
  20362. /**
  20363. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20364. * @param source LineMesh used to generate edges
  20365. * @param epsilon not important (specified angle for edge detection)
  20366. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20367. */
  20368. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20369. /**
  20370. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20371. */
  20372. _generateEdgesLines(): void;
  20373. }
  20374. }
  20375. declare module "babylonjs/Rendering/renderingGroup" {
  20376. import { SmartArray } from "babylonjs/Misc/smartArray";
  20377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20379. import { Nullable } from "babylonjs/types";
  20380. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20381. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20382. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20383. import { Material } from "babylonjs/Materials/material";
  20384. import { Scene } from "babylonjs/scene";
  20385. /**
  20386. * This represents the object necessary to create a rendering group.
  20387. * This is exclusively used and created by the rendering manager.
  20388. * To modify the behavior, you use the available helpers in your scene or meshes.
  20389. * @hidden
  20390. */
  20391. export class RenderingGroup {
  20392. index: number;
  20393. private static _zeroVector;
  20394. private _scene;
  20395. private _opaqueSubMeshes;
  20396. private _transparentSubMeshes;
  20397. private _alphaTestSubMeshes;
  20398. private _depthOnlySubMeshes;
  20399. private _particleSystems;
  20400. private _spriteManagers;
  20401. private _opaqueSortCompareFn;
  20402. private _alphaTestSortCompareFn;
  20403. private _transparentSortCompareFn;
  20404. private _renderOpaque;
  20405. private _renderAlphaTest;
  20406. private _renderTransparent;
  20407. /** @hidden */
  20408. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20409. onBeforeTransparentRendering: () => void;
  20410. /**
  20411. * Set the opaque sort comparison function.
  20412. * If null the sub meshes will be render in the order they were created
  20413. */
  20414. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20415. /**
  20416. * Set the alpha test sort comparison function.
  20417. * If null the sub meshes will be render in the order they were created
  20418. */
  20419. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20420. /**
  20421. * Set the transparent sort comparison function.
  20422. * If null the sub meshes will be render in the order they were created
  20423. */
  20424. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20425. /**
  20426. * Creates a new rendering group.
  20427. * @param index The rendering group index
  20428. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20429. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20430. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20431. */
  20432. 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>);
  20433. /**
  20434. * Render all the sub meshes contained in the group.
  20435. * @param customRenderFunction Used to override the default render behaviour of the group.
  20436. * @returns true if rendered some submeshes.
  20437. */
  20438. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20439. /**
  20440. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20441. * @param subMeshes The submeshes to render
  20442. */
  20443. private renderOpaqueSorted;
  20444. /**
  20445. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20446. * @param subMeshes The submeshes to render
  20447. */
  20448. private renderAlphaTestSorted;
  20449. /**
  20450. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20451. * @param subMeshes The submeshes to render
  20452. */
  20453. private renderTransparentSorted;
  20454. /**
  20455. * Renders the submeshes in a specified order.
  20456. * @param subMeshes The submeshes to sort before render
  20457. * @param sortCompareFn The comparison function use to sort
  20458. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20459. * @param transparent Specifies to activate blending if true
  20460. */
  20461. private static renderSorted;
  20462. /**
  20463. * Renders the submeshes in the order they were dispatched (no sort applied).
  20464. * @param subMeshes The submeshes to render
  20465. */
  20466. private static renderUnsorted;
  20467. /**
  20468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20469. * are rendered back to front if in the same alpha index.
  20470. *
  20471. * @param a The first submesh
  20472. * @param b The second submesh
  20473. * @returns The result of the comparison
  20474. */
  20475. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20476. /**
  20477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20478. * are rendered back to front.
  20479. *
  20480. * @param a The first submesh
  20481. * @param b The second submesh
  20482. * @returns The result of the comparison
  20483. */
  20484. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20485. /**
  20486. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20487. * are rendered front to back (prevent overdraw).
  20488. *
  20489. * @param a The first submesh
  20490. * @param b The second submesh
  20491. * @returns The result of the comparison
  20492. */
  20493. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20494. /**
  20495. * Resets the different lists of submeshes to prepare a new frame.
  20496. */
  20497. prepare(): void;
  20498. dispose(): void;
  20499. /**
  20500. * Inserts the submesh in its correct queue depending on its material.
  20501. * @param subMesh The submesh to dispatch
  20502. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20503. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20504. */
  20505. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20506. dispatchSprites(spriteManager: ISpriteManager): void;
  20507. dispatchParticles(particleSystem: IParticleSystem): void;
  20508. private _renderParticles;
  20509. private _renderSprites;
  20510. }
  20511. }
  20512. declare module "babylonjs/Rendering/renderingManager" {
  20513. import { Nullable } from "babylonjs/types";
  20514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20515. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20516. import { SmartArray } from "babylonjs/Misc/smartArray";
  20517. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20519. import { Material } from "babylonjs/Materials/material";
  20520. import { Scene } from "babylonjs/scene";
  20521. import { Camera } from "babylonjs/Cameras/camera";
  20522. /**
  20523. * Interface describing the different options available in the rendering manager
  20524. * regarding Auto Clear between groups.
  20525. */
  20526. export interface IRenderingManagerAutoClearSetup {
  20527. /**
  20528. * Defines whether or not autoclear is enable.
  20529. */
  20530. autoClear: boolean;
  20531. /**
  20532. * Defines whether or not to autoclear the depth buffer.
  20533. */
  20534. depth: boolean;
  20535. /**
  20536. * Defines whether or not to autoclear the stencil buffer.
  20537. */
  20538. stencil: boolean;
  20539. }
  20540. /**
  20541. * This class is used by the onRenderingGroupObservable
  20542. */
  20543. export class RenderingGroupInfo {
  20544. /**
  20545. * The Scene that being rendered
  20546. */
  20547. scene: Scene;
  20548. /**
  20549. * The camera currently used for the rendering pass
  20550. */
  20551. camera: Nullable<Camera>;
  20552. /**
  20553. * The ID of the renderingGroup being processed
  20554. */
  20555. renderingGroupId: number;
  20556. }
  20557. /**
  20558. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20559. * It is enable to manage the different groups as well as the different necessary sort functions.
  20560. * This should not be used directly aside of the few static configurations
  20561. */
  20562. export class RenderingManager {
  20563. /**
  20564. * The max id used for rendering groups (not included)
  20565. */
  20566. static MAX_RENDERINGGROUPS: number;
  20567. /**
  20568. * The min id used for rendering groups (included)
  20569. */
  20570. static MIN_RENDERINGGROUPS: number;
  20571. /**
  20572. * Used to globally prevent autoclearing scenes.
  20573. */
  20574. static AUTOCLEAR: boolean;
  20575. /**
  20576. * @hidden
  20577. */
  20578. _useSceneAutoClearSetup: boolean;
  20579. private _scene;
  20580. private _renderingGroups;
  20581. private _depthStencilBufferAlreadyCleaned;
  20582. private _autoClearDepthStencil;
  20583. private _customOpaqueSortCompareFn;
  20584. private _customAlphaTestSortCompareFn;
  20585. private _customTransparentSortCompareFn;
  20586. private _renderingGroupInfo;
  20587. /**
  20588. * Instantiates a new rendering group for a particular scene
  20589. * @param scene Defines the scene the groups belongs to
  20590. */
  20591. constructor(scene: Scene);
  20592. private _clearDepthStencilBuffer;
  20593. /**
  20594. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20595. * @hidden
  20596. */
  20597. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20598. /**
  20599. * Resets the different information of the group to prepare a new frame
  20600. * @hidden
  20601. */
  20602. reset(): void;
  20603. /**
  20604. * Dispose and release the group and its associated resources.
  20605. * @hidden
  20606. */
  20607. dispose(): void;
  20608. /**
  20609. * Clear the info related to rendering groups preventing retention points during dispose.
  20610. */
  20611. freeRenderingGroups(): void;
  20612. private _prepareRenderingGroup;
  20613. /**
  20614. * Add a sprite manager to the rendering manager in order to render it this frame.
  20615. * @param spriteManager Define the sprite manager to render
  20616. */
  20617. dispatchSprites(spriteManager: ISpriteManager): void;
  20618. /**
  20619. * Add a particle system to the rendering manager in order to render it this frame.
  20620. * @param particleSystem Define the particle system to render
  20621. */
  20622. dispatchParticles(particleSystem: IParticleSystem): void;
  20623. /**
  20624. * Add a submesh to the manager in order to render it this frame
  20625. * @param subMesh The submesh to dispatch
  20626. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20627. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20628. */
  20629. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20630. /**
  20631. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20632. * This allowed control for front to back rendering or reversly depending of the special needs.
  20633. *
  20634. * @param renderingGroupId The rendering group id corresponding to its index
  20635. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20636. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20637. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20638. */
  20639. 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;
  20640. /**
  20641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20642. *
  20643. * @param renderingGroupId The rendering group id corresponding to its index
  20644. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20645. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20646. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20647. */
  20648. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20649. /**
  20650. * Gets the current auto clear configuration for one rendering group of the rendering
  20651. * manager.
  20652. * @param index the rendering group index to get the information for
  20653. * @returns The auto clear setup for the requested rendering group
  20654. */
  20655. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20656. }
  20657. }
  20658. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20659. import { Observable } from "babylonjs/Misc/observable";
  20660. import { SmartArray } from "babylonjs/Misc/smartArray";
  20661. import { Nullable } from "babylonjs/types";
  20662. import { Camera } from "babylonjs/Cameras/camera";
  20663. import { Scene } from "babylonjs/scene";
  20664. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20665. import { Color4 } from "babylonjs/Maths/math.color";
  20666. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20670. import { Texture } from "babylonjs/Materials/Textures/texture";
  20671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20672. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20673. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20674. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20675. import { Engine } from "babylonjs/Engines/engine";
  20676. /**
  20677. * This Helps creating a texture that will be created from a camera in your scene.
  20678. * It is basically a dynamic texture that could be used to create special effects for instance.
  20679. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20680. */
  20681. export class RenderTargetTexture extends Texture {
  20682. isCube: boolean;
  20683. /**
  20684. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONCE: number;
  20687. /**
  20688. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20689. */
  20690. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20691. /**
  20692. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20693. * the central point of your effect and can save a lot of performances.
  20694. */
  20695. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20696. /**
  20697. * Use this predicate to dynamically define the list of mesh you want to render.
  20698. * If set, the renderList property will be overwritten.
  20699. */
  20700. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20701. private _renderList;
  20702. /**
  20703. * Use this list to define the list of mesh you want to render.
  20704. */
  20705. renderList: Nullable<Array<AbstractMesh>>;
  20706. private _hookArray;
  20707. /**
  20708. * Define if particles should be rendered in your texture.
  20709. */
  20710. renderParticles: boolean;
  20711. /**
  20712. * Define if sprites should be rendered in your texture.
  20713. */
  20714. renderSprites: boolean;
  20715. /**
  20716. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20717. */
  20718. coordinatesMode: number;
  20719. /**
  20720. * Define the camera used to render the texture.
  20721. */
  20722. activeCamera: Nullable<Camera>;
  20723. /**
  20724. * Override the render function of the texture with your own one.
  20725. */
  20726. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20727. /**
  20728. * Define if camera post processes should be use while rendering the texture.
  20729. */
  20730. useCameraPostProcesses: boolean;
  20731. /**
  20732. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20733. */
  20734. ignoreCameraViewport: boolean;
  20735. private _postProcessManager;
  20736. private _postProcesses;
  20737. private _resizeObserver;
  20738. /**
  20739. * An event triggered when the texture is unbind.
  20740. */
  20741. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20742. /**
  20743. * An event triggered when the texture is unbind.
  20744. */
  20745. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20746. private _onAfterUnbindObserver;
  20747. /**
  20748. * Set a after unbind callback in the texture.
  20749. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20750. */
  20751. onAfterUnbind: () => void;
  20752. /**
  20753. * An event triggered before rendering the texture
  20754. */
  20755. onBeforeRenderObservable: Observable<number>;
  20756. private _onBeforeRenderObserver;
  20757. /**
  20758. * Set a before render callback in the texture.
  20759. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20760. */
  20761. onBeforeRender: (faceIndex: number) => void;
  20762. /**
  20763. * An event triggered after rendering the texture
  20764. */
  20765. onAfterRenderObservable: Observable<number>;
  20766. private _onAfterRenderObserver;
  20767. /**
  20768. * Set a after render callback in the texture.
  20769. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20770. */
  20771. onAfterRender: (faceIndex: number) => void;
  20772. /**
  20773. * An event triggered after the texture clear
  20774. */
  20775. onClearObservable: Observable<Engine>;
  20776. private _onClearObserver;
  20777. /**
  20778. * Set a clear callback in the texture.
  20779. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20780. */
  20781. onClear: (Engine: Engine) => void;
  20782. /**
  20783. * An event triggered when the texture is resized.
  20784. */
  20785. onResizeObservable: Observable<RenderTargetTexture>;
  20786. /**
  20787. * Define the clear color of the Render Target if it should be different from the scene.
  20788. */
  20789. clearColor: Color4;
  20790. protected _size: number | {
  20791. width: number;
  20792. height: number;
  20793. };
  20794. protected _initialSizeParameter: number | {
  20795. width: number;
  20796. height: number;
  20797. } | {
  20798. ratio: number;
  20799. };
  20800. protected _sizeRatio: Nullable<number>;
  20801. /** @hidden */
  20802. _generateMipMaps: boolean;
  20803. protected _renderingManager: RenderingManager;
  20804. /** @hidden */
  20805. _waitingRenderList: string[];
  20806. protected _doNotChangeAspectRatio: boolean;
  20807. protected _currentRefreshId: number;
  20808. protected _refreshRate: number;
  20809. protected _textureMatrix: Matrix;
  20810. protected _samples: number;
  20811. protected _renderTargetOptions: RenderTargetCreationOptions;
  20812. /**
  20813. * Gets render target creation options that were used.
  20814. */
  20815. readonly renderTargetOptions: RenderTargetCreationOptions;
  20816. protected _engine: Engine;
  20817. protected _onRatioRescale(): void;
  20818. /**
  20819. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20820. * It must define where the camera used to render the texture is set
  20821. */
  20822. boundingBoxPosition: Vector3;
  20823. private _boundingBoxSize;
  20824. /**
  20825. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20826. * When defined, the cubemap will switch to local mode
  20827. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20828. * @example https://www.babylonjs-playground.com/#RNASML
  20829. */
  20830. boundingBoxSize: Vector3;
  20831. /**
  20832. * In case the RTT has been created with a depth texture, get the associated
  20833. * depth texture.
  20834. * Otherwise, return null.
  20835. */
  20836. depthStencilTexture: Nullable<InternalTexture>;
  20837. /**
  20838. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20839. * or used a shadow, depth texture...
  20840. * @param name The friendly name of the texture
  20841. * @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)
  20842. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20843. * @param generateMipMaps True if mip maps need to be generated after render.
  20844. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20845. * @param type The type of the buffer in the RTT (int, half float, float...)
  20846. * @param isCube True if a cube texture needs to be created
  20847. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20848. * @param generateDepthBuffer True to generate a depth buffer
  20849. * @param generateStencilBuffer True to generate a stencil buffer
  20850. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20851. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20852. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20853. */
  20854. constructor(name: string, size: number | {
  20855. width: number;
  20856. height: number;
  20857. } | {
  20858. ratio: number;
  20859. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20860. /**
  20861. * Creates a depth stencil texture.
  20862. * This is only available in WebGL 2 or with the depth texture extension available.
  20863. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20864. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20865. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20866. */
  20867. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20868. private _processSizeParameter;
  20869. /**
  20870. * Define the number of samples to use in case of MSAA.
  20871. * It defaults to one meaning no MSAA has been enabled.
  20872. */
  20873. samples: number;
  20874. /**
  20875. * Resets the refresh counter of the texture and start bak from scratch.
  20876. * Could be useful to regenerate the texture if it is setup to render only once.
  20877. */
  20878. resetRefreshCounter(): void;
  20879. /**
  20880. * Define the refresh rate of the texture or the rendering frequency.
  20881. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20882. */
  20883. refreshRate: number;
  20884. /**
  20885. * Adds a post process to the render target rendering passes.
  20886. * @param postProcess define the post process to add
  20887. */
  20888. addPostProcess(postProcess: PostProcess): void;
  20889. /**
  20890. * Clear all the post processes attached to the render target
  20891. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20892. */
  20893. clearPostProcesses(dispose?: boolean): void;
  20894. /**
  20895. * Remove one of the post process from the list of attached post processes to the texture
  20896. * @param postProcess define the post process to remove from the list
  20897. */
  20898. removePostProcess(postProcess: PostProcess): void;
  20899. /** @hidden */
  20900. _shouldRender(): boolean;
  20901. /**
  20902. * Gets the actual render size of the texture.
  20903. * @returns the width of the render size
  20904. */
  20905. getRenderSize(): number;
  20906. /**
  20907. * Gets the actual render width of the texture.
  20908. * @returns the width of the render size
  20909. */
  20910. getRenderWidth(): number;
  20911. /**
  20912. * Gets the actual render height of the texture.
  20913. * @returns the height of the render size
  20914. */
  20915. getRenderHeight(): number;
  20916. /**
  20917. * Get if the texture can be rescaled or not.
  20918. */
  20919. readonly canRescale: boolean;
  20920. /**
  20921. * Resize the texture using a ratio.
  20922. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20923. */
  20924. scale(ratio: number): void;
  20925. /**
  20926. * Get the texture reflection matrix used to rotate/transform the reflection.
  20927. * @returns the reflection matrix
  20928. */
  20929. getReflectionTextureMatrix(): Matrix;
  20930. /**
  20931. * Resize the texture to a new desired size.
  20932. * Be carrefull as it will recreate all the data in the new texture.
  20933. * @param size Define the new size. It can be:
  20934. * - a number for squared texture,
  20935. * - an object containing { width: number, height: number }
  20936. * - or an object containing a ratio { ratio: number }
  20937. */
  20938. resize(size: number | {
  20939. width: number;
  20940. height: number;
  20941. } | {
  20942. ratio: number;
  20943. }): void;
  20944. /**
  20945. * Renders all the objects from the render list into the texture.
  20946. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20947. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20948. */
  20949. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20950. private _bestReflectionRenderTargetDimension;
  20951. /**
  20952. * @hidden
  20953. * @param faceIndex face index to bind to if this is a cubetexture
  20954. */
  20955. _bindFrameBuffer(faceIndex?: number): void;
  20956. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20957. private renderToTarget;
  20958. /**
  20959. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20960. * This allowed control for front to back rendering or reversly depending of the special needs.
  20961. *
  20962. * @param renderingGroupId The rendering group id corresponding to its index
  20963. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20964. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20965. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20966. */
  20967. 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;
  20968. /**
  20969. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20970. *
  20971. * @param renderingGroupId The rendering group id corresponding to its index
  20972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20973. */
  20974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20975. /**
  20976. * Clones the texture.
  20977. * @returns the cloned texture
  20978. */
  20979. clone(): RenderTargetTexture;
  20980. /**
  20981. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20982. * @returns The JSON representation of the texture
  20983. */
  20984. serialize(): any;
  20985. /**
  20986. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20987. */
  20988. disposeFramebufferObjects(): void;
  20989. /**
  20990. * Dispose the texture and release its associated resources.
  20991. */
  20992. dispose(): void;
  20993. /** @hidden */
  20994. _rebuild(): void;
  20995. /**
  20996. * Clear the info related to rendering groups preventing retention point in material dispose.
  20997. */
  20998. freeRenderingGroups(): void;
  20999. /**
  21000. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21001. * @returns the view count
  21002. */
  21003. getViewCount(): number;
  21004. }
  21005. }
  21006. declare module "babylonjs/Materials/material" {
  21007. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21008. import { SmartArray } from "babylonjs/Misc/smartArray";
  21009. import { Observable } from "babylonjs/Misc/observable";
  21010. import { Nullable } from "babylonjs/types";
  21011. import { Scene } from "babylonjs/scene";
  21012. import { Matrix } from "babylonjs/Maths/math.vector";
  21013. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21015. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21016. import { Effect } from "babylonjs/Materials/effect";
  21017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21018. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21019. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21020. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21021. import { Mesh } from "babylonjs/Meshes/mesh";
  21022. import { Animation } from "babylonjs/Animations/animation";
  21023. /**
  21024. * Options for compiling materials.
  21025. */
  21026. export interface IMaterialCompilationOptions {
  21027. /**
  21028. * Defines whether clip planes are enabled.
  21029. */
  21030. clipPlane: boolean;
  21031. /**
  21032. * Defines whether instances are enabled.
  21033. */
  21034. useInstances: boolean;
  21035. }
  21036. /**
  21037. * Base class for the main features of a material in Babylon.js
  21038. */
  21039. export class Material implements IAnimatable {
  21040. /**
  21041. * Returns the triangle fill mode
  21042. */
  21043. static readonly TriangleFillMode: number;
  21044. /**
  21045. * Returns the wireframe mode
  21046. */
  21047. static readonly WireFrameFillMode: number;
  21048. /**
  21049. * Returns the point fill mode
  21050. */
  21051. static readonly PointFillMode: number;
  21052. /**
  21053. * Returns the point list draw mode
  21054. */
  21055. static readonly PointListDrawMode: number;
  21056. /**
  21057. * Returns the line list draw mode
  21058. */
  21059. static readonly LineListDrawMode: number;
  21060. /**
  21061. * Returns the line loop draw mode
  21062. */
  21063. static readonly LineLoopDrawMode: number;
  21064. /**
  21065. * Returns the line strip draw mode
  21066. */
  21067. static readonly LineStripDrawMode: number;
  21068. /**
  21069. * Returns the triangle strip draw mode
  21070. */
  21071. static readonly TriangleStripDrawMode: number;
  21072. /**
  21073. * Returns the triangle fan draw mode
  21074. */
  21075. static readonly TriangleFanDrawMode: number;
  21076. /**
  21077. * Stores the clock-wise side orientation
  21078. */
  21079. static readonly ClockWiseSideOrientation: number;
  21080. /**
  21081. * Stores the counter clock-wise side orientation
  21082. */
  21083. static readonly CounterClockWiseSideOrientation: number;
  21084. /**
  21085. * The dirty texture flag value
  21086. */
  21087. static readonly TextureDirtyFlag: number;
  21088. /**
  21089. * The dirty light flag value
  21090. */
  21091. static readonly LightDirtyFlag: number;
  21092. /**
  21093. * The dirty fresnel flag value
  21094. */
  21095. static readonly FresnelDirtyFlag: number;
  21096. /**
  21097. * The dirty attribute flag value
  21098. */
  21099. static readonly AttributesDirtyFlag: number;
  21100. /**
  21101. * The dirty misc flag value
  21102. */
  21103. static readonly MiscDirtyFlag: number;
  21104. /**
  21105. * The all dirty flag value
  21106. */
  21107. static readonly AllDirtyFlag: number;
  21108. /**
  21109. * The ID of the material
  21110. */
  21111. id: string;
  21112. /**
  21113. * Gets or sets the unique id of the material
  21114. */
  21115. uniqueId: number;
  21116. /**
  21117. * The name of the material
  21118. */
  21119. name: string;
  21120. /**
  21121. * Gets or sets user defined metadata
  21122. */
  21123. metadata: any;
  21124. /**
  21125. * For internal use only. Please do not use.
  21126. */
  21127. reservedDataStore: any;
  21128. /**
  21129. * Specifies if the ready state should be checked on each call
  21130. */
  21131. checkReadyOnEveryCall: boolean;
  21132. /**
  21133. * Specifies if the ready state should be checked once
  21134. */
  21135. checkReadyOnlyOnce: boolean;
  21136. /**
  21137. * The state of the material
  21138. */
  21139. state: string;
  21140. /**
  21141. * The alpha value of the material
  21142. */
  21143. protected _alpha: number;
  21144. /**
  21145. * List of inspectable custom properties (used by the Inspector)
  21146. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21147. */
  21148. inspectableCustomProperties: IInspectable[];
  21149. /**
  21150. * Sets the alpha value of the material
  21151. */
  21152. /**
  21153. * Gets the alpha value of the material
  21154. */
  21155. alpha: number;
  21156. /**
  21157. * Specifies if back face culling is enabled
  21158. */
  21159. protected _backFaceCulling: boolean;
  21160. /**
  21161. * Sets the back-face culling state
  21162. */
  21163. /**
  21164. * Gets the back-face culling state
  21165. */
  21166. backFaceCulling: boolean;
  21167. /**
  21168. * Stores the value for side orientation
  21169. */
  21170. sideOrientation: number;
  21171. /**
  21172. * Callback triggered when the material is compiled
  21173. */
  21174. onCompiled: Nullable<(effect: Effect) => void>;
  21175. /**
  21176. * Callback triggered when an error occurs
  21177. */
  21178. onError: Nullable<(effect: Effect, errors: string) => void>;
  21179. /**
  21180. * Callback triggered to get the render target textures
  21181. */
  21182. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21183. /**
  21184. * Gets a boolean indicating that current material needs to register RTT
  21185. */
  21186. readonly hasRenderTargetTextures: boolean;
  21187. /**
  21188. * Specifies if the material should be serialized
  21189. */
  21190. doNotSerialize: boolean;
  21191. /**
  21192. * @hidden
  21193. */
  21194. _storeEffectOnSubMeshes: boolean;
  21195. /**
  21196. * Stores the animations for the material
  21197. */
  21198. animations: Nullable<Array<Animation>>;
  21199. /**
  21200. * An event triggered when the material is disposed
  21201. */
  21202. onDisposeObservable: Observable<Material>;
  21203. /**
  21204. * An observer which watches for dispose events
  21205. */
  21206. private _onDisposeObserver;
  21207. private _onUnBindObservable;
  21208. /**
  21209. * Called during a dispose event
  21210. */
  21211. onDispose: () => void;
  21212. private _onBindObservable;
  21213. /**
  21214. * An event triggered when the material is bound
  21215. */
  21216. readonly onBindObservable: Observable<AbstractMesh>;
  21217. /**
  21218. * An observer which watches for bind events
  21219. */
  21220. private _onBindObserver;
  21221. /**
  21222. * Called during a bind event
  21223. */
  21224. onBind: (Mesh: AbstractMesh) => void;
  21225. /**
  21226. * An event triggered when the material is unbound
  21227. */
  21228. readonly onUnBindObservable: Observable<Material>;
  21229. /**
  21230. * Stores the value of the alpha mode
  21231. */
  21232. private _alphaMode;
  21233. /**
  21234. * Sets the value of the alpha mode.
  21235. *
  21236. * | Value | Type | Description |
  21237. * | --- | --- | --- |
  21238. * | 0 | ALPHA_DISABLE | |
  21239. * | 1 | ALPHA_ADD | |
  21240. * | 2 | ALPHA_COMBINE | |
  21241. * | 3 | ALPHA_SUBTRACT | |
  21242. * | 4 | ALPHA_MULTIPLY | |
  21243. * | 5 | ALPHA_MAXIMIZED | |
  21244. * | 6 | ALPHA_ONEONE | |
  21245. * | 7 | ALPHA_PREMULTIPLIED | |
  21246. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21247. * | 9 | ALPHA_INTERPOLATE | |
  21248. * | 10 | ALPHA_SCREENMODE | |
  21249. *
  21250. */
  21251. /**
  21252. * Gets the value of the alpha mode
  21253. */
  21254. alphaMode: number;
  21255. /**
  21256. * Stores the state of the need depth pre-pass value
  21257. */
  21258. private _needDepthPrePass;
  21259. /**
  21260. * Sets the need depth pre-pass value
  21261. */
  21262. /**
  21263. * Gets the depth pre-pass value
  21264. */
  21265. needDepthPrePass: boolean;
  21266. /**
  21267. * Specifies if depth writing should be disabled
  21268. */
  21269. disableDepthWrite: boolean;
  21270. /**
  21271. * Specifies if depth writing should be forced
  21272. */
  21273. forceDepthWrite: boolean;
  21274. /**
  21275. * Specifies the depth function that should be used. 0 means the default engine function
  21276. */
  21277. depthFunction: number;
  21278. /**
  21279. * Specifies if there should be a separate pass for culling
  21280. */
  21281. separateCullingPass: boolean;
  21282. /**
  21283. * Stores the state specifing if fog should be enabled
  21284. */
  21285. private _fogEnabled;
  21286. /**
  21287. * Sets the state for enabling fog
  21288. */
  21289. /**
  21290. * Gets the value of the fog enabled state
  21291. */
  21292. fogEnabled: boolean;
  21293. /**
  21294. * Stores the size of points
  21295. */
  21296. pointSize: number;
  21297. /**
  21298. * Stores the z offset value
  21299. */
  21300. zOffset: number;
  21301. /**
  21302. * Gets a value specifying if wireframe mode is enabled
  21303. */
  21304. /**
  21305. * Sets the state of wireframe mode
  21306. */
  21307. wireframe: boolean;
  21308. /**
  21309. * Gets the value specifying if point clouds are enabled
  21310. */
  21311. /**
  21312. * Sets the state of point cloud mode
  21313. */
  21314. pointsCloud: boolean;
  21315. /**
  21316. * Gets the material fill mode
  21317. */
  21318. /**
  21319. * Sets the material fill mode
  21320. */
  21321. fillMode: number;
  21322. /**
  21323. * @hidden
  21324. * Stores the effects for the material
  21325. */
  21326. _effect: Nullable<Effect>;
  21327. /**
  21328. * @hidden
  21329. * Specifies if the material was previously ready
  21330. */
  21331. _wasPreviouslyReady: boolean;
  21332. /**
  21333. * Specifies if uniform buffers should be used
  21334. */
  21335. private _useUBO;
  21336. /**
  21337. * Stores a reference to the scene
  21338. */
  21339. private _scene;
  21340. /**
  21341. * Stores the fill mode state
  21342. */
  21343. private _fillMode;
  21344. /**
  21345. * Specifies if the depth write state should be cached
  21346. */
  21347. private _cachedDepthWriteState;
  21348. /**
  21349. * Specifies if the depth function state should be cached
  21350. */
  21351. private _cachedDepthFunctionState;
  21352. /**
  21353. * Stores the uniform buffer
  21354. */
  21355. protected _uniformBuffer: UniformBuffer;
  21356. /** @hidden */
  21357. _indexInSceneMaterialArray: number;
  21358. /** @hidden */
  21359. meshMap: Nullable<{
  21360. [id: string]: AbstractMesh | undefined;
  21361. }>;
  21362. /**
  21363. * Creates a material instance
  21364. * @param name defines the name of the material
  21365. * @param scene defines the scene to reference
  21366. * @param doNotAdd specifies if the material should be added to the scene
  21367. */
  21368. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21369. /**
  21370. * Returns a string representation of the current material
  21371. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21372. * @returns a string with material information
  21373. */
  21374. toString(fullDetails?: boolean): string;
  21375. /**
  21376. * Gets the class name of the material
  21377. * @returns a string with the class name of the material
  21378. */
  21379. getClassName(): string;
  21380. /**
  21381. * Specifies if updates for the material been locked
  21382. */
  21383. readonly isFrozen: boolean;
  21384. /**
  21385. * Locks updates for the material
  21386. */
  21387. freeze(): void;
  21388. /**
  21389. * Unlocks updates for the material
  21390. */
  21391. unfreeze(): void;
  21392. /**
  21393. * Specifies if the material is ready to be used
  21394. * @param mesh defines the mesh to check
  21395. * @param useInstances specifies if instances should be used
  21396. * @returns a boolean indicating if the material is ready to be used
  21397. */
  21398. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21399. /**
  21400. * Specifies that the submesh is ready to be used
  21401. * @param mesh defines the mesh to check
  21402. * @param subMesh defines which submesh to check
  21403. * @param useInstances specifies that instances should be used
  21404. * @returns a boolean indicating that the submesh is ready or not
  21405. */
  21406. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21407. /**
  21408. * Returns the material effect
  21409. * @returns the effect associated with the material
  21410. */
  21411. getEffect(): Nullable<Effect>;
  21412. /**
  21413. * Returns the current scene
  21414. * @returns a Scene
  21415. */
  21416. getScene(): Scene;
  21417. /**
  21418. * Specifies if the material will require alpha blending
  21419. * @returns a boolean specifying if alpha blending is needed
  21420. */
  21421. needAlphaBlending(): boolean;
  21422. /**
  21423. * Specifies if the mesh will require alpha blending
  21424. * @param mesh defines the mesh to check
  21425. * @returns a boolean specifying if alpha blending is needed for the mesh
  21426. */
  21427. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21428. /**
  21429. * Specifies if this material should be rendered in alpha test mode
  21430. * @returns a boolean specifying if an alpha test is needed.
  21431. */
  21432. needAlphaTesting(): boolean;
  21433. /**
  21434. * Gets the texture used for the alpha test
  21435. * @returns the texture to use for alpha testing
  21436. */
  21437. getAlphaTestTexture(): Nullable<BaseTexture>;
  21438. /**
  21439. * Marks the material to indicate that it needs to be re-calculated
  21440. */
  21441. markDirty(): void;
  21442. /** @hidden */
  21443. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21444. /**
  21445. * Binds the material to the mesh
  21446. * @param world defines the world transformation matrix
  21447. * @param mesh defines the mesh to bind the material to
  21448. */
  21449. bind(world: Matrix, mesh?: Mesh): void;
  21450. /**
  21451. * Binds the submesh to the material
  21452. * @param world defines the world transformation matrix
  21453. * @param mesh defines the mesh containing the submesh
  21454. * @param subMesh defines the submesh to bind the material to
  21455. */
  21456. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21457. /**
  21458. * Binds the world matrix to the material
  21459. * @param world defines the world transformation matrix
  21460. */
  21461. bindOnlyWorldMatrix(world: Matrix): void;
  21462. /**
  21463. * Binds the scene's uniform buffer to the effect.
  21464. * @param effect defines the effect to bind to the scene uniform buffer
  21465. * @param sceneUbo defines the uniform buffer storing scene data
  21466. */
  21467. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21468. /**
  21469. * Binds the view matrix to the effect
  21470. * @param effect defines the effect to bind the view matrix to
  21471. */
  21472. bindView(effect: Effect): void;
  21473. /**
  21474. * Binds the view projection matrix to the effect
  21475. * @param effect defines the effect to bind the view projection matrix to
  21476. */
  21477. bindViewProjection(effect: Effect): void;
  21478. /**
  21479. * Specifies if material alpha testing should be turned on for the mesh
  21480. * @param mesh defines the mesh to check
  21481. */
  21482. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21483. /**
  21484. * Processes to execute after binding the material to a mesh
  21485. * @param mesh defines the rendered mesh
  21486. */
  21487. protected _afterBind(mesh?: Mesh): void;
  21488. /**
  21489. * Unbinds the material from the mesh
  21490. */
  21491. unbind(): void;
  21492. /**
  21493. * Gets the active textures from the material
  21494. * @returns an array of textures
  21495. */
  21496. getActiveTextures(): BaseTexture[];
  21497. /**
  21498. * Specifies if the material uses a texture
  21499. * @param texture defines the texture to check against the material
  21500. * @returns a boolean specifying if the material uses the texture
  21501. */
  21502. hasTexture(texture: BaseTexture): boolean;
  21503. /**
  21504. * Makes a duplicate of the material, and gives it a new name
  21505. * @param name defines the new name for the duplicated material
  21506. * @returns the cloned material
  21507. */
  21508. clone(name: string): Nullable<Material>;
  21509. /**
  21510. * Gets the meshes bound to the material
  21511. * @returns an array of meshes bound to the material
  21512. */
  21513. getBindedMeshes(): AbstractMesh[];
  21514. /**
  21515. * Force shader compilation
  21516. * @param mesh defines the mesh associated with this material
  21517. * @param onCompiled defines a function to execute once the material is compiled
  21518. * @param options defines the options to configure the compilation
  21519. * @param onError defines a function to execute if the material fails compiling
  21520. */
  21521. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21522. /**
  21523. * Force shader compilation
  21524. * @param mesh defines the mesh that will use this material
  21525. * @param options defines additional options for compiling the shaders
  21526. * @returns a promise that resolves when the compilation completes
  21527. */
  21528. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21529. private static readonly _AllDirtyCallBack;
  21530. private static readonly _ImageProcessingDirtyCallBack;
  21531. private static readonly _TextureDirtyCallBack;
  21532. private static readonly _FresnelDirtyCallBack;
  21533. private static readonly _MiscDirtyCallBack;
  21534. private static readonly _LightsDirtyCallBack;
  21535. private static readonly _AttributeDirtyCallBack;
  21536. private static _FresnelAndMiscDirtyCallBack;
  21537. private static _TextureAndMiscDirtyCallBack;
  21538. private static readonly _DirtyCallbackArray;
  21539. private static readonly _RunDirtyCallBacks;
  21540. /**
  21541. * Marks a define in the material to indicate that it needs to be re-computed
  21542. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21543. */
  21544. markAsDirty(flag: number): void;
  21545. /**
  21546. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21547. * @param func defines a function which checks material defines against the submeshes
  21548. */
  21549. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21550. /**
  21551. * Indicates that we need to re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsAllDirty(): void;
  21554. /**
  21555. * Indicates that image processing needs to be re-calculated for all submeshes
  21556. */
  21557. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21558. /**
  21559. * Indicates that textures need to be re-calculated for all submeshes
  21560. */
  21561. protected _markAllSubMeshesAsTexturesDirty(): void;
  21562. /**
  21563. * Indicates that fresnel needs to be re-calculated for all submeshes
  21564. */
  21565. protected _markAllSubMeshesAsFresnelDirty(): void;
  21566. /**
  21567. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21568. */
  21569. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21570. /**
  21571. * Indicates that lights need to be re-calculated for all submeshes
  21572. */
  21573. protected _markAllSubMeshesAsLightsDirty(): void;
  21574. /**
  21575. * Indicates that attributes need to be re-calculated for all submeshes
  21576. */
  21577. protected _markAllSubMeshesAsAttributesDirty(): void;
  21578. /**
  21579. * Indicates that misc needs to be re-calculated for all submeshes
  21580. */
  21581. protected _markAllSubMeshesAsMiscDirty(): void;
  21582. /**
  21583. * Indicates that textures and misc need to be re-calculated for all submeshes
  21584. */
  21585. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21586. /**
  21587. * Disposes the material
  21588. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21589. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21590. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21591. */
  21592. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21593. /** @hidden */
  21594. private releaseVertexArrayObject;
  21595. /**
  21596. * Serializes this material
  21597. * @returns the serialized material object
  21598. */
  21599. serialize(): any;
  21600. /**
  21601. * Creates a material from parsed material data
  21602. * @param parsedMaterial defines parsed material data
  21603. * @param scene defines the hosting scene
  21604. * @param rootUrl defines the root URL to use to load textures
  21605. * @returns a new material
  21606. */
  21607. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21608. }
  21609. }
  21610. declare module "babylonjs/Materials/multiMaterial" {
  21611. import { Nullable } from "babylonjs/types";
  21612. import { Scene } from "babylonjs/scene";
  21613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21614. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21616. import { Material } from "babylonjs/Materials/material";
  21617. /**
  21618. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21619. * separate meshes. This can be use to improve performances.
  21620. * @see http://doc.babylonjs.com/how_to/multi_materials
  21621. */
  21622. export class MultiMaterial extends Material {
  21623. private _subMaterials;
  21624. /**
  21625. * Gets or Sets the list of Materials used within the multi material.
  21626. * They need to be ordered according to the submeshes order in the associated mesh
  21627. */
  21628. subMaterials: Nullable<Material>[];
  21629. /**
  21630. * Function used to align with Node.getChildren()
  21631. * @returns the list of Materials used within the multi material
  21632. */
  21633. getChildren(): Nullable<Material>[];
  21634. /**
  21635. * Instantiates a new Multi Material
  21636. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21637. * separate meshes. This can be use to improve performances.
  21638. * @see http://doc.babylonjs.com/how_to/multi_materials
  21639. * @param name Define the name in the scene
  21640. * @param scene Define the scene the material belongs to
  21641. */
  21642. constructor(name: string, scene: Scene);
  21643. private _hookArray;
  21644. /**
  21645. * Get one of the submaterial by its index in the submaterials array
  21646. * @param index The index to look the sub material at
  21647. * @returns The Material if the index has been defined
  21648. */
  21649. getSubMaterial(index: number): Nullable<Material>;
  21650. /**
  21651. * Get the list of active textures for the whole sub materials list.
  21652. * @returns All the textures that will be used during the rendering
  21653. */
  21654. getActiveTextures(): BaseTexture[];
  21655. /**
  21656. * Gets the current class name of the material e.g. "MultiMaterial"
  21657. * Mainly use in serialization.
  21658. * @returns the class name
  21659. */
  21660. getClassName(): string;
  21661. /**
  21662. * Checks if the material is ready to render the requested sub mesh
  21663. * @param mesh Define the mesh the submesh belongs to
  21664. * @param subMesh Define the sub mesh to look readyness for
  21665. * @param useInstances Define whether or not the material is used with instances
  21666. * @returns true if ready, otherwise false
  21667. */
  21668. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21669. /**
  21670. * Clones the current material and its related sub materials
  21671. * @param name Define the name of the newly cloned material
  21672. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21673. * @returns the cloned material
  21674. */
  21675. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21676. /**
  21677. * Serializes the materials into a JSON representation.
  21678. * @returns the JSON representation
  21679. */
  21680. serialize(): any;
  21681. /**
  21682. * Dispose the material and release its associated resources
  21683. * @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)
  21684. * @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)
  21685. * @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)
  21686. */
  21687. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21688. /**
  21689. * Creates a MultiMaterial from parsed MultiMaterial data.
  21690. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21691. * @param scene defines the hosting scene
  21692. * @returns a new MultiMaterial
  21693. */
  21694. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21695. }
  21696. }
  21697. declare module "babylonjs/Meshes/subMesh" {
  21698. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21699. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21700. import { Engine } from "babylonjs/Engines/engine";
  21701. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21702. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21703. import { Effect } from "babylonjs/Materials/effect";
  21704. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21705. import { Plane } from "babylonjs/Maths/math.plane";
  21706. import { Collider } from "babylonjs/Collisions/collider";
  21707. import { Material } from "babylonjs/Materials/material";
  21708. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21710. import { Mesh } from "babylonjs/Meshes/mesh";
  21711. import { Ray } from "babylonjs/Culling/ray";
  21712. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21713. /**
  21714. * Base class for submeshes
  21715. */
  21716. export class BaseSubMesh {
  21717. /** @hidden */
  21718. _materialDefines: Nullable<MaterialDefines>;
  21719. /** @hidden */
  21720. _materialEffect: Nullable<Effect>;
  21721. /**
  21722. * Gets material defines used by the effect associated to the sub mesh
  21723. */
  21724. /**
  21725. * Sets material defines used by the effect associated to the sub mesh
  21726. */
  21727. materialDefines: Nullable<MaterialDefines>;
  21728. /**
  21729. * Gets associated effect
  21730. */
  21731. readonly effect: Nullable<Effect>;
  21732. /**
  21733. * Sets associated effect (effect used to render this submesh)
  21734. * @param effect defines the effect to associate with
  21735. * @param defines defines the set of defines used to compile this effect
  21736. */
  21737. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21738. }
  21739. /**
  21740. * Defines a subdivision inside a mesh
  21741. */
  21742. export class SubMesh extends BaseSubMesh implements ICullable {
  21743. /** the material index to use */
  21744. materialIndex: number;
  21745. /** vertex index start */
  21746. verticesStart: number;
  21747. /** vertices count */
  21748. verticesCount: number;
  21749. /** index start */
  21750. indexStart: number;
  21751. /** indices count */
  21752. indexCount: number;
  21753. /** @hidden */
  21754. _linesIndexCount: number;
  21755. private _mesh;
  21756. private _renderingMesh;
  21757. private _boundingInfo;
  21758. private _linesIndexBuffer;
  21759. /** @hidden */
  21760. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21761. /** @hidden */
  21762. _trianglePlanes: Plane[];
  21763. /** @hidden */
  21764. _lastColliderTransformMatrix: Nullable<Matrix>;
  21765. /** @hidden */
  21766. _renderId: number;
  21767. /** @hidden */
  21768. _alphaIndex: number;
  21769. /** @hidden */
  21770. _distanceToCamera: number;
  21771. /** @hidden */
  21772. _id: number;
  21773. private _currentMaterial;
  21774. /**
  21775. * Add a new submesh to a mesh
  21776. * @param materialIndex defines the material index to use
  21777. * @param verticesStart defines vertex index start
  21778. * @param verticesCount defines vertices count
  21779. * @param indexStart defines index start
  21780. * @param indexCount defines indices count
  21781. * @param mesh defines the parent mesh
  21782. * @param renderingMesh defines an optional rendering mesh
  21783. * @param createBoundingBox defines if bounding box should be created for this submesh
  21784. * @returns the new submesh
  21785. */
  21786. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21787. /**
  21788. * Creates a new submesh
  21789. * @param materialIndex defines the material index to use
  21790. * @param verticesStart defines vertex index start
  21791. * @param verticesCount defines vertices count
  21792. * @param indexStart defines index start
  21793. * @param indexCount defines indices count
  21794. * @param mesh defines the parent mesh
  21795. * @param renderingMesh defines an optional rendering mesh
  21796. * @param createBoundingBox defines if bounding box should be created for this submesh
  21797. */
  21798. constructor(
  21799. /** the material index to use */
  21800. materialIndex: number,
  21801. /** vertex index start */
  21802. verticesStart: number,
  21803. /** vertices count */
  21804. verticesCount: number,
  21805. /** index start */
  21806. indexStart: number,
  21807. /** indices count */
  21808. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21809. /**
  21810. * Returns true if this submesh covers the entire parent mesh
  21811. * @ignorenaming
  21812. */
  21813. readonly IsGlobal: boolean;
  21814. /**
  21815. * Returns the submesh BoudingInfo object
  21816. * @returns current bounding info (or mesh's one if the submesh is global)
  21817. */
  21818. getBoundingInfo(): BoundingInfo;
  21819. /**
  21820. * Sets the submesh BoundingInfo
  21821. * @param boundingInfo defines the new bounding info to use
  21822. * @returns the SubMesh
  21823. */
  21824. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21825. /**
  21826. * Returns the mesh of the current submesh
  21827. * @return the parent mesh
  21828. */
  21829. getMesh(): AbstractMesh;
  21830. /**
  21831. * Returns the rendering mesh of the submesh
  21832. * @returns the rendering mesh (could be different from parent mesh)
  21833. */
  21834. getRenderingMesh(): Mesh;
  21835. /**
  21836. * Returns the submesh material
  21837. * @returns null or the current material
  21838. */
  21839. getMaterial(): Nullable<Material>;
  21840. /**
  21841. * Sets a new updated BoundingInfo object to the submesh
  21842. * @param data defines an optional position array to use to determine the bounding info
  21843. * @returns the SubMesh
  21844. */
  21845. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21846. /** @hidden */
  21847. _checkCollision(collider: Collider): boolean;
  21848. /**
  21849. * Updates the submesh BoundingInfo
  21850. * @param world defines the world matrix to use to update the bounding info
  21851. * @returns the submesh
  21852. */
  21853. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21854. /**
  21855. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21856. * @param frustumPlanes defines the frustum planes
  21857. * @returns true if the submesh is intersecting with the frustum
  21858. */
  21859. isInFrustum(frustumPlanes: Plane[]): boolean;
  21860. /**
  21861. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21862. * @param frustumPlanes defines the frustum planes
  21863. * @returns true if the submesh is inside the frustum
  21864. */
  21865. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21866. /**
  21867. * Renders the submesh
  21868. * @param enableAlphaMode defines if alpha needs to be used
  21869. * @returns the submesh
  21870. */
  21871. render(enableAlphaMode: boolean): SubMesh;
  21872. /**
  21873. * @hidden
  21874. */
  21875. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21876. /**
  21877. * Checks if the submesh intersects with a ray
  21878. * @param ray defines the ray to test
  21879. * @returns true is the passed ray intersects the submesh bounding box
  21880. */
  21881. canIntersects(ray: Ray): boolean;
  21882. /**
  21883. * Intersects current submesh with a ray
  21884. * @param ray defines the ray to test
  21885. * @param positions defines mesh's positions array
  21886. * @param indices defines mesh's indices array
  21887. * @param fastCheck defines if only bounding info should be used
  21888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21889. * @returns intersection info or null if no intersection
  21890. */
  21891. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21892. /** @hidden */
  21893. private _intersectLines;
  21894. /** @hidden */
  21895. private _intersectUnIndexedLines;
  21896. /** @hidden */
  21897. private _intersectTriangles;
  21898. /** @hidden */
  21899. private _intersectUnIndexedTriangles;
  21900. /** @hidden */
  21901. _rebuild(): void;
  21902. /**
  21903. * Creates a new submesh from the passed mesh
  21904. * @param newMesh defines the new hosting mesh
  21905. * @param newRenderingMesh defines an optional rendering mesh
  21906. * @returns the new submesh
  21907. */
  21908. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21909. /**
  21910. * Release associated resources
  21911. */
  21912. dispose(): void;
  21913. /**
  21914. * Gets the class name
  21915. * @returns the string "SubMesh".
  21916. */
  21917. getClassName(): string;
  21918. /**
  21919. * Creates a new submesh from indices data
  21920. * @param materialIndex the index of the main mesh material
  21921. * @param startIndex the index where to start the copy in the mesh indices array
  21922. * @param indexCount the number of indices to copy then from the startIndex
  21923. * @param mesh the main mesh to create the submesh from
  21924. * @param renderingMesh the optional rendering mesh
  21925. * @returns a new submesh
  21926. */
  21927. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21928. }
  21929. }
  21930. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21931. /**
  21932. * Class used to represent data loading progression
  21933. */
  21934. export class SceneLoaderFlags {
  21935. private static _ForceFullSceneLoadingForIncremental;
  21936. private static _ShowLoadingScreen;
  21937. private static _CleanBoneMatrixWeights;
  21938. private static _loggingLevel;
  21939. /**
  21940. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21941. */
  21942. static ForceFullSceneLoadingForIncremental: boolean;
  21943. /**
  21944. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21945. */
  21946. static ShowLoadingScreen: boolean;
  21947. /**
  21948. * Defines the current logging level (while loading the scene)
  21949. * @ignorenaming
  21950. */
  21951. static loggingLevel: number;
  21952. /**
  21953. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21954. */
  21955. static CleanBoneMatrixWeights: boolean;
  21956. }
  21957. }
  21958. declare module "babylonjs/Meshes/geometry" {
  21959. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21960. import { Scene } from "babylonjs/scene";
  21961. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21962. import { Engine } from "babylonjs/Engines/engine";
  21963. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21964. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21965. import { Effect } from "babylonjs/Materials/effect";
  21966. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21967. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21968. import { Mesh } from "babylonjs/Meshes/mesh";
  21969. /**
  21970. * Class used to store geometry data (vertex buffers + index buffer)
  21971. */
  21972. export class Geometry implements IGetSetVerticesData {
  21973. /**
  21974. * Gets or sets the ID of the geometry
  21975. */
  21976. id: string;
  21977. /**
  21978. * Gets or sets the unique ID of the geometry
  21979. */
  21980. uniqueId: number;
  21981. /**
  21982. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21983. */
  21984. delayLoadState: number;
  21985. /**
  21986. * Gets the file containing the data to load when running in delay load state
  21987. */
  21988. delayLoadingFile: Nullable<string>;
  21989. /**
  21990. * Callback called when the geometry is updated
  21991. */
  21992. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21993. private _scene;
  21994. private _engine;
  21995. private _meshes;
  21996. private _totalVertices;
  21997. /** @hidden */
  21998. _indices: IndicesArray;
  21999. /** @hidden */
  22000. _vertexBuffers: {
  22001. [key: string]: VertexBuffer;
  22002. };
  22003. private _isDisposed;
  22004. private _extend;
  22005. private _boundingBias;
  22006. /** @hidden */
  22007. _delayInfo: Array<string>;
  22008. private _indexBuffer;
  22009. private _indexBufferIsUpdatable;
  22010. /** @hidden */
  22011. _boundingInfo: Nullable<BoundingInfo>;
  22012. /** @hidden */
  22013. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22014. /** @hidden */
  22015. _softwareSkinningFrameId: number;
  22016. private _vertexArrayObjects;
  22017. private _updatable;
  22018. /** @hidden */
  22019. _positions: Nullable<Vector3[]>;
  22020. /**
  22021. * 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
  22022. */
  22023. /**
  22024. * 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
  22025. */
  22026. boundingBias: Vector2;
  22027. /**
  22028. * Static function used to attach a new empty geometry to a mesh
  22029. * @param mesh defines the mesh to attach the geometry to
  22030. * @returns the new Geometry
  22031. */
  22032. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22033. /**
  22034. * Creates a new geometry
  22035. * @param id defines the unique ID
  22036. * @param scene defines the hosting scene
  22037. * @param vertexData defines the VertexData used to get geometry data
  22038. * @param updatable defines if geometry must be updatable (false by default)
  22039. * @param mesh defines the mesh that will be associated with the geometry
  22040. */
  22041. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22042. /**
  22043. * Gets the current extend of the geometry
  22044. */
  22045. readonly extend: {
  22046. minimum: Vector3;
  22047. maximum: Vector3;
  22048. };
  22049. /**
  22050. * Gets the hosting scene
  22051. * @returns the hosting Scene
  22052. */
  22053. getScene(): Scene;
  22054. /**
  22055. * Gets the hosting engine
  22056. * @returns the hosting Engine
  22057. */
  22058. getEngine(): Engine;
  22059. /**
  22060. * Defines if the geometry is ready to use
  22061. * @returns true if the geometry is ready to be used
  22062. */
  22063. isReady(): boolean;
  22064. /**
  22065. * Gets a value indicating that the geometry should not be serialized
  22066. */
  22067. readonly doNotSerialize: boolean;
  22068. /** @hidden */
  22069. _rebuild(): void;
  22070. /**
  22071. * Affects all geometry data in one call
  22072. * @param vertexData defines the geometry data
  22073. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22074. */
  22075. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22076. /**
  22077. * Set specific vertex data
  22078. * @param kind defines the data kind (Position, normal, etc...)
  22079. * @param data defines the vertex data to use
  22080. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22081. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22082. */
  22083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22084. /**
  22085. * Removes a specific vertex data
  22086. * @param kind defines the data kind (Position, normal, etc...)
  22087. */
  22088. removeVerticesData(kind: string): void;
  22089. /**
  22090. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22091. * @param buffer defines the vertex buffer to use
  22092. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22093. */
  22094. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22095. /**
  22096. * Update a specific vertex buffer
  22097. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22098. * It will do nothing if the buffer is not updatable
  22099. * @param kind defines the data kind (Position, normal, etc...)
  22100. * @param data defines the data to use
  22101. * @param offset defines the offset in the target buffer where to store the data
  22102. * @param useBytes set to true if the offset is in bytes
  22103. */
  22104. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22105. /**
  22106. * Update a specific vertex buffer
  22107. * This function will create a new buffer if the current one is not updatable
  22108. * @param kind defines the data kind (Position, normal, etc...)
  22109. * @param data defines the data to use
  22110. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22111. */
  22112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22113. private _updateBoundingInfo;
  22114. /** @hidden */
  22115. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22116. /**
  22117. * Gets total number of vertices
  22118. * @returns the total number of vertices
  22119. */
  22120. getTotalVertices(): number;
  22121. /**
  22122. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22123. * @param kind defines the data kind (Position, normal, etc...)
  22124. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22125. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22126. * @returns a float array containing vertex data
  22127. */
  22128. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22129. /**
  22130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22131. * @param kind defines the data kind (Position, normal, etc...)
  22132. * @returns true if the vertex buffer with the specified kind is updatable
  22133. */
  22134. isVertexBufferUpdatable(kind: string): boolean;
  22135. /**
  22136. * Gets a specific vertex buffer
  22137. * @param kind defines the data kind (Position, normal, etc...)
  22138. * @returns a VertexBuffer
  22139. */
  22140. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22141. /**
  22142. * Returns all vertex buffers
  22143. * @return an object holding all vertex buffers indexed by kind
  22144. */
  22145. getVertexBuffers(): Nullable<{
  22146. [key: string]: VertexBuffer;
  22147. }>;
  22148. /**
  22149. * Gets a boolean indicating if specific vertex buffer is present
  22150. * @param kind defines the data kind (Position, normal, etc...)
  22151. * @returns true if data is present
  22152. */
  22153. isVerticesDataPresent(kind: string): boolean;
  22154. /**
  22155. * Gets a list of all attached data kinds (Position, normal, etc...)
  22156. * @returns a list of string containing all kinds
  22157. */
  22158. getVerticesDataKinds(): string[];
  22159. /**
  22160. * Update index buffer
  22161. * @param indices defines the indices to store in the index buffer
  22162. * @param offset defines the offset in the target buffer where to store the data
  22163. * @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)
  22164. */
  22165. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22166. /**
  22167. * Creates a new index buffer
  22168. * @param indices defines the indices to store in the index buffer
  22169. * @param totalVertices defines the total number of vertices (could be null)
  22170. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22171. */
  22172. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22173. /**
  22174. * Return the total number of indices
  22175. * @returns the total number of indices
  22176. */
  22177. getTotalIndices(): number;
  22178. /**
  22179. * Gets the index buffer array
  22180. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22181. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22182. * @returns the index buffer array
  22183. */
  22184. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22185. /**
  22186. * Gets the index buffer
  22187. * @return the index buffer
  22188. */
  22189. getIndexBuffer(): Nullable<DataBuffer>;
  22190. /** @hidden */
  22191. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22192. /**
  22193. * Release the associated resources for a specific mesh
  22194. * @param mesh defines the source mesh
  22195. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22196. */
  22197. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22198. /**
  22199. * Apply current geometry to a given mesh
  22200. * @param mesh defines the mesh to apply geometry to
  22201. */
  22202. applyToMesh(mesh: Mesh): void;
  22203. private _updateExtend;
  22204. private _applyToMesh;
  22205. private notifyUpdate;
  22206. /**
  22207. * Load the geometry if it was flagged as delay loaded
  22208. * @param scene defines the hosting scene
  22209. * @param onLoaded defines a callback called when the geometry is loaded
  22210. */
  22211. load(scene: Scene, onLoaded?: () => void): void;
  22212. private _queueLoad;
  22213. /**
  22214. * Invert the geometry to move from a right handed system to a left handed one.
  22215. */
  22216. toLeftHanded(): void;
  22217. /** @hidden */
  22218. _resetPointsArrayCache(): void;
  22219. /** @hidden */
  22220. _generatePointsArray(): boolean;
  22221. /**
  22222. * Gets a value indicating if the geometry is disposed
  22223. * @returns true if the geometry was disposed
  22224. */
  22225. isDisposed(): boolean;
  22226. private _disposeVertexArrayObjects;
  22227. /**
  22228. * Free all associated resources
  22229. */
  22230. dispose(): void;
  22231. /**
  22232. * Clone the current geometry into a new geometry
  22233. * @param id defines the unique ID of the new geometry
  22234. * @returns a new geometry object
  22235. */
  22236. copy(id: string): Geometry;
  22237. /**
  22238. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22239. * @return a JSON representation of the current geometry data (without the vertices data)
  22240. */
  22241. serialize(): any;
  22242. private toNumberArray;
  22243. /**
  22244. * Serialize all vertices data into a JSON oject
  22245. * @returns a JSON representation of the current geometry data
  22246. */
  22247. serializeVerticeData(): any;
  22248. /**
  22249. * Extracts a clone of a mesh geometry
  22250. * @param mesh defines the source mesh
  22251. * @param id defines the unique ID of the new geometry object
  22252. * @returns the new geometry object
  22253. */
  22254. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22255. /**
  22256. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22257. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22258. * Be aware Math.random() could cause collisions, but:
  22259. * "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"
  22260. * @returns a string containing a new GUID
  22261. */
  22262. static RandomId(): string;
  22263. /** @hidden */
  22264. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22265. private static _CleanMatricesWeights;
  22266. /**
  22267. * Create a new geometry from persisted data (Using .babylon file format)
  22268. * @param parsedVertexData defines the persisted data
  22269. * @param scene defines the hosting scene
  22270. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22271. * @returns the new geometry object
  22272. */
  22273. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22274. }
  22275. }
  22276. declare module "babylonjs/Meshes/mesh.vertexData" {
  22277. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22278. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22279. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22280. import { Geometry } from "babylonjs/Meshes/geometry";
  22281. import { Mesh } from "babylonjs/Meshes/mesh";
  22282. /**
  22283. * Define an interface for all classes that will get and set the data on vertices
  22284. */
  22285. export interface IGetSetVerticesData {
  22286. /**
  22287. * Gets a boolean indicating if specific vertex data is present
  22288. * @param kind defines the vertex data kind to use
  22289. * @returns true is data kind is present
  22290. */
  22291. isVerticesDataPresent(kind: string): boolean;
  22292. /**
  22293. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22294. * @param kind defines the data kind (Position, normal, etc...)
  22295. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22296. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22297. * @returns a float array containing vertex data
  22298. */
  22299. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22300. /**
  22301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22302. * @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.
  22303. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22304. * @returns the indices array or an empty array if the mesh has no geometry
  22305. */
  22306. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22307. /**
  22308. * Set specific vertex data
  22309. * @param kind defines the data kind (Position, normal, etc...)
  22310. * @param data defines the vertex data to use
  22311. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22312. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22313. */
  22314. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22315. /**
  22316. * Update a specific associated vertex buffer
  22317. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22318. * - VertexBuffer.PositionKind
  22319. * - VertexBuffer.UVKind
  22320. * - VertexBuffer.UV2Kind
  22321. * - VertexBuffer.UV3Kind
  22322. * - VertexBuffer.UV4Kind
  22323. * - VertexBuffer.UV5Kind
  22324. * - VertexBuffer.UV6Kind
  22325. * - VertexBuffer.ColorKind
  22326. * - VertexBuffer.MatricesIndicesKind
  22327. * - VertexBuffer.MatricesIndicesExtraKind
  22328. * - VertexBuffer.MatricesWeightsKind
  22329. * - VertexBuffer.MatricesWeightsExtraKind
  22330. * @param data defines the data source
  22331. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22332. * @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)
  22333. */
  22334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22335. /**
  22336. * Creates a new index buffer
  22337. * @param indices defines the indices to store in the index buffer
  22338. * @param totalVertices defines the total number of vertices (could be null)
  22339. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22340. */
  22341. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22342. }
  22343. /**
  22344. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22345. */
  22346. export class VertexData {
  22347. /**
  22348. * Mesh side orientation : usually the external or front surface
  22349. */
  22350. static readonly FRONTSIDE: number;
  22351. /**
  22352. * Mesh side orientation : usually the internal or back surface
  22353. */
  22354. static readonly BACKSIDE: number;
  22355. /**
  22356. * Mesh side orientation : both internal and external or front and back surfaces
  22357. */
  22358. static readonly DOUBLESIDE: number;
  22359. /**
  22360. * Mesh side orientation : by default, `FRONTSIDE`
  22361. */
  22362. static readonly DEFAULTSIDE: number;
  22363. /**
  22364. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22365. */
  22366. positions: Nullable<FloatArray>;
  22367. /**
  22368. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22369. */
  22370. normals: Nullable<FloatArray>;
  22371. /**
  22372. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22373. */
  22374. tangents: Nullable<FloatArray>;
  22375. /**
  22376. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22377. */
  22378. uvs: Nullable<FloatArray>;
  22379. /**
  22380. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22381. */
  22382. uvs2: Nullable<FloatArray>;
  22383. /**
  22384. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22385. */
  22386. uvs3: Nullable<FloatArray>;
  22387. /**
  22388. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22389. */
  22390. uvs4: Nullable<FloatArray>;
  22391. /**
  22392. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22393. */
  22394. uvs5: Nullable<FloatArray>;
  22395. /**
  22396. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22397. */
  22398. uvs6: Nullable<FloatArray>;
  22399. /**
  22400. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22401. */
  22402. colors: Nullable<FloatArray>;
  22403. /**
  22404. * 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).
  22405. */
  22406. matricesIndices: Nullable<FloatArray>;
  22407. /**
  22408. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22409. */
  22410. matricesWeights: Nullable<FloatArray>;
  22411. /**
  22412. * An array extending the number of possible indices
  22413. */
  22414. matricesIndicesExtra: Nullable<FloatArray>;
  22415. /**
  22416. * An array extending the number of possible weights when the number of indices is extended
  22417. */
  22418. matricesWeightsExtra: Nullable<FloatArray>;
  22419. /**
  22420. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22421. */
  22422. indices: Nullable<IndicesArray>;
  22423. /**
  22424. * Uses the passed data array to set the set the values for the specified kind of data
  22425. * @param data a linear array of floating numbers
  22426. * @param kind the type of data that is being set, eg positions, colors etc
  22427. */
  22428. set(data: FloatArray, kind: string): void;
  22429. /**
  22430. * Associates the vertexData to the passed Mesh.
  22431. * Sets it as updatable or not (default `false`)
  22432. * @param mesh the mesh the vertexData is applied to
  22433. * @param updatable when used and having the value true allows new data to update the vertexData
  22434. * @returns the VertexData
  22435. */
  22436. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22437. /**
  22438. * Associates the vertexData to the passed Geometry.
  22439. * Sets it as updatable or not (default `false`)
  22440. * @param geometry the geometry the vertexData is applied to
  22441. * @param updatable when used and having the value true allows new data to update the vertexData
  22442. * @returns VertexData
  22443. */
  22444. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22445. /**
  22446. * Updates the associated mesh
  22447. * @param mesh the mesh to be updated
  22448. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22449. * @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
  22450. * @returns VertexData
  22451. */
  22452. updateMesh(mesh: Mesh): VertexData;
  22453. /**
  22454. * Updates the associated geometry
  22455. * @param geometry the geometry to be updated
  22456. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22457. * @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
  22458. * @returns VertexData.
  22459. */
  22460. updateGeometry(geometry: Geometry): VertexData;
  22461. private _applyTo;
  22462. private _update;
  22463. /**
  22464. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22465. * @param matrix the transforming matrix
  22466. * @returns the VertexData
  22467. */
  22468. transform(matrix: Matrix): VertexData;
  22469. /**
  22470. * Merges the passed VertexData into the current one
  22471. * @param other the VertexData to be merged into the current one
  22472. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22473. * @returns the modified VertexData
  22474. */
  22475. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22476. private _mergeElement;
  22477. private _validate;
  22478. /**
  22479. * Serializes the VertexData
  22480. * @returns a serialized object
  22481. */
  22482. serialize(): any;
  22483. /**
  22484. * Extracts the vertexData from a mesh
  22485. * @param mesh the mesh from which to extract the VertexData
  22486. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22487. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22488. * @returns the object VertexData associated to the passed mesh
  22489. */
  22490. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22491. /**
  22492. * Extracts the vertexData from the geometry
  22493. * @param geometry the geometry from which to extract the VertexData
  22494. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22495. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22496. * @returns the object VertexData associated to the passed mesh
  22497. */
  22498. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22499. private static _ExtractFrom;
  22500. /**
  22501. * Creates the VertexData for a Ribbon
  22502. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22503. * * pathArray array of paths, each of which an array of successive Vector3
  22504. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22505. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22506. * * 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
  22507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22508. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22509. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22510. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22511. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22512. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22513. * @returns the VertexData of the ribbon
  22514. */
  22515. static CreateRibbon(options: {
  22516. pathArray: Vector3[][];
  22517. closeArray?: boolean;
  22518. closePath?: boolean;
  22519. offset?: number;
  22520. sideOrientation?: number;
  22521. frontUVs?: Vector4;
  22522. backUVs?: Vector4;
  22523. invertUV?: boolean;
  22524. uvs?: Vector2[];
  22525. colors?: Color4[];
  22526. }): VertexData;
  22527. /**
  22528. * Creates the VertexData for a box
  22529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22530. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22531. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22532. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22533. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22534. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22535. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22537. * * 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)
  22538. * * 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)
  22539. * @returns the VertexData of the box
  22540. */
  22541. static CreateBox(options: {
  22542. size?: number;
  22543. width?: number;
  22544. height?: number;
  22545. depth?: number;
  22546. faceUV?: Vector4[];
  22547. faceColors?: Color4[];
  22548. sideOrientation?: number;
  22549. frontUVs?: Vector4;
  22550. backUVs?: Vector4;
  22551. }): VertexData;
  22552. /**
  22553. * Creates the VertexData for a tiled box
  22554. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22555. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22556. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22557. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22559. * @returns the VertexData of the box
  22560. */
  22561. static CreateTiledBox(options: {
  22562. pattern?: number;
  22563. width?: number;
  22564. height?: number;
  22565. depth?: number;
  22566. tileSize?: number;
  22567. tileWidth?: number;
  22568. tileHeight?: number;
  22569. alignHorizontal?: number;
  22570. alignVertical?: number;
  22571. faceUV?: Vector4[];
  22572. faceColors?: Color4[];
  22573. sideOrientation?: number;
  22574. }): VertexData;
  22575. /**
  22576. * Creates the VertexData for a tiled plane
  22577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22578. * * pattern a limited pattern arrangement depending on the number
  22579. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22580. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22581. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22583. * * 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)
  22584. * * 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)
  22585. * @returns the VertexData of the tiled plane
  22586. */
  22587. static CreateTiledPlane(options: {
  22588. pattern?: number;
  22589. tileSize?: number;
  22590. tileWidth?: number;
  22591. tileHeight?: number;
  22592. size?: number;
  22593. width?: number;
  22594. height?: number;
  22595. alignHorizontal?: number;
  22596. alignVertical?: number;
  22597. sideOrientation?: number;
  22598. frontUVs?: Vector4;
  22599. backUVs?: Vector4;
  22600. }): VertexData;
  22601. /**
  22602. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22603. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22604. * * segments sets the number of horizontal strips optional, default 32
  22605. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22606. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22607. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22608. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22609. * * 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
  22610. * * 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
  22611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22612. * * 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)
  22613. * * 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)
  22614. * @returns the VertexData of the ellipsoid
  22615. */
  22616. static CreateSphere(options: {
  22617. segments?: number;
  22618. diameter?: number;
  22619. diameterX?: number;
  22620. diameterY?: number;
  22621. diameterZ?: number;
  22622. arc?: number;
  22623. slice?: number;
  22624. sideOrientation?: number;
  22625. frontUVs?: Vector4;
  22626. backUVs?: Vector4;
  22627. }): VertexData;
  22628. /**
  22629. * Creates the VertexData for a cylinder, cone or prism
  22630. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22631. * * height sets the height (y direction) of the cylinder, optional, default 2
  22632. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22633. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22634. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22635. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22636. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22637. * * 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
  22638. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22639. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22640. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22641. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22643. * * 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)
  22644. * * 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)
  22645. * @returns the VertexData of the cylinder, cone or prism
  22646. */
  22647. static CreateCylinder(options: {
  22648. height?: number;
  22649. diameterTop?: number;
  22650. diameterBottom?: number;
  22651. diameter?: number;
  22652. tessellation?: number;
  22653. subdivisions?: number;
  22654. arc?: number;
  22655. faceColors?: Color4[];
  22656. faceUV?: Vector4[];
  22657. hasRings?: boolean;
  22658. enclose?: boolean;
  22659. sideOrientation?: number;
  22660. frontUVs?: Vector4;
  22661. backUVs?: Vector4;
  22662. }): VertexData;
  22663. /**
  22664. * Creates the VertexData for a torus
  22665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22666. * * diameter the diameter of the torus, optional default 1
  22667. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22668. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22669. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22670. * * 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)
  22671. * * 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)
  22672. * @returns the VertexData of the torus
  22673. */
  22674. static CreateTorus(options: {
  22675. diameter?: number;
  22676. thickness?: number;
  22677. tessellation?: number;
  22678. sideOrientation?: number;
  22679. frontUVs?: Vector4;
  22680. backUVs?: Vector4;
  22681. }): VertexData;
  22682. /**
  22683. * Creates the VertexData of the LineSystem
  22684. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22685. * - lines an array of lines, each line being an array of successive Vector3
  22686. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22687. * @returns the VertexData of the LineSystem
  22688. */
  22689. static CreateLineSystem(options: {
  22690. lines: Vector3[][];
  22691. colors?: Nullable<Color4[][]>;
  22692. }): VertexData;
  22693. /**
  22694. * Create the VertexData for a DashedLines
  22695. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22696. * - points an array successive Vector3
  22697. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22698. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22699. * - dashNb the intended total number of dashes, optional, default 200
  22700. * @returns the VertexData for the DashedLines
  22701. */
  22702. static CreateDashedLines(options: {
  22703. points: Vector3[];
  22704. dashSize?: number;
  22705. gapSize?: number;
  22706. dashNb?: number;
  22707. }): VertexData;
  22708. /**
  22709. * Creates the VertexData for a Ground
  22710. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22711. * - width the width (x direction) of the ground, optional, default 1
  22712. * - height the height (z direction) of the ground, optional, default 1
  22713. * - subdivisions the number of subdivisions per side, optional, default 1
  22714. * @returns the VertexData of the Ground
  22715. */
  22716. static CreateGround(options: {
  22717. width?: number;
  22718. height?: number;
  22719. subdivisions?: number;
  22720. subdivisionsX?: number;
  22721. subdivisionsY?: number;
  22722. }): VertexData;
  22723. /**
  22724. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22725. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22726. * * xmin the ground minimum X coordinate, optional, default -1
  22727. * * zmin the ground minimum Z coordinate, optional, default -1
  22728. * * xmax the ground maximum X coordinate, optional, default 1
  22729. * * zmax the ground maximum Z coordinate, optional, default 1
  22730. * * 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}
  22731. * * 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}
  22732. * @returns the VertexData of the TiledGround
  22733. */
  22734. static CreateTiledGround(options: {
  22735. xmin: number;
  22736. zmin: number;
  22737. xmax: number;
  22738. zmax: number;
  22739. subdivisions?: {
  22740. w: number;
  22741. h: number;
  22742. };
  22743. precision?: {
  22744. w: number;
  22745. h: number;
  22746. };
  22747. }): VertexData;
  22748. /**
  22749. * Creates the VertexData of the Ground designed from a heightmap
  22750. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22751. * * width the width (x direction) of the ground
  22752. * * height the height (z direction) of the ground
  22753. * * subdivisions the number of subdivisions per side
  22754. * * minHeight the minimum altitude on the ground, optional, default 0
  22755. * * maxHeight the maximum altitude on the ground, optional default 1
  22756. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22757. * * buffer the array holding the image color data
  22758. * * bufferWidth the width of image
  22759. * * bufferHeight the height of image
  22760. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22761. * @returns the VertexData of the Ground designed from a heightmap
  22762. */
  22763. static CreateGroundFromHeightMap(options: {
  22764. width: number;
  22765. height: number;
  22766. subdivisions: number;
  22767. minHeight: number;
  22768. maxHeight: number;
  22769. colorFilter: Color3;
  22770. buffer: Uint8Array;
  22771. bufferWidth: number;
  22772. bufferHeight: number;
  22773. alphaFilter: number;
  22774. }): VertexData;
  22775. /**
  22776. * Creates the VertexData for a Plane
  22777. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22778. * * size sets the width and height of the plane to the value of size, optional default 1
  22779. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22780. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22782. * * 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)
  22783. * * 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)
  22784. * @returns the VertexData of the box
  22785. */
  22786. static CreatePlane(options: {
  22787. size?: number;
  22788. width?: number;
  22789. height?: number;
  22790. sideOrientation?: number;
  22791. frontUVs?: Vector4;
  22792. backUVs?: Vector4;
  22793. }): VertexData;
  22794. /**
  22795. * Creates the VertexData of the Disc or regular Polygon
  22796. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22797. * * radius the radius of the disc, optional default 0.5
  22798. * * tessellation the number of polygon sides, optional, default 64
  22799. * * 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
  22800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22801. * * 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)
  22802. * * 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)
  22803. * @returns the VertexData of the box
  22804. */
  22805. static CreateDisc(options: {
  22806. radius?: number;
  22807. tessellation?: number;
  22808. arc?: number;
  22809. sideOrientation?: number;
  22810. frontUVs?: Vector4;
  22811. backUVs?: Vector4;
  22812. }): VertexData;
  22813. /**
  22814. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22815. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22816. * @param polygon a mesh built from polygonTriangulation.build()
  22817. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22818. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22819. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22820. * @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)
  22821. * @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)
  22822. * @returns the VertexData of the Polygon
  22823. */
  22824. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22825. /**
  22826. * Creates the VertexData of the IcoSphere
  22827. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22828. * * radius the radius of the IcoSphere, optional default 1
  22829. * * radiusX allows stretching in the x direction, optional, default radius
  22830. * * radiusY allows stretching in the y direction, optional, default radius
  22831. * * radiusZ allows stretching in the z direction, optional, default radius
  22832. * * flat when true creates a flat shaded mesh, optional, default true
  22833. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22835. * * 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)
  22836. * * 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)
  22837. * @returns the VertexData of the IcoSphere
  22838. */
  22839. static CreateIcoSphere(options: {
  22840. radius?: number;
  22841. radiusX?: number;
  22842. radiusY?: number;
  22843. radiusZ?: number;
  22844. flat?: boolean;
  22845. subdivisions?: number;
  22846. sideOrientation?: number;
  22847. frontUVs?: Vector4;
  22848. backUVs?: Vector4;
  22849. }): VertexData;
  22850. /**
  22851. * Creates the VertexData for a Polyhedron
  22852. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22853. * * type provided types are:
  22854. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22855. * * 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)
  22856. * * size the size of the IcoSphere, optional default 1
  22857. * * sizeX allows stretching in the x direction, optional, default size
  22858. * * sizeY allows stretching in the y direction, optional, default size
  22859. * * sizeZ allows stretching in the z direction, optional, default size
  22860. * * 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
  22861. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22862. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22863. * * flat when true creates a flat shaded mesh, optional, default true
  22864. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22865. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22866. * * 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)
  22867. * * 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)
  22868. * @returns the VertexData of the Polyhedron
  22869. */
  22870. static CreatePolyhedron(options: {
  22871. type?: number;
  22872. size?: number;
  22873. sizeX?: number;
  22874. sizeY?: number;
  22875. sizeZ?: number;
  22876. custom?: any;
  22877. faceUV?: Vector4[];
  22878. faceColors?: Color4[];
  22879. flat?: boolean;
  22880. sideOrientation?: number;
  22881. frontUVs?: Vector4;
  22882. backUVs?: Vector4;
  22883. }): VertexData;
  22884. /**
  22885. * Creates the VertexData for a TorusKnot
  22886. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22887. * * radius the radius of the torus knot, optional, default 2
  22888. * * tube the thickness of the tube, optional, default 0.5
  22889. * * radialSegments the number of sides on each tube segments, optional, default 32
  22890. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22891. * * p the number of windings around the z axis, optional, default 2
  22892. * * q the number of windings around the x axis, optional, default 3
  22893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22894. * * 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)
  22895. * * 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)
  22896. * @returns the VertexData of the Torus Knot
  22897. */
  22898. static CreateTorusKnot(options: {
  22899. radius?: number;
  22900. tube?: number;
  22901. radialSegments?: number;
  22902. tubularSegments?: number;
  22903. p?: number;
  22904. q?: number;
  22905. sideOrientation?: number;
  22906. frontUVs?: Vector4;
  22907. backUVs?: Vector4;
  22908. }): VertexData;
  22909. /**
  22910. * Compute normals for given positions and indices
  22911. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22912. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22913. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22914. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22915. * * facetNormals : optional array of facet normals (vector3)
  22916. * * facetPositions : optional array of facet positions (vector3)
  22917. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22918. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22919. * * bInfo : optional bounding info, required for facetPartitioning computation
  22920. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22921. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22922. * * useRightHandedSystem: optional boolean to for right handed system computation
  22923. * * depthSort : optional boolean to enable the facet depth sort computation
  22924. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22925. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22926. */
  22927. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22928. facetNormals?: any;
  22929. facetPositions?: any;
  22930. facetPartitioning?: any;
  22931. ratio?: number;
  22932. bInfo?: any;
  22933. bbSize?: Vector3;
  22934. subDiv?: any;
  22935. useRightHandedSystem?: boolean;
  22936. depthSort?: boolean;
  22937. distanceTo?: Vector3;
  22938. depthSortedFacets?: any;
  22939. }): void;
  22940. /** @hidden */
  22941. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22942. /**
  22943. * Applies VertexData created from the imported parameters to the geometry
  22944. * @param parsedVertexData the parsed data from an imported file
  22945. * @param geometry the geometry to apply the VertexData to
  22946. */
  22947. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22948. }
  22949. }
  22950. declare module "babylonjs/Morph/morphTarget" {
  22951. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22952. import { Observable } from "babylonjs/Misc/observable";
  22953. import { Nullable, FloatArray } from "babylonjs/types";
  22954. import { Scene } from "babylonjs/scene";
  22955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22956. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22957. /**
  22958. * Defines a target to use with MorphTargetManager
  22959. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22960. */
  22961. export class MorphTarget implements IAnimatable {
  22962. /** defines the name of the target */
  22963. name: string;
  22964. /**
  22965. * Gets or sets the list of animations
  22966. */
  22967. animations: import("babylonjs/Animations/animation").Animation[];
  22968. private _scene;
  22969. private _positions;
  22970. private _normals;
  22971. private _tangents;
  22972. private _uvs;
  22973. private _influence;
  22974. private _uniqueId;
  22975. /**
  22976. * Observable raised when the influence changes
  22977. */
  22978. onInfluenceChanged: Observable<boolean>;
  22979. /** @hidden */
  22980. _onDataLayoutChanged: Observable<void>;
  22981. /**
  22982. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22983. */
  22984. influence: number;
  22985. /**
  22986. * Gets or sets the id of the morph Target
  22987. */
  22988. id: string;
  22989. private _animationPropertiesOverride;
  22990. /**
  22991. * Gets or sets the animation properties override
  22992. */
  22993. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22994. /**
  22995. * Creates a new MorphTarget
  22996. * @param name defines the name of the target
  22997. * @param influence defines the influence to use
  22998. * @param scene defines the scene the morphtarget belongs to
  22999. */
  23000. constructor(
  23001. /** defines the name of the target */
  23002. name: string, influence?: number, scene?: Nullable<Scene>);
  23003. /**
  23004. * Gets the unique ID of this manager
  23005. */
  23006. readonly uniqueId: number;
  23007. /**
  23008. * Gets a boolean defining if the target contains position data
  23009. */
  23010. readonly hasPositions: boolean;
  23011. /**
  23012. * Gets a boolean defining if the target contains normal data
  23013. */
  23014. readonly hasNormals: boolean;
  23015. /**
  23016. * Gets a boolean defining if the target contains tangent data
  23017. */
  23018. readonly hasTangents: boolean;
  23019. /**
  23020. * Gets a boolean defining if the target contains texture coordinates data
  23021. */
  23022. readonly hasUVs: boolean;
  23023. /**
  23024. * Affects position data to this target
  23025. * @param data defines the position data to use
  23026. */
  23027. setPositions(data: Nullable<FloatArray>): void;
  23028. /**
  23029. * Gets the position data stored in this target
  23030. * @returns a FloatArray containing the position data (or null if not present)
  23031. */
  23032. getPositions(): Nullable<FloatArray>;
  23033. /**
  23034. * Affects normal data to this target
  23035. * @param data defines the normal data to use
  23036. */
  23037. setNormals(data: Nullable<FloatArray>): void;
  23038. /**
  23039. * Gets the normal data stored in this target
  23040. * @returns a FloatArray containing the normal data (or null if not present)
  23041. */
  23042. getNormals(): Nullable<FloatArray>;
  23043. /**
  23044. * Affects tangent data to this target
  23045. * @param data defines the tangent data to use
  23046. */
  23047. setTangents(data: Nullable<FloatArray>): void;
  23048. /**
  23049. * Gets the tangent data stored in this target
  23050. * @returns a FloatArray containing the tangent data (or null if not present)
  23051. */
  23052. getTangents(): Nullable<FloatArray>;
  23053. /**
  23054. * Affects texture coordinates data to this target
  23055. * @param data defines the texture coordinates data to use
  23056. */
  23057. setUVs(data: Nullable<FloatArray>): void;
  23058. /**
  23059. * Gets the texture coordinates data stored in this target
  23060. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23061. */
  23062. getUVs(): Nullable<FloatArray>;
  23063. /**
  23064. * Clone the current target
  23065. * @returns a new MorphTarget
  23066. */
  23067. clone(): MorphTarget;
  23068. /**
  23069. * Serializes the current target into a Serialization object
  23070. * @returns the serialized object
  23071. */
  23072. serialize(): any;
  23073. /**
  23074. * Returns the string "MorphTarget"
  23075. * @returns "MorphTarget"
  23076. */
  23077. getClassName(): string;
  23078. /**
  23079. * Creates a new target from serialized data
  23080. * @param serializationObject defines the serialized data to use
  23081. * @returns a new MorphTarget
  23082. */
  23083. static Parse(serializationObject: any): MorphTarget;
  23084. /**
  23085. * Creates a MorphTarget from mesh data
  23086. * @param mesh defines the source mesh
  23087. * @param name defines the name to use for the new target
  23088. * @param influence defines the influence to attach to the target
  23089. * @returns a new MorphTarget
  23090. */
  23091. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23092. }
  23093. }
  23094. declare module "babylonjs/Morph/morphTargetManager" {
  23095. import { Nullable } from "babylonjs/types";
  23096. import { Scene } from "babylonjs/scene";
  23097. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23098. /**
  23099. * This class is used to deform meshes using morphing between different targets
  23100. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23101. */
  23102. export class MorphTargetManager {
  23103. private _targets;
  23104. private _targetInfluenceChangedObservers;
  23105. private _targetDataLayoutChangedObservers;
  23106. private _activeTargets;
  23107. private _scene;
  23108. private _influences;
  23109. private _supportsNormals;
  23110. private _supportsTangents;
  23111. private _supportsUVs;
  23112. private _vertexCount;
  23113. private _uniqueId;
  23114. private _tempInfluences;
  23115. /**
  23116. * Gets or sets a boolean indicating if normals must be morphed
  23117. */
  23118. enableNormalMorphing: boolean;
  23119. /**
  23120. * Gets or sets a boolean indicating if tangents must be morphed
  23121. */
  23122. enableTangentMorphing: boolean;
  23123. /**
  23124. * Gets or sets a boolean indicating if UV must be morphed
  23125. */
  23126. enableUVMorphing: boolean;
  23127. /**
  23128. * Creates a new MorphTargetManager
  23129. * @param scene defines the current scene
  23130. */
  23131. constructor(scene?: Nullable<Scene>);
  23132. /**
  23133. * Gets the unique ID of this manager
  23134. */
  23135. readonly uniqueId: number;
  23136. /**
  23137. * Gets the number of vertices handled by this manager
  23138. */
  23139. readonly vertexCount: number;
  23140. /**
  23141. * Gets a boolean indicating if this manager supports morphing of normals
  23142. */
  23143. readonly supportsNormals: boolean;
  23144. /**
  23145. * Gets a boolean indicating if this manager supports morphing of tangents
  23146. */
  23147. readonly supportsTangents: boolean;
  23148. /**
  23149. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23150. */
  23151. readonly supportsUVs: boolean;
  23152. /**
  23153. * Gets the number of targets stored in this manager
  23154. */
  23155. readonly numTargets: number;
  23156. /**
  23157. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23158. */
  23159. readonly numInfluencers: number;
  23160. /**
  23161. * Gets the list of influences (one per target)
  23162. */
  23163. readonly influences: Float32Array;
  23164. /**
  23165. * Gets the active target at specified index. An active target is a target with an influence > 0
  23166. * @param index defines the index to check
  23167. * @returns the requested target
  23168. */
  23169. getActiveTarget(index: number): MorphTarget;
  23170. /**
  23171. * Gets the target at specified index
  23172. * @param index defines the index to check
  23173. * @returns the requested target
  23174. */
  23175. getTarget(index: number): MorphTarget;
  23176. /**
  23177. * Add a new target to this manager
  23178. * @param target defines the target to add
  23179. */
  23180. addTarget(target: MorphTarget): void;
  23181. /**
  23182. * Removes a target from the manager
  23183. * @param target defines the target to remove
  23184. */
  23185. removeTarget(target: MorphTarget): void;
  23186. /**
  23187. * Clone the current manager
  23188. * @returns a new MorphTargetManager
  23189. */
  23190. clone(): MorphTargetManager;
  23191. /**
  23192. * Serializes the current manager into a Serialization object
  23193. * @returns the serialized object
  23194. */
  23195. serialize(): any;
  23196. private _syncActiveTargets;
  23197. /**
  23198. * Syncrhonize the targets with all the meshes using this morph target manager
  23199. */
  23200. synchronize(): void;
  23201. /**
  23202. * Creates a new MorphTargetManager from serialized data
  23203. * @param serializationObject defines the serialized data
  23204. * @param scene defines the hosting scene
  23205. * @returns the new MorphTargetManager
  23206. */
  23207. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23208. }
  23209. }
  23210. declare module "babylonjs/Meshes/meshLODLevel" {
  23211. import { Mesh } from "babylonjs/Meshes/mesh";
  23212. import { Nullable } from "babylonjs/types";
  23213. /**
  23214. * Class used to represent a specific level of detail of a mesh
  23215. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23216. */
  23217. export class MeshLODLevel {
  23218. /** Defines the distance where this level should start being displayed */
  23219. distance: number;
  23220. /** Defines the mesh to use to render this level */
  23221. mesh: Nullable<Mesh>;
  23222. /**
  23223. * Creates a new LOD level
  23224. * @param distance defines the distance where this level should star being displayed
  23225. * @param mesh defines the mesh to use to render this level
  23226. */
  23227. constructor(
  23228. /** Defines the distance where this level should start being displayed */
  23229. distance: number,
  23230. /** Defines the mesh to use to render this level */
  23231. mesh: Nullable<Mesh>);
  23232. }
  23233. }
  23234. declare module "babylonjs/Meshes/groundMesh" {
  23235. import { Scene } from "babylonjs/scene";
  23236. import { Vector3 } from "babylonjs/Maths/math.vector";
  23237. import { Mesh } from "babylonjs/Meshes/mesh";
  23238. /**
  23239. * Mesh representing the gorund
  23240. */
  23241. export class GroundMesh extends Mesh {
  23242. /** If octree should be generated */
  23243. generateOctree: boolean;
  23244. private _heightQuads;
  23245. /** @hidden */
  23246. _subdivisionsX: number;
  23247. /** @hidden */
  23248. _subdivisionsY: number;
  23249. /** @hidden */
  23250. _width: number;
  23251. /** @hidden */
  23252. _height: number;
  23253. /** @hidden */
  23254. _minX: number;
  23255. /** @hidden */
  23256. _maxX: number;
  23257. /** @hidden */
  23258. _minZ: number;
  23259. /** @hidden */
  23260. _maxZ: number;
  23261. constructor(name: string, scene: Scene);
  23262. /**
  23263. * "GroundMesh"
  23264. * @returns "GroundMesh"
  23265. */
  23266. getClassName(): string;
  23267. /**
  23268. * The minimum of x and y subdivisions
  23269. */
  23270. readonly subdivisions: number;
  23271. /**
  23272. * X subdivisions
  23273. */
  23274. readonly subdivisionsX: number;
  23275. /**
  23276. * Y subdivisions
  23277. */
  23278. readonly subdivisionsY: number;
  23279. /**
  23280. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23281. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23282. * @param chunksCount the number of subdivisions for x and y
  23283. * @param octreeBlocksSize (Default: 32)
  23284. */
  23285. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23286. /**
  23287. * Returns a height (y) value in the Worl system :
  23288. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23289. * @param x x coordinate
  23290. * @param z z coordinate
  23291. * @returns the ground y position if (x, z) are outside the ground surface.
  23292. */
  23293. getHeightAtCoordinates(x: number, z: number): number;
  23294. /**
  23295. * Returns a normalized vector (Vector3) orthogonal to the ground
  23296. * at the ground coordinates (x, z) expressed in the World system.
  23297. * @param x x coordinate
  23298. * @param z z coordinate
  23299. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23300. */
  23301. getNormalAtCoordinates(x: number, z: number): Vector3;
  23302. /**
  23303. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23304. * at the ground coordinates (x, z) expressed in the World system.
  23305. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23306. * @param x x coordinate
  23307. * @param z z coordinate
  23308. * @param ref vector to store the result
  23309. * @returns the GroundMesh.
  23310. */
  23311. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23312. /**
  23313. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23314. * if the ground has been updated.
  23315. * This can be used in the render loop.
  23316. * @returns the GroundMesh.
  23317. */
  23318. updateCoordinateHeights(): GroundMesh;
  23319. private _getFacetAt;
  23320. private _initHeightQuads;
  23321. private _computeHeightQuads;
  23322. /**
  23323. * Serializes this ground mesh
  23324. * @param serializationObject object to write serialization to
  23325. */
  23326. serialize(serializationObject: any): void;
  23327. /**
  23328. * Parses a serialized ground mesh
  23329. * @param parsedMesh the serialized mesh
  23330. * @param scene the scene to create the ground mesh in
  23331. * @returns the created ground mesh
  23332. */
  23333. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23334. }
  23335. }
  23336. declare module "babylonjs/Physics/physicsJoint" {
  23337. import { Vector3 } from "babylonjs/Maths/math.vector";
  23338. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23339. /**
  23340. * Interface for Physics-Joint data
  23341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23342. */
  23343. export interface PhysicsJointData {
  23344. /**
  23345. * The main pivot of the joint
  23346. */
  23347. mainPivot?: Vector3;
  23348. /**
  23349. * The connected pivot of the joint
  23350. */
  23351. connectedPivot?: Vector3;
  23352. /**
  23353. * The main axis of the joint
  23354. */
  23355. mainAxis?: Vector3;
  23356. /**
  23357. * The connected axis of the joint
  23358. */
  23359. connectedAxis?: Vector3;
  23360. /**
  23361. * The collision of the joint
  23362. */
  23363. collision?: boolean;
  23364. /**
  23365. * Native Oimo/Cannon/Energy data
  23366. */
  23367. nativeParams?: any;
  23368. }
  23369. /**
  23370. * This is a holder class for the physics joint created by the physics plugin
  23371. * It holds a set of functions to control the underlying joint
  23372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23373. */
  23374. export class PhysicsJoint {
  23375. /**
  23376. * The type of the physics joint
  23377. */
  23378. type: number;
  23379. /**
  23380. * The data for the physics joint
  23381. */
  23382. jointData: PhysicsJointData;
  23383. private _physicsJoint;
  23384. protected _physicsPlugin: IPhysicsEnginePlugin;
  23385. /**
  23386. * Initializes the physics joint
  23387. * @param type The type of the physics joint
  23388. * @param jointData The data for the physics joint
  23389. */
  23390. constructor(
  23391. /**
  23392. * The type of the physics joint
  23393. */
  23394. type: number,
  23395. /**
  23396. * The data for the physics joint
  23397. */
  23398. jointData: PhysicsJointData);
  23399. /**
  23400. * Gets the physics joint
  23401. */
  23402. /**
  23403. * Sets the physics joint
  23404. */
  23405. physicsJoint: any;
  23406. /**
  23407. * Sets the physics plugin
  23408. */
  23409. physicsPlugin: IPhysicsEnginePlugin;
  23410. /**
  23411. * Execute a function that is physics-plugin specific.
  23412. * @param {Function} func the function that will be executed.
  23413. * It accepts two parameters: the physics world and the physics joint
  23414. */
  23415. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23416. /**
  23417. * Distance-Joint type
  23418. */
  23419. static DistanceJoint: number;
  23420. /**
  23421. * Hinge-Joint type
  23422. */
  23423. static HingeJoint: number;
  23424. /**
  23425. * Ball-and-Socket joint type
  23426. */
  23427. static BallAndSocketJoint: number;
  23428. /**
  23429. * Wheel-Joint type
  23430. */
  23431. static WheelJoint: number;
  23432. /**
  23433. * Slider-Joint type
  23434. */
  23435. static SliderJoint: number;
  23436. /**
  23437. * Prismatic-Joint type
  23438. */
  23439. static PrismaticJoint: number;
  23440. /**
  23441. * Universal-Joint type
  23442. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23443. */
  23444. static UniversalJoint: number;
  23445. /**
  23446. * Hinge-Joint 2 type
  23447. */
  23448. static Hinge2Joint: number;
  23449. /**
  23450. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23451. */
  23452. static PointToPointJoint: number;
  23453. /**
  23454. * Spring-Joint type
  23455. */
  23456. static SpringJoint: number;
  23457. /**
  23458. * Lock-Joint type
  23459. */
  23460. static LockJoint: number;
  23461. }
  23462. /**
  23463. * A class representing a physics distance joint
  23464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23465. */
  23466. export class DistanceJoint extends PhysicsJoint {
  23467. /**
  23468. *
  23469. * @param jointData The data for the Distance-Joint
  23470. */
  23471. constructor(jointData: DistanceJointData);
  23472. /**
  23473. * Update the predefined distance.
  23474. * @param maxDistance The maximum preferred distance
  23475. * @param minDistance The minimum preferred distance
  23476. */
  23477. updateDistance(maxDistance: number, minDistance?: number): void;
  23478. }
  23479. /**
  23480. * Represents a Motor-Enabled Joint
  23481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23482. */
  23483. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23484. /**
  23485. * Initializes the Motor-Enabled Joint
  23486. * @param type The type of the joint
  23487. * @param jointData The physica joint data for the joint
  23488. */
  23489. constructor(type: number, jointData: PhysicsJointData);
  23490. /**
  23491. * Set the motor values.
  23492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23493. * @param force the force to apply
  23494. * @param maxForce max force for this motor.
  23495. */
  23496. setMotor(force?: number, maxForce?: number): void;
  23497. /**
  23498. * Set the motor's limits.
  23499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23500. * @param upperLimit The upper limit of the motor
  23501. * @param lowerLimit The lower limit of the motor
  23502. */
  23503. setLimit(upperLimit: number, lowerLimit?: number): void;
  23504. }
  23505. /**
  23506. * This class represents a single physics Hinge-Joint
  23507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23508. */
  23509. export class HingeJoint extends MotorEnabledJoint {
  23510. /**
  23511. * Initializes the Hinge-Joint
  23512. * @param jointData The joint data for the Hinge-Joint
  23513. */
  23514. constructor(jointData: PhysicsJointData);
  23515. /**
  23516. * Set the motor values.
  23517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23518. * @param {number} force the force to apply
  23519. * @param {number} maxForce max force for this motor.
  23520. */
  23521. setMotor(force?: number, maxForce?: number): void;
  23522. /**
  23523. * Set the motor's limits.
  23524. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23525. * @param upperLimit The upper limit of the motor
  23526. * @param lowerLimit The lower limit of the motor
  23527. */
  23528. setLimit(upperLimit: number, lowerLimit?: number): void;
  23529. }
  23530. /**
  23531. * This class represents a dual hinge physics joint (same as wheel joint)
  23532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23533. */
  23534. export class Hinge2Joint extends MotorEnabledJoint {
  23535. /**
  23536. * Initializes the Hinge2-Joint
  23537. * @param jointData The joint data for the Hinge2-Joint
  23538. */
  23539. constructor(jointData: PhysicsJointData);
  23540. /**
  23541. * Set the motor values.
  23542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23543. * @param {number} targetSpeed the speed the motor is to reach
  23544. * @param {number} maxForce max force for this motor.
  23545. * @param {motorIndex} the motor's index, 0 or 1.
  23546. */
  23547. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23548. /**
  23549. * Set the motor limits.
  23550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23551. * @param {number} upperLimit the upper limit
  23552. * @param {number} lowerLimit lower limit
  23553. * @param {motorIndex} the motor's index, 0 or 1.
  23554. */
  23555. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23556. }
  23557. /**
  23558. * Interface for a motor enabled joint
  23559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23560. */
  23561. export interface IMotorEnabledJoint {
  23562. /**
  23563. * Physics joint
  23564. */
  23565. physicsJoint: any;
  23566. /**
  23567. * Sets the motor of the motor-enabled joint
  23568. * @param force The force of the motor
  23569. * @param maxForce The maximum force of the motor
  23570. * @param motorIndex The index of the motor
  23571. */
  23572. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23573. /**
  23574. * Sets the limit of the motor
  23575. * @param upperLimit The upper limit of the motor
  23576. * @param lowerLimit The lower limit of the motor
  23577. * @param motorIndex The index of the motor
  23578. */
  23579. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23580. }
  23581. /**
  23582. * Joint data for a Distance-Joint
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export interface DistanceJointData extends PhysicsJointData {
  23586. /**
  23587. * Max distance the 2 joint objects can be apart
  23588. */
  23589. maxDistance: number;
  23590. }
  23591. /**
  23592. * Joint data from a spring joint
  23593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23594. */
  23595. export interface SpringJointData extends PhysicsJointData {
  23596. /**
  23597. * Length of the spring
  23598. */
  23599. length: number;
  23600. /**
  23601. * Stiffness of the spring
  23602. */
  23603. stiffness: number;
  23604. /**
  23605. * Damping of the spring
  23606. */
  23607. damping: number;
  23608. /** this callback will be called when applying the force to the impostors. */
  23609. forceApplicationCallback: () => void;
  23610. }
  23611. }
  23612. declare module "babylonjs/Physics/physicsRaycastResult" {
  23613. import { Vector3 } from "babylonjs/Maths/math.vector";
  23614. /**
  23615. * Holds the data for the raycast result
  23616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23617. */
  23618. export class PhysicsRaycastResult {
  23619. private _hasHit;
  23620. private _hitDistance;
  23621. private _hitNormalWorld;
  23622. private _hitPointWorld;
  23623. private _rayFromWorld;
  23624. private _rayToWorld;
  23625. /**
  23626. * Gets if there was a hit
  23627. */
  23628. readonly hasHit: boolean;
  23629. /**
  23630. * Gets the distance from the hit
  23631. */
  23632. readonly hitDistance: number;
  23633. /**
  23634. * Gets the hit normal/direction in the world
  23635. */
  23636. readonly hitNormalWorld: Vector3;
  23637. /**
  23638. * Gets the hit point in the world
  23639. */
  23640. readonly hitPointWorld: Vector3;
  23641. /**
  23642. * Gets the ray "start point" of the ray in the world
  23643. */
  23644. readonly rayFromWorld: Vector3;
  23645. /**
  23646. * Gets the ray "end point" of the ray in the world
  23647. */
  23648. readonly rayToWorld: Vector3;
  23649. /**
  23650. * Sets the hit data (normal & point in world space)
  23651. * @param hitNormalWorld defines the normal in world space
  23652. * @param hitPointWorld defines the point in world space
  23653. */
  23654. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23655. /**
  23656. * Sets the distance from the start point to the hit point
  23657. * @param distance
  23658. */
  23659. setHitDistance(distance: number): void;
  23660. /**
  23661. * Calculates the distance manually
  23662. */
  23663. calculateHitDistance(): void;
  23664. /**
  23665. * Resets all the values to default
  23666. * @param from The from point on world space
  23667. * @param to The to point on world space
  23668. */
  23669. reset(from?: Vector3, to?: Vector3): void;
  23670. }
  23671. /**
  23672. * Interface for the size containing width and height
  23673. */
  23674. interface IXYZ {
  23675. /**
  23676. * X
  23677. */
  23678. x: number;
  23679. /**
  23680. * Y
  23681. */
  23682. y: number;
  23683. /**
  23684. * Z
  23685. */
  23686. z: number;
  23687. }
  23688. }
  23689. declare module "babylonjs/Physics/IPhysicsEngine" {
  23690. import { Nullable } from "babylonjs/types";
  23691. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23693. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23694. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23695. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23696. /**
  23697. * Interface used to describe a physics joint
  23698. */
  23699. export interface PhysicsImpostorJoint {
  23700. /** Defines the main impostor to which the joint is linked */
  23701. mainImpostor: PhysicsImpostor;
  23702. /** Defines the impostor that is connected to the main impostor using this joint */
  23703. connectedImpostor: PhysicsImpostor;
  23704. /** Defines the joint itself */
  23705. joint: PhysicsJoint;
  23706. }
  23707. /** @hidden */
  23708. export interface IPhysicsEnginePlugin {
  23709. world: any;
  23710. name: string;
  23711. setGravity(gravity: Vector3): void;
  23712. setTimeStep(timeStep: number): void;
  23713. getTimeStep(): number;
  23714. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23715. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23716. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23717. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23718. removePhysicsBody(impostor: PhysicsImpostor): void;
  23719. generateJoint(joint: PhysicsImpostorJoint): void;
  23720. removeJoint(joint: PhysicsImpostorJoint): void;
  23721. isSupported(): boolean;
  23722. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23723. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23724. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23725. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23726. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23728. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23729. getBodyMass(impostor: PhysicsImpostor): number;
  23730. getBodyFriction(impostor: PhysicsImpostor): number;
  23731. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23732. getBodyRestitution(impostor: PhysicsImpostor): number;
  23733. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23734. getBodyPressure?(impostor: PhysicsImpostor): number;
  23735. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23736. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23737. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23738. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23739. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23740. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23741. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23742. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23743. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23744. sleepBody(impostor: PhysicsImpostor): void;
  23745. wakeUpBody(impostor: PhysicsImpostor): void;
  23746. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23747. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23748. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23749. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23750. getRadius(impostor: PhysicsImpostor): number;
  23751. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23752. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23753. dispose(): void;
  23754. }
  23755. /**
  23756. * Interface used to define a physics engine
  23757. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23758. */
  23759. export interface IPhysicsEngine {
  23760. /**
  23761. * Gets the gravity vector used by the simulation
  23762. */
  23763. gravity: Vector3;
  23764. /**
  23765. * Sets the gravity vector used by the simulation
  23766. * @param gravity defines the gravity vector to use
  23767. */
  23768. setGravity(gravity: Vector3): void;
  23769. /**
  23770. * Set the time step of the physics engine.
  23771. * Default is 1/60.
  23772. * To slow it down, enter 1/600 for example.
  23773. * To speed it up, 1/30
  23774. * @param newTimeStep the new timestep to apply to this world.
  23775. */
  23776. setTimeStep(newTimeStep: number): void;
  23777. /**
  23778. * Get the time step of the physics engine.
  23779. * @returns the current time step
  23780. */
  23781. getTimeStep(): number;
  23782. /**
  23783. * Set the sub time step of the physics engine.
  23784. * Default is 0 meaning there is no sub steps
  23785. * To increase physics resolution precision, set a small value (like 1 ms)
  23786. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23787. */
  23788. setSubTimeStep(subTimeStep: number): void;
  23789. /**
  23790. * Get the sub time step of the physics engine.
  23791. * @returns the current sub time step
  23792. */
  23793. getSubTimeStep(): number;
  23794. /**
  23795. * Release all resources
  23796. */
  23797. dispose(): void;
  23798. /**
  23799. * Gets the name of the current physics plugin
  23800. * @returns the name of the plugin
  23801. */
  23802. getPhysicsPluginName(): string;
  23803. /**
  23804. * Adding a new impostor for the impostor tracking.
  23805. * This will be done by the impostor itself.
  23806. * @param impostor the impostor to add
  23807. */
  23808. addImpostor(impostor: PhysicsImpostor): void;
  23809. /**
  23810. * Remove an impostor from the engine.
  23811. * This impostor and its mesh will not longer be updated by the physics engine.
  23812. * @param impostor the impostor to remove
  23813. */
  23814. removeImpostor(impostor: PhysicsImpostor): void;
  23815. /**
  23816. * Add a joint to the physics engine
  23817. * @param mainImpostor defines the main impostor to which the joint is added.
  23818. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23819. * @param joint defines the joint that will connect both impostors.
  23820. */
  23821. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23822. /**
  23823. * Removes a joint from the simulation
  23824. * @param mainImpostor defines the impostor used with the joint
  23825. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23826. * @param joint defines the joint to remove
  23827. */
  23828. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23829. /**
  23830. * Gets the current plugin used to run the simulation
  23831. * @returns current plugin
  23832. */
  23833. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23834. /**
  23835. * Gets the list of physic impostors
  23836. * @returns an array of PhysicsImpostor
  23837. */
  23838. getImpostors(): Array<PhysicsImpostor>;
  23839. /**
  23840. * Gets the impostor for a physics enabled object
  23841. * @param object defines the object impersonated by the impostor
  23842. * @returns the PhysicsImpostor or null if not found
  23843. */
  23844. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23845. /**
  23846. * Gets the impostor for a physics body object
  23847. * @param body defines physics body used by the impostor
  23848. * @returns the PhysicsImpostor or null if not found
  23849. */
  23850. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23851. /**
  23852. * Does a raycast in the physics world
  23853. * @param from when should the ray start?
  23854. * @param to when should the ray end?
  23855. * @returns PhysicsRaycastResult
  23856. */
  23857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23858. /**
  23859. * Called by the scene. No need to call it.
  23860. * @param delta defines the timespam between frames
  23861. */
  23862. _step(delta: number): void;
  23863. }
  23864. }
  23865. declare module "babylonjs/Physics/physicsImpostor" {
  23866. import { Nullable, IndicesArray } from "babylonjs/types";
  23867. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23870. import { Scene } from "babylonjs/scene";
  23871. import { Bone } from "babylonjs/Bones/bone";
  23872. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23873. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23874. import { Space } from "babylonjs/Maths/math.axis";
  23875. /**
  23876. * The interface for the physics imposter parameters
  23877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23878. */
  23879. export interface PhysicsImpostorParameters {
  23880. /**
  23881. * The mass of the physics imposter
  23882. */
  23883. mass: number;
  23884. /**
  23885. * The friction of the physics imposter
  23886. */
  23887. friction?: number;
  23888. /**
  23889. * The coefficient of restitution of the physics imposter
  23890. */
  23891. restitution?: number;
  23892. /**
  23893. * The native options of the physics imposter
  23894. */
  23895. nativeOptions?: any;
  23896. /**
  23897. * Specifies if the parent should be ignored
  23898. */
  23899. ignoreParent?: boolean;
  23900. /**
  23901. * Specifies if bi-directional transformations should be disabled
  23902. */
  23903. disableBidirectionalTransformation?: boolean;
  23904. /**
  23905. * The pressure inside the physics imposter, soft object only
  23906. */
  23907. pressure?: number;
  23908. /**
  23909. * The stiffness the physics imposter, soft object only
  23910. */
  23911. stiffness?: number;
  23912. /**
  23913. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23914. */
  23915. velocityIterations?: number;
  23916. /**
  23917. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23918. */
  23919. positionIterations?: number;
  23920. /**
  23921. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23922. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23923. * Add to fix multiple points
  23924. */
  23925. fixedPoints?: number;
  23926. /**
  23927. * The collision margin around a soft object
  23928. */
  23929. margin?: number;
  23930. /**
  23931. * The collision margin around a soft object
  23932. */
  23933. damping?: number;
  23934. /**
  23935. * The path for a rope based on an extrusion
  23936. */
  23937. path?: any;
  23938. /**
  23939. * The shape of an extrusion used for a rope based on an extrusion
  23940. */
  23941. shape?: any;
  23942. }
  23943. /**
  23944. * Interface for a physics-enabled object
  23945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23946. */
  23947. export interface IPhysicsEnabledObject {
  23948. /**
  23949. * The position of the physics-enabled object
  23950. */
  23951. position: Vector3;
  23952. /**
  23953. * The rotation of the physics-enabled object
  23954. */
  23955. rotationQuaternion: Nullable<Quaternion>;
  23956. /**
  23957. * The scale of the physics-enabled object
  23958. */
  23959. scaling: Vector3;
  23960. /**
  23961. * The rotation of the physics-enabled object
  23962. */
  23963. rotation?: Vector3;
  23964. /**
  23965. * The parent of the physics-enabled object
  23966. */
  23967. parent?: any;
  23968. /**
  23969. * The bounding info of the physics-enabled object
  23970. * @returns The bounding info of the physics-enabled object
  23971. */
  23972. getBoundingInfo(): BoundingInfo;
  23973. /**
  23974. * Computes the world matrix
  23975. * @param force Specifies if the world matrix should be computed by force
  23976. * @returns A world matrix
  23977. */
  23978. computeWorldMatrix(force: boolean): Matrix;
  23979. /**
  23980. * Gets the world matrix
  23981. * @returns A world matrix
  23982. */
  23983. getWorldMatrix?(): Matrix;
  23984. /**
  23985. * Gets the child meshes
  23986. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23987. * @returns An array of abstract meshes
  23988. */
  23989. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23990. /**
  23991. * Gets the vertex data
  23992. * @param kind The type of vertex data
  23993. * @returns A nullable array of numbers, or a float32 array
  23994. */
  23995. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23996. /**
  23997. * Gets the indices from the mesh
  23998. * @returns A nullable array of index arrays
  23999. */
  24000. getIndices?(): Nullable<IndicesArray>;
  24001. /**
  24002. * Gets the scene from the mesh
  24003. * @returns the indices array or null
  24004. */
  24005. getScene?(): Scene;
  24006. /**
  24007. * Gets the absolute position from the mesh
  24008. * @returns the absolute position
  24009. */
  24010. getAbsolutePosition(): Vector3;
  24011. /**
  24012. * Gets the absolute pivot point from the mesh
  24013. * @returns the absolute pivot point
  24014. */
  24015. getAbsolutePivotPoint(): Vector3;
  24016. /**
  24017. * Rotates the mesh
  24018. * @param axis The axis of rotation
  24019. * @param amount The amount of rotation
  24020. * @param space The space of the rotation
  24021. * @returns The rotation transform node
  24022. */
  24023. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24024. /**
  24025. * Translates the mesh
  24026. * @param axis The axis of translation
  24027. * @param distance The distance of translation
  24028. * @param space The space of the translation
  24029. * @returns The transform node
  24030. */
  24031. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24032. /**
  24033. * Sets the absolute position of the mesh
  24034. * @param absolutePosition The absolute position of the mesh
  24035. * @returns The transform node
  24036. */
  24037. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24038. /**
  24039. * Gets the class name of the mesh
  24040. * @returns The class name
  24041. */
  24042. getClassName(): string;
  24043. }
  24044. /**
  24045. * Represents a physics imposter
  24046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24047. */
  24048. export class PhysicsImpostor {
  24049. /**
  24050. * The physics-enabled object used as the physics imposter
  24051. */
  24052. object: IPhysicsEnabledObject;
  24053. /**
  24054. * The type of the physics imposter
  24055. */
  24056. type: number;
  24057. private _options;
  24058. private _scene?;
  24059. /**
  24060. * The default object size of the imposter
  24061. */
  24062. static DEFAULT_OBJECT_SIZE: Vector3;
  24063. /**
  24064. * The identity quaternion of the imposter
  24065. */
  24066. static IDENTITY_QUATERNION: Quaternion;
  24067. /** @hidden */
  24068. _pluginData: any;
  24069. private _physicsEngine;
  24070. private _physicsBody;
  24071. private _bodyUpdateRequired;
  24072. private _onBeforePhysicsStepCallbacks;
  24073. private _onAfterPhysicsStepCallbacks;
  24074. /** @hidden */
  24075. _onPhysicsCollideCallbacks: Array<{
  24076. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24077. otherImpostors: Array<PhysicsImpostor>;
  24078. }>;
  24079. private _deltaPosition;
  24080. private _deltaRotation;
  24081. private _deltaRotationConjugated;
  24082. /** @hidden */
  24083. _isFromLine: boolean;
  24084. private _parent;
  24085. private _isDisposed;
  24086. private static _tmpVecs;
  24087. private static _tmpQuat;
  24088. /**
  24089. * Specifies if the physics imposter is disposed
  24090. */
  24091. readonly isDisposed: boolean;
  24092. /**
  24093. * Gets the mass of the physics imposter
  24094. */
  24095. mass: number;
  24096. /**
  24097. * Gets the coefficient of friction
  24098. */
  24099. /**
  24100. * Sets the coefficient of friction
  24101. */
  24102. friction: number;
  24103. /**
  24104. * Gets the coefficient of restitution
  24105. */
  24106. /**
  24107. * Sets the coefficient of restitution
  24108. */
  24109. restitution: number;
  24110. /**
  24111. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24112. */
  24113. /**
  24114. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24115. */
  24116. pressure: number;
  24117. /**
  24118. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24119. */
  24120. /**
  24121. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24122. */
  24123. stiffness: number;
  24124. /**
  24125. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24126. */
  24127. /**
  24128. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24129. */
  24130. velocityIterations: number;
  24131. /**
  24132. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24133. */
  24134. /**
  24135. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24136. */
  24137. positionIterations: number;
  24138. /**
  24139. * The unique id of the physics imposter
  24140. * set by the physics engine when adding this impostor to the array
  24141. */
  24142. uniqueId: number;
  24143. /**
  24144. * @hidden
  24145. */
  24146. soft: boolean;
  24147. /**
  24148. * @hidden
  24149. */
  24150. segments: number;
  24151. private _joints;
  24152. /**
  24153. * Initializes the physics imposter
  24154. * @param object The physics-enabled object used as the physics imposter
  24155. * @param type The type of the physics imposter
  24156. * @param _options The options for the physics imposter
  24157. * @param _scene The Babylon scene
  24158. */
  24159. constructor(
  24160. /**
  24161. * The physics-enabled object used as the physics imposter
  24162. */
  24163. object: IPhysicsEnabledObject,
  24164. /**
  24165. * The type of the physics imposter
  24166. */
  24167. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24168. /**
  24169. * This function will completly initialize this impostor.
  24170. * It will create a new body - but only if this mesh has no parent.
  24171. * If it has, this impostor will not be used other than to define the impostor
  24172. * of the child mesh.
  24173. * @hidden
  24174. */
  24175. _init(): void;
  24176. private _getPhysicsParent;
  24177. /**
  24178. * Should a new body be generated.
  24179. * @returns boolean specifying if body initialization is required
  24180. */
  24181. isBodyInitRequired(): boolean;
  24182. /**
  24183. * Sets the updated scaling
  24184. * @param updated Specifies if the scaling is updated
  24185. */
  24186. setScalingUpdated(): void;
  24187. /**
  24188. * Force a regeneration of this or the parent's impostor's body.
  24189. * Use under cautious - This will remove all joints already implemented.
  24190. */
  24191. forceUpdate(): void;
  24192. /**
  24193. * Gets the body that holds this impostor. Either its own, or its parent.
  24194. */
  24195. /**
  24196. * Set the physics body. Used mainly by the physics engine/plugin
  24197. */
  24198. physicsBody: any;
  24199. /**
  24200. * Get the parent of the physics imposter
  24201. * @returns Physics imposter or null
  24202. */
  24203. /**
  24204. * Sets the parent of the physics imposter
  24205. */
  24206. parent: Nullable<PhysicsImpostor>;
  24207. /**
  24208. * Resets the update flags
  24209. */
  24210. resetUpdateFlags(): void;
  24211. /**
  24212. * Gets the object extend size
  24213. * @returns the object extend size
  24214. */
  24215. getObjectExtendSize(): Vector3;
  24216. /**
  24217. * Gets the object center
  24218. * @returns The object center
  24219. */
  24220. getObjectCenter(): Vector3;
  24221. /**
  24222. * Get a specific parametes from the options parameter
  24223. * @param paramName The object parameter name
  24224. * @returns The object parameter
  24225. */
  24226. getParam(paramName: string): any;
  24227. /**
  24228. * Sets a specific parameter in the options given to the physics plugin
  24229. * @param paramName The parameter name
  24230. * @param value The value of the parameter
  24231. */
  24232. setParam(paramName: string, value: number): void;
  24233. /**
  24234. * Specifically change the body's mass option. Won't recreate the physics body object
  24235. * @param mass The mass of the physics imposter
  24236. */
  24237. setMass(mass: number): void;
  24238. /**
  24239. * Gets the linear velocity
  24240. * @returns linear velocity or null
  24241. */
  24242. getLinearVelocity(): Nullable<Vector3>;
  24243. /**
  24244. * Sets the linear velocity
  24245. * @param velocity linear velocity or null
  24246. */
  24247. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24248. /**
  24249. * Gets the angular velocity
  24250. * @returns angular velocity or null
  24251. */
  24252. getAngularVelocity(): Nullable<Vector3>;
  24253. /**
  24254. * Sets the angular velocity
  24255. * @param velocity The velocity or null
  24256. */
  24257. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24258. /**
  24259. * Execute a function with the physics plugin native code
  24260. * Provide a function the will have two variables - the world object and the physics body object
  24261. * @param func The function to execute with the physics plugin native code
  24262. */
  24263. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24264. /**
  24265. * Register a function that will be executed before the physics world is stepping forward
  24266. * @param func The function to execute before the physics world is stepped forward
  24267. */
  24268. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24269. /**
  24270. * Unregister a function that will be executed before the physics world is stepping forward
  24271. * @param func The function to execute before the physics world is stepped forward
  24272. */
  24273. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24274. /**
  24275. * Register a function that will be executed after the physics step
  24276. * @param func The function to execute after physics step
  24277. */
  24278. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24279. /**
  24280. * Unregisters a function that will be executed after the physics step
  24281. * @param func The function to execute after physics step
  24282. */
  24283. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24284. /**
  24285. * register a function that will be executed when this impostor collides against a different body
  24286. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24287. * @param func Callback that is executed on collision
  24288. */
  24289. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24290. /**
  24291. * Unregisters the physics imposter on contact
  24292. * @param collideAgainst The physics object to collide against
  24293. * @param func Callback to execute on collision
  24294. */
  24295. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24296. private _tmpQuat;
  24297. private _tmpQuat2;
  24298. /**
  24299. * Get the parent rotation
  24300. * @returns The parent rotation
  24301. */
  24302. getParentsRotation(): Quaternion;
  24303. /**
  24304. * this function is executed by the physics engine.
  24305. */
  24306. beforeStep: () => void;
  24307. /**
  24308. * this function is executed by the physics engine
  24309. */
  24310. afterStep: () => void;
  24311. /**
  24312. * Legacy collision detection event support
  24313. */
  24314. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24315. /**
  24316. * event and body object due to cannon's event-based architecture.
  24317. */
  24318. onCollide: (e: {
  24319. body: any;
  24320. }) => void;
  24321. /**
  24322. * Apply a force
  24323. * @param force The force to apply
  24324. * @param contactPoint The contact point for the force
  24325. * @returns The physics imposter
  24326. */
  24327. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24328. /**
  24329. * Apply an impulse
  24330. * @param force The impulse force
  24331. * @param contactPoint The contact point for the impulse force
  24332. * @returns The physics imposter
  24333. */
  24334. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24335. /**
  24336. * A help function to create a joint
  24337. * @param otherImpostor A physics imposter used to create a joint
  24338. * @param jointType The type of joint
  24339. * @param jointData The data for the joint
  24340. * @returns The physics imposter
  24341. */
  24342. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24343. /**
  24344. * Add a joint to this impostor with a different impostor
  24345. * @param otherImpostor A physics imposter used to add a joint
  24346. * @param joint The joint to add
  24347. * @returns The physics imposter
  24348. */
  24349. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24350. /**
  24351. * Add an anchor to a cloth impostor
  24352. * @param otherImpostor rigid impostor to anchor to
  24353. * @param width ratio across width from 0 to 1
  24354. * @param height ratio up height from 0 to 1
  24355. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24356. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24357. * @returns impostor the soft imposter
  24358. */
  24359. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24360. /**
  24361. * Add a hook to a rope impostor
  24362. * @param otherImpostor rigid impostor to anchor to
  24363. * @param length ratio across rope from 0 to 1
  24364. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24365. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24366. * @returns impostor the rope imposter
  24367. */
  24368. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24369. /**
  24370. * Will keep this body still, in a sleep mode.
  24371. * @returns the physics imposter
  24372. */
  24373. sleep(): PhysicsImpostor;
  24374. /**
  24375. * Wake the body up.
  24376. * @returns The physics imposter
  24377. */
  24378. wakeUp(): PhysicsImpostor;
  24379. /**
  24380. * Clones the physics imposter
  24381. * @param newObject The physics imposter clones to this physics-enabled object
  24382. * @returns A nullable physics imposter
  24383. */
  24384. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24385. /**
  24386. * Disposes the physics imposter
  24387. */
  24388. dispose(): void;
  24389. /**
  24390. * Sets the delta position
  24391. * @param position The delta position amount
  24392. */
  24393. setDeltaPosition(position: Vector3): void;
  24394. /**
  24395. * Sets the delta rotation
  24396. * @param rotation The delta rotation amount
  24397. */
  24398. setDeltaRotation(rotation: Quaternion): void;
  24399. /**
  24400. * Gets the box size of the physics imposter and stores the result in the input parameter
  24401. * @param result Stores the box size
  24402. * @returns The physics imposter
  24403. */
  24404. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24405. /**
  24406. * Gets the radius of the physics imposter
  24407. * @returns Radius of the physics imposter
  24408. */
  24409. getRadius(): number;
  24410. /**
  24411. * Sync a bone with this impostor
  24412. * @param bone The bone to sync to the impostor.
  24413. * @param boneMesh The mesh that the bone is influencing.
  24414. * @param jointPivot The pivot of the joint / bone in local space.
  24415. * @param distToJoint Optional distance from the impostor to the joint.
  24416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24417. */
  24418. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24419. /**
  24420. * Sync impostor to a bone
  24421. * @param bone The bone that the impostor will be synced to.
  24422. * @param boneMesh The mesh that the bone is influencing.
  24423. * @param jointPivot The pivot of the joint / bone in local space.
  24424. * @param distToJoint Optional distance from the impostor to the joint.
  24425. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24426. * @param boneAxis Optional vector3 axis the bone is aligned with
  24427. */
  24428. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24429. /**
  24430. * No-Imposter type
  24431. */
  24432. static NoImpostor: number;
  24433. /**
  24434. * Sphere-Imposter type
  24435. */
  24436. static SphereImpostor: number;
  24437. /**
  24438. * Box-Imposter type
  24439. */
  24440. static BoxImpostor: number;
  24441. /**
  24442. * Plane-Imposter type
  24443. */
  24444. static PlaneImpostor: number;
  24445. /**
  24446. * Mesh-imposter type
  24447. */
  24448. static MeshImpostor: number;
  24449. /**
  24450. * Capsule-Impostor type (Ammo.js plugin only)
  24451. */
  24452. static CapsuleImpostor: number;
  24453. /**
  24454. * Cylinder-Imposter type
  24455. */
  24456. static CylinderImpostor: number;
  24457. /**
  24458. * Particle-Imposter type
  24459. */
  24460. static ParticleImpostor: number;
  24461. /**
  24462. * Heightmap-Imposter type
  24463. */
  24464. static HeightmapImpostor: number;
  24465. /**
  24466. * ConvexHull-Impostor type (Ammo.js plugin only)
  24467. */
  24468. static ConvexHullImpostor: number;
  24469. /**
  24470. * Custom-Imposter type (Ammo.js plugin only)
  24471. */
  24472. static CustomImpostor: number;
  24473. /**
  24474. * Rope-Imposter type
  24475. */
  24476. static RopeImpostor: number;
  24477. /**
  24478. * Cloth-Imposter type
  24479. */
  24480. static ClothImpostor: number;
  24481. /**
  24482. * Softbody-Imposter type
  24483. */
  24484. static SoftbodyImpostor: number;
  24485. }
  24486. }
  24487. declare module "babylonjs/Meshes/mesh" {
  24488. import { Observable } from "babylonjs/Misc/observable";
  24489. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24490. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24491. import { Camera } from "babylonjs/Cameras/camera";
  24492. import { Scene } from "babylonjs/scene";
  24493. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24494. import { Color4 } from "babylonjs/Maths/math.color";
  24495. import { Engine } from "babylonjs/Engines/engine";
  24496. import { Node } from "babylonjs/node";
  24497. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24498. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24499. import { Buffer } from "babylonjs/Meshes/buffer";
  24500. import { Geometry } from "babylonjs/Meshes/geometry";
  24501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24502. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24503. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24504. import { Effect } from "babylonjs/Materials/effect";
  24505. import { Material } from "babylonjs/Materials/material";
  24506. import { Skeleton } from "babylonjs/Bones/skeleton";
  24507. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24508. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24509. import { Path3D } from "babylonjs/Maths/math.path";
  24510. import { Plane } from "babylonjs/Maths/math.plane";
  24511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24512. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24513. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24514. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24515. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24516. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24517. /**
  24518. * @hidden
  24519. **/
  24520. export class _CreationDataStorage {
  24521. closePath?: boolean;
  24522. closeArray?: boolean;
  24523. idx: number[];
  24524. dashSize: number;
  24525. gapSize: number;
  24526. path3D: Path3D;
  24527. pathArray: Vector3[][];
  24528. arc: number;
  24529. radius: number;
  24530. cap: number;
  24531. tessellation: number;
  24532. }
  24533. /**
  24534. * @hidden
  24535. **/
  24536. class _InstanceDataStorage {
  24537. visibleInstances: any;
  24538. batchCache: _InstancesBatch;
  24539. instancesBufferSize: number;
  24540. instancesBuffer: Nullable<Buffer>;
  24541. instancesData: Float32Array;
  24542. overridenInstanceCount: number;
  24543. isFrozen: boolean;
  24544. previousBatch: Nullable<_InstancesBatch>;
  24545. hardwareInstancedRendering: boolean;
  24546. sideOrientation: number;
  24547. manualUpdate: boolean;
  24548. }
  24549. /**
  24550. * @hidden
  24551. **/
  24552. export class _InstancesBatch {
  24553. mustReturn: boolean;
  24554. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24555. renderSelf: boolean[];
  24556. hardwareInstancedRendering: boolean[];
  24557. }
  24558. /**
  24559. * Class used to represent renderable models
  24560. */
  24561. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24562. /**
  24563. * Mesh side orientation : usually the external or front surface
  24564. */
  24565. static readonly FRONTSIDE: number;
  24566. /**
  24567. * Mesh side orientation : usually the internal or back surface
  24568. */
  24569. static readonly BACKSIDE: number;
  24570. /**
  24571. * Mesh side orientation : both internal and external or front and back surfaces
  24572. */
  24573. static readonly DOUBLESIDE: number;
  24574. /**
  24575. * Mesh side orientation : by default, `FRONTSIDE`
  24576. */
  24577. static readonly DEFAULTSIDE: number;
  24578. /**
  24579. * Mesh cap setting : no cap
  24580. */
  24581. static readonly NO_CAP: number;
  24582. /**
  24583. * Mesh cap setting : one cap at the beginning of the mesh
  24584. */
  24585. static readonly CAP_START: number;
  24586. /**
  24587. * Mesh cap setting : one cap at the end of the mesh
  24588. */
  24589. static readonly CAP_END: number;
  24590. /**
  24591. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24592. */
  24593. static readonly CAP_ALL: number;
  24594. /**
  24595. * Mesh pattern setting : no flip or rotate
  24596. */
  24597. static readonly NO_FLIP: number;
  24598. /**
  24599. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24600. */
  24601. static readonly FLIP_TILE: number;
  24602. /**
  24603. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24604. */
  24605. static readonly ROTATE_TILE: number;
  24606. /**
  24607. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24608. */
  24609. static readonly FLIP_ROW: number;
  24610. /**
  24611. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24612. */
  24613. static readonly ROTATE_ROW: number;
  24614. /**
  24615. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24616. */
  24617. static readonly FLIP_N_ROTATE_TILE: number;
  24618. /**
  24619. * Mesh pattern setting : rotate pattern and rotate
  24620. */
  24621. static readonly FLIP_N_ROTATE_ROW: number;
  24622. /**
  24623. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24624. */
  24625. static readonly CENTER: number;
  24626. /**
  24627. * Mesh tile positioning : part tiles on left
  24628. */
  24629. static readonly LEFT: number;
  24630. /**
  24631. * Mesh tile positioning : part tiles on right
  24632. */
  24633. static readonly RIGHT: number;
  24634. /**
  24635. * Mesh tile positioning : part tiles on top
  24636. */
  24637. static readonly TOP: number;
  24638. /**
  24639. * Mesh tile positioning : part tiles on bottom
  24640. */
  24641. static readonly BOTTOM: number;
  24642. /**
  24643. * Gets the default side orientation.
  24644. * @param orientation the orientation to value to attempt to get
  24645. * @returns the default orientation
  24646. * @hidden
  24647. */
  24648. static _GetDefaultSideOrientation(orientation?: number): number;
  24649. private _internalMeshDataInfo;
  24650. /**
  24651. * An event triggered before rendering the mesh
  24652. */
  24653. readonly onBeforeRenderObservable: Observable<Mesh>;
  24654. /**
  24655. * An event triggered before binding the mesh
  24656. */
  24657. readonly onBeforeBindObservable: Observable<Mesh>;
  24658. /**
  24659. * An event triggered after rendering the mesh
  24660. */
  24661. readonly onAfterRenderObservable: Observable<Mesh>;
  24662. /**
  24663. * An event triggered before drawing the mesh
  24664. */
  24665. readonly onBeforeDrawObservable: Observable<Mesh>;
  24666. private _onBeforeDrawObserver;
  24667. /**
  24668. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24669. */
  24670. onBeforeDraw: () => void;
  24671. readonly hasInstances: boolean;
  24672. /**
  24673. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24674. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24675. */
  24676. delayLoadState: number;
  24677. /**
  24678. * Gets the list of instances created from this mesh
  24679. * it is not supposed to be modified manually.
  24680. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24681. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24682. */
  24683. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24684. /**
  24685. * Gets the file containing delay loading data for this mesh
  24686. */
  24687. delayLoadingFile: string;
  24688. /** @hidden */
  24689. _binaryInfo: any;
  24690. /**
  24691. * User defined function used to change how LOD level selection is done
  24692. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24693. */
  24694. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24695. /**
  24696. * Gets or sets the morph target manager
  24697. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24698. */
  24699. morphTargetManager: Nullable<MorphTargetManager>;
  24700. /** @hidden */
  24701. _creationDataStorage: Nullable<_CreationDataStorage>;
  24702. /** @hidden */
  24703. _geometry: Nullable<Geometry>;
  24704. /** @hidden */
  24705. _delayInfo: Array<string>;
  24706. /** @hidden */
  24707. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24708. /** @hidden */
  24709. _instanceDataStorage: _InstanceDataStorage;
  24710. private _effectiveMaterial;
  24711. /** @hidden */
  24712. _shouldGenerateFlatShading: boolean;
  24713. /** @hidden */
  24714. _originalBuilderSideOrientation: number;
  24715. /**
  24716. * Use this property to change the original side orientation defined at construction time
  24717. */
  24718. overrideMaterialSideOrientation: Nullable<number>;
  24719. /**
  24720. * Gets the source mesh (the one used to clone this one from)
  24721. */
  24722. readonly source: Nullable<Mesh>;
  24723. /**
  24724. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24725. */
  24726. isUnIndexed: boolean;
  24727. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24728. readonly worldMatrixInstancedBuffer: Float32Array;
  24729. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24730. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24731. /**
  24732. * @constructor
  24733. * @param name The value used by scene.getMeshByName() to do a lookup.
  24734. * @param scene The scene to add this mesh to.
  24735. * @param parent The parent of this mesh, if it has one
  24736. * @param source An optional Mesh from which geometry is shared, cloned.
  24737. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24738. * When false, achieved by calling a clone(), also passing False.
  24739. * This will make creation of children, recursive.
  24740. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24741. */
  24742. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24743. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24744. doNotInstantiate: boolean;
  24745. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24746. /**
  24747. * Gets the class name
  24748. * @returns the string "Mesh".
  24749. */
  24750. getClassName(): string;
  24751. /** @hidden */
  24752. readonly _isMesh: boolean;
  24753. /**
  24754. * Returns a description of this mesh
  24755. * @param fullDetails define if full details about this mesh must be used
  24756. * @returns a descriptive string representing this mesh
  24757. */
  24758. toString(fullDetails?: boolean): string;
  24759. /** @hidden */
  24760. _unBindEffect(): void;
  24761. /**
  24762. * Gets a boolean indicating if this mesh has LOD
  24763. */
  24764. readonly hasLODLevels: boolean;
  24765. /**
  24766. * Gets the list of MeshLODLevel associated with the current mesh
  24767. * @returns an array of MeshLODLevel
  24768. */
  24769. getLODLevels(): MeshLODLevel[];
  24770. private _sortLODLevels;
  24771. /**
  24772. * Add a mesh as LOD level triggered at the given distance.
  24773. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24774. * @param distance The distance from the center of the object to show this level
  24775. * @param mesh The mesh to be added as LOD level (can be null)
  24776. * @return This mesh (for chaining)
  24777. */
  24778. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24779. /**
  24780. * Returns the LOD level mesh at the passed distance or null if not found.
  24781. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24782. * @param distance The distance from the center of the object to show this level
  24783. * @returns a Mesh or `null`
  24784. */
  24785. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24786. /**
  24787. * Remove a mesh from the LOD array
  24788. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24789. * @param mesh defines the mesh to be removed
  24790. * @return This mesh (for chaining)
  24791. */
  24792. removeLODLevel(mesh: Mesh): Mesh;
  24793. /**
  24794. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24795. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24796. * @param camera defines the camera to use to compute distance
  24797. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24798. * @return This mesh (for chaining)
  24799. */
  24800. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24801. /**
  24802. * Gets the mesh internal Geometry object
  24803. */
  24804. readonly geometry: Nullable<Geometry>;
  24805. /**
  24806. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24807. * @returns the total number of vertices
  24808. */
  24809. getTotalVertices(): number;
  24810. /**
  24811. * Returns the content of an associated vertex buffer
  24812. * @param kind defines which buffer to read from (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. * @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
  24826. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24827. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24828. */
  24829. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24830. /**
  24831. * Returns the mesh VertexBuffer object from the requested `kind`
  24832. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24833. * - VertexBuffer.PositionKind
  24834. * - VertexBuffer.NormalKind
  24835. * - VertexBuffer.UVKind
  24836. * - VertexBuffer.UV2Kind
  24837. * - VertexBuffer.UV3Kind
  24838. * - VertexBuffer.UV4Kind
  24839. * - VertexBuffer.UV5Kind
  24840. * - VertexBuffer.UV6Kind
  24841. * - VertexBuffer.ColorKind
  24842. * - VertexBuffer.MatricesIndicesKind
  24843. * - VertexBuffer.MatricesIndicesExtraKind
  24844. * - VertexBuffer.MatricesWeightsKind
  24845. * - VertexBuffer.MatricesWeightsExtraKind
  24846. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24847. */
  24848. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24849. /**
  24850. * Tests if a specific vertex buffer is associated with this mesh
  24851. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24852. * - VertexBuffer.PositionKind
  24853. * - VertexBuffer.NormalKind
  24854. * - VertexBuffer.UVKind
  24855. * - VertexBuffer.UV2Kind
  24856. * - VertexBuffer.UV3Kind
  24857. * - VertexBuffer.UV4Kind
  24858. * - VertexBuffer.UV5Kind
  24859. * - VertexBuffer.UV6Kind
  24860. * - VertexBuffer.ColorKind
  24861. * - VertexBuffer.MatricesIndicesKind
  24862. * - VertexBuffer.MatricesIndicesExtraKind
  24863. * - VertexBuffer.MatricesWeightsKind
  24864. * - VertexBuffer.MatricesWeightsExtraKind
  24865. * @returns a boolean
  24866. */
  24867. isVerticesDataPresent(kind: string): boolean;
  24868. /**
  24869. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24870. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24871. * - VertexBuffer.PositionKind
  24872. * - VertexBuffer.UVKind
  24873. * - VertexBuffer.UV2Kind
  24874. * - VertexBuffer.UV3Kind
  24875. * - VertexBuffer.UV4Kind
  24876. * - VertexBuffer.UV5Kind
  24877. * - VertexBuffer.UV6Kind
  24878. * - VertexBuffer.ColorKind
  24879. * - VertexBuffer.MatricesIndicesKind
  24880. * - VertexBuffer.MatricesIndicesExtraKind
  24881. * - VertexBuffer.MatricesWeightsKind
  24882. * - VertexBuffer.MatricesWeightsExtraKind
  24883. * @returns a boolean
  24884. */
  24885. isVertexBufferUpdatable(kind: string): boolean;
  24886. /**
  24887. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24888. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24889. * - VertexBuffer.PositionKind
  24890. * - VertexBuffer.NormalKind
  24891. * - VertexBuffer.UVKind
  24892. * - VertexBuffer.UV2Kind
  24893. * - VertexBuffer.UV3Kind
  24894. * - VertexBuffer.UV4Kind
  24895. * - VertexBuffer.UV5Kind
  24896. * - VertexBuffer.UV6Kind
  24897. * - VertexBuffer.ColorKind
  24898. * - VertexBuffer.MatricesIndicesKind
  24899. * - VertexBuffer.MatricesIndicesExtraKind
  24900. * - VertexBuffer.MatricesWeightsKind
  24901. * - VertexBuffer.MatricesWeightsExtraKind
  24902. * @returns an array of strings
  24903. */
  24904. getVerticesDataKinds(): string[];
  24905. /**
  24906. * Returns a positive integer : the total number of indices in this mesh geometry.
  24907. * @returns the numner of indices or zero if the mesh has no geometry.
  24908. */
  24909. getTotalIndices(): number;
  24910. /**
  24911. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24912. * @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.
  24913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24914. * @returns the indices array or an empty array if the mesh has no geometry
  24915. */
  24916. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24917. readonly isBlocked: boolean;
  24918. /**
  24919. * Determine if the current mesh is ready to be rendered
  24920. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24921. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24922. * @returns true if all associated assets are ready (material, textures, shaders)
  24923. */
  24924. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24925. /**
  24926. * 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.
  24927. */
  24928. readonly areNormalsFrozen: boolean;
  24929. /**
  24930. * 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.
  24931. * @returns the current mesh
  24932. */
  24933. freezeNormals(): Mesh;
  24934. /**
  24935. * 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
  24936. * @returns the current mesh
  24937. */
  24938. unfreezeNormals(): Mesh;
  24939. /**
  24940. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24941. */
  24942. overridenInstanceCount: number;
  24943. /** @hidden */
  24944. _preActivate(): Mesh;
  24945. /** @hidden */
  24946. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24947. /** @hidden */
  24948. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24949. /**
  24950. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24951. * This means the mesh underlying bounding box and sphere are recomputed.
  24952. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24953. * @returns the current mesh
  24954. */
  24955. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24956. /** @hidden */
  24957. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24958. /**
  24959. * This function will subdivide the mesh into multiple submeshes
  24960. * @param count defines the expected number of submeshes
  24961. */
  24962. subdivide(count: number): void;
  24963. /**
  24964. * Copy a FloatArray into a specific associated vertex buffer
  24965. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24966. * - VertexBuffer.PositionKind
  24967. * - VertexBuffer.UVKind
  24968. * - VertexBuffer.UV2Kind
  24969. * - VertexBuffer.UV3Kind
  24970. * - VertexBuffer.UV4Kind
  24971. * - VertexBuffer.UV5Kind
  24972. * - VertexBuffer.UV6Kind
  24973. * - VertexBuffer.ColorKind
  24974. * - VertexBuffer.MatricesIndicesKind
  24975. * - VertexBuffer.MatricesIndicesExtraKind
  24976. * - VertexBuffer.MatricesWeightsKind
  24977. * - VertexBuffer.MatricesWeightsExtraKind
  24978. * @param data defines the data source
  24979. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24980. * @param stride defines the data stride size (can be null)
  24981. * @returns the current mesh
  24982. */
  24983. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24984. /**
  24985. * Delete a vertex buffer associated with this mesh
  24986. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24987. * - VertexBuffer.PositionKind
  24988. * - VertexBuffer.UVKind
  24989. * - VertexBuffer.UV2Kind
  24990. * - VertexBuffer.UV3Kind
  24991. * - VertexBuffer.UV4Kind
  24992. * - VertexBuffer.UV5Kind
  24993. * - VertexBuffer.UV6Kind
  24994. * - VertexBuffer.ColorKind
  24995. * - VertexBuffer.MatricesIndicesKind
  24996. * - VertexBuffer.MatricesIndicesExtraKind
  24997. * - VertexBuffer.MatricesWeightsKind
  24998. * - VertexBuffer.MatricesWeightsExtraKind
  24999. */
  25000. removeVerticesData(kind: string): void;
  25001. /**
  25002. * Flags an associated vertex buffer as updatable
  25003. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25004. * - VertexBuffer.PositionKind
  25005. * - VertexBuffer.UVKind
  25006. * - VertexBuffer.UV2Kind
  25007. * - VertexBuffer.UV3Kind
  25008. * - VertexBuffer.UV4Kind
  25009. * - VertexBuffer.UV5Kind
  25010. * - VertexBuffer.UV6Kind
  25011. * - VertexBuffer.ColorKind
  25012. * - VertexBuffer.MatricesIndicesKind
  25013. * - VertexBuffer.MatricesIndicesExtraKind
  25014. * - VertexBuffer.MatricesWeightsKind
  25015. * - VertexBuffer.MatricesWeightsExtraKind
  25016. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25017. */
  25018. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25019. /**
  25020. * Sets the mesh global Vertex Buffer
  25021. * @param buffer defines the buffer to use
  25022. * @returns the current mesh
  25023. */
  25024. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25025. /**
  25026. * Update a specific associated vertex buffer
  25027. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25028. * - VertexBuffer.PositionKind
  25029. * - VertexBuffer.UVKind
  25030. * - VertexBuffer.UV2Kind
  25031. * - VertexBuffer.UV3Kind
  25032. * - VertexBuffer.UV4Kind
  25033. * - VertexBuffer.UV5Kind
  25034. * - VertexBuffer.UV6Kind
  25035. * - VertexBuffer.ColorKind
  25036. * - VertexBuffer.MatricesIndicesKind
  25037. * - VertexBuffer.MatricesIndicesExtraKind
  25038. * - VertexBuffer.MatricesWeightsKind
  25039. * - VertexBuffer.MatricesWeightsExtraKind
  25040. * @param data defines the data source
  25041. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25042. * @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)
  25043. * @returns the current mesh
  25044. */
  25045. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25046. /**
  25047. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25048. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25049. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25050. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25051. * @returns the current mesh
  25052. */
  25053. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25054. /**
  25055. * Creates a un-shared specific occurence of the geometry for the mesh.
  25056. * @returns the current mesh
  25057. */
  25058. makeGeometryUnique(): Mesh;
  25059. /**
  25060. * Set the index buffer of this mesh
  25061. * @param indices defines the source data
  25062. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25063. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25064. * @returns the current mesh
  25065. */
  25066. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25067. /**
  25068. * Update the current index buffer
  25069. * @param indices defines the source data
  25070. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25071. * @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)
  25072. * @returns the current mesh
  25073. */
  25074. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25075. /**
  25076. * Invert the geometry to move from a right handed system to a left handed one.
  25077. * @returns the current mesh
  25078. */
  25079. toLeftHanded(): Mesh;
  25080. /** @hidden */
  25081. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25082. /** @hidden */
  25083. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25084. /**
  25085. * Registers for this mesh a javascript function called just before the rendering process
  25086. * @param func defines the function to call before rendering this mesh
  25087. * @returns the current mesh
  25088. */
  25089. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25090. /**
  25091. * Disposes a previously registered javascript function called before the rendering
  25092. * @param func defines the function to remove
  25093. * @returns the current mesh
  25094. */
  25095. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25096. /**
  25097. * Registers for this mesh a javascript function called just after the rendering is complete
  25098. * @param func defines the function to call after rendering this mesh
  25099. * @returns the current mesh
  25100. */
  25101. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25102. /**
  25103. * Disposes a previously registered javascript function called after the rendering.
  25104. * @param func defines the function to remove
  25105. * @returns the current mesh
  25106. */
  25107. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25108. /** @hidden */
  25109. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25110. /** @hidden */
  25111. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25112. /** @hidden */
  25113. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25114. /** @hidden */
  25115. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25116. /** @hidden */
  25117. _rebuild(): void;
  25118. /** @hidden */
  25119. _freeze(): void;
  25120. /** @hidden */
  25121. _unFreeze(): void;
  25122. /**
  25123. * 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
  25124. * @param subMesh defines the subMesh to render
  25125. * @param enableAlphaMode defines if alpha mode can be changed
  25126. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25127. * @returns the current mesh
  25128. */
  25129. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25130. private _onBeforeDraw;
  25131. /**
  25132. * Renormalize the mesh and patch it up if there are no weights
  25133. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25134. * However in the case of zero weights then we set just a single influence to 1.
  25135. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25136. */
  25137. cleanMatrixWeights(): void;
  25138. private normalizeSkinFourWeights;
  25139. private normalizeSkinWeightsAndExtra;
  25140. /**
  25141. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25142. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25143. * the user know there was an issue with importing the mesh
  25144. * @returns a validation object with skinned, valid and report string
  25145. */
  25146. validateSkinning(): {
  25147. skinned: boolean;
  25148. valid: boolean;
  25149. report: string;
  25150. };
  25151. /** @hidden */
  25152. _checkDelayState(): Mesh;
  25153. private _queueLoad;
  25154. /**
  25155. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25156. * A mesh is in the frustum if its bounding box intersects the frustum
  25157. * @param frustumPlanes defines the frustum to test
  25158. * @returns true if the mesh is in the frustum planes
  25159. */
  25160. isInFrustum(frustumPlanes: Plane[]): boolean;
  25161. /**
  25162. * Sets the mesh material by the material or multiMaterial `id` property
  25163. * @param id is a string identifying the material or the multiMaterial
  25164. * @returns the current mesh
  25165. */
  25166. setMaterialByID(id: string): Mesh;
  25167. /**
  25168. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25169. * @returns an array of IAnimatable
  25170. */
  25171. getAnimatables(): IAnimatable[];
  25172. /**
  25173. * Modifies the mesh geometry according to the passed transformation matrix.
  25174. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25175. * The mesh normals are modified using the same transformation.
  25176. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25177. * @param transform defines the transform matrix to use
  25178. * @see http://doc.babylonjs.com/resources/baking_transformations
  25179. * @returns the current mesh
  25180. */
  25181. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25182. /**
  25183. * Modifies the mesh geometry according to its own current World Matrix.
  25184. * The mesh World Matrix is then reset.
  25185. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25186. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25187. * @see http://doc.babylonjs.com/resources/baking_transformations
  25188. * @returns the current mesh
  25189. */
  25190. bakeCurrentTransformIntoVertices(): Mesh;
  25191. /** @hidden */
  25192. readonly _positions: Nullable<Vector3[]>;
  25193. /** @hidden */
  25194. _resetPointsArrayCache(): Mesh;
  25195. /** @hidden */
  25196. _generatePointsArray(): boolean;
  25197. /**
  25198. * Returns a new Mesh object generated from the current mesh properties.
  25199. * This method must not get confused with createInstance()
  25200. * @param name is a string, the name given to the new mesh
  25201. * @param newParent can be any Node object (default `null`)
  25202. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25203. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25204. * @returns a new mesh
  25205. */
  25206. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25207. /**
  25208. * Releases resources associated with this mesh.
  25209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25211. */
  25212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25213. /** @hidden */
  25214. _disposeInstanceSpecificData(): void;
  25215. /**
  25216. * Modifies the mesh geometry according to a displacement map.
  25217. * 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.
  25218. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25219. * @param url is a string, the URL from the image file is to be downloaded.
  25220. * @param minHeight is the lower limit of the displacement.
  25221. * @param maxHeight is the upper limit of the displacement.
  25222. * @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.
  25223. * @param uvOffset is an optional vector2 used to offset UV.
  25224. * @param uvScale is an optional vector2 used to scale UV.
  25225. * @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.
  25226. * @returns the Mesh.
  25227. */
  25228. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25229. /**
  25230. * Modifies the mesh geometry according to a displacementMap buffer.
  25231. * 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.
  25232. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25233. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25234. * @param heightMapWidth is the width of the buffer image.
  25235. * @param heightMapHeight is the height of the buffer image.
  25236. * @param minHeight is the lower limit of the displacement.
  25237. * @param maxHeight is the upper limit of the displacement.
  25238. * @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.
  25239. * @param uvOffset is an optional vector2 used to offset UV.
  25240. * @param uvScale is an optional vector2 used to scale UV.
  25241. * @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.
  25242. * @returns the Mesh.
  25243. */
  25244. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25245. /**
  25246. * Modify the mesh to get a flat shading rendering.
  25247. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25248. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25249. * @returns current mesh
  25250. */
  25251. convertToFlatShadedMesh(): Mesh;
  25252. /**
  25253. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25254. * In other words, more vertices, no more indices and a single bigger VBO.
  25255. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25256. * @returns current mesh
  25257. */
  25258. convertToUnIndexedMesh(): Mesh;
  25259. /**
  25260. * Inverses facet orientations.
  25261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25262. * @param flipNormals will also inverts the normals
  25263. * @returns current mesh
  25264. */
  25265. flipFaces(flipNormals?: boolean): Mesh;
  25266. /**
  25267. * Increase the number of facets and hence vertices in a mesh
  25268. * Vertex normals are interpolated from existing vertex normals
  25269. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25270. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25271. */
  25272. increaseVertices(numberPerEdge: number): void;
  25273. /**
  25274. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25275. * This will undo any application of covertToFlatShadedMesh
  25276. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25277. */
  25278. forceSharedVertices(): void;
  25279. /** @hidden */
  25280. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25281. /** @hidden */
  25282. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25283. /**
  25284. * Creates a new InstancedMesh object from the mesh model.
  25285. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25286. * @param name defines the name of the new instance
  25287. * @returns a new InstancedMesh
  25288. */
  25289. createInstance(name: string): InstancedMesh;
  25290. /**
  25291. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25292. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25293. * @returns the current mesh
  25294. */
  25295. synchronizeInstances(): Mesh;
  25296. /**
  25297. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25298. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25299. * This should be used together with the simplification to avoid disappearing triangles.
  25300. * @param successCallback an optional success callback to be called after the optimization finished.
  25301. * @returns the current mesh
  25302. */
  25303. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25304. /**
  25305. * Serialize current mesh
  25306. * @param serializationObject defines the object which will receive the serialization data
  25307. */
  25308. serialize(serializationObject: any): void;
  25309. /** @hidden */
  25310. _syncGeometryWithMorphTargetManager(): void;
  25311. /** @hidden */
  25312. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25313. /**
  25314. * Returns a new Mesh object parsed from the source provided.
  25315. * @param parsedMesh is the source
  25316. * @param scene defines the hosting scene
  25317. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25318. * @returns a new Mesh
  25319. */
  25320. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25321. /**
  25322. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25323. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25324. * @param name defines the name of the mesh to create
  25325. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25326. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25327. * @param closePath creates a seam between the first and the last points of each path of the path array
  25328. * @param offset is taken in account only if the `pathArray` is containing a single path
  25329. * @param scene defines the hosting scene
  25330. * @param updatable defines if the mesh must be flagged as updatable
  25331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25332. * @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)
  25333. * @returns a new Mesh
  25334. */
  25335. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25336. /**
  25337. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25338. * @param name defines the name of the mesh to create
  25339. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25340. * @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
  25341. * @param scene defines the hosting scene
  25342. * @param updatable defines if the mesh must be flagged as updatable
  25343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25344. * @returns a new Mesh
  25345. */
  25346. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25347. /**
  25348. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25349. * @param name defines the name of the mesh to create
  25350. * @param size sets the size (float) of each box side (default 1)
  25351. * @param scene defines the hosting scene
  25352. * @param updatable defines if the mesh must be flagged as updatable
  25353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25357. /**
  25358. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25359. * @param name defines the name of the mesh to create
  25360. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25361. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25362. * @param scene defines the hosting scene
  25363. * @param updatable defines if the mesh must be flagged as updatable
  25364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25365. * @returns a new Mesh
  25366. */
  25367. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25368. /**
  25369. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25372. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25373. * @param scene defines the hosting scene
  25374. * @returns a new Mesh
  25375. */
  25376. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25377. /**
  25378. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25379. * @param name defines the name of the mesh to create
  25380. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25381. * @param diameterTop set the top cap diameter (floats, default 1)
  25382. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25383. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25384. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25385. * @param scene defines the hosting scene
  25386. * @param updatable defines if the mesh must be flagged as updatable
  25387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25388. * @returns a new Mesh
  25389. */
  25390. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25391. /**
  25392. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25393. * @param name defines the name of the mesh to create
  25394. * @param diameter sets the diameter size (float) of the torus (default 1)
  25395. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25396. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25397. * @param scene defines the hosting scene
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25400. * @returns a new Mesh
  25401. */
  25402. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25403. /**
  25404. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25405. * @param name defines the name of the mesh to create
  25406. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25407. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25408. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25409. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25410. * @param p the number of windings on X axis (positive integers, default 2)
  25411. * @param q the number of windings on Y axis (positive integers, default 3)
  25412. * @param scene defines the hosting scene
  25413. * @param updatable defines if the mesh must be flagged as updatable
  25414. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25415. * @returns a new Mesh
  25416. */
  25417. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25418. /**
  25419. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25420. * @param name defines the name of the mesh to create
  25421. * @param points is an array successive Vector3
  25422. * @param scene defines the hosting scene
  25423. * @param updatable defines if the mesh must be flagged as updatable
  25424. * @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).
  25425. * @returns a new Mesh
  25426. */
  25427. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25428. /**
  25429. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25430. * @param name defines the name of the mesh to create
  25431. * @param points is an array successive Vector3
  25432. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25433. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25434. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25435. * @param scene defines the hosting scene
  25436. * @param updatable defines if the mesh must be flagged as updatable
  25437. * @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)
  25438. * @returns a new Mesh
  25439. */
  25440. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25441. /**
  25442. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25443. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25444. * 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.
  25445. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25446. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25447. * Remember you can only change the shape positions, not their number when updating a polygon.
  25448. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25449. * @param name defines the name of the mesh to create
  25450. * @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
  25451. * @param scene defines the hosting scene
  25452. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25453. * @param updatable defines if the mesh must be flagged as updatable
  25454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25455. * @param earcutInjection can be used to inject your own earcut reference
  25456. * @returns a new Mesh
  25457. */
  25458. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25459. /**
  25460. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25461. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25462. * @param name defines the name of the mesh to create
  25463. * @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
  25464. * @param depth defines the height of extrusion
  25465. * @param scene defines the hosting scene
  25466. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25467. * @param updatable defines if the mesh must be flagged as updatable
  25468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25469. * @param earcutInjection can be used to inject your own earcut reference
  25470. * @returns a new Mesh
  25471. */
  25472. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25473. /**
  25474. * Creates an extruded shape mesh.
  25475. * 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
  25476. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25477. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25478. * @param name defines the name of the mesh to create
  25479. * @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
  25480. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25481. * @param scale is the value to scale the shape
  25482. * @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
  25483. * @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
  25484. * @param scene defines the hosting scene
  25485. * @param updatable defines if the mesh must be flagged as updatable
  25486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25487. * @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)
  25488. * @returns a new Mesh
  25489. */
  25490. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25491. /**
  25492. * Creates an custom extruded shape mesh.
  25493. * The custom extrusion is a parametric shape.
  25494. * It has no predefined shape. Its final shape will depend on the input parameters.
  25495. * Please consider using the same method from the MeshBuilder class instead
  25496. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25497. * @param name defines the name of the mesh to create
  25498. * @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
  25499. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25500. * @param scaleFunction is a custom Javascript function called on each path point
  25501. * @param rotationFunction is a custom Javascript function called on each path point
  25502. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25503. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25504. * @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
  25505. * @param scene defines the hosting scene
  25506. * @param updatable defines if the mesh must be flagged as updatable
  25507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25508. * @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)
  25509. * @returns a new Mesh
  25510. */
  25511. 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;
  25512. /**
  25513. * Creates lathe mesh.
  25514. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25515. * Please consider using the same method from the MeshBuilder class instead
  25516. * @param name defines the name of the mesh to create
  25517. * @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
  25518. * @param radius is the radius value of the lathe
  25519. * @param tessellation is the side number of the lathe.
  25520. * @param scene defines the hosting scene
  25521. * @param updatable defines if the mesh must be flagged as updatable
  25522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25523. * @returns a new Mesh
  25524. */
  25525. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25526. /**
  25527. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25528. * @param name defines the name of the mesh to create
  25529. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25530. * @param scene defines the hosting scene
  25531. * @param updatable defines if the mesh must be flagged as updatable
  25532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25533. * @returns a new Mesh
  25534. */
  25535. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25536. /**
  25537. * Creates a ground mesh.
  25538. * Please consider using the same method from the MeshBuilder class instead
  25539. * @param name defines the name of the mesh to create
  25540. * @param width set the width of the ground
  25541. * @param height set the height of the ground
  25542. * @param subdivisions sets the number of subdivisions per side
  25543. * @param scene defines the hosting scene
  25544. * @param updatable defines if the mesh must be flagged as updatable
  25545. * @returns a new Mesh
  25546. */
  25547. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25548. /**
  25549. * Creates a tiled ground mesh.
  25550. * Please consider using the same method from the MeshBuilder class instead
  25551. * @param name defines the name of the mesh to create
  25552. * @param xmin set the ground minimum X coordinate
  25553. * @param zmin set the ground minimum Y coordinate
  25554. * @param xmax set the ground maximum X coordinate
  25555. * @param zmax set the ground maximum Z coordinate
  25556. * @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
  25557. * @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
  25558. * @param scene defines the hosting scene
  25559. * @param updatable defines if the mesh must be flagged as updatable
  25560. * @returns a new Mesh
  25561. */
  25562. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25563. w: number;
  25564. h: number;
  25565. }, precision: {
  25566. w: number;
  25567. h: number;
  25568. }, scene: Scene, updatable?: boolean): Mesh;
  25569. /**
  25570. * Creates a ground mesh from a height map.
  25571. * Please consider using the same method from the MeshBuilder class instead
  25572. * @see http://doc.babylonjs.com/babylon101/height_map
  25573. * @param name defines the name of the mesh to create
  25574. * @param url sets the URL of the height map image resource
  25575. * @param width set the ground width size
  25576. * @param height set the ground height size
  25577. * @param subdivisions sets the number of subdivision per side
  25578. * @param minHeight is the minimum altitude on the ground
  25579. * @param maxHeight is the maximum altitude on the ground
  25580. * @param scene defines the hosting scene
  25581. * @param updatable defines if the mesh must be flagged as updatable
  25582. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25583. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25584. * @returns a new Mesh
  25585. */
  25586. 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;
  25587. /**
  25588. * Creates a tube mesh.
  25589. * The tube is a parametric shape.
  25590. * It has no predefined shape. Its final shape will depend on the input parameters.
  25591. * Please consider using the same method from the MeshBuilder class instead
  25592. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25593. * @param name defines the name of the mesh to create
  25594. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25595. * @param radius sets the tube radius size
  25596. * @param tessellation is the number of sides on the tubular surface
  25597. * @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
  25598. * @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
  25599. * @param scene defines the hosting scene
  25600. * @param updatable defines if the mesh must be flagged as updatable
  25601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25602. * @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)
  25603. * @returns a new Mesh
  25604. */
  25605. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25606. (i: number, distance: number): number;
  25607. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25608. /**
  25609. * Creates a polyhedron mesh.
  25610. * Please consider using the same method from the MeshBuilder class instead.
  25611. * * 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
  25612. * * The parameter `size` (positive float, default 1) sets the polygon size
  25613. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25614. * * 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`
  25615. * * 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
  25616. * * 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)`)
  25617. * * 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
  25618. * * 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
  25619. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25620. * * If you create a double-sided mesh, you can choose what parts of 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
  25621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25622. * @param name defines the name of the mesh to create
  25623. * @param options defines the options used to create the mesh
  25624. * @param scene defines the hosting scene
  25625. * @returns a new Mesh
  25626. */
  25627. static CreatePolyhedron(name: string, options: {
  25628. type?: number;
  25629. size?: number;
  25630. sizeX?: number;
  25631. sizeY?: number;
  25632. sizeZ?: number;
  25633. custom?: any;
  25634. faceUV?: Vector4[];
  25635. faceColors?: Color4[];
  25636. updatable?: boolean;
  25637. sideOrientation?: number;
  25638. }, scene: Scene): Mesh;
  25639. /**
  25640. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25641. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25642. * * 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`)
  25643. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25644. * * 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
  25645. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25646. * * If you create a double-sided mesh, you can choose what parts of 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
  25647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25648. * @param name defines the name of the mesh
  25649. * @param options defines the options used to create the mesh
  25650. * @param scene defines the hosting scene
  25651. * @returns a new Mesh
  25652. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25653. */
  25654. static CreateIcoSphere(name: string, options: {
  25655. radius?: number;
  25656. flat?: boolean;
  25657. subdivisions?: number;
  25658. sideOrientation?: number;
  25659. updatable?: boolean;
  25660. }, scene: Scene): Mesh;
  25661. /**
  25662. * Creates a decal mesh.
  25663. * Please consider using the same method from the MeshBuilder class instead.
  25664. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25665. * @param name defines the name of the mesh
  25666. * @param sourceMesh defines the mesh receiving the decal
  25667. * @param position sets the position of the decal in world coordinates
  25668. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25669. * @param size sets the decal scaling
  25670. * @param angle sets the angle to rotate the decal
  25671. * @returns a new Mesh
  25672. */
  25673. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25674. /**
  25675. * Prepare internal position array for software CPU skinning
  25676. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25677. */
  25678. setPositionsForCPUSkinning(): Float32Array;
  25679. /**
  25680. * Prepare internal normal array for software CPU skinning
  25681. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25682. */
  25683. setNormalsForCPUSkinning(): Float32Array;
  25684. /**
  25685. * Updates the vertex buffer by applying transformation from the bones
  25686. * @param skeleton defines the skeleton to apply to current mesh
  25687. * @returns the current mesh
  25688. */
  25689. applySkeleton(skeleton: Skeleton): Mesh;
  25690. /**
  25691. * 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
  25692. * @param meshes defines the list of meshes to scan
  25693. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25694. */
  25695. static MinMax(meshes: AbstractMesh[]): {
  25696. min: Vector3;
  25697. max: Vector3;
  25698. };
  25699. /**
  25700. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25701. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25702. * @returns a vector3
  25703. */
  25704. static Center(meshesOrMinMaxVector: {
  25705. min: Vector3;
  25706. max: Vector3;
  25707. } | AbstractMesh[]): Vector3;
  25708. /**
  25709. * Merge the array of meshes into a single mesh for performance reasons.
  25710. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25711. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25712. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25713. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25714. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25715. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25716. * @returns a new mesh
  25717. */
  25718. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25719. /** @hidden */
  25720. addInstance(instance: InstancedMesh): void;
  25721. /** @hidden */
  25722. removeInstance(instance: InstancedMesh): void;
  25723. }
  25724. }
  25725. declare module "babylonjs/Cameras/camera" {
  25726. import { SmartArray } from "babylonjs/Misc/smartArray";
  25727. import { Observable } from "babylonjs/Misc/observable";
  25728. import { Nullable } from "babylonjs/types";
  25729. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25730. import { Scene } from "babylonjs/scene";
  25731. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25732. import { Node } from "babylonjs/node";
  25733. import { Mesh } from "babylonjs/Meshes/mesh";
  25734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25735. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25736. import { Viewport } from "babylonjs/Maths/math.viewport";
  25737. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25739. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25740. import { Ray } from "babylonjs/Culling/ray";
  25741. /**
  25742. * This is the base class of all the camera used in the application.
  25743. * @see http://doc.babylonjs.com/features/cameras
  25744. */
  25745. export class Camera extends Node {
  25746. /** @hidden */
  25747. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25748. /**
  25749. * This is the default projection mode used by the cameras.
  25750. * It helps recreating a feeling of perspective and better appreciate depth.
  25751. * This is the best way to simulate real life cameras.
  25752. */
  25753. static readonly PERSPECTIVE_CAMERA: number;
  25754. /**
  25755. * This helps creating camera with an orthographic mode.
  25756. * 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.
  25757. */
  25758. static readonly ORTHOGRAPHIC_CAMERA: number;
  25759. /**
  25760. * This is the default FOV mode for perspective cameras.
  25761. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25762. */
  25763. static readonly FOVMODE_VERTICAL_FIXED: number;
  25764. /**
  25765. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25766. */
  25767. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25768. /**
  25769. * This specifies ther is no need for a camera rig.
  25770. * Basically only one eye is rendered corresponding to the camera.
  25771. */
  25772. static readonly RIG_MODE_NONE: number;
  25773. /**
  25774. * Simulates a camera Rig with one blue eye and one red eye.
  25775. * This can be use with 3d blue and red glasses.
  25776. */
  25777. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25778. /**
  25779. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25780. */
  25781. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25782. /**
  25783. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25784. */
  25785. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25786. /**
  25787. * Defines that both eyes of the camera will be rendered over under each other.
  25788. */
  25789. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25790. /**
  25791. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25792. */
  25793. static readonly RIG_MODE_VR: number;
  25794. /**
  25795. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25796. */
  25797. static readonly RIG_MODE_WEBVR: number;
  25798. /**
  25799. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25800. */
  25801. static readonly RIG_MODE_CUSTOM: number;
  25802. /**
  25803. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25804. */
  25805. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25806. /**
  25807. * Define the input manager associated with the camera.
  25808. */
  25809. inputs: CameraInputsManager<Camera>;
  25810. /** @hidden */
  25811. _position: Vector3;
  25812. /**
  25813. * Define the current local position of the camera in the scene
  25814. */
  25815. position: Vector3;
  25816. /**
  25817. * The vector the camera should consider as up.
  25818. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25819. */
  25820. upVector: Vector3;
  25821. /**
  25822. * Define the current limit on the left side for an orthographic camera
  25823. * In scene unit
  25824. */
  25825. orthoLeft: Nullable<number>;
  25826. /**
  25827. * Define the current limit on the right side for an orthographic camera
  25828. * In scene unit
  25829. */
  25830. orthoRight: Nullable<number>;
  25831. /**
  25832. * Define the current limit on the bottom side for an orthographic camera
  25833. * In scene unit
  25834. */
  25835. orthoBottom: Nullable<number>;
  25836. /**
  25837. * Define the current limit on the top side for an orthographic camera
  25838. * In scene unit
  25839. */
  25840. orthoTop: Nullable<number>;
  25841. /**
  25842. * Field Of View is set in Radians. (default is 0.8)
  25843. */
  25844. fov: number;
  25845. /**
  25846. * Define the minimum distance the camera can see from.
  25847. * This is important to note that the depth buffer are not infinite and the closer it starts
  25848. * the more your scene might encounter depth fighting issue.
  25849. */
  25850. minZ: number;
  25851. /**
  25852. * Define the maximum distance the camera can see to.
  25853. * This is important to note that the depth buffer are not infinite and the further it end
  25854. * the more your scene might encounter depth fighting issue.
  25855. */
  25856. maxZ: number;
  25857. /**
  25858. * Define the default inertia of the camera.
  25859. * This helps giving a smooth feeling to the camera movement.
  25860. */
  25861. inertia: number;
  25862. /**
  25863. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25864. */
  25865. mode: number;
  25866. /**
  25867. * Define wether the camera is intermediate.
  25868. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25869. */
  25870. isIntermediate: boolean;
  25871. /**
  25872. * Define the viewport of the camera.
  25873. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25874. */
  25875. viewport: Viewport;
  25876. /**
  25877. * Restricts the camera to viewing objects with the same layerMask.
  25878. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25879. */
  25880. layerMask: number;
  25881. /**
  25882. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25883. */
  25884. fovMode: number;
  25885. /**
  25886. * Rig mode of the camera.
  25887. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25888. * This is normally controlled byt the camera themselves as internal use.
  25889. */
  25890. cameraRigMode: number;
  25891. /**
  25892. * Defines the distance between both "eyes" in case of a RIG
  25893. */
  25894. interaxialDistance: number;
  25895. /**
  25896. * Defines if stereoscopic rendering is done side by side or over under.
  25897. */
  25898. isStereoscopicSideBySide: boolean;
  25899. /**
  25900. * 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
  25901. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25902. * else in the scene. (Eg. security camera)
  25903. *
  25904. * 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)
  25905. */
  25906. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25907. /**
  25908. * When set, the camera will render to this render target instead of the default canvas
  25909. *
  25910. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25911. */
  25912. outputRenderTarget: Nullable<RenderTargetTexture>;
  25913. /**
  25914. * Observable triggered when the camera view matrix has changed.
  25915. */
  25916. onViewMatrixChangedObservable: Observable<Camera>;
  25917. /**
  25918. * Observable triggered when the camera Projection matrix has changed.
  25919. */
  25920. onProjectionMatrixChangedObservable: Observable<Camera>;
  25921. /**
  25922. * Observable triggered when the inputs have been processed.
  25923. */
  25924. onAfterCheckInputsObservable: Observable<Camera>;
  25925. /**
  25926. * Observable triggered when reset has been called and applied to the camera.
  25927. */
  25928. onRestoreStateObservable: Observable<Camera>;
  25929. /** @hidden */
  25930. _cameraRigParams: any;
  25931. /** @hidden */
  25932. _rigCameras: Camera[];
  25933. /** @hidden */
  25934. _rigPostProcess: Nullable<PostProcess>;
  25935. protected _webvrViewMatrix: Matrix;
  25936. /** @hidden */
  25937. _skipRendering: boolean;
  25938. /** @hidden */
  25939. _projectionMatrix: Matrix;
  25940. /** @hidden */
  25941. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25942. /** @hidden */
  25943. _activeMeshes: SmartArray<AbstractMesh>;
  25944. protected _globalPosition: Vector3;
  25945. /** @hidden */
  25946. _computedViewMatrix: Matrix;
  25947. private _doNotComputeProjectionMatrix;
  25948. private _transformMatrix;
  25949. private _frustumPlanes;
  25950. private _refreshFrustumPlanes;
  25951. private _storedFov;
  25952. private _stateStored;
  25953. /**
  25954. * Instantiates a new camera object.
  25955. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25956. * @see http://doc.babylonjs.com/features/cameras
  25957. * @param name Defines the name of the camera in the scene
  25958. * @param position Defines the position of the camera
  25959. * @param scene Defines the scene the camera belongs too
  25960. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25961. */
  25962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25963. /**
  25964. * Store current camera state (fov, position, etc..)
  25965. * @returns the camera
  25966. */
  25967. storeState(): Camera;
  25968. /**
  25969. * Restores the camera state values if it has been stored. You must call storeState() first
  25970. */
  25971. protected _restoreStateValues(): boolean;
  25972. /**
  25973. * Restored camera state. You must call storeState() first.
  25974. * @returns true if restored and false otherwise
  25975. */
  25976. restoreState(): boolean;
  25977. /**
  25978. * Gets the class name of the camera.
  25979. * @returns the class name
  25980. */
  25981. getClassName(): string;
  25982. /** @hidden */
  25983. readonly _isCamera: boolean;
  25984. /**
  25985. * Gets a string representation of the camera useful for debug purpose.
  25986. * @param fullDetails Defines that a more verboe level of logging is required
  25987. * @returns the string representation
  25988. */
  25989. toString(fullDetails?: boolean): string;
  25990. /**
  25991. * Gets the current world space position of the camera.
  25992. */
  25993. readonly globalPosition: Vector3;
  25994. /**
  25995. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25996. * @returns the active meshe list
  25997. */
  25998. getActiveMeshes(): SmartArray<AbstractMesh>;
  25999. /**
  26000. * Check wether a mesh is part of the current active mesh list of the camera
  26001. * @param mesh Defines the mesh to check
  26002. * @returns true if active, false otherwise
  26003. */
  26004. isActiveMesh(mesh: Mesh): boolean;
  26005. /**
  26006. * Is this camera ready to be used/rendered
  26007. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26008. * @return true if the camera is ready
  26009. */
  26010. isReady(completeCheck?: boolean): boolean;
  26011. /** @hidden */
  26012. _initCache(): void;
  26013. /** @hidden */
  26014. _updateCache(ignoreParentClass?: boolean): void;
  26015. /** @hidden */
  26016. _isSynchronized(): boolean;
  26017. /** @hidden */
  26018. _isSynchronizedViewMatrix(): boolean;
  26019. /** @hidden */
  26020. _isSynchronizedProjectionMatrix(): boolean;
  26021. /**
  26022. * Attach the input controls to a specific dom element to get the input from.
  26023. * @param element Defines the element the controls should be listened from
  26024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26025. */
  26026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26027. /**
  26028. * Detach the current controls from the specified dom element.
  26029. * @param element Defines the element to stop listening the inputs from
  26030. */
  26031. detachControl(element: HTMLElement): void;
  26032. /**
  26033. * Update the camera state according to the different inputs gathered during the frame.
  26034. */
  26035. update(): void;
  26036. /** @hidden */
  26037. _checkInputs(): void;
  26038. /** @hidden */
  26039. readonly rigCameras: Camera[];
  26040. /**
  26041. * Gets the post process used by the rig cameras
  26042. */
  26043. readonly rigPostProcess: Nullable<PostProcess>;
  26044. /**
  26045. * Internal, gets the first post proces.
  26046. * @returns the first post process to be run on this camera.
  26047. */
  26048. _getFirstPostProcess(): Nullable<PostProcess>;
  26049. private _cascadePostProcessesToRigCams;
  26050. /**
  26051. * Attach a post process to the camera.
  26052. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26053. * @param postProcess The post process to attach to the camera
  26054. * @param insertAt The position of the post process in case several of them are in use in the scene
  26055. * @returns the position the post process has been inserted at
  26056. */
  26057. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26058. /**
  26059. * Detach a post process to the camera.
  26060. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26061. * @param postProcess The post process to detach from the camera
  26062. */
  26063. detachPostProcess(postProcess: PostProcess): void;
  26064. /**
  26065. * Gets the current world matrix of the camera
  26066. */
  26067. getWorldMatrix(): Matrix;
  26068. /** @hidden */
  26069. _getViewMatrix(): Matrix;
  26070. /**
  26071. * Gets the current view matrix of the camera.
  26072. * @param force forces the camera to recompute the matrix without looking at the cached state
  26073. * @returns the view matrix
  26074. */
  26075. getViewMatrix(force?: boolean): Matrix;
  26076. /**
  26077. * Freeze the projection matrix.
  26078. * It will prevent the cache check of the camera projection compute and can speed up perf
  26079. * if no parameter of the camera are meant to change
  26080. * @param projection Defines manually a projection if necessary
  26081. */
  26082. freezeProjectionMatrix(projection?: Matrix): void;
  26083. /**
  26084. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26085. */
  26086. unfreezeProjectionMatrix(): void;
  26087. /**
  26088. * Gets the current projection matrix of the camera.
  26089. * @param force forces the camera to recompute the matrix without looking at the cached state
  26090. * @returns the projection matrix
  26091. */
  26092. getProjectionMatrix(force?: boolean): Matrix;
  26093. /**
  26094. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26095. * @returns a Matrix
  26096. */
  26097. getTransformationMatrix(): Matrix;
  26098. private _updateFrustumPlanes;
  26099. /**
  26100. * Checks if a cullable object (mesh...) is in the camera frustum
  26101. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26102. * @param target The object to check
  26103. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26104. * @returns true if the object is in frustum otherwise false
  26105. */
  26106. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26107. /**
  26108. * Checks if a cullable object (mesh...) is in the camera frustum
  26109. * Unlike isInFrustum this cheks the full bounding box
  26110. * @param target The object to check
  26111. * @returns true if the object is in frustum otherwise false
  26112. */
  26113. isCompletelyInFrustum(target: ICullable): boolean;
  26114. /**
  26115. * Gets a ray in the forward direction from the camera.
  26116. * @param length Defines the length of the ray to create
  26117. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26118. * @param origin Defines the start point of the ray which defaults to the camera position
  26119. * @returns the forward ray
  26120. */
  26121. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26122. /**
  26123. * Releases resources associated with this node.
  26124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26126. */
  26127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26128. /** @hidden */
  26129. _isLeftCamera: boolean;
  26130. /**
  26131. * Gets the left camera of a rig setup in case of Rigged Camera
  26132. */
  26133. readonly isLeftCamera: boolean;
  26134. /** @hidden */
  26135. _isRightCamera: boolean;
  26136. /**
  26137. * Gets the right camera of a rig setup in case of Rigged Camera
  26138. */
  26139. readonly isRightCamera: boolean;
  26140. /**
  26141. * Gets the left camera of a rig setup in case of Rigged Camera
  26142. */
  26143. readonly leftCamera: Nullable<FreeCamera>;
  26144. /**
  26145. * Gets the right camera of a rig setup in case of Rigged Camera
  26146. */
  26147. readonly rightCamera: Nullable<FreeCamera>;
  26148. /**
  26149. * Gets the left camera target of a rig setup in case of Rigged Camera
  26150. * @returns the target position
  26151. */
  26152. getLeftTarget(): Nullable<Vector3>;
  26153. /**
  26154. * Gets the right camera target of a rig setup in case of Rigged Camera
  26155. * @returns the target position
  26156. */
  26157. getRightTarget(): Nullable<Vector3>;
  26158. /**
  26159. * @hidden
  26160. */
  26161. setCameraRigMode(mode: number, rigParams: any): void;
  26162. /** @hidden */
  26163. static _setStereoscopicRigMode(camera: Camera): void;
  26164. /** @hidden */
  26165. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26166. /** @hidden */
  26167. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26168. /** @hidden */
  26169. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26170. /** @hidden */
  26171. _getVRProjectionMatrix(): Matrix;
  26172. protected _updateCameraRotationMatrix(): void;
  26173. protected _updateWebVRCameraRotationMatrix(): void;
  26174. /**
  26175. * This function MUST be overwritten by the different WebVR cameras available.
  26176. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26177. * @hidden
  26178. */
  26179. _getWebVRProjectionMatrix(): Matrix;
  26180. /**
  26181. * This function MUST be overwritten by the different WebVR cameras available.
  26182. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26183. * @hidden
  26184. */
  26185. _getWebVRViewMatrix(): Matrix;
  26186. /** @hidden */
  26187. setCameraRigParameter(name: string, value: any): void;
  26188. /**
  26189. * needs to be overridden by children so sub has required properties to be copied
  26190. * @hidden
  26191. */
  26192. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26193. /**
  26194. * May need to be overridden by children
  26195. * @hidden
  26196. */
  26197. _updateRigCameras(): void;
  26198. /** @hidden */
  26199. _setupInputs(): void;
  26200. /**
  26201. * Serialiaze the camera setup to a json represention
  26202. * @returns the JSON representation
  26203. */
  26204. serialize(): any;
  26205. /**
  26206. * Clones the current camera.
  26207. * @param name The cloned camera name
  26208. * @returns the cloned camera
  26209. */
  26210. clone(name: string): Camera;
  26211. /**
  26212. * Gets the direction of the camera relative to a given local axis.
  26213. * @param localAxis Defines the reference axis to provide a relative direction.
  26214. * @return the direction
  26215. */
  26216. getDirection(localAxis: Vector3): Vector3;
  26217. /**
  26218. * Returns the current camera absolute rotation
  26219. */
  26220. readonly absoluteRotation: Quaternion;
  26221. /**
  26222. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26223. * @param localAxis Defines the reference axis to provide a relative direction.
  26224. * @param result Defines the vector to store the result in
  26225. */
  26226. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26227. /**
  26228. * Gets a camera constructor for a given camera type
  26229. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26230. * @param name The name of the camera the result will be able to instantiate
  26231. * @param scene The scene the result will construct the camera in
  26232. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26233. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26234. * @returns a factory method to construc the camera
  26235. */
  26236. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26237. /**
  26238. * Compute the world matrix of the camera.
  26239. * @returns the camera world matrix
  26240. */
  26241. computeWorldMatrix(): Matrix;
  26242. /**
  26243. * Parse a JSON and creates the camera from the parsed information
  26244. * @param parsedCamera The JSON to parse
  26245. * @param scene The scene to instantiate the camera in
  26246. * @returns the newly constructed camera
  26247. */
  26248. static Parse(parsedCamera: any, scene: Scene): Camera;
  26249. }
  26250. }
  26251. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26252. import { Nullable } from "babylonjs/types";
  26253. import { Scene } from "babylonjs/scene";
  26254. import { Vector4 } from "babylonjs/Maths/math.vector";
  26255. import { Mesh } from "babylonjs/Meshes/mesh";
  26256. /**
  26257. * Class containing static functions to help procedurally build meshes
  26258. */
  26259. export class DiscBuilder {
  26260. /**
  26261. * Creates a plane polygonal mesh. By default, this is a disc
  26262. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26263. * * 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
  26264. * * 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
  26265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26268. * @param name defines the name of the mesh
  26269. * @param options defines the options used to create the mesh
  26270. * @param scene defines the hosting scene
  26271. * @returns the plane polygonal mesh
  26272. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26273. */
  26274. static CreateDisc(name: string, options: {
  26275. radius?: number;
  26276. tessellation?: number;
  26277. arc?: number;
  26278. updatable?: boolean;
  26279. sideOrientation?: number;
  26280. frontUVs?: Vector4;
  26281. backUVs?: Vector4;
  26282. }, scene?: Nullable<Scene>): Mesh;
  26283. }
  26284. }
  26285. declare module "babylonjs/Materials/fresnelParameters" {
  26286. import { Color3 } from "babylonjs/Maths/math.color";
  26287. /**
  26288. * This represents all the required information to add a fresnel effect on a material:
  26289. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26290. */
  26291. export class FresnelParameters {
  26292. private _isEnabled;
  26293. /**
  26294. * Define if the fresnel effect is enable or not.
  26295. */
  26296. isEnabled: boolean;
  26297. /**
  26298. * Define the color used on edges (grazing angle)
  26299. */
  26300. leftColor: Color3;
  26301. /**
  26302. * Define the color used on center
  26303. */
  26304. rightColor: Color3;
  26305. /**
  26306. * Define bias applied to computed fresnel term
  26307. */
  26308. bias: number;
  26309. /**
  26310. * Defined the power exponent applied to fresnel term
  26311. */
  26312. power: number;
  26313. /**
  26314. * Clones the current fresnel and its valuues
  26315. * @returns a clone fresnel configuration
  26316. */
  26317. clone(): FresnelParameters;
  26318. /**
  26319. * Serializes the current fresnel parameters to a JSON representation.
  26320. * @return the JSON serialization
  26321. */
  26322. serialize(): any;
  26323. /**
  26324. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26325. * @param parsedFresnelParameters Define the JSON representation
  26326. * @returns the parsed parameters
  26327. */
  26328. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26329. }
  26330. }
  26331. declare module "babylonjs/Materials/pushMaterial" {
  26332. import { Nullable } from "babylonjs/types";
  26333. import { Scene } from "babylonjs/scene";
  26334. import { Matrix } from "babylonjs/Maths/math.vector";
  26335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26336. import { Mesh } from "babylonjs/Meshes/mesh";
  26337. import { Material } from "babylonjs/Materials/material";
  26338. import { Effect } from "babylonjs/Materials/effect";
  26339. /**
  26340. * Base class of materials working in push mode in babylon JS
  26341. * @hidden
  26342. */
  26343. export class PushMaterial extends Material {
  26344. protected _activeEffect: Effect;
  26345. protected _normalMatrix: Matrix;
  26346. /**
  26347. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26348. * This means that the material can keep using a previous shader while a new one is being compiled.
  26349. * This is mostly used when shader parallel compilation is supported (true by default)
  26350. */
  26351. allowShaderHotSwapping: boolean;
  26352. constructor(name: string, scene: Scene);
  26353. getEffect(): Effect;
  26354. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26355. /**
  26356. * Binds the given world matrix to the active effect
  26357. *
  26358. * @param world the matrix to bind
  26359. */
  26360. bindOnlyWorldMatrix(world: Matrix): void;
  26361. /**
  26362. * Binds the given normal matrix to the active effect
  26363. *
  26364. * @param normalMatrix the matrix to bind
  26365. */
  26366. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26367. bind(world: Matrix, mesh?: Mesh): void;
  26368. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26369. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26370. }
  26371. }
  26372. declare module "babylonjs/Materials/materialFlags" {
  26373. /**
  26374. * This groups all the flags used to control the materials channel.
  26375. */
  26376. export class MaterialFlags {
  26377. private static _DiffuseTextureEnabled;
  26378. /**
  26379. * Are diffuse textures enabled in the application.
  26380. */
  26381. static DiffuseTextureEnabled: boolean;
  26382. private static _AmbientTextureEnabled;
  26383. /**
  26384. * Are ambient textures enabled in the application.
  26385. */
  26386. static AmbientTextureEnabled: boolean;
  26387. private static _OpacityTextureEnabled;
  26388. /**
  26389. * Are opacity textures enabled in the application.
  26390. */
  26391. static OpacityTextureEnabled: boolean;
  26392. private static _ReflectionTextureEnabled;
  26393. /**
  26394. * Are reflection textures enabled in the application.
  26395. */
  26396. static ReflectionTextureEnabled: boolean;
  26397. private static _EmissiveTextureEnabled;
  26398. /**
  26399. * Are emissive textures enabled in the application.
  26400. */
  26401. static EmissiveTextureEnabled: boolean;
  26402. private static _SpecularTextureEnabled;
  26403. /**
  26404. * Are specular textures enabled in the application.
  26405. */
  26406. static SpecularTextureEnabled: boolean;
  26407. private static _BumpTextureEnabled;
  26408. /**
  26409. * Are bump textures enabled in the application.
  26410. */
  26411. static BumpTextureEnabled: boolean;
  26412. private static _LightmapTextureEnabled;
  26413. /**
  26414. * Are lightmap textures enabled in the application.
  26415. */
  26416. static LightmapTextureEnabled: boolean;
  26417. private static _RefractionTextureEnabled;
  26418. /**
  26419. * Are refraction textures enabled in the application.
  26420. */
  26421. static RefractionTextureEnabled: boolean;
  26422. private static _ColorGradingTextureEnabled;
  26423. /**
  26424. * Are color grading textures enabled in the application.
  26425. */
  26426. static ColorGradingTextureEnabled: boolean;
  26427. private static _FresnelEnabled;
  26428. /**
  26429. * Are fresnels enabled in the application.
  26430. */
  26431. static FresnelEnabled: boolean;
  26432. private static _ClearCoatTextureEnabled;
  26433. /**
  26434. * Are clear coat textures enabled in the application.
  26435. */
  26436. static ClearCoatTextureEnabled: boolean;
  26437. private static _ClearCoatBumpTextureEnabled;
  26438. /**
  26439. * Are clear coat bump textures enabled in the application.
  26440. */
  26441. static ClearCoatBumpTextureEnabled: boolean;
  26442. private static _ClearCoatTintTextureEnabled;
  26443. /**
  26444. * Are clear coat tint textures enabled in the application.
  26445. */
  26446. static ClearCoatTintTextureEnabled: boolean;
  26447. private static _SheenTextureEnabled;
  26448. /**
  26449. * Are sheen textures enabled in the application.
  26450. */
  26451. static SheenTextureEnabled: boolean;
  26452. private static _AnisotropicTextureEnabled;
  26453. /**
  26454. * Are anisotropic textures enabled in the application.
  26455. */
  26456. static AnisotropicTextureEnabled: boolean;
  26457. private static _ThicknessTextureEnabled;
  26458. /**
  26459. * Are thickness textures enabled in the application.
  26460. */
  26461. static ThicknessTextureEnabled: boolean;
  26462. }
  26463. }
  26464. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26465. /** @hidden */
  26466. export var defaultFragmentDeclaration: {
  26467. name: string;
  26468. shader: string;
  26469. };
  26470. }
  26471. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26472. /** @hidden */
  26473. export var defaultUboDeclaration: {
  26474. name: string;
  26475. shader: string;
  26476. };
  26477. }
  26478. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26479. /** @hidden */
  26480. export var lightFragmentDeclaration: {
  26481. name: string;
  26482. shader: string;
  26483. };
  26484. }
  26485. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26486. /** @hidden */
  26487. export var lightUboDeclaration: {
  26488. name: string;
  26489. shader: string;
  26490. };
  26491. }
  26492. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26493. /** @hidden */
  26494. export var lightsFragmentFunctions: {
  26495. name: string;
  26496. shader: string;
  26497. };
  26498. }
  26499. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26500. /** @hidden */
  26501. export var shadowsFragmentFunctions: {
  26502. name: string;
  26503. shader: string;
  26504. };
  26505. }
  26506. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26507. /** @hidden */
  26508. export var fresnelFunction: {
  26509. name: string;
  26510. shader: string;
  26511. };
  26512. }
  26513. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26514. /** @hidden */
  26515. export var reflectionFunction: {
  26516. name: string;
  26517. shader: string;
  26518. };
  26519. }
  26520. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26521. /** @hidden */
  26522. export var bumpFragmentFunctions: {
  26523. name: string;
  26524. shader: string;
  26525. };
  26526. }
  26527. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26528. /** @hidden */
  26529. export var logDepthDeclaration: {
  26530. name: string;
  26531. shader: string;
  26532. };
  26533. }
  26534. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26535. /** @hidden */
  26536. export var bumpFragment: {
  26537. name: string;
  26538. shader: string;
  26539. };
  26540. }
  26541. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26542. /** @hidden */
  26543. export var depthPrePass: {
  26544. name: string;
  26545. shader: string;
  26546. };
  26547. }
  26548. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26549. /** @hidden */
  26550. export var lightFragment: {
  26551. name: string;
  26552. shader: string;
  26553. };
  26554. }
  26555. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26556. /** @hidden */
  26557. export var logDepthFragment: {
  26558. name: string;
  26559. shader: string;
  26560. };
  26561. }
  26562. declare module "babylonjs/Shaders/default.fragment" {
  26563. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26567. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26568. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26569. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26570. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26571. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26572. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26573. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26574. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26575. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26576. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26577. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26578. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26579. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26580. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26581. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26582. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26583. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26584. /** @hidden */
  26585. export var defaultPixelShader: {
  26586. name: string;
  26587. shader: string;
  26588. };
  26589. }
  26590. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26591. /** @hidden */
  26592. export var defaultVertexDeclaration: {
  26593. name: string;
  26594. shader: string;
  26595. };
  26596. }
  26597. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26598. /** @hidden */
  26599. export var bumpVertexDeclaration: {
  26600. name: string;
  26601. shader: string;
  26602. };
  26603. }
  26604. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26605. /** @hidden */
  26606. export var bumpVertex: {
  26607. name: string;
  26608. shader: string;
  26609. };
  26610. }
  26611. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26612. /** @hidden */
  26613. export var fogVertex: {
  26614. name: string;
  26615. shader: string;
  26616. };
  26617. }
  26618. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26619. /** @hidden */
  26620. export var shadowsVertex: {
  26621. name: string;
  26622. shader: string;
  26623. };
  26624. }
  26625. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26626. /** @hidden */
  26627. export var pointCloudVertex: {
  26628. name: string;
  26629. shader: string;
  26630. };
  26631. }
  26632. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26633. /** @hidden */
  26634. export var logDepthVertex: {
  26635. name: string;
  26636. shader: string;
  26637. };
  26638. }
  26639. declare module "babylonjs/Shaders/default.vertex" {
  26640. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26643. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26645. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26646. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26647. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26648. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26649. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26650. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26652. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26653. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26654. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26655. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26656. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26657. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26658. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26659. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26660. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26661. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26662. /** @hidden */
  26663. export var defaultVertexShader: {
  26664. name: string;
  26665. shader: string;
  26666. };
  26667. }
  26668. declare module "babylonjs/Materials/standardMaterial" {
  26669. import { SmartArray } from "babylonjs/Misc/smartArray";
  26670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26671. import { Nullable } from "babylonjs/types";
  26672. import { Scene } from "babylonjs/scene";
  26673. import { Matrix } from "babylonjs/Maths/math.vector";
  26674. import { Color3 } from "babylonjs/Maths/math.color";
  26675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26677. import { Mesh } from "babylonjs/Meshes/mesh";
  26678. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26679. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26680. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26681. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26682. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26685. import "babylonjs/Shaders/default.fragment";
  26686. import "babylonjs/Shaders/default.vertex";
  26687. /** @hidden */
  26688. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26689. MAINUV1: boolean;
  26690. MAINUV2: boolean;
  26691. DIFFUSE: boolean;
  26692. DIFFUSEDIRECTUV: number;
  26693. AMBIENT: boolean;
  26694. AMBIENTDIRECTUV: number;
  26695. OPACITY: boolean;
  26696. OPACITYDIRECTUV: number;
  26697. OPACITYRGB: boolean;
  26698. REFLECTION: boolean;
  26699. EMISSIVE: boolean;
  26700. EMISSIVEDIRECTUV: number;
  26701. SPECULAR: boolean;
  26702. SPECULARDIRECTUV: number;
  26703. BUMP: boolean;
  26704. BUMPDIRECTUV: number;
  26705. PARALLAX: boolean;
  26706. PARALLAXOCCLUSION: boolean;
  26707. SPECULAROVERALPHA: boolean;
  26708. CLIPPLANE: boolean;
  26709. CLIPPLANE2: boolean;
  26710. CLIPPLANE3: boolean;
  26711. CLIPPLANE4: boolean;
  26712. ALPHATEST: boolean;
  26713. DEPTHPREPASS: boolean;
  26714. ALPHAFROMDIFFUSE: boolean;
  26715. POINTSIZE: boolean;
  26716. FOG: boolean;
  26717. SPECULARTERM: boolean;
  26718. DIFFUSEFRESNEL: boolean;
  26719. OPACITYFRESNEL: boolean;
  26720. REFLECTIONFRESNEL: boolean;
  26721. REFRACTIONFRESNEL: boolean;
  26722. EMISSIVEFRESNEL: boolean;
  26723. FRESNEL: boolean;
  26724. NORMAL: boolean;
  26725. UV1: boolean;
  26726. UV2: boolean;
  26727. VERTEXCOLOR: boolean;
  26728. VERTEXALPHA: boolean;
  26729. NUM_BONE_INFLUENCERS: number;
  26730. BonesPerMesh: number;
  26731. BONETEXTURE: boolean;
  26732. INSTANCES: boolean;
  26733. GLOSSINESS: boolean;
  26734. ROUGHNESS: boolean;
  26735. EMISSIVEASILLUMINATION: boolean;
  26736. LINKEMISSIVEWITHDIFFUSE: boolean;
  26737. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26738. LIGHTMAP: boolean;
  26739. LIGHTMAPDIRECTUV: number;
  26740. OBJECTSPACE_NORMALMAP: boolean;
  26741. USELIGHTMAPASSHADOWMAP: boolean;
  26742. REFLECTIONMAP_3D: boolean;
  26743. REFLECTIONMAP_SPHERICAL: boolean;
  26744. REFLECTIONMAP_PLANAR: boolean;
  26745. REFLECTIONMAP_CUBIC: boolean;
  26746. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26747. REFLECTIONMAP_PROJECTION: boolean;
  26748. REFLECTIONMAP_SKYBOX: boolean;
  26749. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26750. REFLECTIONMAP_EXPLICIT: boolean;
  26751. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26752. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26753. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26754. INVERTCUBICMAP: boolean;
  26755. LOGARITHMICDEPTH: boolean;
  26756. REFRACTION: boolean;
  26757. REFRACTIONMAP_3D: boolean;
  26758. REFLECTIONOVERALPHA: boolean;
  26759. TWOSIDEDLIGHTING: boolean;
  26760. SHADOWFLOAT: boolean;
  26761. MORPHTARGETS: boolean;
  26762. MORPHTARGETS_NORMAL: boolean;
  26763. MORPHTARGETS_TANGENT: boolean;
  26764. MORPHTARGETS_UV: boolean;
  26765. NUM_MORPH_INFLUENCERS: number;
  26766. NONUNIFORMSCALING: boolean;
  26767. PREMULTIPLYALPHA: boolean;
  26768. IMAGEPROCESSING: boolean;
  26769. VIGNETTE: boolean;
  26770. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26771. VIGNETTEBLENDMODEOPAQUE: boolean;
  26772. TONEMAPPING: boolean;
  26773. TONEMAPPING_ACES: boolean;
  26774. CONTRAST: boolean;
  26775. COLORCURVES: boolean;
  26776. COLORGRADING: boolean;
  26777. COLORGRADING3D: boolean;
  26778. SAMPLER3DGREENDEPTH: boolean;
  26779. SAMPLER3DBGRMAP: boolean;
  26780. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26781. MULTIVIEW: boolean;
  26782. /**
  26783. * If the reflection texture on this material is in linear color space
  26784. * @hidden
  26785. */
  26786. IS_REFLECTION_LINEAR: boolean;
  26787. /**
  26788. * If the refraction texture on this material is in linear color space
  26789. * @hidden
  26790. */
  26791. IS_REFRACTION_LINEAR: boolean;
  26792. EXPOSURE: boolean;
  26793. constructor();
  26794. setReflectionMode(modeToEnable: string): void;
  26795. }
  26796. /**
  26797. * This is the default material used in Babylon. It is the best trade off between quality
  26798. * and performances.
  26799. * @see http://doc.babylonjs.com/babylon101/materials
  26800. */
  26801. export class StandardMaterial extends PushMaterial {
  26802. private _diffuseTexture;
  26803. /**
  26804. * The basic texture of the material as viewed under a light.
  26805. */
  26806. diffuseTexture: Nullable<BaseTexture>;
  26807. private _ambientTexture;
  26808. /**
  26809. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26810. */
  26811. ambientTexture: Nullable<BaseTexture>;
  26812. private _opacityTexture;
  26813. /**
  26814. * Define the transparency of the material from a texture.
  26815. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26816. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26817. */
  26818. opacityTexture: Nullable<BaseTexture>;
  26819. private _reflectionTexture;
  26820. /**
  26821. * Define the texture used to display the reflection.
  26822. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26823. */
  26824. reflectionTexture: Nullable<BaseTexture>;
  26825. private _emissiveTexture;
  26826. /**
  26827. * Define texture of the material as if self lit.
  26828. * This will be mixed in the final result even in the absence of light.
  26829. */
  26830. emissiveTexture: Nullable<BaseTexture>;
  26831. private _specularTexture;
  26832. /**
  26833. * Define how the color and intensity of the highlight given by the light in the material.
  26834. */
  26835. specularTexture: Nullable<BaseTexture>;
  26836. private _bumpTexture;
  26837. /**
  26838. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26839. * 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.
  26840. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26841. */
  26842. bumpTexture: Nullable<BaseTexture>;
  26843. private _lightmapTexture;
  26844. /**
  26845. * Complex lighting can be computationally expensive to compute at runtime.
  26846. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26847. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26848. */
  26849. lightmapTexture: Nullable<BaseTexture>;
  26850. private _refractionTexture;
  26851. /**
  26852. * Define the texture used to display the refraction.
  26853. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26854. */
  26855. refractionTexture: Nullable<BaseTexture>;
  26856. /**
  26857. * The color of the material lit by the environmental background lighting.
  26858. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26859. */
  26860. ambientColor: Color3;
  26861. /**
  26862. * The basic color of the material as viewed under a light.
  26863. */
  26864. diffuseColor: Color3;
  26865. /**
  26866. * Define how the color and intensity of the highlight given by the light in the material.
  26867. */
  26868. specularColor: Color3;
  26869. /**
  26870. * Define the color of the material as if self lit.
  26871. * This will be mixed in the final result even in the absence of light.
  26872. */
  26873. emissiveColor: Color3;
  26874. /**
  26875. * Defines how sharp are the highlights in the material.
  26876. * The bigger the value the sharper giving a more glossy feeling to the result.
  26877. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26878. */
  26879. specularPower: number;
  26880. private _useAlphaFromDiffuseTexture;
  26881. /**
  26882. * Does the transparency come from the diffuse texture alpha channel.
  26883. */
  26884. useAlphaFromDiffuseTexture: boolean;
  26885. private _useEmissiveAsIllumination;
  26886. /**
  26887. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26888. */
  26889. useEmissiveAsIllumination: boolean;
  26890. private _linkEmissiveWithDiffuse;
  26891. /**
  26892. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26893. * the emissive level when the final color is close to one.
  26894. */
  26895. linkEmissiveWithDiffuse: boolean;
  26896. private _useSpecularOverAlpha;
  26897. /**
  26898. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26899. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26900. */
  26901. useSpecularOverAlpha: boolean;
  26902. private _useReflectionOverAlpha;
  26903. /**
  26904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26906. */
  26907. useReflectionOverAlpha: boolean;
  26908. private _disableLighting;
  26909. /**
  26910. * Does lights from the scene impacts this material.
  26911. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26912. */
  26913. disableLighting: boolean;
  26914. private _useObjectSpaceNormalMap;
  26915. /**
  26916. * Allows using an object space normal map (instead of tangent space).
  26917. */
  26918. useObjectSpaceNormalMap: boolean;
  26919. private _useParallax;
  26920. /**
  26921. * Is parallax enabled or not.
  26922. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26923. */
  26924. useParallax: boolean;
  26925. private _useParallaxOcclusion;
  26926. /**
  26927. * Is parallax occlusion enabled or not.
  26928. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26929. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26930. */
  26931. useParallaxOcclusion: boolean;
  26932. /**
  26933. * 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.
  26934. */
  26935. parallaxScaleBias: number;
  26936. private _roughness;
  26937. /**
  26938. * Helps to define how blurry the reflections should appears in the material.
  26939. */
  26940. roughness: number;
  26941. /**
  26942. * In case of refraction, define the value of the index of refraction.
  26943. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26944. */
  26945. indexOfRefraction: number;
  26946. /**
  26947. * Invert the refraction texture alongside the y axis.
  26948. * It can be useful with procedural textures or probe for instance.
  26949. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26950. */
  26951. invertRefractionY: boolean;
  26952. /**
  26953. * Defines the alpha limits in alpha test mode.
  26954. */
  26955. alphaCutOff: number;
  26956. private _useLightmapAsShadowmap;
  26957. /**
  26958. * In case of light mapping, define whether the map contains light or shadow informations.
  26959. */
  26960. useLightmapAsShadowmap: boolean;
  26961. private _diffuseFresnelParameters;
  26962. /**
  26963. * Define the diffuse fresnel parameters of the material.
  26964. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26965. */
  26966. diffuseFresnelParameters: FresnelParameters;
  26967. private _opacityFresnelParameters;
  26968. /**
  26969. * Define the opacity fresnel parameters of the material.
  26970. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26971. */
  26972. opacityFresnelParameters: FresnelParameters;
  26973. private _reflectionFresnelParameters;
  26974. /**
  26975. * Define the reflection fresnel parameters of the material.
  26976. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26977. */
  26978. reflectionFresnelParameters: FresnelParameters;
  26979. private _refractionFresnelParameters;
  26980. /**
  26981. * Define the refraction fresnel parameters of the material.
  26982. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26983. */
  26984. refractionFresnelParameters: FresnelParameters;
  26985. private _emissiveFresnelParameters;
  26986. /**
  26987. * Define the emissive fresnel parameters of the material.
  26988. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26989. */
  26990. emissiveFresnelParameters: FresnelParameters;
  26991. private _useReflectionFresnelFromSpecular;
  26992. /**
  26993. * If true automatically deducts the fresnels values from the material specularity.
  26994. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26995. */
  26996. useReflectionFresnelFromSpecular: boolean;
  26997. private _useGlossinessFromSpecularMapAlpha;
  26998. /**
  26999. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27000. */
  27001. useGlossinessFromSpecularMapAlpha: boolean;
  27002. private _maxSimultaneousLights;
  27003. /**
  27004. * Defines the maximum number of lights that can be used in the material
  27005. */
  27006. maxSimultaneousLights: number;
  27007. private _invertNormalMapX;
  27008. /**
  27009. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27010. */
  27011. invertNormalMapX: boolean;
  27012. private _invertNormalMapY;
  27013. /**
  27014. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27015. */
  27016. invertNormalMapY: boolean;
  27017. private _twoSidedLighting;
  27018. /**
  27019. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27020. */
  27021. twoSidedLighting: boolean;
  27022. /**
  27023. * Default configuration related to image processing available in the standard Material.
  27024. */
  27025. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27026. /**
  27027. * Gets the image processing configuration used either in this material.
  27028. */
  27029. /**
  27030. * Sets the Default image processing configuration used either in the this material.
  27031. *
  27032. * If sets to null, the scene one is in use.
  27033. */
  27034. imageProcessingConfiguration: ImageProcessingConfiguration;
  27035. /**
  27036. * Keep track of the image processing observer to allow dispose and replace.
  27037. */
  27038. private _imageProcessingObserver;
  27039. /**
  27040. * Attaches a new image processing configuration to the Standard Material.
  27041. * @param configuration
  27042. */
  27043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27044. /**
  27045. * Gets wether the color curves effect is enabled.
  27046. */
  27047. /**
  27048. * Sets wether the color curves effect is enabled.
  27049. */
  27050. cameraColorCurvesEnabled: boolean;
  27051. /**
  27052. * Gets wether the color grading effect is enabled.
  27053. */
  27054. /**
  27055. * Gets wether the color grading effect is enabled.
  27056. */
  27057. cameraColorGradingEnabled: boolean;
  27058. /**
  27059. * Gets wether tonemapping is enabled or not.
  27060. */
  27061. /**
  27062. * Sets wether tonemapping is enabled or not
  27063. */
  27064. cameraToneMappingEnabled: boolean;
  27065. /**
  27066. * The camera exposure used on this material.
  27067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27068. * This corresponds to a photographic exposure.
  27069. */
  27070. /**
  27071. * The camera exposure used on this material.
  27072. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27073. * This corresponds to a photographic exposure.
  27074. */
  27075. cameraExposure: number;
  27076. /**
  27077. * Gets The camera contrast used on this material.
  27078. */
  27079. /**
  27080. * Sets The camera contrast used on this material.
  27081. */
  27082. cameraContrast: number;
  27083. /**
  27084. * Gets the Color Grading 2D Lookup Texture.
  27085. */
  27086. /**
  27087. * Sets the Color Grading 2D Lookup Texture.
  27088. */
  27089. cameraColorGradingTexture: Nullable<BaseTexture>;
  27090. /**
  27091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27093. * 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;
  27094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27095. */
  27096. /**
  27097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27099. * 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;
  27100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27101. */
  27102. cameraColorCurves: Nullable<ColorCurves>;
  27103. /**
  27104. * Custom callback helping to override the default shader used in the material.
  27105. */
  27106. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27107. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27108. protected _worldViewProjectionMatrix: Matrix;
  27109. protected _globalAmbientColor: Color3;
  27110. protected _useLogarithmicDepth: boolean;
  27111. protected _rebuildInParallel: boolean;
  27112. /**
  27113. * Instantiates a new standard material.
  27114. * This is the default material used in Babylon. It is the best trade off between quality
  27115. * and performances.
  27116. * @see http://doc.babylonjs.com/babylon101/materials
  27117. * @param name Define the name of the material in the scene
  27118. * @param scene Define the scene the material belong to
  27119. */
  27120. constructor(name: string, scene: Scene);
  27121. /**
  27122. * Gets a boolean indicating that current material needs to register RTT
  27123. */
  27124. readonly hasRenderTargetTextures: boolean;
  27125. /**
  27126. * Gets the current class name of the material e.g. "StandardMaterial"
  27127. * Mainly use in serialization.
  27128. * @returns the class name
  27129. */
  27130. getClassName(): string;
  27131. /**
  27132. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27133. * You can try switching to logarithmic depth.
  27134. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27135. */
  27136. useLogarithmicDepth: boolean;
  27137. /**
  27138. * Specifies if the material will require alpha blending
  27139. * @returns a boolean specifying if alpha blending is needed
  27140. */
  27141. needAlphaBlending(): boolean;
  27142. /**
  27143. * Specifies if this material should be rendered in alpha test mode
  27144. * @returns a boolean specifying if an alpha test is needed.
  27145. */
  27146. needAlphaTesting(): boolean;
  27147. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27148. /**
  27149. * Get the texture used for alpha test purpose.
  27150. * @returns the diffuse texture in case of the standard material.
  27151. */
  27152. getAlphaTestTexture(): Nullable<BaseTexture>;
  27153. /**
  27154. * Get if the submesh is ready to be used and all its information available.
  27155. * Child classes can use it to update shaders
  27156. * @param mesh defines the mesh to check
  27157. * @param subMesh defines which submesh to check
  27158. * @param useInstances specifies that instances should be used
  27159. * @returns a boolean indicating that the submesh is ready or not
  27160. */
  27161. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27162. /**
  27163. * Builds the material UBO layouts.
  27164. * Used internally during the effect preparation.
  27165. */
  27166. buildUniformLayout(): void;
  27167. /**
  27168. * Unbinds the material from the mesh
  27169. */
  27170. unbind(): void;
  27171. /**
  27172. * Binds the submesh to this material by preparing the effect and shader to draw
  27173. * @param world defines the world transformation matrix
  27174. * @param mesh defines the mesh containing the submesh
  27175. * @param subMesh defines the submesh to bind the material to
  27176. */
  27177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27178. /**
  27179. * Get the list of animatables in the material.
  27180. * @returns the list of animatables object used in the material
  27181. */
  27182. getAnimatables(): IAnimatable[];
  27183. /**
  27184. * Gets the active textures from the material
  27185. * @returns an array of textures
  27186. */
  27187. getActiveTextures(): BaseTexture[];
  27188. /**
  27189. * Specifies if the material uses a texture
  27190. * @param texture defines the texture to check against the material
  27191. * @returns a boolean specifying if the material uses the texture
  27192. */
  27193. hasTexture(texture: BaseTexture): boolean;
  27194. /**
  27195. * Disposes the material
  27196. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27197. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27198. */
  27199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27200. /**
  27201. * Makes a duplicate of the material, and gives it a new name
  27202. * @param name defines the new name for the duplicated material
  27203. * @returns the cloned material
  27204. */
  27205. clone(name: string): StandardMaterial;
  27206. /**
  27207. * Serializes this material in a JSON representation
  27208. * @returns the serialized material object
  27209. */
  27210. serialize(): any;
  27211. /**
  27212. * Creates a standard material from parsed material data
  27213. * @param source defines the JSON representation of the material
  27214. * @param scene defines the hosting scene
  27215. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27216. * @returns a new standard material
  27217. */
  27218. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27219. /**
  27220. * Are diffuse textures enabled in the application.
  27221. */
  27222. static DiffuseTextureEnabled: boolean;
  27223. /**
  27224. * Are ambient textures enabled in the application.
  27225. */
  27226. static AmbientTextureEnabled: boolean;
  27227. /**
  27228. * Are opacity textures enabled in the application.
  27229. */
  27230. static OpacityTextureEnabled: boolean;
  27231. /**
  27232. * Are reflection textures enabled in the application.
  27233. */
  27234. static ReflectionTextureEnabled: boolean;
  27235. /**
  27236. * Are emissive textures enabled in the application.
  27237. */
  27238. static EmissiveTextureEnabled: boolean;
  27239. /**
  27240. * Are specular textures enabled in the application.
  27241. */
  27242. static SpecularTextureEnabled: boolean;
  27243. /**
  27244. * Are bump textures enabled in the application.
  27245. */
  27246. static BumpTextureEnabled: boolean;
  27247. /**
  27248. * Are lightmap textures enabled in the application.
  27249. */
  27250. static LightmapTextureEnabled: boolean;
  27251. /**
  27252. * Are refraction textures enabled in the application.
  27253. */
  27254. static RefractionTextureEnabled: boolean;
  27255. /**
  27256. * Are color grading textures enabled in the application.
  27257. */
  27258. static ColorGradingTextureEnabled: boolean;
  27259. /**
  27260. * Are fresnels enabled in the application.
  27261. */
  27262. static FresnelEnabled: boolean;
  27263. }
  27264. }
  27265. declare module "babylonjs/Particles/solidParticleSystem" {
  27266. import { Nullable } from "babylonjs/types";
  27267. import { Vector3 } from "babylonjs/Maths/math.vector";
  27268. import { Mesh } from "babylonjs/Meshes/mesh";
  27269. import { Scene, IDisposable } from "babylonjs/scene";
  27270. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27271. import { Material } from "babylonjs/Materials/material";
  27272. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27273. /**
  27274. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27275. *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.
  27276. * The SPS is also a particle system. It provides some methods to manage the particles.
  27277. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27278. *
  27279. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27280. */
  27281. export class SolidParticleSystem implements IDisposable {
  27282. /**
  27283. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27284. * Example : var p = SPS.particles[i];
  27285. */
  27286. particles: SolidParticle[];
  27287. /**
  27288. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27289. */
  27290. nbParticles: number;
  27291. /**
  27292. * If the particles must ever face the camera (default false). Useful for planar particles.
  27293. */
  27294. billboard: boolean;
  27295. /**
  27296. * Recompute normals when adding a shape
  27297. */
  27298. recomputeNormals: boolean;
  27299. /**
  27300. * This a counter ofr your own usage. It's not set by any SPS functions.
  27301. */
  27302. counter: number;
  27303. /**
  27304. * The SPS name. This name is also given to the underlying mesh.
  27305. */
  27306. name: string;
  27307. /**
  27308. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27309. */
  27310. mesh: Mesh;
  27311. /**
  27312. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27314. */
  27315. vars: any;
  27316. /**
  27317. * This array is populated when the SPS is set as 'pickable'.
  27318. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27319. * Each element of this array is an object `{idx: int, faceId: int}`.
  27320. * `idx` is the picked particle index in the `SPS.particles` array
  27321. * `faceId` is the picked face index counted within this particle.
  27322. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27323. */
  27324. pickedParticles: {
  27325. idx: number;
  27326. faceId: number;
  27327. }[];
  27328. /**
  27329. * This array is populated when `enableDepthSort` is set to true.
  27330. * Each element of this array is an instance of the class DepthSortedParticle.
  27331. */
  27332. depthSortedParticles: DepthSortedParticle[];
  27333. /**
  27334. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27335. * @hidden
  27336. */
  27337. _bSphereOnly: boolean;
  27338. /**
  27339. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27340. * @hidden
  27341. */
  27342. _bSphereRadiusFactor: number;
  27343. private _scene;
  27344. private _positions;
  27345. private _indices;
  27346. private _normals;
  27347. private _colors;
  27348. private _uvs;
  27349. private _indices32;
  27350. private _positions32;
  27351. private _normals32;
  27352. private _fixedNormal32;
  27353. private _colors32;
  27354. private _uvs32;
  27355. private _index;
  27356. private _updatable;
  27357. private _pickable;
  27358. private _isVisibilityBoxLocked;
  27359. private _alwaysVisible;
  27360. private _depthSort;
  27361. private _expandable;
  27362. private _shapeCounter;
  27363. private _copy;
  27364. private _color;
  27365. private _computeParticleColor;
  27366. private _computeParticleTexture;
  27367. private _computeParticleRotation;
  27368. private _computeParticleVertex;
  27369. private _computeBoundingBox;
  27370. private _depthSortParticles;
  27371. private _camera;
  27372. private _mustUnrotateFixedNormals;
  27373. private _particlesIntersect;
  27374. private _needs32Bits;
  27375. private _isNotBuilt;
  27376. private _lastParticleId;
  27377. private _idxOfId;
  27378. private _multimaterialEnabled;
  27379. private _useModelMaterial;
  27380. private _indicesByMaterial;
  27381. private _materialIndexes;
  27382. private _depthSortFunction;
  27383. private _materialSortFunction;
  27384. private _materials;
  27385. private _multimaterial;
  27386. private _materialIndexesById;
  27387. private _defaultMaterial;
  27388. private _autoUpdateSubMeshes;
  27389. /**
  27390. * Creates a SPS (Solid Particle System) object.
  27391. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27392. * @param scene (Scene) is the scene in which the SPS is added.
  27393. * @param options defines the options of the sps e.g.
  27394. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27395. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27396. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27397. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27398. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27399. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27400. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27401. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27402. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27403. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27404. */
  27405. constructor(name: string, scene: Scene, options?: {
  27406. updatable?: boolean;
  27407. isPickable?: boolean;
  27408. enableDepthSort?: boolean;
  27409. particleIntersection?: boolean;
  27410. boundingSphereOnly?: boolean;
  27411. bSphereRadiusFactor?: number;
  27412. expandable?: boolean;
  27413. useModelMaterial?: boolean;
  27414. enableMultiMaterial?: boolean;
  27415. });
  27416. /**
  27417. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27418. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27419. * @returns the created mesh
  27420. */
  27421. buildMesh(): Mesh;
  27422. /**
  27423. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27424. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27425. * Thus the particles generated from `digest()` have their property `position` set yet.
  27426. * @param mesh ( Mesh ) is the mesh to be digested
  27427. * @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
  27428. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27429. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27430. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27431. * @returns the current SPS
  27432. */
  27433. digest(mesh: Mesh, options?: {
  27434. facetNb?: number;
  27435. number?: number;
  27436. delta?: number;
  27437. storage?: [];
  27438. }): SolidParticleSystem;
  27439. /**
  27440. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27441. * @hidden
  27442. */
  27443. private _unrotateFixedNormals;
  27444. /**
  27445. * Resets the temporary working copy particle
  27446. * @hidden
  27447. */
  27448. private _resetCopy;
  27449. /**
  27450. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27451. * @param p the current index in the positions array to be updated
  27452. * @param ind the current index in the indices array
  27453. * @param shape a Vector3 array, the shape geometry
  27454. * @param positions the positions array to be updated
  27455. * @param meshInd the shape indices array
  27456. * @param indices the indices array to be updated
  27457. * @param meshUV the shape uv array
  27458. * @param uvs the uv array to be updated
  27459. * @param meshCol the shape color array
  27460. * @param colors the color array to be updated
  27461. * @param meshNor the shape normals array
  27462. * @param normals the normals array to be updated
  27463. * @param idx the particle index
  27464. * @param idxInShape the particle index in its shape
  27465. * @param options the addShape() method passed options
  27466. * @model the particle model
  27467. * @hidden
  27468. */
  27469. private _meshBuilder;
  27470. /**
  27471. * Returns a shape Vector3 array from positions float array
  27472. * @param positions float array
  27473. * @returns a vector3 array
  27474. * @hidden
  27475. */
  27476. private _posToShape;
  27477. /**
  27478. * Returns a shapeUV array from a float uvs (array deep copy)
  27479. * @param uvs as a float array
  27480. * @returns a shapeUV array
  27481. * @hidden
  27482. */
  27483. private _uvsToShapeUV;
  27484. /**
  27485. * Adds a new particle object in the particles array
  27486. * @param idx particle index in particles array
  27487. * @param id particle id
  27488. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27489. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27490. * @param model particle ModelShape object
  27491. * @param shapeId model shape identifier
  27492. * @param idxInShape index of the particle in the current model
  27493. * @param bInfo model bounding info object
  27494. * @param storage target storage array, if any
  27495. * @hidden
  27496. */
  27497. private _addParticle;
  27498. /**
  27499. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27500. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27501. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27502. * @param nb (positive integer) the number of particles to be created from this model
  27503. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27504. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27505. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27506. * @returns the number of shapes in the system
  27507. */
  27508. addShape(mesh: Mesh, nb: number, options?: {
  27509. positionFunction?: any;
  27510. vertexFunction?: any;
  27511. storage?: [];
  27512. }): number;
  27513. /**
  27514. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27515. * @hidden
  27516. */
  27517. private _rebuildParticle;
  27518. /**
  27519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27520. * @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.
  27521. * @returns the SPS.
  27522. */
  27523. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27524. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27525. * Returns an array with the removed particles.
  27526. * 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.
  27527. * The SPS can't be empty so at least one particle needs to remain in place.
  27528. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27529. * @param start index of the first particle to remove
  27530. * @param end index of the last particle to remove (included)
  27531. * @returns an array populated with the removed particles
  27532. */
  27533. removeParticles(start: number, end: number): SolidParticle[];
  27534. /**
  27535. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27536. * @param solidParticleArray an array populated with Solid Particles objects
  27537. * @returns the SPS
  27538. */
  27539. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27540. /**
  27541. * Creates a new particle and modifies the SPS mesh geometry :
  27542. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27543. * - calls _addParticle() to populate the particle array
  27544. * factorized code from addShape() and insertParticlesFromArray()
  27545. * @param idx particle index in the particles array
  27546. * @param i particle index in its shape
  27547. * @param modelShape particle ModelShape object
  27548. * @param shape shape vertex array
  27549. * @param meshInd shape indices array
  27550. * @param meshUV shape uv array
  27551. * @param meshCol shape color array
  27552. * @param meshNor shape normals array
  27553. * @param bbInfo shape bounding info
  27554. * @param storage target particle storage
  27555. * @options addShape() passed options
  27556. * @hidden
  27557. */
  27558. private _insertNewParticle;
  27559. /**
  27560. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27561. * This method calls `updateParticle()` for each particle of the SPS.
  27562. * For an animated SPS, it is usually called within the render loop.
  27563. * 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.
  27564. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27565. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27566. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27567. * @returns the SPS.
  27568. */
  27569. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27570. /**
  27571. * Disposes the SPS.
  27572. */
  27573. dispose(): void;
  27574. /**
  27575. * Returns a SolidParticle object from its identifier : particle.id
  27576. * @param id (integer) the particle Id
  27577. * @returns the searched particle or null if not found in the SPS.
  27578. */
  27579. getParticleById(id: number): Nullable<SolidParticle>;
  27580. /**
  27581. * Returns a new array populated with the particles having the passed shapeId.
  27582. * @param shapeId (integer) the shape identifier
  27583. * @returns a new solid particle array
  27584. */
  27585. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27586. /**
  27587. * Populates the passed array "ref" with the particles having the passed shapeId.
  27588. * @param shapeId the shape identifier
  27589. * @returns the SPS
  27590. * @param ref
  27591. */
  27592. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27593. /**
  27594. * Computes the required SubMeshes according the materials assigned to the particles.
  27595. * @returns the solid particle system.
  27596. * Does nothing if called before the SPS mesh is built.
  27597. */
  27598. computeSubMeshes(): SolidParticleSystem;
  27599. /**
  27600. * Sorts the solid particles by material when MultiMaterial is enabled.
  27601. * Updates the indices32 array.
  27602. * Updates the indicesByMaterial array.
  27603. * Updates the mesh indices array.
  27604. * @returns the SPS
  27605. * @hidden
  27606. */
  27607. private _sortParticlesByMaterial;
  27608. /**
  27609. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27610. * @hidden
  27611. */
  27612. private _setMaterialIndexesById;
  27613. /**
  27614. * Returns an array with unique values of Materials from the passed array
  27615. * @param array the material array to be checked and filtered
  27616. * @hidden
  27617. */
  27618. private _filterUniqueMaterialId;
  27619. /**
  27620. * Sets a new Standard Material as _defaultMaterial if not already set.
  27621. * @hidden
  27622. */
  27623. private _setDefaultMaterial;
  27624. /**
  27625. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27626. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27627. * @returns the SPS.
  27628. */
  27629. refreshVisibleSize(): SolidParticleSystem;
  27630. /**
  27631. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27632. * @param size the size (float) of the visibility box
  27633. * note : this doesn't lock the SPS mesh bounding box.
  27634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27635. */
  27636. setVisibilityBox(size: number): void;
  27637. /**
  27638. * Gets whether the SPS as always visible or not
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. /**
  27642. * Sets the SPS as always visible or not
  27643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27644. */
  27645. isAlwaysVisible: boolean;
  27646. /**
  27647. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27649. */
  27650. /**
  27651. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27652. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27653. */
  27654. isVisibilityBoxLocked: boolean;
  27655. /**
  27656. * Tells to `setParticles()` to compute the particle rotations or not.
  27657. * Default value : true. The SPS is faster when it's set to false.
  27658. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27659. */
  27660. /**
  27661. * Gets if `setParticles()` computes the particle rotations or not.
  27662. * Default value : true. The SPS is faster when it's set to false.
  27663. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27664. */
  27665. computeParticleRotation: boolean;
  27666. /**
  27667. * Tells to `setParticles()` to compute the particle colors or not.
  27668. * Default value : true. The SPS is faster when it's set to false.
  27669. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27670. */
  27671. /**
  27672. * Gets if `setParticles()` computes the particle colors or not.
  27673. * Default value : true. The SPS is faster when it's set to false.
  27674. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27675. */
  27676. computeParticleColor: boolean;
  27677. /**
  27678. * Gets if `setParticles()` computes the particle textures or not.
  27679. * Default value : true. The SPS is faster when it's set to false.
  27680. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27681. */
  27682. computeParticleTexture: boolean;
  27683. /**
  27684. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27685. * Default value : false. The SPS is faster when it's set to false.
  27686. * Note : the particle custom vertex positions aren't stored values.
  27687. */
  27688. /**
  27689. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27690. * Default value : false. The SPS is faster when it's set to false.
  27691. * Note : the particle custom vertex positions aren't stored values.
  27692. */
  27693. computeParticleVertex: boolean;
  27694. /**
  27695. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27696. */
  27697. /**
  27698. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27699. */
  27700. computeBoundingBox: boolean;
  27701. /**
  27702. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27703. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27704. * Default : `true`
  27705. */
  27706. /**
  27707. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27708. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27709. * Default : `true`
  27710. */
  27711. depthSortParticles: boolean;
  27712. /**
  27713. * Gets if the SPS is created as expandable at construction time.
  27714. * Default : `false`
  27715. */
  27716. readonly expandable: boolean;
  27717. /**
  27718. * Gets if the SPS supports the Multi Materials
  27719. */
  27720. readonly multimaterialEnabled: boolean;
  27721. /**
  27722. * Gets if the SPS uses the model materials for its own multimaterial.
  27723. */
  27724. readonly useModelMaterial: boolean;
  27725. /**
  27726. * The SPS used material array.
  27727. */
  27728. readonly materials: Material[];
  27729. /**
  27730. * Sets the SPS MultiMaterial from the passed materials.
  27731. * Note : the passed array is internally copied and not used then by reference.
  27732. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27733. */
  27734. setMultiMaterial(materials: Material[]): void;
  27735. /**
  27736. * The SPS computed multimaterial object
  27737. */
  27738. multimaterial: MultiMaterial;
  27739. /**
  27740. * If the subMeshes must be updated on the next call to setParticles()
  27741. */
  27742. autoUpdateSubMeshes: boolean;
  27743. /**
  27744. * This function does nothing. It may be overwritten to set all the particle first values.
  27745. * The SPS doesn't call this function, you may have to call it by your own.
  27746. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27747. */
  27748. initParticles(): void;
  27749. /**
  27750. * This function does nothing. It may be overwritten to recycle a particle.
  27751. * The SPS doesn't call this function, you may have to call it by your own.
  27752. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27753. * @param particle The particle to recycle
  27754. * @returns the recycled particle
  27755. */
  27756. recycleParticle(particle: SolidParticle): SolidParticle;
  27757. /**
  27758. * Updates a particle : this function should be overwritten by the user.
  27759. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27761. * @example : just set a particle position or velocity and recycle conditions
  27762. * @param particle The particle to update
  27763. * @returns the updated particle
  27764. */
  27765. updateParticle(particle: SolidParticle): SolidParticle;
  27766. /**
  27767. * Updates a vertex of a particle : it can be overwritten by the user.
  27768. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27769. * @param particle the current particle
  27770. * @param vertex the current index of the current particle
  27771. * @param pt the index of the current vertex in the particle shape
  27772. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27773. * @example : just set a vertex particle position
  27774. * @returns the updated vertex
  27775. */
  27776. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27777. /**
  27778. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27779. * This does nothing and may be overwritten by the user.
  27780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27782. * @param update the boolean update value actually passed to setParticles()
  27783. */
  27784. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27785. /**
  27786. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27787. * This will be passed three parameters.
  27788. * This does nothing and may be overwritten by the user.
  27789. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27790. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27791. * @param update the boolean update value actually passed to setParticles()
  27792. */
  27793. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27794. }
  27795. }
  27796. declare module "babylonjs/Particles/solidParticle" {
  27797. import { Nullable } from "babylonjs/types";
  27798. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27799. import { Color4 } from "babylonjs/Maths/math.color";
  27800. import { Mesh } from "babylonjs/Meshes/mesh";
  27801. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27802. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27803. import { Plane } from "babylonjs/Maths/math.plane";
  27804. import { Material } from "babylonjs/Materials/material";
  27805. /**
  27806. * Represents one particle of a solid particle system.
  27807. */
  27808. export class SolidParticle {
  27809. /**
  27810. * particle global index
  27811. */
  27812. idx: number;
  27813. /**
  27814. * particle identifier
  27815. */
  27816. id: number;
  27817. /**
  27818. * The color of the particle
  27819. */
  27820. color: Nullable<Color4>;
  27821. /**
  27822. * The world space position of the particle.
  27823. */
  27824. position: Vector3;
  27825. /**
  27826. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27827. */
  27828. rotation: Vector3;
  27829. /**
  27830. * The world space rotation quaternion of the particle.
  27831. */
  27832. rotationQuaternion: Nullable<Quaternion>;
  27833. /**
  27834. * The scaling of the particle.
  27835. */
  27836. scaling: Vector3;
  27837. /**
  27838. * The uvs of the particle.
  27839. */
  27840. uvs: Vector4;
  27841. /**
  27842. * The current speed of the particle.
  27843. */
  27844. velocity: Vector3;
  27845. /**
  27846. * The pivot point in the particle local space.
  27847. */
  27848. pivot: Vector3;
  27849. /**
  27850. * Must the particle be translated from its pivot point in its local space ?
  27851. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27852. * Default : false
  27853. */
  27854. translateFromPivot: boolean;
  27855. /**
  27856. * Is the particle active or not ?
  27857. */
  27858. alive: boolean;
  27859. /**
  27860. * Is the particle visible or not ?
  27861. */
  27862. isVisible: boolean;
  27863. /**
  27864. * Index of this particle in the global "positions" array (Internal use)
  27865. * @hidden
  27866. */
  27867. _pos: number;
  27868. /**
  27869. * @hidden Index of this particle in the global "indices" array (Internal use)
  27870. */
  27871. _ind: number;
  27872. /**
  27873. * @hidden ModelShape of this particle (Internal use)
  27874. */
  27875. _model: ModelShape;
  27876. /**
  27877. * ModelShape id of this particle
  27878. */
  27879. shapeId: number;
  27880. /**
  27881. * Index of the particle in its shape id
  27882. */
  27883. idxInShape: number;
  27884. /**
  27885. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27886. */
  27887. _modelBoundingInfo: BoundingInfo;
  27888. /**
  27889. * @hidden Particle BoundingInfo object (Internal use)
  27890. */
  27891. _boundingInfo: BoundingInfo;
  27892. /**
  27893. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27894. */
  27895. _sps: SolidParticleSystem;
  27896. /**
  27897. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27898. */
  27899. _stillInvisible: boolean;
  27900. /**
  27901. * @hidden Last computed particle rotation matrix
  27902. */
  27903. _rotationMatrix: number[];
  27904. /**
  27905. * Parent particle Id, if any.
  27906. * Default null.
  27907. */
  27908. parentId: Nullable<number>;
  27909. /**
  27910. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27911. */
  27912. materialIndex: Nullable<number>;
  27913. /**
  27914. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27915. * The possible values are :
  27916. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27917. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27918. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27919. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27920. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27921. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27922. * */
  27923. cullingStrategy: number;
  27924. /**
  27925. * @hidden Internal global position in the SPS.
  27926. */
  27927. _globalPosition: Vector3;
  27928. /**
  27929. * Creates a Solid Particle object.
  27930. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27931. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27932. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27933. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27934. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27935. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27936. * @param shapeId (integer) is the model shape identifier in the SPS.
  27937. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27938. * @param sps defines the sps it is associated to
  27939. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27940. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27941. */
  27942. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27943. /**
  27944. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27945. * @param target the particle target
  27946. * @returns the current particle
  27947. */
  27948. copyToRef(target: SolidParticle): SolidParticle;
  27949. /**
  27950. * Legacy support, changed scale to scaling
  27951. */
  27952. /**
  27953. * Legacy support, changed scale to scaling
  27954. */
  27955. scale: Vector3;
  27956. /**
  27957. * Legacy support, changed quaternion to rotationQuaternion
  27958. */
  27959. /**
  27960. * Legacy support, changed quaternion to rotationQuaternion
  27961. */
  27962. quaternion: Nullable<Quaternion>;
  27963. /**
  27964. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27965. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27966. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27967. * @returns true if it intersects
  27968. */
  27969. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27970. /**
  27971. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27972. * A particle is in the frustum if its bounding box intersects the frustum
  27973. * @param frustumPlanes defines the frustum to test
  27974. * @returns true if the particle is in the frustum planes
  27975. */
  27976. isInFrustum(frustumPlanes: Plane[]): boolean;
  27977. /**
  27978. * get the rotation matrix of the particle
  27979. * @hidden
  27980. */
  27981. getRotationMatrix(m: Matrix): void;
  27982. }
  27983. /**
  27984. * Represents the shape of the model used by one particle of a solid particle system.
  27985. * SPS internal tool, don't use it manually.
  27986. */
  27987. export class ModelShape {
  27988. /**
  27989. * The shape id
  27990. * @hidden
  27991. */
  27992. shapeID: number;
  27993. /**
  27994. * flat array of model positions (internal use)
  27995. * @hidden
  27996. */
  27997. _shape: Vector3[];
  27998. /**
  27999. * flat array of model UVs (internal use)
  28000. * @hidden
  28001. */
  28002. _shapeUV: number[];
  28003. /**
  28004. * color array of the model
  28005. * @hidden
  28006. */
  28007. _shapeColors: number[];
  28008. /**
  28009. * indices array of the model
  28010. * @hidden
  28011. */
  28012. _indices: number[];
  28013. /**
  28014. * normals array of the model
  28015. * @hidden
  28016. */
  28017. _normals: number[];
  28018. /**
  28019. * length of the shape in the model indices array (internal use)
  28020. * @hidden
  28021. */
  28022. _indicesLength: number;
  28023. /**
  28024. * Custom position function (internal use)
  28025. * @hidden
  28026. */
  28027. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28028. /**
  28029. * Custom vertex function (internal use)
  28030. * @hidden
  28031. */
  28032. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28033. /**
  28034. * Model material (internal use)
  28035. * @hidden
  28036. */
  28037. _material: Nullable<Material>;
  28038. /**
  28039. * 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.
  28040. * SPS internal tool, don't use it manually.
  28041. * @hidden
  28042. */
  28043. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28044. }
  28045. /**
  28046. * Represents a Depth Sorted Particle in the solid particle system.
  28047. * @hidden
  28048. */
  28049. export class DepthSortedParticle {
  28050. /**
  28051. * Index of the particle in the "indices" array
  28052. */
  28053. ind: number;
  28054. /**
  28055. * Length of the particle shape in the "indices" array
  28056. */
  28057. indicesLength: number;
  28058. /**
  28059. * Squared distance from the particle to the camera
  28060. */
  28061. sqDistance: number;
  28062. /**
  28063. * Material index when used with MultiMaterials
  28064. */
  28065. materialIndex: number;
  28066. /**
  28067. * Creates a new sorted particle
  28068. * @param materialIndex
  28069. */
  28070. constructor(ind: number, indLength: number, materialIndex: number);
  28071. }
  28072. }
  28073. declare module "babylonjs/Collisions/meshCollisionData" {
  28074. import { Collider } from "babylonjs/Collisions/collider";
  28075. import { Vector3 } from "babylonjs/Maths/math.vector";
  28076. import { Nullable } from "babylonjs/types";
  28077. import { Observer } from "babylonjs/Misc/observable";
  28078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28079. /**
  28080. * @hidden
  28081. */
  28082. export class _MeshCollisionData {
  28083. _checkCollisions: boolean;
  28084. _collisionMask: number;
  28085. _collisionGroup: number;
  28086. _collider: Nullable<Collider>;
  28087. _oldPositionForCollisions: Vector3;
  28088. _diffPositionForCollisions: Vector3;
  28089. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28090. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28091. }
  28092. }
  28093. declare module "babylonjs/Meshes/abstractMesh" {
  28094. import { Observable } from "babylonjs/Misc/observable";
  28095. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28096. import { Camera } from "babylonjs/Cameras/camera";
  28097. import { Scene, IDisposable } from "babylonjs/scene";
  28098. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28099. import { Node } from "babylonjs/node";
  28100. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28101. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28102. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28103. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28104. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28105. import { Material } from "babylonjs/Materials/material";
  28106. import { Light } from "babylonjs/Lights/light";
  28107. import { Skeleton } from "babylonjs/Bones/skeleton";
  28108. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28109. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28110. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28111. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28112. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28113. import { Plane } from "babylonjs/Maths/math.plane";
  28114. import { Ray } from "babylonjs/Culling/ray";
  28115. import { Collider } from "babylonjs/Collisions/collider";
  28116. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28117. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28118. /** @hidden */
  28119. class _FacetDataStorage {
  28120. facetPositions: Vector3[];
  28121. facetNormals: Vector3[];
  28122. facetPartitioning: number[][];
  28123. facetNb: number;
  28124. partitioningSubdivisions: number;
  28125. partitioningBBoxRatio: number;
  28126. facetDataEnabled: boolean;
  28127. facetParameters: any;
  28128. bbSize: Vector3;
  28129. subDiv: {
  28130. max: number;
  28131. X: number;
  28132. Y: number;
  28133. Z: number;
  28134. };
  28135. facetDepthSort: boolean;
  28136. facetDepthSortEnabled: boolean;
  28137. depthSortedIndices: IndicesArray;
  28138. depthSortedFacets: {
  28139. ind: number;
  28140. sqDistance: number;
  28141. }[];
  28142. facetDepthSortFunction: (f1: {
  28143. ind: number;
  28144. sqDistance: number;
  28145. }, f2: {
  28146. ind: number;
  28147. sqDistance: number;
  28148. }) => number;
  28149. facetDepthSortFrom: Vector3;
  28150. facetDepthSortOrigin: Vector3;
  28151. invertedMatrix: Matrix;
  28152. }
  28153. /**
  28154. * @hidden
  28155. **/
  28156. class _InternalAbstractMeshDataInfo {
  28157. _hasVertexAlpha: boolean;
  28158. _useVertexColors: boolean;
  28159. _numBoneInfluencers: number;
  28160. _applyFog: boolean;
  28161. _receiveShadows: boolean;
  28162. _facetData: _FacetDataStorage;
  28163. _visibility: number;
  28164. _skeleton: Nullable<Skeleton>;
  28165. _layerMask: number;
  28166. _computeBonesUsingShaders: boolean;
  28167. _isActive: boolean;
  28168. _onlyForInstances: boolean;
  28169. _isActiveIntermediate: boolean;
  28170. _onlyForInstancesIntermediate: boolean;
  28171. _actAsRegularMesh: boolean;
  28172. }
  28173. /**
  28174. * Class used to store all common mesh properties
  28175. */
  28176. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28177. /** No occlusion */
  28178. static OCCLUSION_TYPE_NONE: number;
  28179. /** Occlusion set to optimisitic */
  28180. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28181. /** Occlusion set to strict */
  28182. static OCCLUSION_TYPE_STRICT: number;
  28183. /** Use an accurante occlusion algorithm */
  28184. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28185. /** Use a conservative occlusion algorithm */
  28186. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28187. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28188. * Test order :
  28189. * Is the bounding sphere outside the frustum ?
  28190. * If not, are the bounding box vertices outside the frustum ?
  28191. * It not, then the cullable object is in the frustum.
  28192. */
  28193. static readonly CULLINGSTRATEGY_STANDARD: number;
  28194. /** Culling strategy : Bounding Sphere Only.
  28195. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28196. * It's also less accurate than the standard because some not visible objects can still be selected.
  28197. * Test : is the bounding sphere outside the frustum ?
  28198. * If not, then the cullable object is in the frustum.
  28199. */
  28200. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28201. /** Culling strategy : Optimistic Inclusion.
  28202. * This in an inclusion test first, then the standard exclusion test.
  28203. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28204. * 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.
  28205. * Anyway, it's as accurate as the standard strategy.
  28206. * Test :
  28207. * Is the cullable object bounding sphere center in the frustum ?
  28208. * If not, apply the default culling strategy.
  28209. */
  28210. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28211. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28212. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28213. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28214. * 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.
  28215. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28216. * Test :
  28217. * Is the cullable object bounding sphere center in the frustum ?
  28218. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28219. */
  28220. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28221. /**
  28222. * No billboard
  28223. */
  28224. static readonly BILLBOARDMODE_NONE: number;
  28225. /** Billboard on X axis */
  28226. static readonly BILLBOARDMODE_X: number;
  28227. /** Billboard on Y axis */
  28228. static readonly BILLBOARDMODE_Y: number;
  28229. /** Billboard on Z axis */
  28230. static readonly BILLBOARDMODE_Z: number;
  28231. /** Billboard on all axes */
  28232. static readonly BILLBOARDMODE_ALL: number;
  28233. /** Billboard on using position instead of orientation */
  28234. static readonly BILLBOARDMODE_USE_POSITION: number;
  28235. /** @hidden */
  28236. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28237. /**
  28238. * The culling strategy to use to check whether the mesh must be rendered or not.
  28239. * This value can be changed at any time and will be used on the next render mesh selection.
  28240. * The possible values are :
  28241. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28242. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28243. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28244. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28245. * Please read each static variable documentation to get details about the culling process.
  28246. * */
  28247. cullingStrategy: number;
  28248. /**
  28249. * Gets the number of facets in the mesh
  28250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28251. */
  28252. readonly facetNb: number;
  28253. /**
  28254. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28256. */
  28257. partitioningSubdivisions: number;
  28258. /**
  28259. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28260. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28262. */
  28263. partitioningBBoxRatio: number;
  28264. /**
  28265. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28266. * Works only for updatable meshes.
  28267. * Doesn't work with multi-materials
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28269. */
  28270. mustDepthSortFacets: boolean;
  28271. /**
  28272. * The location (Vector3) where the facet depth sort must be computed from.
  28273. * By default, the active camera position.
  28274. * Used only when facet depth sort is enabled
  28275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28276. */
  28277. facetDepthSortFrom: Vector3;
  28278. /**
  28279. * gets a boolean indicating if facetData is enabled
  28280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28281. */
  28282. readonly isFacetDataEnabled: boolean;
  28283. /** @hidden */
  28284. _updateNonUniformScalingState(value: boolean): boolean;
  28285. /**
  28286. * An event triggered when this mesh collides with another one
  28287. */
  28288. onCollideObservable: Observable<AbstractMesh>;
  28289. /** Set a function to call when this mesh collides with another one */
  28290. onCollide: () => void;
  28291. /**
  28292. * An event triggered when the collision's position changes
  28293. */
  28294. onCollisionPositionChangeObservable: Observable<Vector3>;
  28295. /** Set a function to call when the collision's position changes */
  28296. onCollisionPositionChange: () => void;
  28297. /**
  28298. * An event triggered when material is changed
  28299. */
  28300. onMaterialChangedObservable: Observable<AbstractMesh>;
  28301. /**
  28302. * Gets or sets the orientation for POV movement & rotation
  28303. */
  28304. definedFacingForward: boolean;
  28305. /** @hidden */
  28306. _occlusionQuery: Nullable<WebGLQuery>;
  28307. /** @hidden */
  28308. _renderingGroup: Nullable<RenderingGroup>;
  28309. /**
  28310. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28311. */
  28312. /**
  28313. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28314. */
  28315. visibility: number;
  28316. /** Gets or sets the alpha index used to sort transparent meshes
  28317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28318. */
  28319. alphaIndex: number;
  28320. /**
  28321. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28322. */
  28323. isVisible: boolean;
  28324. /**
  28325. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28326. */
  28327. isPickable: boolean;
  28328. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28329. showSubMeshesBoundingBox: boolean;
  28330. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28331. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28332. */
  28333. isBlocker: boolean;
  28334. /**
  28335. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28336. */
  28337. enablePointerMoveEvents: boolean;
  28338. /**
  28339. * Specifies the rendering group id for this mesh (0 by default)
  28340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28341. */
  28342. renderingGroupId: number;
  28343. private _material;
  28344. /** Gets or sets current material */
  28345. material: Nullable<Material>;
  28346. /**
  28347. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28348. * @see http://doc.babylonjs.com/babylon101/shadows
  28349. */
  28350. receiveShadows: boolean;
  28351. /** Defines color to use when rendering outline */
  28352. outlineColor: Color3;
  28353. /** Define width to use when rendering outline */
  28354. outlineWidth: number;
  28355. /** Defines color to use when rendering overlay */
  28356. overlayColor: Color3;
  28357. /** Defines alpha to use when rendering overlay */
  28358. overlayAlpha: number;
  28359. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28360. hasVertexAlpha: boolean;
  28361. /** 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) */
  28362. useVertexColors: boolean;
  28363. /**
  28364. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28365. */
  28366. computeBonesUsingShaders: boolean;
  28367. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28368. numBoneInfluencers: number;
  28369. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28370. applyFog: boolean;
  28371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28372. useOctreeForRenderingSelection: boolean;
  28373. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28374. useOctreeForPicking: boolean;
  28375. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28376. useOctreeForCollisions: boolean;
  28377. /**
  28378. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28379. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28380. */
  28381. layerMask: number;
  28382. /**
  28383. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28384. */
  28385. alwaysSelectAsActiveMesh: boolean;
  28386. /**
  28387. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28388. */
  28389. doNotSyncBoundingInfo: boolean;
  28390. /**
  28391. * Gets or sets the current action manager
  28392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28393. */
  28394. actionManager: Nullable<AbstractActionManager>;
  28395. private _meshCollisionData;
  28396. /**
  28397. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28399. */
  28400. ellipsoid: Vector3;
  28401. /**
  28402. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28404. */
  28405. ellipsoidOffset: Vector3;
  28406. /**
  28407. * Gets or sets a collision mask used to mask collisions (default is -1).
  28408. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28409. */
  28410. collisionMask: number;
  28411. /**
  28412. * Gets or sets the current collision group mask (-1 by default).
  28413. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28414. */
  28415. collisionGroup: number;
  28416. /**
  28417. * Defines edge width used when edgesRenderer is enabled
  28418. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28419. */
  28420. edgesWidth: number;
  28421. /**
  28422. * Defines edge color used when edgesRenderer is enabled
  28423. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28424. */
  28425. edgesColor: Color4;
  28426. /** @hidden */
  28427. _edgesRenderer: Nullable<IEdgesRenderer>;
  28428. /** @hidden */
  28429. _masterMesh: Nullable<AbstractMesh>;
  28430. /** @hidden */
  28431. _boundingInfo: Nullable<BoundingInfo>;
  28432. /** @hidden */
  28433. _renderId: number;
  28434. /**
  28435. * Gets or sets the list of subMeshes
  28436. * @see http://doc.babylonjs.com/how_to/multi_materials
  28437. */
  28438. subMeshes: SubMesh[];
  28439. /** @hidden */
  28440. _intersectionsInProgress: AbstractMesh[];
  28441. /** @hidden */
  28442. _unIndexed: boolean;
  28443. /** @hidden */
  28444. _lightSources: Light[];
  28445. /** Gets the list of lights affecting that mesh */
  28446. readonly lightSources: Light[];
  28447. /** @hidden */
  28448. readonly _positions: Nullable<Vector3[]>;
  28449. /** @hidden */
  28450. _waitingData: {
  28451. lods: Nullable<any>;
  28452. actions: Nullable<any>;
  28453. freezeWorldMatrix: Nullable<boolean>;
  28454. };
  28455. /** @hidden */
  28456. _bonesTransformMatrices: Nullable<Float32Array>;
  28457. /** @hidden */
  28458. _transformMatrixTexture: Nullable<RawTexture>;
  28459. /**
  28460. * Gets or sets a skeleton to apply skining transformations
  28461. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28462. */
  28463. skeleton: Nullable<Skeleton>;
  28464. /**
  28465. * An event triggered when the mesh is rebuilt.
  28466. */
  28467. onRebuildObservable: Observable<AbstractMesh>;
  28468. /**
  28469. * Creates a new AbstractMesh
  28470. * @param name defines the name of the mesh
  28471. * @param scene defines the hosting scene
  28472. */
  28473. constructor(name: string, scene?: Nullable<Scene>);
  28474. /**
  28475. * Returns the string "AbstractMesh"
  28476. * @returns "AbstractMesh"
  28477. */
  28478. getClassName(): string;
  28479. /**
  28480. * Gets a string representation of the current mesh
  28481. * @param fullDetails defines a boolean indicating if full details must be included
  28482. * @returns a string representation of the current mesh
  28483. */
  28484. toString(fullDetails?: boolean): string;
  28485. /**
  28486. * @hidden
  28487. */
  28488. protected _getEffectiveParent(): Nullable<Node>;
  28489. /** @hidden */
  28490. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28491. /** @hidden */
  28492. _rebuild(): void;
  28493. /** @hidden */
  28494. _resyncLightSources(): void;
  28495. /** @hidden */
  28496. _resyncLightSource(light: Light): void;
  28497. /** @hidden */
  28498. _unBindEffect(): void;
  28499. /** @hidden */
  28500. _removeLightSource(light: Light, dispose: boolean): void;
  28501. private _markSubMeshesAsDirty;
  28502. /** @hidden */
  28503. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28504. /** @hidden */
  28505. _markSubMeshesAsAttributesDirty(): void;
  28506. /** @hidden */
  28507. _markSubMeshesAsMiscDirty(): void;
  28508. /**
  28509. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28510. */
  28511. scaling: Vector3;
  28512. /**
  28513. * Returns true if the mesh is blocked. Implemented by child classes
  28514. */
  28515. readonly isBlocked: boolean;
  28516. /**
  28517. * Returns the mesh itself by default. Implemented by child classes
  28518. * @param camera defines the camera to use to pick the right LOD level
  28519. * @returns the currentAbstractMesh
  28520. */
  28521. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28522. /**
  28523. * Returns 0 by default. Implemented by child classes
  28524. * @returns an integer
  28525. */
  28526. getTotalVertices(): number;
  28527. /**
  28528. * Returns a positive integer : the total number of indices in this mesh geometry.
  28529. * @returns the numner of indices or zero if the mesh has no geometry.
  28530. */
  28531. getTotalIndices(): number;
  28532. /**
  28533. * Returns null by default. Implemented by child classes
  28534. * @returns null
  28535. */
  28536. getIndices(): Nullable<IndicesArray>;
  28537. /**
  28538. * Returns the array of the requested vertex data kind. Implemented by child classes
  28539. * @param kind defines the vertex data kind to use
  28540. * @returns null
  28541. */
  28542. getVerticesData(kind: string): Nullable<FloatArray>;
  28543. /**
  28544. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28545. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28546. * Note that a new underlying VertexBuffer object is created each call.
  28547. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28548. * @param kind defines vertex data kind:
  28549. * * VertexBuffer.PositionKind
  28550. * * VertexBuffer.UVKind
  28551. * * VertexBuffer.UV2Kind
  28552. * * VertexBuffer.UV3Kind
  28553. * * VertexBuffer.UV4Kind
  28554. * * VertexBuffer.UV5Kind
  28555. * * VertexBuffer.UV6Kind
  28556. * * VertexBuffer.ColorKind
  28557. * * VertexBuffer.MatricesIndicesKind
  28558. * * VertexBuffer.MatricesIndicesExtraKind
  28559. * * VertexBuffer.MatricesWeightsKind
  28560. * * VertexBuffer.MatricesWeightsExtraKind
  28561. * @param data defines the data source
  28562. * @param updatable defines if the data must be flagged as updatable (or static)
  28563. * @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
  28564. * @returns the current mesh
  28565. */
  28566. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28567. /**
  28568. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28569. * If the mesh has no geometry, it is simply returned as it is.
  28570. * @param kind defines vertex data kind:
  28571. * * VertexBuffer.PositionKind
  28572. * * VertexBuffer.UVKind
  28573. * * VertexBuffer.UV2Kind
  28574. * * VertexBuffer.UV3Kind
  28575. * * VertexBuffer.UV4Kind
  28576. * * VertexBuffer.UV5Kind
  28577. * * VertexBuffer.UV6Kind
  28578. * * VertexBuffer.ColorKind
  28579. * * VertexBuffer.MatricesIndicesKind
  28580. * * VertexBuffer.MatricesIndicesExtraKind
  28581. * * VertexBuffer.MatricesWeightsKind
  28582. * * VertexBuffer.MatricesWeightsExtraKind
  28583. * @param data defines the data source
  28584. * @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
  28585. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28586. * @returns the current mesh
  28587. */
  28588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28589. /**
  28590. * Sets the mesh indices,
  28591. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28592. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28593. * @param totalVertices Defines the total number of vertices
  28594. * @returns the current mesh
  28595. */
  28596. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28597. /**
  28598. * Gets a boolean indicating if specific vertex data is present
  28599. * @param kind defines the vertex data kind to use
  28600. * @returns true is data kind is present
  28601. */
  28602. isVerticesDataPresent(kind: string): boolean;
  28603. /**
  28604. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28605. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28606. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28607. * @returns a BoundingInfo
  28608. */
  28609. getBoundingInfo(): BoundingInfo;
  28610. /**
  28611. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28612. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28613. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28614. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28615. * @returns the current mesh
  28616. */
  28617. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28618. /**
  28619. * Overwrite the current bounding info
  28620. * @param boundingInfo defines the new bounding info
  28621. * @returns the current mesh
  28622. */
  28623. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28624. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28625. readonly useBones: boolean;
  28626. /** @hidden */
  28627. _preActivate(): void;
  28628. /** @hidden */
  28629. _preActivateForIntermediateRendering(renderId: number): void;
  28630. /** @hidden */
  28631. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28632. /** @hidden */
  28633. _postActivate(): void;
  28634. /** @hidden */
  28635. _freeze(): void;
  28636. /** @hidden */
  28637. _unFreeze(): void;
  28638. /**
  28639. * Gets the current world matrix
  28640. * @returns a Matrix
  28641. */
  28642. getWorldMatrix(): Matrix;
  28643. /** @hidden */
  28644. _getWorldMatrixDeterminant(): number;
  28645. /**
  28646. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28647. */
  28648. readonly isAnInstance: boolean;
  28649. /**
  28650. * Gets a boolean indicating if this mesh has instances
  28651. */
  28652. readonly hasInstances: boolean;
  28653. /**
  28654. * Perform relative position change from the point of view of behind the front of the mesh.
  28655. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28656. * Supports definition of mesh facing forward or backward
  28657. * @param amountRight defines the distance on the right axis
  28658. * @param amountUp defines the distance on the up axis
  28659. * @param amountForward defines the distance on the forward axis
  28660. * @returns the current mesh
  28661. */
  28662. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28663. /**
  28664. * Calculate relative position change from the point of view of behind the front of the mesh.
  28665. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28666. * Supports definition of mesh facing forward or backward
  28667. * @param amountRight defines the distance on the right axis
  28668. * @param amountUp defines the distance on the up axis
  28669. * @param amountForward defines the distance on the forward axis
  28670. * @returns the new displacement vector
  28671. */
  28672. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28673. /**
  28674. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28675. * Supports definition of mesh facing forward or backward
  28676. * @param flipBack defines the flip
  28677. * @param twirlClockwise defines the twirl
  28678. * @param tiltRight defines the tilt
  28679. * @returns the current mesh
  28680. */
  28681. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28682. /**
  28683. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28684. * Supports definition of mesh facing forward or backward.
  28685. * @param flipBack defines the flip
  28686. * @param twirlClockwise defines the twirl
  28687. * @param tiltRight defines the tilt
  28688. * @returns the new rotation vector
  28689. */
  28690. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28691. /**
  28692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28693. * This means the mesh underlying bounding box and sphere are recomputed.
  28694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28695. * @returns the current mesh
  28696. */
  28697. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28698. /** @hidden */
  28699. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28700. /** @hidden */
  28701. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28702. /** @hidden */
  28703. _updateBoundingInfo(): AbstractMesh;
  28704. /** @hidden */
  28705. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28706. /** @hidden */
  28707. protected _afterComputeWorldMatrix(): void;
  28708. /** @hidden */
  28709. readonly _effectiveMesh: AbstractMesh;
  28710. /**
  28711. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28712. * A mesh is in the frustum if its bounding box intersects the frustum
  28713. * @param frustumPlanes defines the frustum to test
  28714. * @returns true if the mesh is in the frustum planes
  28715. */
  28716. isInFrustum(frustumPlanes: Plane[]): boolean;
  28717. /**
  28718. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28719. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28720. * @param frustumPlanes defines the frustum to test
  28721. * @returns true if the mesh is completely in the frustum planes
  28722. */
  28723. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28724. /**
  28725. * True if the mesh intersects another mesh or a SolidParticle object
  28726. * @param mesh defines a target mesh or SolidParticle to test
  28727. * @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)
  28728. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28729. * @returns true if there is an intersection
  28730. */
  28731. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28732. /**
  28733. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28734. * @param point defines the point to test
  28735. * @returns true if there is an intersection
  28736. */
  28737. intersectsPoint(point: Vector3): boolean;
  28738. /**
  28739. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28741. */
  28742. checkCollisions: boolean;
  28743. /**
  28744. * Gets Collider object used to compute collisions (not physics)
  28745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28746. */
  28747. readonly collider: Nullable<Collider>;
  28748. /**
  28749. * Move the mesh using collision engine
  28750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28751. * @param displacement defines the requested displacement vector
  28752. * @returns the current mesh
  28753. */
  28754. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28755. private _onCollisionPositionChange;
  28756. /** @hidden */
  28757. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28758. /** @hidden */
  28759. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28760. /** @hidden */
  28761. _checkCollision(collider: Collider): AbstractMesh;
  28762. /** @hidden */
  28763. _generatePointsArray(): boolean;
  28764. /**
  28765. * Checks if the passed Ray intersects with the mesh
  28766. * @param ray defines the ray to use
  28767. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28768. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28769. * @returns the picking info
  28770. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28771. */
  28772. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28773. /**
  28774. * Clones the current mesh
  28775. * @param name defines the mesh name
  28776. * @param newParent defines the new mesh parent
  28777. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28778. * @returns the new mesh
  28779. */
  28780. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28781. /**
  28782. * Disposes all the submeshes of the current meshnp
  28783. * @returns the current mesh
  28784. */
  28785. releaseSubMeshes(): AbstractMesh;
  28786. /**
  28787. * Releases resources associated with this abstract mesh.
  28788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28790. */
  28791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28792. /**
  28793. * Adds the passed mesh as a child to the current mesh
  28794. * @param mesh defines the child mesh
  28795. * @returns the current mesh
  28796. */
  28797. addChild(mesh: AbstractMesh): AbstractMesh;
  28798. /**
  28799. * Removes the passed mesh from the current mesh children list
  28800. * @param mesh defines the child mesh
  28801. * @returns the current mesh
  28802. */
  28803. removeChild(mesh: AbstractMesh): AbstractMesh;
  28804. /** @hidden */
  28805. private _initFacetData;
  28806. /**
  28807. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28808. * This method can be called within the render loop.
  28809. * 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
  28810. * @returns the current mesh
  28811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28812. */
  28813. updateFacetData(): AbstractMesh;
  28814. /**
  28815. * Returns the facetLocalNormals array.
  28816. * The normals are expressed in the mesh local spac
  28817. * @returns an array of Vector3
  28818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28819. */
  28820. getFacetLocalNormals(): Vector3[];
  28821. /**
  28822. * Returns the facetLocalPositions array.
  28823. * The facet positions are expressed in the mesh local space
  28824. * @returns an array of Vector3
  28825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28826. */
  28827. getFacetLocalPositions(): Vector3[];
  28828. /**
  28829. * Returns the facetLocalPartioning array
  28830. * @returns an array of array of numbers
  28831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28832. */
  28833. getFacetLocalPartitioning(): number[][];
  28834. /**
  28835. * Returns the i-th facet position in the world system.
  28836. * This method allocates a new Vector3 per call
  28837. * @param i defines the facet index
  28838. * @returns a new Vector3
  28839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28840. */
  28841. getFacetPosition(i: number): Vector3;
  28842. /**
  28843. * Sets the reference Vector3 with the i-th facet position in the world system
  28844. * @param i defines the facet index
  28845. * @param ref defines the target vector
  28846. * @returns the current mesh
  28847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28848. */
  28849. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28850. /**
  28851. * Returns the i-th facet normal in the world system.
  28852. * This method allocates a new Vector3 per call
  28853. * @param i defines the facet index
  28854. * @returns a new Vector3
  28855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28856. */
  28857. getFacetNormal(i: number): Vector3;
  28858. /**
  28859. * Sets the reference Vector3 with the i-th facet normal in the world system
  28860. * @param i defines the facet index
  28861. * @param ref defines the target vector
  28862. * @returns the current mesh
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetNormalToRef(i: number, ref: Vector3): this;
  28866. /**
  28867. * 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)
  28868. * @param x defines x coordinate
  28869. * @param y defines y coordinate
  28870. * @param z defines z coordinate
  28871. * @returns the array of facet indexes
  28872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28873. */
  28874. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28875. /**
  28876. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28877. * @param projected sets as the (x,y,z) world projection on the facet
  28878. * @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
  28879. * @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
  28880. * @param x defines x coordinate
  28881. * @param y defines y coordinate
  28882. * @param z defines z coordinate
  28883. * @returns the face index if found (or null instead)
  28884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28885. */
  28886. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28887. /**
  28888. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28889. * @param projected sets as the (x,y,z) local projection on the facet
  28890. * @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
  28891. * @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
  28892. * @param x defines x coordinate
  28893. * @param y defines y coordinate
  28894. * @param z defines z coordinate
  28895. * @returns the face index if found (or null instead)
  28896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28897. */
  28898. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28899. /**
  28900. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28901. * @returns the parameters
  28902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28903. */
  28904. getFacetDataParameters(): any;
  28905. /**
  28906. * Disables the feature FacetData and frees the related memory
  28907. * @returns the current mesh
  28908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28909. */
  28910. disableFacetData(): AbstractMesh;
  28911. /**
  28912. * Updates the AbstractMesh indices array
  28913. * @param indices defines the data source
  28914. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28915. * @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)
  28916. * @returns the current mesh
  28917. */
  28918. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28919. /**
  28920. * Creates new normals data for the mesh
  28921. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28922. * @returns the current mesh
  28923. */
  28924. createNormals(updatable: boolean): AbstractMesh;
  28925. /**
  28926. * Align the mesh with a normal
  28927. * @param normal defines the normal to use
  28928. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28929. * @returns the current mesh
  28930. */
  28931. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28932. /** @hidden */
  28933. _checkOcclusionQuery(): boolean;
  28934. /**
  28935. * Disables the mesh edge rendering mode
  28936. * @returns the currentAbstractMesh
  28937. */
  28938. disableEdgesRendering(): AbstractMesh;
  28939. /**
  28940. * Enables the edge rendering mode on the mesh.
  28941. * This mode makes the mesh edges visible
  28942. * @param epsilon defines the maximal distance between two angles to detect a face
  28943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28944. * @returns the currentAbstractMesh
  28945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28946. */
  28947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28948. }
  28949. }
  28950. declare module "babylonjs/Actions/actionEvent" {
  28951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28952. import { Nullable } from "babylonjs/types";
  28953. import { Sprite } from "babylonjs/Sprites/sprite";
  28954. import { Scene } from "babylonjs/scene";
  28955. import { Vector2 } from "babylonjs/Maths/math.vector";
  28956. /**
  28957. * Interface used to define ActionEvent
  28958. */
  28959. export interface IActionEvent {
  28960. /** The mesh or sprite that triggered the action */
  28961. source: any;
  28962. /** The X mouse cursor position at the time of the event */
  28963. pointerX: number;
  28964. /** The Y mouse cursor position at the time of the event */
  28965. pointerY: number;
  28966. /** The mesh that is currently pointed at (can be null) */
  28967. meshUnderPointer: Nullable<AbstractMesh>;
  28968. /** the original (browser) event that triggered the ActionEvent */
  28969. sourceEvent?: any;
  28970. /** additional data for the event */
  28971. additionalData?: any;
  28972. }
  28973. /**
  28974. * ActionEvent is the event being sent when an action is triggered.
  28975. */
  28976. export class ActionEvent implements IActionEvent {
  28977. /** The mesh or sprite that triggered the action */
  28978. source: any;
  28979. /** The X mouse cursor position at the time of the event */
  28980. pointerX: number;
  28981. /** The Y mouse cursor position at the time of the event */
  28982. pointerY: number;
  28983. /** The mesh that is currently pointed at (can be null) */
  28984. meshUnderPointer: Nullable<AbstractMesh>;
  28985. /** the original (browser) event that triggered the ActionEvent */
  28986. sourceEvent?: any;
  28987. /** additional data for the event */
  28988. additionalData?: any;
  28989. /**
  28990. * Creates a new ActionEvent
  28991. * @param source The mesh or sprite that triggered the action
  28992. * @param pointerX The X mouse cursor position at the time of the event
  28993. * @param pointerY The Y mouse cursor position at the time of the event
  28994. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28995. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28996. * @param additionalData additional data for the event
  28997. */
  28998. constructor(
  28999. /** The mesh or sprite that triggered the action */
  29000. source: any,
  29001. /** The X mouse cursor position at the time of the event */
  29002. pointerX: number,
  29003. /** The Y mouse cursor position at the time of the event */
  29004. pointerY: number,
  29005. /** The mesh that is currently pointed at (can be null) */
  29006. meshUnderPointer: Nullable<AbstractMesh>,
  29007. /** the original (browser) event that triggered the ActionEvent */
  29008. sourceEvent?: any,
  29009. /** additional data for the event */
  29010. additionalData?: any);
  29011. /**
  29012. * Helper function to auto-create an ActionEvent from a source mesh.
  29013. * @param source The source mesh that triggered the event
  29014. * @param evt The original (browser) event
  29015. * @param additionalData additional data for the event
  29016. * @returns the new ActionEvent
  29017. */
  29018. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29019. /**
  29020. * Helper function to auto-create an ActionEvent from a source sprite
  29021. * @param source The source sprite that triggered the event
  29022. * @param scene Scene associated with the sprite
  29023. * @param evt The original (browser) event
  29024. * @param additionalData additional data for the event
  29025. * @returns the new ActionEvent
  29026. */
  29027. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29028. /**
  29029. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29030. * @param scene the scene where the event occurred
  29031. * @param evt The original (browser) event
  29032. * @returns the new ActionEvent
  29033. */
  29034. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29035. /**
  29036. * Helper function to auto-create an ActionEvent from a primitive
  29037. * @param prim defines the target primitive
  29038. * @param pointerPos defines the pointer position
  29039. * @param evt The original (browser) event
  29040. * @param additionalData additional data for the event
  29041. * @returns the new ActionEvent
  29042. */
  29043. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29044. }
  29045. }
  29046. declare module "babylonjs/Actions/abstractActionManager" {
  29047. import { IDisposable } from "babylonjs/scene";
  29048. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29049. import { IAction } from "babylonjs/Actions/action";
  29050. import { Nullable } from "babylonjs/types";
  29051. /**
  29052. * Abstract class used to decouple action Manager from scene and meshes.
  29053. * Do not instantiate.
  29054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29055. */
  29056. export abstract class AbstractActionManager implements IDisposable {
  29057. /** Gets the list of active triggers */
  29058. static Triggers: {
  29059. [key: string]: number;
  29060. };
  29061. /** Gets the cursor to use when hovering items */
  29062. hoverCursor: string;
  29063. /** Gets the list of actions */
  29064. actions: IAction[];
  29065. /**
  29066. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29067. */
  29068. isRecursive: boolean;
  29069. /**
  29070. * Releases all associated resources
  29071. */
  29072. abstract dispose(): void;
  29073. /**
  29074. * Does this action manager has pointer triggers
  29075. */
  29076. abstract readonly hasPointerTriggers: boolean;
  29077. /**
  29078. * Does this action manager has pick triggers
  29079. */
  29080. abstract readonly hasPickTriggers: boolean;
  29081. /**
  29082. * Process a specific trigger
  29083. * @param trigger defines the trigger to process
  29084. * @param evt defines the event details to be processed
  29085. */
  29086. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29087. /**
  29088. * Does this action manager handles actions of any of the given triggers
  29089. * @param triggers defines the triggers to be tested
  29090. * @return a boolean indicating whether one (or more) of the triggers is handled
  29091. */
  29092. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29093. /**
  29094. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29095. * speed.
  29096. * @param triggerA defines the trigger to be tested
  29097. * @param triggerB defines the trigger to be tested
  29098. * @return a boolean indicating whether one (or more) of the triggers is handled
  29099. */
  29100. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29101. /**
  29102. * Does this action manager handles actions of a given trigger
  29103. * @param trigger defines the trigger to be tested
  29104. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29105. * @return whether the trigger is handled
  29106. */
  29107. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29108. /**
  29109. * Serialize this manager to a JSON object
  29110. * @param name defines the property name to store this manager
  29111. * @returns a JSON representation of this manager
  29112. */
  29113. abstract serialize(name: string): any;
  29114. /**
  29115. * Registers an action to this action manager
  29116. * @param action defines the action to be registered
  29117. * @return the action amended (prepared) after registration
  29118. */
  29119. abstract registerAction(action: IAction): Nullable<IAction>;
  29120. /**
  29121. * Unregisters an action to this action manager
  29122. * @param action defines the action to be unregistered
  29123. * @return a boolean indicating whether the action has been unregistered
  29124. */
  29125. abstract unregisterAction(action: IAction): Boolean;
  29126. /**
  29127. * Does exist one action manager with at least one trigger
  29128. **/
  29129. static readonly HasTriggers: boolean;
  29130. /**
  29131. * Does exist one action manager with at least one pick trigger
  29132. **/
  29133. static readonly HasPickTriggers: boolean;
  29134. /**
  29135. * Does exist one action manager that handles actions of a given trigger
  29136. * @param trigger defines the trigger to be tested
  29137. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29138. **/
  29139. static HasSpecificTrigger(trigger: number): boolean;
  29140. }
  29141. }
  29142. declare module "babylonjs/node" {
  29143. import { Scene } from "babylonjs/scene";
  29144. import { Nullable } from "babylonjs/types";
  29145. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29146. import { Engine } from "babylonjs/Engines/engine";
  29147. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29148. import { Observable } from "babylonjs/Misc/observable";
  29149. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29150. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29151. import { Animatable } from "babylonjs/Animations/animatable";
  29152. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29153. import { Animation } from "babylonjs/Animations/animation";
  29154. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29156. /**
  29157. * Defines how a node can be built from a string name.
  29158. */
  29159. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29160. /**
  29161. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29162. */
  29163. export class Node implements IBehaviorAware<Node> {
  29164. /** @hidden */
  29165. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29166. private static _NodeConstructors;
  29167. /**
  29168. * Add a new node constructor
  29169. * @param type defines the type name of the node to construct
  29170. * @param constructorFunc defines the constructor function
  29171. */
  29172. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29173. /**
  29174. * Returns a node constructor based on type name
  29175. * @param type defines the type name
  29176. * @param name defines the new node name
  29177. * @param scene defines the hosting scene
  29178. * @param options defines optional options to transmit to constructors
  29179. * @returns the new constructor or null
  29180. */
  29181. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29182. /**
  29183. * Gets or sets the name of the node
  29184. */
  29185. name: string;
  29186. /**
  29187. * Gets or sets the id of the node
  29188. */
  29189. id: string;
  29190. /**
  29191. * Gets or sets the unique id of the node
  29192. */
  29193. uniqueId: number;
  29194. /**
  29195. * Gets or sets a string used to store user defined state for the node
  29196. */
  29197. state: string;
  29198. /**
  29199. * Gets or sets an object used to store user defined information for the node
  29200. */
  29201. metadata: any;
  29202. /**
  29203. * For internal use only. Please do not use.
  29204. */
  29205. reservedDataStore: any;
  29206. /**
  29207. * List of inspectable custom properties (used by the Inspector)
  29208. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29209. */
  29210. inspectableCustomProperties: IInspectable[];
  29211. private _doNotSerialize;
  29212. /**
  29213. * Gets or sets a boolean used to define if the node must be serialized
  29214. */
  29215. doNotSerialize: boolean;
  29216. /** @hidden */
  29217. _isDisposed: boolean;
  29218. /**
  29219. * Gets a list of Animations associated with the node
  29220. */
  29221. animations: import("babylonjs/Animations/animation").Animation[];
  29222. protected _ranges: {
  29223. [name: string]: Nullable<AnimationRange>;
  29224. };
  29225. /**
  29226. * Callback raised when the node is ready to be used
  29227. */
  29228. onReady: Nullable<(node: Node) => void>;
  29229. private _isEnabled;
  29230. private _isParentEnabled;
  29231. private _isReady;
  29232. /** @hidden */
  29233. _currentRenderId: number;
  29234. private _parentUpdateId;
  29235. /** @hidden */
  29236. _childUpdateId: number;
  29237. /** @hidden */
  29238. _waitingParentId: Nullable<string>;
  29239. /** @hidden */
  29240. _scene: Scene;
  29241. /** @hidden */
  29242. _cache: any;
  29243. private _parentNode;
  29244. private _children;
  29245. /** @hidden */
  29246. _worldMatrix: Matrix;
  29247. /** @hidden */
  29248. _worldMatrixDeterminant: number;
  29249. /** @hidden */
  29250. _worldMatrixDeterminantIsDirty: boolean;
  29251. /** @hidden */
  29252. private _sceneRootNodesIndex;
  29253. /**
  29254. * Gets a boolean indicating if the node has been disposed
  29255. * @returns true if the node was disposed
  29256. */
  29257. isDisposed(): boolean;
  29258. /**
  29259. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29260. * @see https://doc.babylonjs.com/how_to/parenting
  29261. */
  29262. parent: Nullable<Node>;
  29263. /** @hidden */
  29264. _addToSceneRootNodes(): void;
  29265. /** @hidden */
  29266. _removeFromSceneRootNodes(): void;
  29267. private _animationPropertiesOverride;
  29268. /**
  29269. * Gets or sets the animation properties override
  29270. */
  29271. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29272. /**
  29273. * Gets a string idenfifying the name of the class
  29274. * @returns "Node" string
  29275. */
  29276. getClassName(): string;
  29277. /** @hidden */
  29278. readonly _isNode: boolean;
  29279. /**
  29280. * An event triggered when the mesh is disposed
  29281. */
  29282. onDisposeObservable: Observable<Node>;
  29283. private _onDisposeObserver;
  29284. /**
  29285. * Sets a callback that will be raised when the node will be disposed
  29286. */
  29287. onDispose: () => void;
  29288. /**
  29289. * Creates a new Node
  29290. * @param name the name and id to be given to this node
  29291. * @param scene the scene this node will be added to
  29292. */
  29293. constructor(name: string, scene?: Nullable<Scene>);
  29294. /**
  29295. * Gets the scene of the node
  29296. * @returns a scene
  29297. */
  29298. getScene(): Scene;
  29299. /**
  29300. * Gets the engine of the node
  29301. * @returns a Engine
  29302. */
  29303. getEngine(): Engine;
  29304. private _behaviors;
  29305. /**
  29306. * Attach a behavior to the node
  29307. * @see http://doc.babylonjs.com/features/behaviour
  29308. * @param behavior defines the behavior to attach
  29309. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29310. * @returns the current Node
  29311. */
  29312. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29313. /**
  29314. * Remove an attached behavior
  29315. * @see http://doc.babylonjs.com/features/behaviour
  29316. * @param behavior defines the behavior to attach
  29317. * @returns the current Node
  29318. */
  29319. removeBehavior(behavior: Behavior<Node>): Node;
  29320. /**
  29321. * Gets the list of attached behaviors
  29322. * @see http://doc.babylonjs.com/features/behaviour
  29323. */
  29324. readonly behaviors: Behavior<Node>[];
  29325. /**
  29326. * Gets an attached behavior by name
  29327. * @param name defines the name of the behavior to look for
  29328. * @see http://doc.babylonjs.com/features/behaviour
  29329. * @returns null if behavior was not found else the requested behavior
  29330. */
  29331. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29332. /**
  29333. * Returns the latest update of the World matrix
  29334. * @returns a Matrix
  29335. */
  29336. getWorldMatrix(): Matrix;
  29337. /** @hidden */
  29338. _getWorldMatrixDeterminant(): number;
  29339. /**
  29340. * Returns directly the latest state of the mesh World matrix.
  29341. * A Matrix is returned.
  29342. */
  29343. readonly worldMatrixFromCache: Matrix;
  29344. /** @hidden */
  29345. _initCache(): void;
  29346. /** @hidden */
  29347. updateCache(force?: boolean): void;
  29348. /** @hidden */
  29349. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29350. /** @hidden */
  29351. _updateCache(ignoreParentClass?: boolean): void;
  29352. /** @hidden */
  29353. _isSynchronized(): boolean;
  29354. /** @hidden */
  29355. _markSyncedWithParent(): void;
  29356. /** @hidden */
  29357. isSynchronizedWithParent(): boolean;
  29358. /** @hidden */
  29359. isSynchronized(): boolean;
  29360. /**
  29361. * Is this node ready to be used/rendered
  29362. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29363. * @return true if the node is ready
  29364. */
  29365. isReady(completeCheck?: boolean): boolean;
  29366. /**
  29367. * Is this node enabled?
  29368. * 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
  29369. * @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
  29370. * @return whether this node (and its parent) is enabled
  29371. */
  29372. isEnabled(checkAncestors?: boolean): boolean;
  29373. /** @hidden */
  29374. protected _syncParentEnabledState(): void;
  29375. /**
  29376. * Set the enabled state of this node
  29377. * @param value defines the new enabled state
  29378. */
  29379. setEnabled(value: boolean): void;
  29380. /**
  29381. * Is this node a descendant of the given node?
  29382. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29383. * @param ancestor defines the parent node to inspect
  29384. * @returns a boolean indicating if this node is a descendant of the given node
  29385. */
  29386. isDescendantOf(ancestor: Node): boolean;
  29387. /** @hidden */
  29388. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29389. /**
  29390. * Will return all nodes that have this node as ascendant
  29391. * @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
  29392. * @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
  29393. * @return all children nodes of all types
  29394. */
  29395. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29396. /**
  29397. * Get all child-meshes of this node
  29398. * @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)
  29399. * @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
  29400. * @returns an array of AbstractMesh
  29401. */
  29402. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29403. /**
  29404. * Get all direct children of this node
  29405. * @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
  29406. * @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)
  29407. * @returns an array of Node
  29408. */
  29409. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29410. /** @hidden */
  29411. _setReady(state: boolean): void;
  29412. /**
  29413. * Get an animation by name
  29414. * @param name defines the name of the animation to look for
  29415. * @returns null if not found else the requested animation
  29416. */
  29417. getAnimationByName(name: string): Nullable<Animation>;
  29418. /**
  29419. * Creates an animation range for this node
  29420. * @param name defines the name of the range
  29421. * @param from defines the starting key
  29422. * @param to defines the end key
  29423. */
  29424. createAnimationRange(name: string, from: number, to: number): void;
  29425. /**
  29426. * Delete a specific animation range
  29427. * @param name defines the name of the range to delete
  29428. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29429. */
  29430. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29431. /**
  29432. * Get an animation range by name
  29433. * @param name defines the name of the animation range to look for
  29434. * @returns null if not found else the requested animation range
  29435. */
  29436. getAnimationRange(name: string): Nullable<AnimationRange>;
  29437. /**
  29438. * Gets the list of all animation ranges defined on this node
  29439. * @returns an array
  29440. */
  29441. getAnimationRanges(): Nullable<AnimationRange>[];
  29442. /**
  29443. * Will start the animation sequence
  29444. * @param name defines the range frames for animation sequence
  29445. * @param loop defines if the animation should loop (false by default)
  29446. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29447. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29448. * @returns the object created for this animation. If range does not exist, it will return null
  29449. */
  29450. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29451. /**
  29452. * Serialize animation ranges into a JSON compatible object
  29453. * @returns serialization object
  29454. */
  29455. serializeAnimationRanges(): any;
  29456. /**
  29457. * Computes the world matrix of the node
  29458. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29459. * @returns the world matrix
  29460. */
  29461. computeWorldMatrix(force?: boolean): Matrix;
  29462. /**
  29463. * Releases resources associated with this node.
  29464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29466. */
  29467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29468. /**
  29469. * Parse animation range data from a serialization object and store them into a given node
  29470. * @param node defines where to store the animation ranges
  29471. * @param parsedNode defines the serialization object to read data from
  29472. * @param scene defines the hosting scene
  29473. */
  29474. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29475. /**
  29476. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29477. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29478. * @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
  29479. * @returns the new bounding vectors
  29480. */
  29481. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29482. min: Vector3;
  29483. max: Vector3;
  29484. };
  29485. }
  29486. }
  29487. declare module "babylonjs/Animations/animation" {
  29488. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29489. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29490. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29491. import { Nullable } from "babylonjs/types";
  29492. import { Scene } from "babylonjs/scene";
  29493. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29494. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29495. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29496. import { Node } from "babylonjs/node";
  29497. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29498. import { Size } from "babylonjs/Maths/math.size";
  29499. import { Animatable } from "babylonjs/Animations/animatable";
  29500. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29501. /**
  29502. * @hidden
  29503. */
  29504. export class _IAnimationState {
  29505. key: number;
  29506. repeatCount: number;
  29507. workValue?: any;
  29508. loopMode?: number;
  29509. offsetValue?: any;
  29510. highLimitValue?: any;
  29511. }
  29512. /**
  29513. * Class used to store any kind of animation
  29514. */
  29515. export class Animation {
  29516. /**Name of the animation */
  29517. name: string;
  29518. /**Property to animate */
  29519. targetProperty: string;
  29520. /**The frames per second of the animation */
  29521. framePerSecond: number;
  29522. /**The data type of the animation */
  29523. dataType: number;
  29524. /**The loop mode of the animation */
  29525. loopMode?: number | undefined;
  29526. /**Specifies if blending should be enabled */
  29527. enableBlending?: boolean | undefined;
  29528. /**
  29529. * Use matrix interpolation instead of using direct key value when animating matrices
  29530. */
  29531. static AllowMatricesInterpolation: boolean;
  29532. /**
  29533. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29534. */
  29535. static AllowMatrixDecomposeForInterpolation: boolean;
  29536. /**
  29537. * Stores the key frames of the animation
  29538. */
  29539. private _keys;
  29540. /**
  29541. * Stores the easing function of the animation
  29542. */
  29543. private _easingFunction;
  29544. /**
  29545. * @hidden Internal use only
  29546. */
  29547. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29548. /**
  29549. * The set of event that will be linked to this animation
  29550. */
  29551. private _events;
  29552. /**
  29553. * Stores an array of target property paths
  29554. */
  29555. targetPropertyPath: string[];
  29556. /**
  29557. * Stores the blending speed of the animation
  29558. */
  29559. blendingSpeed: number;
  29560. /**
  29561. * Stores the animation ranges for the animation
  29562. */
  29563. private _ranges;
  29564. /**
  29565. * @hidden Internal use
  29566. */
  29567. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29568. /**
  29569. * Sets up an animation
  29570. * @param property The property to animate
  29571. * @param animationType The animation type to apply
  29572. * @param framePerSecond The frames per second of the animation
  29573. * @param easingFunction The easing function used in the animation
  29574. * @returns The created animation
  29575. */
  29576. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29577. /**
  29578. * Create and start an animation on a node
  29579. * @param name defines the name of the global animation that will be run on all nodes
  29580. * @param node defines the root node where the animation will take place
  29581. * @param targetProperty defines property to animate
  29582. * @param framePerSecond defines the number of frame per second yo use
  29583. * @param totalFrame defines the number of frames in total
  29584. * @param from defines the initial value
  29585. * @param to defines the final value
  29586. * @param loopMode defines which loop mode you want to use (off by default)
  29587. * @param easingFunction defines the easing function to use (linear by default)
  29588. * @param onAnimationEnd defines the callback to call when animation end
  29589. * @returns the animatable created for this animation
  29590. */
  29591. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29592. /**
  29593. * Create and start an animation on a node and its descendants
  29594. * @param name defines the name of the global animation that will be run on all nodes
  29595. * @param node defines the root node where the animation will take place
  29596. * @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
  29597. * @param targetProperty defines property to animate
  29598. * @param framePerSecond defines the number of frame per second to use
  29599. * @param totalFrame defines the number of frames in total
  29600. * @param from defines the initial value
  29601. * @param to defines the final value
  29602. * @param loopMode defines which loop mode you want to use (off by default)
  29603. * @param easingFunction defines the easing function to use (linear by default)
  29604. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29605. * @returns the list of animatables created for all nodes
  29606. * @example https://www.babylonjs-playground.com/#MH0VLI
  29607. */
  29608. 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[]>;
  29609. /**
  29610. * Creates a new animation, merges it with the existing animations and starts it
  29611. * @param name Name of the animation
  29612. * @param node Node which contains the scene that begins the animations
  29613. * @param targetProperty Specifies which property to animate
  29614. * @param framePerSecond The frames per second of the animation
  29615. * @param totalFrame The total number of frames
  29616. * @param from The frame at the beginning of the animation
  29617. * @param to The frame at the end of the animation
  29618. * @param loopMode Specifies the loop mode of the animation
  29619. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29620. * @param onAnimationEnd Callback to run once the animation is complete
  29621. * @returns Nullable animation
  29622. */
  29623. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29624. /**
  29625. * Transition property of an host to the target Value
  29626. * @param property The property to transition
  29627. * @param targetValue The target Value of the property
  29628. * @param host The object where the property to animate belongs
  29629. * @param scene Scene used to run the animation
  29630. * @param frameRate Framerate (in frame/s) to use
  29631. * @param transition The transition type we want to use
  29632. * @param duration The duration of the animation, in milliseconds
  29633. * @param onAnimationEnd Callback trigger at the end of the animation
  29634. * @returns Nullable animation
  29635. */
  29636. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29637. /**
  29638. * Return the array of runtime animations currently using this animation
  29639. */
  29640. readonly runtimeAnimations: RuntimeAnimation[];
  29641. /**
  29642. * Specifies if any of the runtime animations are currently running
  29643. */
  29644. readonly hasRunningRuntimeAnimations: boolean;
  29645. /**
  29646. * Initializes the animation
  29647. * @param name Name of the animation
  29648. * @param targetProperty Property to animate
  29649. * @param framePerSecond The frames per second of the animation
  29650. * @param dataType The data type of the animation
  29651. * @param loopMode The loop mode of the animation
  29652. * @param enableBlending Specifies if blending should be enabled
  29653. */
  29654. constructor(
  29655. /**Name of the animation */
  29656. name: string,
  29657. /**Property to animate */
  29658. targetProperty: string,
  29659. /**The frames per second of the animation */
  29660. framePerSecond: number,
  29661. /**The data type of the animation */
  29662. dataType: number,
  29663. /**The loop mode of the animation */
  29664. loopMode?: number | undefined,
  29665. /**Specifies if blending should be enabled */
  29666. enableBlending?: boolean | undefined);
  29667. /**
  29668. * Converts the animation to a string
  29669. * @param fullDetails support for multiple levels of logging within scene loading
  29670. * @returns String form of the animation
  29671. */
  29672. toString(fullDetails?: boolean): string;
  29673. /**
  29674. * Add an event to this animation
  29675. * @param event Event to add
  29676. */
  29677. addEvent(event: AnimationEvent): void;
  29678. /**
  29679. * Remove all events found at the given frame
  29680. * @param frame The frame to remove events from
  29681. */
  29682. removeEvents(frame: number): void;
  29683. /**
  29684. * Retrieves all the events from the animation
  29685. * @returns Events from the animation
  29686. */
  29687. getEvents(): AnimationEvent[];
  29688. /**
  29689. * Creates an animation range
  29690. * @param name Name of the animation range
  29691. * @param from Starting frame of the animation range
  29692. * @param to Ending frame of the animation
  29693. */
  29694. createRange(name: string, from: number, to: number): void;
  29695. /**
  29696. * Deletes an animation range by name
  29697. * @param name Name of the animation range to delete
  29698. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29699. */
  29700. deleteRange(name: string, deleteFrames?: boolean): void;
  29701. /**
  29702. * Gets the animation range by name, or null if not defined
  29703. * @param name Name of the animation range
  29704. * @returns Nullable animation range
  29705. */
  29706. getRange(name: string): Nullable<AnimationRange>;
  29707. /**
  29708. * Gets the key frames from the animation
  29709. * @returns The key frames of the animation
  29710. */
  29711. getKeys(): Array<IAnimationKey>;
  29712. /**
  29713. * Gets the highest frame rate of the animation
  29714. * @returns Highest frame rate of the animation
  29715. */
  29716. getHighestFrame(): number;
  29717. /**
  29718. * Gets the easing function of the animation
  29719. * @returns Easing function of the animation
  29720. */
  29721. getEasingFunction(): IEasingFunction;
  29722. /**
  29723. * Sets the easing function of the animation
  29724. * @param easingFunction A custom mathematical formula for animation
  29725. */
  29726. setEasingFunction(easingFunction: EasingFunction): void;
  29727. /**
  29728. * Interpolates a scalar linearly
  29729. * @param startValue Start value of the animation curve
  29730. * @param endValue End value of the animation curve
  29731. * @param gradient Scalar amount to interpolate
  29732. * @returns Interpolated scalar value
  29733. */
  29734. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29735. /**
  29736. * Interpolates a scalar cubically
  29737. * @param startValue Start value of the animation curve
  29738. * @param outTangent End tangent of the animation
  29739. * @param endValue End value of the animation curve
  29740. * @param inTangent Start tangent of the animation curve
  29741. * @param gradient Scalar amount to interpolate
  29742. * @returns Interpolated scalar value
  29743. */
  29744. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29745. /**
  29746. * Interpolates a quaternion using a spherical linear interpolation
  29747. * @param startValue Start value of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param gradient Scalar amount to interpolate
  29750. * @returns Interpolated quaternion value
  29751. */
  29752. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29753. /**
  29754. * Interpolates a quaternion cubically
  29755. * @param startValue Start value of the animation curve
  29756. * @param outTangent End tangent of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param inTangent Start tangent of the animation curve
  29759. * @param gradient Scalar amount to interpolate
  29760. * @returns Interpolated quaternion value
  29761. */
  29762. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29763. /**
  29764. * Interpolates a Vector3 linearl
  29765. * @param startValue Start value of the animation curve
  29766. * @param endValue End value of the animation curve
  29767. * @param gradient Scalar amount to interpolate
  29768. * @returns Interpolated scalar value
  29769. */
  29770. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29771. /**
  29772. * Interpolates a Vector3 cubically
  29773. * @param startValue Start value of the animation curve
  29774. * @param outTangent End tangent of the animation
  29775. * @param endValue End value of the animation curve
  29776. * @param inTangent Start tangent of the animation curve
  29777. * @param gradient Scalar amount to interpolate
  29778. * @returns InterpolatedVector3 value
  29779. */
  29780. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29781. /**
  29782. * Interpolates a Vector2 linearly
  29783. * @param startValue Start value of the animation curve
  29784. * @param endValue End value of the animation curve
  29785. * @param gradient Scalar amount to interpolate
  29786. * @returns Interpolated Vector2 value
  29787. */
  29788. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29789. /**
  29790. * Interpolates a Vector2 cubically
  29791. * @param startValue Start value of the animation curve
  29792. * @param outTangent End tangent of the animation
  29793. * @param endValue End value of the animation curve
  29794. * @param inTangent Start tangent of the animation curve
  29795. * @param gradient Scalar amount to interpolate
  29796. * @returns Interpolated Vector2 value
  29797. */
  29798. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29799. /**
  29800. * Interpolates a size linearly
  29801. * @param startValue Start value of the animation curve
  29802. * @param endValue End value of the animation curve
  29803. * @param gradient Scalar amount to interpolate
  29804. * @returns Interpolated Size value
  29805. */
  29806. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29807. /**
  29808. * Interpolates a Color3 linearly
  29809. * @param startValue Start value of the animation curve
  29810. * @param endValue End value of the animation curve
  29811. * @param gradient Scalar amount to interpolate
  29812. * @returns Interpolated Color3 value
  29813. */
  29814. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29815. /**
  29816. * Interpolates a Color4 linearly
  29817. * @param startValue Start value of the animation curve
  29818. * @param endValue End value of the animation curve
  29819. * @param gradient Scalar amount to interpolate
  29820. * @returns Interpolated Color3 value
  29821. */
  29822. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29823. /**
  29824. * @hidden Internal use only
  29825. */
  29826. _getKeyValue(value: any): any;
  29827. /**
  29828. * @hidden Internal use only
  29829. */
  29830. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29831. /**
  29832. * Defines the function to use to interpolate matrices
  29833. * @param startValue defines the start matrix
  29834. * @param endValue defines the end matrix
  29835. * @param gradient defines the gradient between both matrices
  29836. * @param result defines an optional target matrix where to store the interpolation
  29837. * @returns the interpolated matrix
  29838. */
  29839. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29840. /**
  29841. * Makes a copy of the animation
  29842. * @returns Cloned animation
  29843. */
  29844. clone(): Animation;
  29845. /**
  29846. * Sets the key frames of the animation
  29847. * @param values The animation key frames to set
  29848. */
  29849. setKeys(values: Array<IAnimationKey>): void;
  29850. /**
  29851. * Serializes the animation to an object
  29852. * @returns Serialized object
  29853. */
  29854. serialize(): any;
  29855. /**
  29856. * Float animation type
  29857. */
  29858. static readonly ANIMATIONTYPE_FLOAT: number;
  29859. /**
  29860. * Vector3 animation type
  29861. */
  29862. static readonly ANIMATIONTYPE_VECTOR3: number;
  29863. /**
  29864. * Quaternion animation type
  29865. */
  29866. static readonly ANIMATIONTYPE_QUATERNION: number;
  29867. /**
  29868. * Matrix animation type
  29869. */
  29870. static readonly ANIMATIONTYPE_MATRIX: number;
  29871. /**
  29872. * Color3 animation type
  29873. */
  29874. static readonly ANIMATIONTYPE_COLOR3: number;
  29875. /**
  29876. * Color3 animation type
  29877. */
  29878. static readonly ANIMATIONTYPE_COLOR4: number;
  29879. /**
  29880. * Vector2 animation type
  29881. */
  29882. static readonly ANIMATIONTYPE_VECTOR2: number;
  29883. /**
  29884. * Size animation type
  29885. */
  29886. static readonly ANIMATIONTYPE_SIZE: number;
  29887. /**
  29888. * Relative Loop Mode
  29889. */
  29890. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29891. /**
  29892. * Cycle Loop Mode
  29893. */
  29894. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29895. /**
  29896. * Constant Loop Mode
  29897. */
  29898. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29899. /** @hidden */
  29900. static _UniversalLerp(left: any, right: any, amount: number): any;
  29901. /**
  29902. * Parses an animation object and creates an animation
  29903. * @param parsedAnimation Parsed animation object
  29904. * @returns Animation object
  29905. */
  29906. static Parse(parsedAnimation: any): Animation;
  29907. /**
  29908. * Appends the serialized animations from the source animations
  29909. * @param source Source containing the animations
  29910. * @param destination Target to store the animations
  29911. */
  29912. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29913. }
  29914. }
  29915. declare module "babylonjs/Animations/animatable.interface" {
  29916. import { Nullable } from "babylonjs/types";
  29917. import { Animation } from "babylonjs/Animations/animation";
  29918. /**
  29919. * Interface containing an array of animations
  29920. */
  29921. export interface IAnimatable {
  29922. /**
  29923. * Array of animations
  29924. */
  29925. animations: Nullable<Array<Animation>>;
  29926. }
  29927. }
  29928. declare module "babylonjs/Misc/decorators" {
  29929. import { Nullable } from "babylonjs/types";
  29930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29931. import { Scene } from "babylonjs/scene";
  29932. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29933. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29937. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29938. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29942. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29943. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29944. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29945. /**
  29946. * Decorator used to define property that can be serialized as reference to a camera
  29947. * @param sourceName defines the name of the property to decorate
  29948. */
  29949. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29950. /**
  29951. * Class used to help serialization objects
  29952. */
  29953. export class SerializationHelper {
  29954. /** @hidden */
  29955. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29956. /** @hidden */
  29957. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29958. /** @hidden */
  29959. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29960. /** @hidden */
  29961. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29962. /**
  29963. * Appends the serialized animations from the source animations
  29964. * @param source Source containing the animations
  29965. * @param destination Target to store the animations
  29966. */
  29967. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29968. /**
  29969. * Static function used to serialized a specific entity
  29970. * @param entity defines the entity to serialize
  29971. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29972. * @returns a JSON compatible object representing the serialization of the entity
  29973. */
  29974. static Serialize<T>(entity: T, serializationObject?: any): any;
  29975. /**
  29976. * Creates a new entity from a serialization data object
  29977. * @param creationFunction defines a function used to instanciated the new entity
  29978. * @param source defines the source serialization data
  29979. * @param scene defines the hosting scene
  29980. * @param rootUrl defines the root url for resources
  29981. * @returns a new entity
  29982. */
  29983. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29984. /**
  29985. * Clones an object
  29986. * @param creationFunction defines the function used to instanciate the new object
  29987. * @param source defines the source object
  29988. * @returns the cloned object
  29989. */
  29990. static Clone<T>(creationFunction: () => T, source: T): T;
  29991. /**
  29992. * Instanciates a new object based on a source one (some data will be shared between both object)
  29993. * @param creationFunction defines the function used to instanciate the new object
  29994. * @param source defines the source object
  29995. * @returns the new object
  29996. */
  29997. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29998. }
  29999. }
  30000. declare module "babylonjs/Misc/guid" {
  30001. /**
  30002. * Class used to manipulate GUIDs
  30003. */
  30004. export class GUID {
  30005. /**
  30006. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30007. * Be aware Math.random() could cause collisions, but:
  30008. * "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"
  30009. * @returns a pseudo random id
  30010. */
  30011. static RandomId(): string;
  30012. }
  30013. }
  30014. declare module "babylonjs/Materials/Textures/baseTexture" {
  30015. import { Observable } from "babylonjs/Misc/observable";
  30016. import { Nullable } from "babylonjs/types";
  30017. import { Scene } from "babylonjs/scene";
  30018. import { Matrix } from "babylonjs/Maths/math.vector";
  30019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30020. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30021. import { ISize } from "babylonjs/Maths/math.size";
  30022. /**
  30023. * Base class of all the textures in babylon.
  30024. * It groups all the common properties the materials, post process, lights... might need
  30025. * in order to make a correct use of the texture.
  30026. */
  30027. export class BaseTexture implements IAnimatable {
  30028. /**
  30029. * Default anisotropic filtering level for the application.
  30030. * It is set to 4 as a good tradeoff between perf and quality.
  30031. */
  30032. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30033. /**
  30034. * Gets or sets the unique id of the texture
  30035. */
  30036. uniqueId: number;
  30037. /**
  30038. * Define the name of the texture.
  30039. */
  30040. name: string;
  30041. /**
  30042. * Gets or sets an object used to store user defined information.
  30043. */
  30044. metadata: any;
  30045. /**
  30046. * For internal use only. Please do not use.
  30047. */
  30048. reservedDataStore: any;
  30049. private _hasAlpha;
  30050. /**
  30051. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30052. */
  30053. hasAlpha: boolean;
  30054. /**
  30055. * Defines if the alpha value should be determined via the rgb values.
  30056. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30057. */
  30058. getAlphaFromRGB: boolean;
  30059. /**
  30060. * Intensity or strength of the texture.
  30061. * It is commonly used by materials to fine tune the intensity of the texture
  30062. */
  30063. level: number;
  30064. /**
  30065. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30066. * This is part of the texture as textures usually maps to one uv set.
  30067. */
  30068. coordinatesIndex: number;
  30069. private _coordinatesMode;
  30070. /**
  30071. * How a texture is mapped.
  30072. *
  30073. * | Value | Type | Description |
  30074. * | ----- | ----------------------------------- | ----------- |
  30075. * | 0 | EXPLICIT_MODE | |
  30076. * | 1 | SPHERICAL_MODE | |
  30077. * | 2 | PLANAR_MODE | |
  30078. * | 3 | CUBIC_MODE | |
  30079. * | 4 | PROJECTION_MODE | |
  30080. * | 5 | SKYBOX_MODE | |
  30081. * | 6 | INVCUBIC_MODE | |
  30082. * | 7 | EQUIRECTANGULAR_MODE | |
  30083. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30084. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30085. */
  30086. coordinatesMode: number;
  30087. /**
  30088. * | Value | Type | Description |
  30089. * | ----- | ------------------ | ----------- |
  30090. * | 0 | CLAMP_ADDRESSMODE | |
  30091. * | 1 | WRAP_ADDRESSMODE | |
  30092. * | 2 | MIRROR_ADDRESSMODE | |
  30093. */
  30094. wrapU: number;
  30095. /**
  30096. * | Value | Type | Description |
  30097. * | ----- | ------------------ | ----------- |
  30098. * | 0 | CLAMP_ADDRESSMODE | |
  30099. * | 1 | WRAP_ADDRESSMODE | |
  30100. * | 2 | MIRROR_ADDRESSMODE | |
  30101. */
  30102. wrapV: number;
  30103. /**
  30104. * | Value | Type | Description |
  30105. * | ----- | ------------------ | ----------- |
  30106. * | 0 | CLAMP_ADDRESSMODE | |
  30107. * | 1 | WRAP_ADDRESSMODE | |
  30108. * | 2 | MIRROR_ADDRESSMODE | |
  30109. */
  30110. wrapR: number;
  30111. /**
  30112. * With compliant hardware and browser (supporting anisotropic filtering)
  30113. * this defines the level of anisotropic filtering in the texture.
  30114. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30115. */
  30116. anisotropicFilteringLevel: number;
  30117. /**
  30118. * Define if the texture is a cube texture or if false a 2d texture.
  30119. */
  30120. isCube: boolean;
  30121. /**
  30122. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30123. */
  30124. is3D: boolean;
  30125. /**
  30126. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30127. */
  30128. is2DArray: boolean;
  30129. /**
  30130. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30131. * HDR texture are usually stored in linear space.
  30132. * This only impacts the PBR and Background materials
  30133. */
  30134. gammaSpace: boolean;
  30135. /**
  30136. * Gets or sets whether or not the texture contains RGBD data.
  30137. */
  30138. isRGBD: boolean;
  30139. /**
  30140. * Is Z inverted in the texture (useful in a cube texture).
  30141. */
  30142. invertZ: boolean;
  30143. /**
  30144. * Are mip maps generated for this texture or not.
  30145. */
  30146. readonly noMipmap: boolean;
  30147. /**
  30148. * @hidden
  30149. */
  30150. lodLevelInAlpha: boolean;
  30151. /**
  30152. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30153. */
  30154. lodGenerationOffset: number;
  30155. /**
  30156. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30157. */
  30158. lodGenerationScale: number;
  30159. /**
  30160. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30161. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30162. * average roughness values.
  30163. */
  30164. linearSpecularLOD: boolean;
  30165. /**
  30166. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30167. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30168. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30169. */
  30170. irradianceTexture: Nullable<BaseTexture>;
  30171. /**
  30172. * Define if the texture is a render target.
  30173. */
  30174. isRenderTarget: boolean;
  30175. /**
  30176. * Define the unique id of the texture in the scene.
  30177. */
  30178. readonly uid: string;
  30179. /**
  30180. * Return a string representation of the texture.
  30181. * @returns the texture as a string
  30182. */
  30183. toString(): string;
  30184. /**
  30185. * Get the class name of the texture.
  30186. * @returns "BaseTexture"
  30187. */
  30188. getClassName(): string;
  30189. /**
  30190. * Define the list of animation attached to the texture.
  30191. */
  30192. animations: import("babylonjs/Animations/animation").Animation[];
  30193. /**
  30194. * An event triggered when the texture is disposed.
  30195. */
  30196. onDisposeObservable: Observable<BaseTexture>;
  30197. private _onDisposeObserver;
  30198. /**
  30199. * Callback triggered when the texture has been disposed.
  30200. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30201. */
  30202. onDispose: () => void;
  30203. /**
  30204. * Define the current state of the loading sequence when in delayed load mode.
  30205. */
  30206. delayLoadState: number;
  30207. private _scene;
  30208. /** @hidden */
  30209. _texture: Nullable<InternalTexture>;
  30210. private _uid;
  30211. /**
  30212. * Define if the texture is preventinga material to render or not.
  30213. * If not and the texture is not ready, the engine will use a default black texture instead.
  30214. */
  30215. readonly isBlocking: boolean;
  30216. /**
  30217. * Instantiates a new BaseTexture.
  30218. * Base class of all the textures in babylon.
  30219. * It groups all the common properties the materials, post process, lights... might need
  30220. * in order to make a correct use of the texture.
  30221. * @param scene Define the scene the texture blongs to
  30222. */
  30223. constructor(scene: Nullable<Scene>);
  30224. /**
  30225. * Get the scene the texture belongs to.
  30226. * @returns the scene or null if undefined
  30227. */
  30228. getScene(): Nullable<Scene>;
  30229. /**
  30230. * Get the texture transform matrix used to offset tile the texture for istance.
  30231. * @returns the transformation matrix
  30232. */
  30233. getTextureMatrix(): Matrix;
  30234. /**
  30235. * Get the texture reflection matrix used to rotate/transform the reflection.
  30236. * @returns the reflection matrix
  30237. */
  30238. getReflectionTextureMatrix(): Matrix;
  30239. /**
  30240. * Get the underlying lower level texture from Babylon.
  30241. * @returns the insternal texture
  30242. */
  30243. getInternalTexture(): Nullable<InternalTexture>;
  30244. /**
  30245. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30246. * @returns true if ready or not blocking
  30247. */
  30248. isReadyOrNotBlocking(): boolean;
  30249. /**
  30250. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30251. * @returns true if fully ready
  30252. */
  30253. isReady(): boolean;
  30254. private _cachedSize;
  30255. /**
  30256. * Get the size of the texture.
  30257. * @returns the texture size.
  30258. */
  30259. getSize(): ISize;
  30260. /**
  30261. * Get the base size of the texture.
  30262. * It can be different from the size if the texture has been resized for POT for instance
  30263. * @returns the base size
  30264. */
  30265. getBaseSize(): ISize;
  30266. /**
  30267. * Update the sampling mode of the texture.
  30268. * Default is Trilinear mode.
  30269. *
  30270. * | Value | Type | Description |
  30271. * | ----- | ------------------ | ----------- |
  30272. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30273. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30274. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30275. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30276. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30277. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30278. * | 7 | NEAREST_LINEAR | |
  30279. * | 8 | NEAREST_NEAREST | |
  30280. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30281. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30282. * | 11 | LINEAR_LINEAR | |
  30283. * | 12 | LINEAR_NEAREST | |
  30284. *
  30285. * > _mag_: magnification filter (close to the viewer)
  30286. * > _min_: minification filter (far from the viewer)
  30287. * > _mip_: filter used between mip map levels
  30288. *@param samplingMode Define the new sampling mode of the texture
  30289. */
  30290. updateSamplingMode(samplingMode: number): void;
  30291. /**
  30292. * Scales the texture if is `canRescale()`
  30293. * @param ratio the resize factor we want to use to rescale
  30294. */
  30295. scale(ratio: number): void;
  30296. /**
  30297. * Get if the texture can rescale.
  30298. */
  30299. readonly canRescale: boolean;
  30300. /** @hidden */
  30301. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30302. /** @hidden */
  30303. _rebuild(): void;
  30304. /**
  30305. * Triggers the load sequence in delayed load mode.
  30306. */
  30307. delayLoad(): void;
  30308. /**
  30309. * Clones the texture.
  30310. * @returns the cloned texture
  30311. */
  30312. clone(): Nullable<BaseTexture>;
  30313. /**
  30314. * Get the texture underlying type (INT, FLOAT...)
  30315. */
  30316. readonly textureType: number;
  30317. /**
  30318. * Get the texture underlying format (RGB, RGBA...)
  30319. */
  30320. readonly textureFormat: number;
  30321. /**
  30322. * Indicates that textures need to be re-calculated for all materials
  30323. */
  30324. protected _markAllSubMeshesAsTexturesDirty(): void;
  30325. /**
  30326. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30327. * This will returns an RGBA array buffer containing either in values (0-255) or
  30328. * float values (0-1) depending of the underlying buffer type.
  30329. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30330. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30331. * @param buffer defines a user defined buffer to fill with data (can be null)
  30332. * @returns The Array buffer containing the pixels data.
  30333. */
  30334. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30335. /**
  30336. * Release and destroy the underlying lower level texture aka internalTexture.
  30337. */
  30338. releaseInternalTexture(): void;
  30339. /** @hidden */
  30340. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30341. /** @hidden */
  30342. readonly _lodTextureMid: Nullable<BaseTexture>;
  30343. /** @hidden */
  30344. readonly _lodTextureLow: Nullable<BaseTexture>;
  30345. /**
  30346. * Dispose the texture and release its associated resources.
  30347. */
  30348. dispose(): void;
  30349. /**
  30350. * Serialize the texture into a JSON representation that can be parsed later on.
  30351. * @returns the JSON representation of the texture
  30352. */
  30353. serialize(): any;
  30354. /**
  30355. * Helper function to be called back once a list of texture contains only ready textures.
  30356. * @param textures Define the list of textures to wait for
  30357. * @param callback Define the callback triggered once the entire list will be ready
  30358. */
  30359. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30360. }
  30361. }
  30362. declare module "babylonjs/Materials/effect" {
  30363. import { Observable } from "babylonjs/Misc/observable";
  30364. import { Nullable } from "babylonjs/types";
  30365. import { IDisposable } from "babylonjs/scene";
  30366. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30367. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30368. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30369. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30370. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30371. import { Engine } from "babylonjs/Engines/engine";
  30372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30374. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30375. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30376. /**
  30377. * Options to be used when creating an effect.
  30378. */
  30379. export interface IEffectCreationOptions {
  30380. /**
  30381. * Atrributes that will be used in the shader.
  30382. */
  30383. attributes: string[];
  30384. /**
  30385. * Uniform varible names that will be set in the shader.
  30386. */
  30387. uniformsNames: string[];
  30388. /**
  30389. * Uniform buffer variable names that will be set in the shader.
  30390. */
  30391. uniformBuffersNames: string[];
  30392. /**
  30393. * Sampler texture variable names that will be set in the shader.
  30394. */
  30395. samplers: string[];
  30396. /**
  30397. * Define statements that will be set in the shader.
  30398. */
  30399. defines: any;
  30400. /**
  30401. * Possible fallbacks for this effect to improve performance when needed.
  30402. */
  30403. fallbacks: Nullable<IEffectFallbacks>;
  30404. /**
  30405. * Callback that will be called when the shader is compiled.
  30406. */
  30407. onCompiled: Nullable<(effect: Effect) => void>;
  30408. /**
  30409. * Callback that will be called if an error occurs during shader compilation.
  30410. */
  30411. onError: Nullable<(effect: Effect, errors: string) => void>;
  30412. /**
  30413. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30414. */
  30415. indexParameters?: any;
  30416. /**
  30417. * Max number of lights that can be used in the shader.
  30418. */
  30419. maxSimultaneousLights?: number;
  30420. /**
  30421. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30422. */
  30423. transformFeedbackVaryings?: Nullable<string[]>;
  30424. }
  30425. /**
  30426. * Effect containing vertex and fragment shader that can be executed on an object.
  30427. */
  30428. export class Effect implements IDisposable {
  30429. /**
  30430. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30431. */
  30432. static ShadersRepository: string;
  30433. /**
  30434. * Name of the effect.
  30435. */
  30436. name: any;
  30437. /**
  30438. * String container all the define statements that should be set on the shader.
  30439. */
  30440. defines: string;
  30441. /**
  30442. * Callback that will be called when the shader is compiled.
  30443. */
  30444. onCompiled: Nullable<(effect: Effect) => void>;
  30445. /**
  30446. * Callback that will be called if an error occurs during shader compilation.
  30447. */
  30448. onError: Nullable<(effect: Effect, errors: string) => void>;
  30449. /**
  30450. * Callback that will be called when effect is bound.
  30451. */
  30452. onBind: Nullable<(effect: Effect) => void>;
  30453. /**
  30454. * Unique ID of the effect.
  30455. */
  30456. uniqueId: number;
  30457. /**
  30458. * Observable that will be called when the shader is compiled.
  30459. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30460. */
  30461. onCompileObservable: Observable<Effect>;
  30462. /**
  30463. * Observable that will be called if an error occurs during shader compilation.
  30464. */
  30465. onErrorObservable: Observable<Effect>;
  30466. /** @hidden */
  30467. _onBindObservable: Nullable<Observable<Effect>>;
  30468. /**
  30469. * Observable that will be called when effect is bound.
  30470. */
  30471. readonly onBindObservable: Observable<Effect>;
  30472. /** @hidden */
  30473. _bonesComputationForcedToCPU: boolean;
  30474. private static _uniqueIdSeed;
  30475. private _engine;
  30476. private _uniformBuffersNames;
  30477. private _uniformsNames;
  30478. private _samplerList;
  30479. private _samplers;
  30480. private _isReady;
  30481. private _compilationError;
  30482. private _allFallbacksProcessed;
  30483. private _attributesNames;
  30484. private _attributes;
  30485. private _attributeLocationByName;
  30486. private _uniforms;
  30487. /**
  30488. * Key for the effect.
  30489. * @hidden
  30490. */
  30491. _key: string;
  30492. private _indexParameters;
  30493. private _fallbacks;
  30494. private _vertexSourceCode;
  30495. private _fragmentSourceCode;
  30496. private _vertexSourceCodeOverride;
  30497. private _fragmentSourceCodeOverride;
  30498. private _transformFeedbackVaryings;
  30499. /**
  30500. * Compiled shader to webGL program.
  30501. * @hidden
  30502. */
  30503. _pipelineContext: Nullable<IPipelineContext>;
  30504. private _valueCache;
  30505. private static _baseCache;
  30506. /**
  30507. * Instantiates an effect.
  30508. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30509. * @param baseName Name of the effect.
  30510. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30511. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30512. * @param samplers List of sampler variables that will be passed to the shader.
  30513. * @param engine Engine to be used to render the effect
  30514. * @param defines Define statements to be added to the shader.
  30515. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30516. * @param onCompiled Callback that will be called when the shader is compiled.
  30517. * @param onError Callback that will be called if an error occurs during shader compilation.
  30518. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30519. */
  30520. 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);
  30521. private _useFinalCode;
  30522. /**
  30523. * Unique key for this effect
  30524. */
  30525. readonly key: string;
  30526. /**
  30527. * If the effect has been compiled and prepared.
  30528. * @returns if the effect is compiled and prepared.
  30529. */
  30530. isReady(): boolean;
  30531. private _isReadyInternal;
  30532. /**
  30533. * The engine the effect was initialized with.
  30534. * @returns the engine.
  30535. */
  30536. getEngine(): Engine;
  30537. /**
  30538. * The pipeline context for this effect
  30539. * @returns the associated pipeline context
  30540. */
  30541. getPipelineContext(): Nullable<IPipelineContext>;
  30542. /**
  30543. * The set of names of attribute variables for the shader.
  30544. * @returns An array of attribute names.
  30545. */
  30546. getAttributesNames(): string[];
  30547. /**
  30548. * Returns the attribute at the given index.
  30549. * @param index The index of the attribute.
  30550. * @returns The location of the attribute.
  30551. */
  30552. getAttributeLocation(index: number): number;
  30553. /**
  30554. * Returns the attribute based on the name of the variable.
  30555. * @param name of the attribute to look up.
  30556. * @returns the attribute location.
  30557. */
  30558. getAttributeLocationByName(name: string): number;
  30559. /**
  30560. * The number of attributes.
  30561. * @returns the numnber of attributes.
  30562. */
  30563. getAttributesCount(): number;
  30564. /**
  30565. * Gets the index of a uniform variable.
  30566. * @param uniformName of the uniform to look up.
  30567. * @returns the index.
  30568. */
  30569. getUniformIndex(uniformName: string): number;
  30570. /**
  30571. * Returns the attribute based on the name of the variable.
  30572. * @param uniformName of the uniform to look up.
  30573. * @returns the location of the uniform.
  30574. */
  30575. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30576. /**
  30577. * Returns an array of sampler variable names
  30578. * @returns The array of sampler variable neames.
  30579. */
  30580. getSamplers(): string[];
  30581. /**
  30582. * The error from the last compilation.
  30583. * @returns the error string.
  30584. */
  30585. getCompilationError(): string;
  30586. /**
  30587. * Gets a boolean indicating that all fallbacks were used during compilation
  30588. * @returns true if all fallbacks were used
  30589. */
  30590. allFallbacksProcessed(): boolean;
  30591. /**
  30592. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30593. * @param func The callback to be used.
  30594. */
  30595. executeWhenCompiled(func: (effect: Effect) => void): void;
  30596. private _checkIsReady;
  30597. private _loadShader;
  30598. /**
  30599. * Recompiles the webGL program
  30600. * @param vertexSourceCode The source code for the vertex shader.
  30601. * @param fragmentSourceCode The source code for the fragment shader.
  30602. * @param onCompiled Callback called when completed.
  30603. * @param onError Callback called on error.
  30604. * @hidden
  30605. */
  30606. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30607. /**
  30608. * Prepares the effect
  30609. * @hidden
  30610. */
  30611. _prepareEffect(): void;
  30612. private _processCompilationErrors;
  30613. /**
  30614. * Checks if the effect is supported. (Must be called after compilation)
  30615. */
  30616. readonly isSupported: boolean;
  30617. /**
  30618. * Binds a texture to the engine to be used as output of the shader.
  30619. * @param channel Name of the output variable.
  30620. * @param texture Texture to bind.
  30621. * @hidden
  30622. */
  30623. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30624. /**
  30625. * Sets a texture on the engine to be used in the shader.
  30626. * @param channel Name of the sampler variable.
  30627. * @param texture Texture to set.
  30628. */
  30629. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30630. /**
  30631. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30632. * @param channel Name of the sampler variable.
  30633. * @param texture Texture to set.
  30634. */
  30635. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30636. /**
  30637. * Sets an array of textures on the engine to be used in the shader.
  30638. * @param channel Name of the variable.
  30639. * @param textures Textures to set.
  30640. */
  30641. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30642. /**
  30643. * 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)
  30644. * @param channel Name of the sampler variable.
  30645. * @param postProcess Post process to get the input texture from.
  30646. */
  30647. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30648. /**
  30649. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30650. * 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)
  30651. * @param channel Name of the sampler variable.
  30652. * @param postProcess Post process to get the output texture from.
  30653. */
  30654. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30655. /** @hidden */
  30656. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30657. /** @hidden */
  30658. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30659. /** @hidden */
  30660. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30661. /** @hidden */
  30662. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30663. /**
  30664. * Binds a buffer to a uniform.
  30665. * @param buffer Buffer to bind.
  30666. * @param name Name of the uniform variable to bind to.
  30667. */
  30668. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30669. /**
  30670. * Binds block to a uniform.
  30671. * @param blockName Name of the block to bind.
  30672. * @param index Index to bind.
  30673. */
  30674. bindUniformBlock(blockName: string, index: number): void;
  30675. /**
  30676. * Sets an interger value on a uniform variable.
  30677. * @param uniformName Name of the variable.
  30678. * @param value Value to be set.
  30679. * @returns this effect.
  30680. */
  30681. setInt(uniformName: string, value: number): Effect;
  30682. /**
  30683. * Sets an int array on a uniform variable.
  30684. * @param uniformName Name of the variable.
  30685. * @param array array to be set.
  30686. * @returns this effect.
  30687. */
  30688. setIntArray(uniformName: string, array: Int32Array): Effect;
  30689. /**
  30690. * 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)
  30691. * @param uniformName Name of the variable.
  30692. * @param array array to be set.
  30693. * @returns this effect.
  30694. */
  30695. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30696. /**
  30697. * 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)
  30698. * @param uniformName Name of the variable.
  30699. * @param array array to be set.
  30700. * @returns this effect.
  30701. */
  30702. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30703. /**
  30704. * 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)
  30705. * @param uniformName Name of the variable.
  30706. * @param array array to be set.
  30707. * @returns this effect.
  30708. */
  30709. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30710. /**
  30711. * Sets an float array on a uniform variable.
  30712. * @param uniformName Name of the variable.
  30713. * @param array array to be set.
  30714. * @returns this effect.
  30715. */
  30716. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30717. /**
  30718. * 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)
  30719. * @param uniformName Name of the variable.
  30720. * @param array array to be set.
  30721. * @returns this effect.
  30722. */
  30723. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30724. /**
  30725. * 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)
  30726. * @param uniformName Name of the variable.
  30727. * @param array array to be set.
  30728. * @returns this effect.
  30729. */
  30730. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30731. /**
  30732. * 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)
  30733. * @param uniformName Name of the variable.
  30734. * @param array array to be set.
  30735. * @returns this effect.
  30736. */
  30737. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30738. /**
  30739. * Sets an array on a uniform variable.
  30740. * @param uniformName Name of the variable.
  30741. * @param array array to be set.
  30742. * @returns this effect.
  30743. */
  30744. setArray(uniformName: string, array: number[]): Effect;
  30745. /**
  30746. * 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)
  30747. * @param uniformName Name of the variable.
  30748. * @param array array to be set.
  30749. * @returns this effect.
  30750. */
  30751. setArray2(uniformName: string, array: number[]): Effect;
  30752. /**
  30753. * 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)
  30754. * @param uniformName Name of the variable.
  30755. * @param array array to be set.
  30756. * @returns this effect.
  30757. */
  30758. setArray3(uniformName: string, array: number[]): Effect;
  30759. /**
  30760. * 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)
  30761. * @param uniformName Name of the variable.
  30762. * @param array array to be set.
  30763. * @returns this effect.
  30764. */
  30765. setArray4(uniformName: string, array: number[]): Effect;
  30766. /**
  30767. * Sets matrices on a uniform variable.
  30768. * @param uniformName Name of the variable.
  30769. * @param matrices matrices to be set.
  30770. * @returns this effect.
  30771. */
  30772. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30773. /**
  30774. * Sets matrix on a uniform variable.
  30775. * @param uniformName Name of the variable.
  30776. * @param matrix matrix to be set.
  30777. * @returns this effect.
  30778. */
  30779. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30780. /**
  30781. * 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)
  30782. * @param uniformName Name of the variable.
  30783. * @param matrix matrix to be set.
  30784. * @returns this effect.
  30785. */
  30786. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30787. /**
  30788. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30789. * @param uniformName Name of the variable.
  30790. * @param matrix matrix to be set.
  30791. * @returns this effect.
  30792. */
  30793. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30794. /**
  30795. * Sets a float on a uniform variable.
  30796. * @param uniformName Name of the variable.
  30797. * @param value value to be set.
  30798. * @returns this effect.
  30799. */
  30800. setFloat(uniformName: string, value: number): Effect;
  30801. /**
  30802. * Sets a boolean on a uniform variable.
  30803. * @param uniformName Name of the variable.
  30804. * @param bool value to be set.
  30805. * @returns this effect.
  30806. */
  30807. setBool(uniformName: string, bool: boolean): Effect;
  30808. /**
  30809. * Sets a Vector2 on a uniform variable.
  30810. * @param uniformName Name of the variable.
  30811. * @param vector2 vector2 to be set.
  30812. * @returns this effect.
  30813. */
  30814. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30815. /**
  30816. * Sets a float2 on a uniform variable.
  30817. * @param uniformName Name of the variable.
  30818. * @param x First float in float2.
  30819. * @param y Second float in float2.
  30820. * @returns this effect.
  30821. */
  30822. setFloat2(uniformName: string, x: number, y: number): Effect;
  30823. /**
  30824. * Sets a Vector3 on a uniform variable.
  30825. * @param uniformName Name of the variable.
  30826. * @param vector3 Value to be set.
  30827. * @returns this effect.
  30828. */
  30829. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30830. /**
  30831. * Sets a float3 on a uniform variable.
  30832. * @param uniformName Name of the variable.
  30833. * @param x First float in float3.
  30834. * @param y Second float in float3.
  30835. * @param z Third float in float3.
  30836. * @returns this effect.
  30837. */
  30838. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30839. /**
  30840. * Sets a Vector4 on a uniform variable.
  30841. * @param uniformName Name of the variable.
  30842. * @param vector4 Value to be set.
  30843. * @returns this effect.
  30844. */
  30845. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30846. /**
  30847. * Sets a float4 on a uniform variable.
  30848. * @param uniformName Name of the variable.
  30849. * @param x First float in float4.
  30850. * @param y Second float in float4.
  30851. * @param z Third float in float4.
  30852. * @param w Fourth float in float4.
  30853. * @returns this effect.
  30854. */
  30855. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30856. /**
  30857. * Sets a Color3 on a uniform variable.
  30858. * @param uniformName Name of the variable.
  30859. * @param color3 Value to be set.
  30860. * @returns this effect.
  30861. */
  30862. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30863. /**
  30864. * Sets a Color4 on a uniform variable.
  30865. * @param uniformName Name of the variable.
  30866. * @param color3 Value to be set.
  30867. * @param alpha Alpha value to be set.
  30868. * @returns this effect.
  30869. */
  30870. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30871. /**
  30872. * Sets a Color4 on a uniform variable
  30873. * @param uniformName defines the name of the variable
  30874. * @param color4 defines the value to be set
  30875. * @returns this effect.
  30876. */
  30877. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30878. /** Release all associated resources */
  30879. dispose(): void;
  30880. /**
  30881. * This function will add a new shader to the shader store
  30882. * @param name the name of the shader
  30883. * @param pixelShader optional pixel shader content
  30884. * @param vertexShader optional vertex shader content
  30885. */
  30886. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30887. /**
  30888. * Store of each shader (The can be looked up using effect.key)
  30889. */
  30890. static ShadersStore: {
  30891. [key: string]: string;
  30892. };
  30893. /**
  30894. * Store of each included file for a shader (The can be looked up using effect.key)
  30895. */
  30896. static IncludesShadersStore: {
  30897. [key: string]: string;
  30898. };
  30899. /**
  30900. * Resets the cache of effects.
  30901. */
  30902. static ResetCache(): void;
  30903. }
  30904. }
  30905. declare module "babylonjs/Engines/engineCapabilities" {
  30906. /**
  30907. * Interface used to describe the capabilities of the engine relatively to the current browser
  30908. */
  30909. export interface EngineCapabilities {
  30910. /** Maximum textures units per fragment shader */
  30911. maxTexturesImageUnits: number;
  30912. /** Maximum texture units per vertex shader */
  30913. maxVertexTextureImageUnits: number;
  30914. /** Maximum textures units in the entire pipeline */
  30915. maxCombinedTexturesImageUnits: number;
  30916. /** Maximum texture size */
  30917. maxTextureSize: number;
  30918. /** Maximum texture samples */
  30919. maxSamples?: number;
  30920. /** Maximum cube texture size */
  30921. maxCubemapTextureSize: number;
  30922. /** Maximum render texture size */
  30923. maxRenderTextureSize: number;
  30924. /** Maximum number of vertex attributes */
  30925. maxVertexAttribs: number;
  30926. /** Maximum number of varyings */
  30927. maxVaryingVectors: number;
  30928. /** Maximum number of uniforms per vertex shader */
  30929. maxVertexUniformVectors: number;
  30930. /** Maximum number of uniforms per fragment shader */
  30931. maxFragmentUniformVectors: number;
  30932. /** Defines if standard derivates (dx/dy) are supported */
  30933. standardDerivatives: boolean;
  30934. /** Defines if s3tc texture compression is supported */
  30935. s3tc?: WEBGL_compressed_texture_s3tc;
  30936. /** Defines if pvrtc texture compression is supported */
  30937. pvrtc: any;
  30938. /** Defines if etc1 texture compression is supported */
  30939. etc1: any;
  30940. /** Defines if etc2 texture compression is supported */
  30941. etc2: any;
  30942. /** Defines if astc texture compression is supported */
  30943. astc: any;
  30944. /** Defines if float textures are supported */
  30945. textureFloat: boolean;
  30946. /** Defines if vertex array objects are supported */
  30947. vertexArrayObject: boolean;
  30948. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30949. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30950. /** Gets the maximum level of anisotropy supported */
  30951. maxAnisotropy: number;
  30952. /** Defines if instancing is supported */
  30953. instancedArrays: boolean;
  30954. /** Defines if 32 bits indices are supported */
  30955. uintIndices: boolean;
  30956. /** Defines if high precision shaders are supported */
  30957. highPrecisionShaderSupported: boolean;
  30958. /** Defines if depth reading in the fragment shader is supported */
  30959. fragmentDepthSupported: boolean;
  30960. /** Defines if float texture linear filtering is supported*/
  30961. textureFloatLinearFiltering: boolean;
  30962. /** Defines if rendering to float textures is supported */
  30963. textureFloatRender: boolean;
  30964. /** Defines if half float textures are supported*/
  30965. textureHalfFloat: boolean;
  30966. /** Defines if half float texture linear filtering is supported*/
  30967. textureHalfFloatLinearFiltering: boolean;
  30968. /** Defines if rendering to half float textures is supported */
  30969. textureHalfFloatRender: boolean;
  30970. /** Defines if textureLOD shader command is supported */
  30971. textureLOD: boolean;
  30972. /** Defines if draw buffers extension is supported */
  30973. drawBuffersExtension: boolean;
  30974. /** Defines if depth textures are supported */
  30975. depthTextureExtension: boolean;
  30976. /** Defines if float color buffer are supported */
  30977. colorBufferFloat: boolean;
  30978. /** Gets disjoint timer query extension (null if not supported) */
  30979. timerQuery?: EXT_disjoint_timer_query;
  30980. /** Defines if timestamp can be used with timer query */
  30981. canUseTimestampForTimerQuery: boolean;
  30982. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30983. multiview?: any;
  30984. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30985. oculusMultiview?: any;
  30986. /** Function used to let the system compiles shaders in background */
  30987. parallelShaderCompile?: {
  30988. COMPLETION_STATUS_KHR: number;
  30989. };
  30990. /** Max number of texture samples for MSAA */
  30991. maxMSAASamples: number;
  30992. /** Defines if the blend min max extension is supported */
  30993. blendMinMax: boolean;
  30994. }
  30995. }
  30996. declare module "babylonjs/States/depthCullingState" {
  30997. import { Nullable } from "babylonjs/types";
  30998. /**
  30999. * @hidden
  31000. **/
  31001. export class DepthCullingState {
  31002. private _isDepthTestDirty;
  31003. private _isDepthMaskDirty;
  31004. private _isDepthFuncDirty;
  31005. private _isCullFaceDirty;
  31006. private _isCullDirty;
  31007. private _isZOffsetDirty;
  31008. private _isFrontFaceDirty;
  31009. private _depthTest;
  31010. private _depthMask;
  31011. private _depthFunc;
  31012. private _cull;
  31013. private _cullFace;
  31014. private _zOffset;
  31015. private _frontFace;
  31016. /**
  31017. * Initializes the state.
  31018. */
  31019. constructor();
  31020. readonly isDirty: boolean;
  31021. zOffset: number;
  31022. cullFace: Nullable<number>;
  31023. cull: Nullable<boolean>;
  31024. depthFunc: Nullable<number>;
  31025. depthMask: boolean;
  31026. depthTest: boolean;
  31027. frontFace: Nullable<number>;
  31028. reset(): void;
  31029. apply(gl: WebGLRenderingContext): void;
  31030. }
  31031. }
  31032. declare module "babylonjs/States/stencilState" {
  31033. /**
  31034. * @hidden
  31035. **/
  31036. export class StencilState {
  31037. /** 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 */
  31038. static readonly ALWAYS: number;
  31039. /** Passed to stencilOperation to specify that stencil value must be kept */
  31040. static readonly KEEP: number;
  31041. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31042. static readonly REPLACE: number;
  31043. private _isStencilTestDirty;
  31044. private _isStencilMaskDirty;
  31045. private _isStencilFuncDirty;
  31046. private _isStencilOpDirty;
  31047. private _stencilTest;
  31048. private _stencilMask;
  31049. private _stencilFunc;
  31050. private _stencilFuncRef;
  31051. private _stencilFuncMask;
  31052. private _stencilOpStencilFail;
  31053. private _stencilOpDepthFail;
  31054. private _stencilOpStencilDepthPass;
  31055. readonly isDirty: boolean;
  31056. stencilFunc: number;
  31057. stencilFuncRef: number;
  31058. stencilFuncMask: number;
  31059. stencilOpStencilFail: number;
  31060. stencilOpDepthFail: number;
  31061. stencilOpStencilDepthPass: number;
  31062. stencilMask: number;
  31063. stencilTest: boolean;
  31064. constructor();
  31065. reset(): void;
  31066. apply(gl: WebGLRenderingContext): void;
  31067. }
  31068. }
  31069. declare module "babylonjs/States/alphaCullingState" {
  31070. /**
  31071. * @hidden
  31072. **/
  31073. export class AlphaState {
  31074. private _isAlphaBlendDirty;
  31075. private _isBlendFunctionParametersDirty;
  31076. private _isBlendEquationParametersDirty;
  31077. private _isBlendConstantsDirty;
  31078. private _alphaBlend;
  31079. private _blendFunctionParameters;
  31080. private _blendEquationParameters;
  31081. private _blendConstants;
  31082. /**
  31083. * Initializes the state.
  31084. */
  31085. constructor();
  31086. readonly isDirty: boolean;
  31087. alphaBlend: boolean;
  31088. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31089. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31090. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31091. reset(): void;
  31092. apply(gl: WebGLRenderingContext): void;
  31093. }
  31094. }
  31095. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31096. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31097. /** @hidden */
  31098. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31099. attributeProcessor(attribute: string): string;
  31100. varyingProcessor(varying: string, isFragment: boolean): string;
  31101. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31102. }
  31103. }
  31104. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31105. /**
  31106. * Interface for attribute information associated with buffer instanciation
  31107. */
  31108. export interface InstancingAttributeInfo {
  31109. /**
  31110. * Name of the GLSL attribute
  31111. * if attribute index is not specified, this is used to retrieve the index from the effect
  31112. */
  31113. attributeName: string;
  31114. /**
  31115. * Index/offset of the attribute in the vertex shader
  31116. * if not specified, this will be computes from the name.
  31117. */
  31118. index?: number;
  31119. /**
  31120. * size of the attribute, 1, 2, 3 or 4
  31121. */
  31122. attributeSize: number;
  31123. /**
  31124. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31125. */
  31126. offset: number;
  31127. /**
  31128. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31129. * default to 1
  31130. */
  31131. divisor?: number;
  31132. /**
  31133. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31134. * default is FLOAT
  31135. */
  31136. attributeType?: number;
  31137. /**
  31138. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31139. */
  31140. normalized?: boolean;
  31141. }
  31142. }
  31143. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31145. import { Nullable } from "babylonjs/types";
  31146. module "babylonjs/Engines/thinEngine" {
  31147. interface ThinEngine {
  31148. /**
  31149. * Update a video texture
  31150. * @param texture defines the texture to update
  31151. * @param video defines the video element to use
  31152. * @param invertY defines if data must be stored with Y axis inverted
  31153. */
  31154. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31155. }
  31156. }
  31157. }
  31158. declare module "babylonjs/Materials/Textures/videoTexture" {
  31159. import { Observable } from "babylonjs/Misc/observable";
  31160. import { Nullable } from "babylonjs/types";
  31161. import { Scene } from "babylonjs/scene";
  31162. import { Texture } from "babylonjs/Materials/Textures/texture";
  31163. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31164. /**
  31165. * Settings for finer control over video usage
  31166. */
  31167. export interface VideoTextureSettings {
  31168. /**
  31169. * Applies `autoplay` to video, if specified
  31170. */
  31171. autoPlay?: boolean;
  31172. /**
  31173. * Applies `loop` to video, if specified
  31174. */
  31175. loop?: boolean;
  31176. /**
  31177. * Automatically updates internal texture from video at every frame in the render loop
  31178. */
  31179. autoUpdateTexture: boolean;
  31180. /**
  31181. * Image src displayed during the video loading or until the user interacts with the video.
  31182. */
  31183. poster?: string;
  31184. }
  31185. /**
  31186. * If you want to display a video in your scene, this is the special texture for that.
  31187. * This special texture works similar to other textures, with the exception of a few parameters.
  31188. * @see https://doc.babylonjs.com/how_to/video_texture
  31189. */
  31190. export class VideoTexture extends Texture {
  31191. /**
  31192. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31193. */
  31194. readonly autoUpdateTexture: boolean;
  31195. /**
  31196. * The video instance used by the texture internally
  31197. */
  31198. readonly video: HTMLVideoElement;
  31199. private _onUserActionRequestedObservable;
  31200. /**
  31201. * Event triggerd when a dom action is required by the user to play the video.
  31202. * This happens due to recent changes in browser policies preventing video to auto start.
  31203. */
  31204. readonly onUserActionRequestedObservable: Observable<Texture>;
  31205. private _generateMipMaps;
  31206. private _engine;
  31207. private _stillImageCaptured;
  31208. private _displayingPosterTexture;
  31209. private _settings;
  31210. private _createInternalTextureOnEvent;
  31211. private _frameId;
  31212. /**
  31213. * Creates a video texture.
  31214. * If you want to display a video in your scene, this is the special texture for that.
  31215. * This special texture works similar to other textures, with the exception of a few parameters.
  31216. * @see https://doc.babylonjs.com/how_to/video_texture
  31217. * @param name optional name, will detect from video source, if not defined
  31218. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31219. * @param scene is obviously the current scene.
  31220. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31221. * @param invertY is false by default but can be used to invert video on Y axis
  31222. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31223. * @param settings allows finer control over video usage
  31224. */
  31225. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31226. private _getName;
  31227. private _getVideo;
  31228. private _createInternalTexture;
  31229. private reset;
  31230. /**
  31231. * @hidden Internal method to initiate `update`.
  31232. */
  31233. _rebuild(): void;
  31234. /**
  31235. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31236. */
  31237. update(): void;
  31238. /**
  31239. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31240. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31241. */
  31242. updateTexture(isVisible: boolean): void;
  31243. protected _updateInternalTexture: () => void;
  31244. /**
  31245. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31246. * @param url New url.
  31247. */
  31248. updateURL(url: string): void;
  31249. /**
  31250. * Dispose the texture and release its associated resources.
  31251. */
  31252. dispose(): void;
  31253. /**
  31254. * Creates a video texture straight from a stream.
  31255. * @param scene Define the scene the texture should be created in
  31256. * @param stream Define the stream the texture should be created from
  31257. * @returns The created video texture as a promise
  31258. */
  31259. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31260. /**
  31261. * Creates a video texture straight from your WebCam video feed.
  31262. * @param scene Define the scene the texture should be created in
  31263. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31264. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31265. * @returns The created video texture as a promise
  31266. */
  31267. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31268. minWidth: number;
  31269. maxWidth: number;
  31270. minHeight: number;
  31271. maxHeight: number;
  31272. deviceId: string;
  31273. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31274. /**
  31275. * Creates a video texture straight from your WebCam video feed.
  31276. * @param scene Define the scene the texture should be created in
  31277. * @param onReady Define a callback to triggered once the texture will be ready
  31278. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31279. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31280. */
  31281. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31282. minWidth: number;
  31283. maxWidth: number;
  31284. minHeight: number;
  31285. maxHeight: number;
  31286. deviceId: string;
  31287. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31288. }
  31289. }
  31290. declare module "babylonjs/Engines/thinEngine" {
  31291. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31292. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31293. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31294. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31295. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31296. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31297. import { Observable } from "babylonjs/Misc/observable";
  31298. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31299. import { StencilState } from "babylonjs/States/stencilState";
  31300. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31302. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31303. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31304. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31305. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31306. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31307. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31308. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31310. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31311. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31312. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31313. /**
  31314. * Defines the interface used by objects working like Scene
  31315. * @hidden
  31316. */
  31317. interface ISceneLike {
  31318. _addPendingData(data: any): void;
  31319. _removePendingData(data: any): void;
  31320. offlineProvider: IOfflineProvider;
  31321. }
  31322. /** Interface defining initialization parameters for Engine class */
  31323. export interface EngineOptions extends WebGLContextAttributes {
  31324. /**
  31325. * Defines if the engine should no exceed a specified device ratio
  31326. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31327. */
  31328. limitDeviceRatio?: number;
  31329. /**
  31330. * Defines if webvr should be enabled automatically
  31331. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31332. */
  31333. autoEnableWebVR?: boolean;
  31334. /**
  31335. * Defines if webgl2 should be turned off even if supported
  31336. * @see http://doc.babylonjs.com/features/webgl2
  31337. */
  31338. disableWebGL2Support?: boolean;
  31339. /**
  31340. * Defines if webaudio should be initialized as well
  31341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31342. */
  31343. audioEngine?: boolean;
  31344. /**
  31345. * Defines if animations should run using a deterministic lock step
  31346. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31347. */
  31348. deterministicLockstep?: boolean;
  31349. /** Defines the maximum steps to use with deterministic lock step mode */
  31350. lockstepMaxSteps?: number;
  31351. /** Defines the seconds between each deterministic lock step */
  31352. timeStep?: number;
  31353. /**
  31354. * Defines that engine should ignore context lost events
  31355. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31356. */
  31357. doNotHandleContextLost?: boolean;
  31358. /**
  31359. * Defines that engine should ignore modifying touch action attribute and style
  31360. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31361. */
  31362. doNotHandleTouchAction?: boolean;
  31363. /**
  31364. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31365. */
  31366. useHighPrecisionFloats?: boolean;
  31367. }
  31368. /**
  31369. * The base engine class (root of all engines)
  31370. */
  31371. export class ThinEngine {
  31372. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31373. static ExceptionList: ({
  31374. key: string;
  31375. capture: string;
  31376. captureConstraint: number;
  31377. targets: string[];
  31378. } | {
  31379. key: string;
  31380. capture: null;
  31381. captureConstraint: null;
  31382. targets: string[];
  31383. })[];
  31384. /** @hidden */
  31385. static _TextureLoaders: IInternalTextureLoader[];
  31386. /**
  31387. * Returns the current npm package of the sdk
  31388. */
  31389. static readonly NpmPackage: string;
  31390. /**
  31391. * Returns the current version of the framework
  31392. */
  31393. static readonly Version: string;
  31394. /**
  31395. * Returns a string describing the current engine
  31396. */
  31397. readonly description: string;
  31398. /**
  31399. * Gets or sets the epsilon value used by collision engine
  31400. */
  31401. static CollisionsEpsilon: number;
  31402. /**
  31403. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31404. */
  31405. static ShadersRepository: string;
  31406. /**
  31407. * Gets or sets the textures that the engine should not attempt to load as compressed
  31408. */
  31409. protected _excludedCompressedTextures: string[];
  31410. /**
  31411. * Filters the compressed texture formats to only include
  31412. * files that are not included in the skippable list
  31413. *
  31414. * @param url the current extension
  31415. * @param textureFormatInUse the current compressed texture format
  31416. * @returns "format" string
  31417. */
  31418. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31419. /** @hidden */
  31420. _shaderProcessor: IShaderProcessor;
  31421. /**
  31422. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31423. */
  31424. forcePOTTextures: boolean;
  31425. /**
  31426. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31427. */
  31428. isFullscreen: boolean;
  31429. /**
  31430. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31431. */
  31432. cullBackFaces: boolean;
  31433. /**
  31434. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31435. */
  31436. renderEvenInBackground: boolean;
  31437. /**
  31438. * Gets or sets a boolean indicating that cache can be kept between frames
  31439. */
  31440. preventCacheWipeBetweenFrames: boolean;
  31441. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31442. validateShaderPrograms: boolean;
  31443. /**
  31444. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31445. * This can provide greater z depth for distant objects.
  31446. */
  31447. useReverseDepthBuffer: boolean;
  31448. /**
  31449. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31450. */
  31451. disableUniformBuffers: boolean;
  31452. /** @hidden */
  31453. _uniformBuffers: UniformBuffer[];
  31454. /**
  31455. * Gets a boolean indicating that the engine supports uniform buffers
  31456. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31457. */
  31458. readonly supportsUniformBuffers: boolean;
  31459. /** @hidden */
  31460. _gl: WebGLRenderingContext;
  31461. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31462. protected _windowIsBackground: boolean;
  31463. protected _webGLVersion: number;
  31464. protected _creationOptions: EngineOptions;
  31465. protected _highPrecisionShadersAllowed: boolean;
  31466. /** @hidden */
  31467. readonly _shouldUseHighPrecisionShader: boolean;
  31468. /**
  31469. * Gets a boolean indicating that only power of 2 textures are supported
  31470. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31471. */
  31472. readonly needPOTTextures: boolean;
  31473. /** @hidden */
  31474. _badOS: boolean;
  31475. /** @hidden */
  31476. _badDesktopOS: boolean;
  31477. private _hardwareScalingLevel;
  31478. /** @hidden */
  31479. _caps: EngineCapabilities;
  31480. private _isStencilEnable;
  31481. private _glVersion;
  31482. private _glRenderer;
  31483. private _glVendor;
  31484. /** @hidden */
  31485. _videoTextureSupported: boolean;
  31486. protected _renderingQueueLaunched: boolean;
  31487. protected _activeRenderLoops: (() => void)[];
  31488. /**
  31489. * Observable signaled when a context lost event is raised
  31490. */
  31491. onContextLostObservable: Observable<ThinEngine>;
  31492. /**
  31493. * Observable signaled when a context restored event is raised
  31494. */
  31495. onContextRestoredObservable: Observable<ThinEngine>;
  31496. private _onContextLost;
  31497. private _onContextRestored;
  31498. protected _contextWasLost: boolean;
  31499. /** @hidden */
  31500. _doNotHandleContextLost: boolean;
  31501. /**
  31502. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31504. */
  31505. doNotHandleContextLost: boolean;
  31506. /**
  31507. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31508. */
  31509. disableVertexArrayObjects: boolean;
  31510. /** @hidden */
  31511. protected _colorWrite: boolean;
  31512. /** @hidden */
  31513. protected _colorWriteChanged: boolean;
  31514. /** @hidden */
  31515. protected _depthCullingState: DepthCullingState;
  31516. /** @hidden */
  31517. protected _stencilState: StencilState;
  31518. /** @hidden */
  31519. _alphaState: AlphaState;
  31520. /** @hidden */
  31521. _alphaMode: number;
  31522. /** @hidden */
  31523. _alphaEquation: number;
  31524. /** @hidden */
  31525. _internalTexturesCache: InternalTexture[];
  31526. /** @hidden */
  31527. protected _activeChannel: number;
  31528. private _currentTextureChannel;
  31529. /** @hidden */
  31530. protected _boundTexturesCache: {
  31531. [key: string]: Nullable<InternalTexture>;
  31532. };
  31533. /** @hidden */
  31534. protected _currentEffect: Nullable<Effect>;
  31535. /** @hidden */
  31536. protected _currentProgram: Nullable<WebGLProgram>;
  31537. private _compiledEffects;
  31538. private _vertexAttribArraysEnabled;
  31539. /** @hidden */
  31540. protected _cachedViewport: Nullable<IViewportLike>;
  31541. private _cachedVertexArrayObject;
  31542. /** @hidden */
  31543. protected _cachedVertexBuffers: any;
  31544. /** @hidden */
  31545. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31546. /** @hidden */
  31547. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31548. /** @hidden */
  31549. _currentRenderTarget: Nullable<InternalTexture>;
  31550. private _uintIndicesCurrentlySet;
  31551. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31552. /** @hidden */
  31553. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31554. private _currentBufferPointers;
  31555. private _currentInstanceLocations;
  31556. private _currentInstanceBuffers;
  31557. private _textureUnits;
  31558. /** @hidden */
  31559. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31560. /** @hidden */
  31561. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31562. /** @hidden */
  31563. _boundRenderFunction: any;
  31564. private _vaoRecordInProgress;
  31565. private _mustWipeVertexAttributes;
  31566. private _emptyTexture;
  31567. private _emptyCubeTexture;
  31568. private _emptyTexture3D;
  31569. private _emptyTexture2DArray;
  31570. /** @hidden */
  31571. _frameHandler: number;
  31572. private _nextFreeTextureSlots;
  31573. private _maxSimultaneousTextures;
  31574. private _activeRequests;
  31575. protected _texturesSupported: string[];
  31576. /** @hidden */
  31577. _textureFormatInUse: Nullable<string>;
  31578. protected readonly _supportsHardwareTextureRescaling: boolean;
  31579. /**
  31580. * Gets the list of texture formats supported
  31581. */
  31582. readonly texturesSupported: Array<string>;
  31583. /**
  31584. * Gets the list of texture formats in use
  31585. */
  31586. readonly textureFormatInUse: Nullable<string>;
  31587. /**
  31588. * Gets the current viewport
  31589. */
  31590. readonly currentViewport: Nullable<IViewportLike>;
  31591. /**
  31592. * Gets the default empty texture
  31593. */
  31594. readonly emptyTexture: InternalTexture;
  31595. /**
  31596. * Gets the default empty 3D texture
  31597. */
  31598. readonly emptyTexture3D: InternalTexture;
  31599. /**
  31600. * Gets the default empty 2D array texture
  31601. */
  31602. readonly emptyTexture2DArray: InternalTexture;
  31603. /**
  31604. * Gets the default empty cube texture
  31605. */
  31606. readonly emptyCubeTexture: InternalTexture;
  31607. /**
  31608. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31609. */
  31610. readonly premultipliedAlpha: boolean;
  31611. /**
  31612. * Observable event triggered before each texture is initialized
  31613. */
  31614. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31615. /**
  31616. * Creates a new engine
  31617. * @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
  31618. * @param antialias defines enable antialiasing (default: false)
  31619. * @param options defines further options to be sent to the getContext() function
  31620. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31621. */
  31622. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31623. private _rebuildInternalTextures;
  31624. private _rebuildEffects;
  31625. /**
  31626. * Gets a boolean indicating if all created effects are ready
  31627. * @returns true if all effects are ready
  31628. */
  31629. areAllEffectsReady(): boolean;
  31630. protected _rebuildBuffers(): void;
  31631. private _initGLContext;
  31632. /**
  31633. * Gets version of the current webGL context
  31634. */
  31635. readonly webGLVersion: number;
  31636. /**
  31637. * Gets a string idenfifying the name of the class
  31638. * @returns "Engine" string
  31639. */
  31640. getClassName(): string;
  31641. /**
  31642. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31643. */
  31644. readonly isStencilEnable: boolean;
  31645. /** @hidden */
  31646. _prepareWorkingCanvas(): void;
  31647. /**
  31648. * Reset the texture cache to empty state
  31649. */
  31650. resetTextureCache(): void;
  31651. /**
  31652. * Gets an object containing information about the current webGL context
  31653. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31654. */
  31655. getGlInfo(): {
  31656. vendor: string;
  31657. renderer: string;
  31658. version: string;
  31659. };
  31660. /**
  31661. * Defines the hardware scaling level.
  31662. * By default the hardware scaling level is computed from the window device ratio.
  31663. * 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.
  31664. * @param level defines the level to use
  31665. */
  31666. setHardwareScalingLevel(level: number): void;
  31667. /**
  31668. * Gets the current hardware scaling level.
  31669. * By default the hardware scaling level is computed from the window device ratio.
  31670. * 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.
  31671. * @returns a number indicating the current hardware scaling level
  31672. */
  31673. getHardwareScalingLevel(): number;
  31674. /**
  31675. * Gets the list of loaded textures
  31676. * @returns an array containing all loaded textures
  31677. */
  31678. getLoadedTexturesCache(): InternalTexture[];
  31679. /**
  31680. * Gets the object containing all engine capabilities
  31681. * @returns the EngineCapabilities object
  31682. */
  31683. getCaps(): EngineCapabilities;
  31684. /**
  31685. * stop executing a render loop function and remove it from the execution array
  31686. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31687. */
  31688. stopRenderLoop(renderFunction?: () => void): void;
  31689. /** @hidden */
  31690. _renderLoop(): void;
  31691. /**
  31692. * Gets the HTML canvas attached with the current webGL context
  31693. * @returns a HTML canvas
  31694. */
  31695. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31696. /**
  31697. * Gets host window
  31698. * @returns the host window object
  31699. */
  31700. getHostWindow(): Nullable<Window>;
  31701. /**
  31702. * Gets the current render width
  31703. * @param useScreen defines if screen size must be used (or the current render target if any)
  31704. * @returns a number defining the current render width
  31705. */
  31706. getRenderWidth(useScreen?: boolean): number;
  31707. /**
  31708. * Gets the current render height
  31709. * @param useScreen defines if screen size must be used (or the current render target if any)
  31710. * @returns a number defining the current render height
  31711. */
  31712. getRenderHeight(useScreen?: boolean): number;
  31713. /**
  31714. * Can be used to override the current requestAnimationFrame requester.
  31715. * @hidden
  31716. */
  31717. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31718. /**
  31719. * Register and execute a render loop. The engine can have more than one render function
  31720. * @param renderFunction defines the function to continuously execute
  31721. */
  31722. runRenderLoop(renderFunction: () => void): void;
  31723. /**
  31724. * Clear the current render buffer or the current render target (if any is set up)
  31725. * @param color defines the color to use
  31726. * @param backBuffer defines if the back buffer must be cleared
  31727. * @param depth defines if the depth buffer must be cleared
  31728. * @param stencil defines if the stencil buffer must be cleared
  31729. */
  31730. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31731. private _viewportCached;
  31732. /** @hidden */
  31733. _viewport(x: number, y: number, width: number, height: number): void;
  31734. /**
  31735. * Set the WebGL's viewport
  31736. * @param viewport defines the viewport element to be used
  31737. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31738. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31739. */
  31740. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31741. /**
  31742. * Begin a new frame
  31743. */
  31744. beginFrame(): void;
  31745. /**
  31746. * Enf the current frame
  31747. */
  31748. endFrame(): void;
  31749. /**
  31750. * Resize the view according to the canvas' size
  31751. */
  31752. resize(): void;
  31753. /**
  31754. * Force a specific size of the canvas
  31755. * @param width defines the new canvas' width
  31756. * @param height defines the new canvas' height
  31757. */
  31758. setSize(width: number, height: number): void;
  31759. /**
  31760. * Binds the frame buffer to the specified texture.
  31761. * @param texture The texture to render to or null for the default canvas
  31762. * @param faceIndex The face of the texture to render to in case of cube texture
  31763. * @param requiredWidth The width of the target to render to
  31764. * @param requiredHeight The height of the target to render to
  31765. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31766. * @param depthStencilTexture The depth stencil texture to use to render
  31767. * @param lodLevel defines le lod level to bind to the frame buffer
  31768. */
  31769. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31770. /** @hidden */
  31771. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31772. /**
  31773. * Unbind the current render target texture from the webGL context
  31774. * @param texture defines the render target texture to unbind
  31775. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31776. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31777. */
  31778. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31779. /**
  31780. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31781. */
  31782. flushFramebuffer(): void;
  31783. /**
  31784. * Unbind the current render target and bind the default framebuffer
  31785. */
  31786. restoreDefaultFramebuffer(): void;
  31787. /** @hidden */
  31788. protected _resetVertexBufferBinding(): void;
  31789. /**
  31790. * Creates a vertex buffer
  31791. * @param data the data for the vertex buffer
  31792. * @returns the new WebGL static buffer
  31793. */
  31794. createVertexBuffer(data: DataArray): DataBuffer;
  31795. private _createVertexBuffer;
  31796. /**
  31797. * Creates a dynamic vertex buffer
  31798. * @param data the data for the dynamic vertex buffer
  31799. * @returns the new WebGL dynamic buffer
  31800. */
  31801. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31802. protected _resetIndexBufferBinding(): void;
  31803. /**
  31804. * Creates a new index buffer
  31805. * @param indices defines the content of the index buffer
  31806. * @param updatable defines if the index buffer must be updatable
  31807. * @returns a new webGL buffer
  31808. */
  31809. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31810. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31811. /**
  31812. * Bind a webGL buffer to the webGL context
  31813. * @param buffer defines the buffer to bind
  31814. */
  31815. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31816. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31817. private bindBuffer;
  31818. /**
  31819. * update the bound buffer with the given data
  31820. * @param data defines the data to update
  31821. */
  31822. updateArrayBuffer(data: Float32Array): void;
  31823. private _vertexAttribPointer;
  31824. private _bindIndexBufferWithCache;
  31825. private _bindVertexBuffersAttributes;
  31826. /**
  31827. * Records a vertex array object
  31828. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31829. * @param vertexBuffers defines the list of vertex buffers to store
  31830. * @param indexBuffer defines the index buffer to store
  31831. * @param effect defines the effect to store
  31832. * @returns the new vertex array object
  31833. */
  31834. recordVertexArrayObject(vertexBuffers: {
  31835. [key: string]: VertexBuffer;
  31836. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31837. /**
  31838. * Bind a specific vertex array object
  31839. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31840. * @param vertexArrayObject defines the vertex array object to bind
  31841. * @param indexBuffer defines the index buffer to bind
  31842. */
  31843. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31844. /**
  31845. * Bind webGl buffers directly to the webGL context
  31846. * @param vertexBuffer defines the vertex buffer to bind
  31847. * @param indexBuffer defines the index buffer to bind
  31848. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31849. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31850. * @param effect defines the effect associated with the vertex buffer
  31851. */
  31852. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31853. private _unbindVertexArrayObject;
  31854. /**
  31855. * Bind a list of vertex buffers to the webGL context
  31856. * @param vertexBuffers defines the list of vertex buffers to bind
  31857. * @param indexBuffer defines the index buffer to bind
  31858. * @param effect defines the effect associated with the vertex buffers
  31859. */
  31860. bindBuffers(vertexBuffers: {
  31861. [key: string]: Nullable<VertexBuffer>;
  31862. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31863. /**
  31864. * Unbind all instance attributes
  31865. */
  31866. unbindInstanceAttributes(): void;
  31867. /**
  31868. * Release and free the memory of a vertex array object
  31869. * @param vao defines the vertex array object to delete
  31870. */
  31871. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31872. /** @hidden */
  31873. _releaseBuffer(buffer: DataBuffer): boolean;
  31874. protected _deleteBuffer(buffer: DataBuffer): void;
  31875. /**
  31876. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31877. * @param instancesBuffer defines the webGL buffer to update and bind
  31878. * @param data defines the data to store in the buffer
  31879. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31880. */
  31881. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31882. /**
  31883. * Bind the content of a webGL buffer used with instanciation
  31884. * @param instancesBuffer defines the webGL buffer to bind
  31885. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31886. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31887. */
  31888. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31889. /**
  31890. * Disable the instance attribute corresponding to the name in parameter
  31891. * @param name defines the name of the attribute to disable
  31892. */
  31893. disableInstanceAttributeByName(name: string): void;
  31894. /**
  31895. * Disable the instance attribute corresponding to the location in parameter
  31896. * @param attributeLocation defines the attribute location of the attribute to disable
  31897. */
  31898. disableInstanceAttribute(attributeLocation: number): void;
  31899. /**
  31900. * Disable the attribute corresponding to the location in parameter
  31901. * @param attributeLocation defines the attribute location of the attribute to disable
  31902. */
  31903. disableAttributeByIndex(attributeLocation: number): void;
  31904. /**
  31905. * Send a draw order
  31906. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31907. * @param indexStart defines the starting index
  31908. * @param indexCount defines the number of index to draw
  31909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31910. */
  31911. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31912. /**
  31913. * Draw a list of points
  31914. * @param verticesStart defines the index of first vertex to draw
  31915. * @param verticesCount defines the count of vertices to draw
  31916. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31917. */
  31918. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31919. /**
  31920. * Draw a list of unindexed primitives
  31921. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31922. * @param verticesStart defines the index of first vertex to draw
  31923. * @param verticesCount defines the count of vertices to draw
  31924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31925. */
  31926. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31927. /**
  31928. * Draw a list of indexed primitives
  31929. * @param fillMode defines the primitive to use
  31930. * @param indexStart defines the starting index
  31931. * @param indexCount defines the number of index to draw
  31932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31933. */
  31934. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31935. /**
  31936. * Draw a list of unindexed primitives
  31937. * @param fillMode defines the primitive to use
  31938. * @param verticesStart defines the index of first vertex to draw
  31939. * @param verticesCount defines the count of vertices to draw
  31940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31941. */
  31942. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31943. private _drawMode;
  31944. /** @hidden */
  31945. protected _reportDrawCall(): void;
  31946. /** @hidden */
  31947. _releaseEffect(effect: Effect): void;
  31948. /** @hidden */
  31949. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31950. /**
  31951. * Create a new effect (used to store vertex/fragment shaders)
  31952. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31953. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31954. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31955. * @param samplers defines an array of string used to represent textures
  31956. * @param defines defines the string containing the defines to use to compile the shaders
  31957. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31958. * @param onCompiled defines a function to call when the effect creation is successful
  31959. * @param onError defines a function to call when the effect creation has failed
  31960. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31961. * @returns the new Effect
  31962. */
  31963. 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;
  31964. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31965. private _compileShader;
  31966. private _compileRawShader;
  31967. /**
  31968. * Directly creates a webGL program
  31969. * @param pipelineContext defines the pipeline context to attach to
  31970. * @param vertexCode defines the vertex shader code to use
  31971. * @param fragmentCode defines the fragment shader code to use
  31972. * @param context defines the webGL context to use (if not set, the current one will be used)
  31973. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31974. * @returns the new webGL program
  31975. */
  31976. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31977. /**
  31978. * Creates a webGL program
  31979. * @param pipelineContext defines the pipeline context to attach to
  31980. * @param vertexCode defines the vertex shader code to use
  31981. * @param fragmentCode defines the fragment shader code to use
  31982. * @param defines defines the string containing the defines to use to compile the shaders
  31983. * @param context defines the webGL context to use (if not set, the current one will be used)
  31984. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31985. * @returns the new webGL program
  31986. */
  31987. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31988. /**
  31989. * Creates a new pipeline context
  31990. * @returns the new pipeline
  31991. */
  31992. createPipelineContext(): IPipelineContext;
  31993. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31994. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31995. /** @hidden */
  31996. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31997. /** @hidden */
  31998. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31999. /** @hidden */
  32000. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32001. /**
  32002. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32003. * @param pipelineContext defines the pipeline context to use
  32004. * @param uniformsNames defines the list of uniform names
  32005. * @returns an array of webGL uniform locations
  32006. */
  32007. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32008. /**
  32009. * Gets the lsit of active attributes for a given webGL program
  32010. * @param pipelineContext defines the pipeline context to use
  32011. * @param attributesNames defines the list of attribute names to get
  32012. * @returns an array of indices indicating the offset of each attribute
  32013. */
  32014. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32015. /**
  32016. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32017. * @param effect defines the effect to activate
  32018. */
  32019. enableEffect(effect: Nullable<Effect>): void;
  32020. /**
  32021. * Set the value of an uniform to a number (int)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param value defines the int number to store
  32024. */
  32025. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32026. /**
  32027. * Set the value of an uniform to an array of int32
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of int32 to store
  32030. */
  32031. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of int32 (stored as vec2)
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param array defines the array of int32 to store
  32036. */
  32037. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32038. /**
  32039. * Set the value of an uniform to an array of int32 (stored as vec3)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param array defines the array of int32 to store
  32042. */
  32043. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32044. /**
  32045. * Set the value of an uniform to an array of int32 (stored as vec4)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param array defines the array of int32 to store
  32048. */
  32049. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32050. /**
  32051. * Set the value of an uniform to an array of number
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param array defines the array of number to store
  32054. */
  32055. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32056. /**
  32057. * Set the value of an uniform to an array of number (stored as vec2)
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param array defines the array of number to store
  32060. */
  32061. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32062. /**
  32063. * Set the value of an uniform to an array of number (stored as vec3)
  32064. * @param uniform defines the webGL uniform location where to store the value
  32065. * @param array defines the array of number to store
  32066. */
  32067. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32068. /**
  32069. * Set the value of an uniform to an array of number (stored as vec4)
  32070. * @param uniform defines the webGL uniform location where to store the value
  32071. * @param array defines the array of number to store
  32072. */
  32073. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32074. /**
  32075. * Set the value of an uniform to an array of float32 (stored as matrices)
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param matrices defines the array of float32 to store
  32078. */
  32079. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32080. /**
  32081. * Set the value of an uniform to a matrix (3x3)
  32082. * @param uniform defines the webGL uniform location where to store the value
  32083. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32084. */
  32085. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32086. /**
  32087. * Set the value of an uniform to a matrix (2x2)
  32088. * @param uniform defines the webGL uniform location where to store the value
  32089. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32090. */
  32091. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32092. /**
  32093. * Set the value of an uniform to a number (float)
  32094. * @param uniform defines the webGL uniform location where to store the value
  32095. * @param value defines the float number to store
  32096. */
  32097. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32098. /**
  32099. * Set the value of an uniform to a vec2
  32100. * @param uniform defines the webGL uniform location where to store the value
  32101. * @param x defines the 1st component of the value
  32102. * @param y defines the 2nd component of the value
  32103. */
  32104. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32105. /**
  32106. * Set the value of an uniform to a vec3
  32107. * @param uniform defines the webGL uniform location where to store the value
  32108. * @param x defines the 1st component of the value
  32109. * @param y defines the 2nd component of the value
  32110. * @param z defines the 3rd component of the value
  32111. */
  32112. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32113. /**
  32114. * Set the value of an uniform to a vec4
  32115. * @param uniform defines the webGL uniform location where to store the value
  32116. * @param x defines the 1st component of the value
  32117. * @param y defines the 2nd component of the value
  32118. * @param z defines the 3rd component of the value
  32119. * @param w defines the 4th component of the value
  32120. */
  32121. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32122. /**
  32123. * Apply all cached states (depth, culling, stencil and alpha)
  32124. */
  32125. applyStates(): void;
  32126. /**
  32127. * Enable or disable color writing
  32128. * @param enable defines the state to set
  32129. */
  32130. setColorWrite(enable: boolean): void;
  32131. /**
  32132. * Gets a boolean indicating if color writing is enabled
  32133. * @returns the current color writing state
  32134. */
  32135. getColorWrite(): boolean;
  32136. /**
  32137. * Gets the depth culling state manager
  32138. */
  32139. readonly depthCullingState: DepthCullingState;
  32140. /**
  32141. * Gets the alpha state manager
  32142. */
  32143. readonly alphaState: AlphaState;
  32144. /**
  32145. * Gets the stencil state manager
  32146. */
  32147. readonly stencilState: StencilState;
  32148. /**
  32149. * Clears the list of texture accessible through engine.
  32150. * This can help preventing texture load conflict due to name collision.
  32151. */
  32152. clearInternalTexturesCache(): void;
  32153. /**
  32154. * Force the entire cache to be cleared
  32155. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32156. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32157. */
  32158. wipeCaches(bruteForce?: boolean): void;
  32159. /** @hidden */
  32160. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32161. min: number;
  32162. mag: number;
  32163. };
  32164. /** @hidden */
  32165. _createTexture(): WebGLTexture;
  32166. /**
  32167. * Usually called from Texture.ts.
  32168. * Passed information to create a WebGLTexture
  32169. * @param urlArg defines a value which contains one of the following:
  32170. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32171. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32172. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32173. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32174. * @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)
  32175. * @param scene needed for loading to the correct scene
  32176. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32177. * @param onLoad optional callback to be called upon successful completion
  32178. * @param onError optional callback to be called upon failure
  32179. * @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
  32180. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32181. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32182. * @param forcedExtension defines the extension to use to pick the right loader
  32183. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32184. * @param mimeType defines an optional mime type
  32185. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32186. */
  32187. 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;
  32188. /**
  32189. * @hidden
  32190. */
  32191. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32192. /**
  32193. * Creates a raw texture
  32194. * @param data defines the data to store in the texture
  32195. * @param width defines the width of the texture
  32196. * @param height defines the height of the texture
  32197. * @param format defines the format of the data
  32198. * @param generateMipMaps defines if the engine should generate the mip levels
  32199. * @param invertY defines if data must be stored with Y axis inverted
  32200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32201. * @param compression defines the compression used (null by default)
  32202. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32203. * @returns the raw texture inside an InternalTexture
  32204. */
  32205. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32206. /**
  32207. * Creates a new raw cube texture
  32208. * @param data defines the array of data to use to create each face
  32209. * @param size defines the size of the textures
  32210. * @param format defines the format of the data
  32211. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32212. * @param generateMipMaps defines if the engine should generate the mip levels
  32213. * @param invertY defines if data must be stored with Y axis inverted
  32214. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32215. * @param compression defines the compression used (null by default)
  32216. * @returns the cube texture as an InternalTexture
  32217. */
  32218. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32219. /**
  32220. * Creates a new raw 3D texture
  32221. * @param data defines the data used to create the texture
  32222. * @param width defines the width of the texture
  32223. * @param height defines the height of the texture
  32224. * @param depth defines the depth of the texture
  32225. * @param format defines the format of the texture
  32226. * @param generateMipMaps defines if the engine must generate mip levels
  32227. * @param invertY defines if data must be stored with Y axis inverted
  32228. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32229. * @param compression defines the compressed used (can be null)
  32230. * @param textureType defines the compressed used (can be null)
  32231. * @returns a new raw 3D texture (stored in an InternalTexture)
  32232. */
  32233. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32234. /**
  32235. * Creates a new raw 2D array texture
  32236. * @param data defines the data used to create the texture
  32237. * @param width defines the width of the texture
  32238. * @param height defines the height of the texture
  32239. * @param depth defines the number of layers of the texture
  32240. * @param format defines the format of the texture
  32241. * @param generateMipMaps defines if the engine must generate mip levels
  32242. * @param invertY defines if data must be stored with Y axis inverted
  32243. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32244. * @param compression defines the compressed used (can be null)
  32245. * @param textureType defines the compressed used (can be null)
  32246. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32247. */
  32248. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32249. private _unpackFlipYCached;
  32250. /**
  32251. * In case you are sharing the context with other applications, it might
  32252. * be interested to not cache the unpack flip y state to ensure a consistent
  32253. * value would be set.
  32254. */
  32255. enableUnpackFlipYCached: boolean;
  32256. /** @hidden */
  32257. _unpackFlipY(value: boolean): void;
  32258. /** @hidden */
  32259. _getUnpackAlignement(): number;
  32260. private _getTextureTarget;
  32261. /**
  32262. * Update the sampling mode of a given texture
  32263. * @param samplingMode defines the required sampling mode
  32264. * @param texture defines the texture to update
  32265. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32266. */
  32267. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32268. /**
  32269. * Update the sampling mode of a given texture
  32270. * @param texture defines the texture to update
  32271. * @param wrapU defines the texture wrap mode of the u coordinates
  32272. * @param wrapV defines the texture wrap mode of the v coordinates
  32273. * @param wrapR defines the texture wrap mode of the r coordinates
  32274. */
  32275. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32276. /** @hidden */
  32277. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32278. width: number;
  32279. height: number;
  32280. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32281. /** @hidden */
  32282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32283. /** @hidden */
  32284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32285. /** @hidden */
  32286. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32287. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32288. private _prepareWebGLTexture;
  32289. /** @hidden */
  32290. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32291. private _getDepthStencilBuffer;
  32292. /** @hidden */
  32293. _releaseFramebufferObjects(texture: InternalTexture): void;
  32294. /** @hidden */
  32295. _releaseTexture(texture: InternalTexture): void;
  32296. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32297. protected _setProgram(program: WebGLProgram): void;
  32298. protected _boundUniforms: {
  32299. [key: number]: WebGLUniformLocation;
  32300. };
  32301. /**
  32302. * Binds an effect to the webGL context
  32303. * @param effect defines the effect to bind
  32304. */
  32305. bindSamplers(effect: Effect): void;
  32306. private _activateCurrentTexture;
  32307. /** @hidden */
  32308. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32309. /** @hidden */
  32310. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32311. /**
  32312. * Unbind all textures from the webGL context
  32313. */
  32314. unbindAllTextures(): void;
  32315. /**
  32316. * Sets a texture to the according uniform.
  32317. * @param channel The texture channel
  32318. * @param uniform The uniform to set
  32319. * @param texture The texture to apply
  32320. */
  32321. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32322. private _bindSamplerUniformToChannel;
  32323. private _getTextureWrapMode;
  32324. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32325. /**
  32326. * Sets an array of texture to the webGL context
  32327. * @param channel defines the channel where the texture array must be set
  32328. * @param uniform defines the associated uniform location
  32329. * @param textures defines the array of textures to bind
  32330. */
  32331. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32332. /** @hidden */
  32333. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32334. private _setTextureParameterFloat;
  32335. private _setTextureParameterInteger;
  32336. /**
  32337. * Unbind all vertex attributes from the webGL context
  32338. */
  32339. unbindAllAttributes(): void;
  32340. /**
  32341. * 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
  32342. */
  32343. releaseEffects(): void;
  32344. /**
  32345. * Dispose and release all associated resources
  32346. */
  32347. dispose(): void;
  32348. /**
  32349. * Attach a new callback raised when context lost event is fired
  32350. * @param callback defines the callback to call
  32351. */
  32352. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32353. /**
  32354. * Attach a new callback raised when context restored event is fired
  32355. * @param callback defines the callback to call
  32356. */
  32357. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32358. /**
  32359. * Get the current error code of the webGL context
  32360. * @returns the error code
  32361. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32362. */
  32363. getError(): number;
  32364. private _canRenderToFloatFramebuffer;
  32365. private _canRenderToHalfFloatFramebuffer;
  32366. private _canRenderToFramebuffer;
  32367. /** @hidden */
  32368. _getWebGLTextureType(type: number): number;
  32369. /** @hidden */
  32370. _getInternalFormat(format: number): number;
  32371. /** @hidden */
  32372. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32373. /** @hidden */
  32374. _getRGBAMultiSampleBufferFormat(type: number): number;
  32375. /** @hidden */
  32376. _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;
  32377. /**
  32378. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32379. * @param x defines the x coordinate of the rectangle where pixels must be read
  32380. * @param y defines the y coordinate of the rectangle where pixels must be read
  32381. * @param width defines the width of the rectangle where pixels must be read
  32382. * @param height defines the height of the rectangle where pixels must be read
  32383. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32384. * @returns a Uint8Array containing RGBA colors
  32385. */
  32386. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32387. /**
  32388. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32389. * @returns true if the engine can be created
  32390. * @ignorenaming
  32391. */
  32392. static isSupported(): boolean;
  32393. /**
  32394. * Find the next highest power of two.
  32395. * @param x Number to start search from.
  32396. * @return Next highest power of two.
  32397. */
  32398. static CeilingPOT(x: number): number;
  32399. /**
  32400. * Find the next lowest power of two.
  32401. * @param x Number to start search from.
  32402. * @return Next lowest power of two.
  32403. */
  32404. static FloorPOT(x: number): number;
  32405. /**
  32406. * Find the nearest power of two.
  32407. * @param x Number to start search from.
  32408. * @return Next nearest power of two.
  32409. */
  32410. static NearestPOT(x: number): number;
  32411. /**
  32412. * Get the closest exponent of two
  32413. * @param value defines the value to approximate
  32414. * @param max defines the maximum value to return
  32415. * @param mode defines how to define the closest value
  32416. * @returns closest exponent of two of the given value
  32417. */
  32418. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32419. /**
  32420. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32421. * @param func - the function to be called
  32422. * @param requester - the object that will request the next frame. Falls back to window.
  32423. * @returns frame number
  32424. */
  32425. static QueueNewFrame(func: () => void, requester?: any): number;
  32426. /**
  32427. * Gets host document
  32428. * @returns the host document object
  32429. */
  32430. getHostDocument(): Nullable<Document>;
  32431. }
  32432. }
  32433. declare module "babylonjs/Maths/sphericalPolynomial" {
  32434. import { Vector3 } from "babylonjs/Maths/math.vector";
  32435. import { Color3 } from "babylonjs/Maths/math.color";
  32436. /**
  32437. * Class representing spherical harmonics coefficients to the 3rd degree
  32438. */
  32439. export class SphericalHarmonics {
  32440. /**
  32441. * Defines whether or not the harmonics have been prescaled for rendering.
  32442. */
  32443. preScaled: boolean;
  32444. /**
  32445. * The l0,0 coefficients of the spherical harmonics
  32446. */
  32447. l00: Vector3;
  32448. /**
  32449. * The l1,-1 coefficients of the spherical harmonics
  32450. */
  32451. l1_1: Vector3;
  32452. /**
  32453. * The l1,0 coefficients of the spherical harmonics
  32454. */
  32455. l10: Vector3;
  32456. /**
  32457. * The l1,1 coefficients of the spherical harmonics
  32458. */
  32459. l11: Vector3;
  32460. /**
  32461. * The l2,-2 coefficients of the spherical harmonics
  32462. */
  32463. l2_2: Vector3;
  32464. /**
  32465. * The l2,-1 coefficients of the spherical harmonics
  32466. */
  32467. l2_1: Vector3;
  32468. /**
  32469. * The l2,0 coefficients of the spherical harmonics
  32470. */
  32471. l20: Vector3;
  32472. /**
  32473. * The l2,1 coefficients of the spherical harmonics
  32474. */
  32475. l21: Vector3;
  32476. /**
  32477. * The l2,2 coefficients of the spherical harmonics
  32478. */
  32479. l22: Vector3;
  32480. /**
  32481. * Adds a light to the spherical harmonics
  32482. * @param direction the direction of the light
  32483. * @param color the color of the light
  32484. * @param deltaSolidAngle the delta solid angle of the light
  32485. */
  32486. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32487. /**
  32488. * Scales the spherical harmonics by the given amount
  32489. * @param scale the amount to scale
  32490. */
  32491. scaleInPlace(scale: number): void;
  32492. /**
  32493. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32494. *
  32495. * ```
  32496. * E_lm = A_l * L_lm
  32497. * ```
  32498. *
  32499. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32500. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32501. * the scaling factors are given in equation 9.
  32502. */
  32503. convertIncidentRadianceToIrradiance(): void;
  32504. /**
  32505. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32506. *
  32507. * ```
  32508. * L = (1/pi) * E * rho
  32509. * ```
  32510. *
  32511. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32512. */
  32513. convertIrradianceToLambertianRadiance(): void;
  32514. /**
  32515. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32516. * required operations at run time.
  32517. *
  32518. * This is simply done by scaling back the SH with Ylm constants parameter.
  32519. * The trigonometric part being applied by the shader at run time.
  32520. */
  32521. preScaleForRendering(): void;
  32522. /**
  32523. * Constructs a spherical harmonics from an array.
  32524. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32525. * @returns the spherical harmonics
  32526. */
  32527. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32528. /**
  32529. * Gets the spherical harmonics from polynomial
  32530. * @param polynomial the spherical polynomial
  32531. * @returns the spherical harmonics
  32532. */
  32533. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32534. }
  32535. /**
  32536. * Class representing spherical polynomial coefficients to the 3rd degree
  32537. */
  32538. export class SphericalPolynomial {
  32539. private _harmonics;
  32540. /**
  32541. * The spherical harmonics used to create the polynomials.
  32542. */
  32543. readonly preScaledHarmonics: SphericalHarmonics;
  32544. /**
  32545. * The x coefficients of the spherical polynomial
  32546. */
  32547. x: Vector3;
  32548. /**
  32549. * The y coefficients of the spherical polynomial
  32550. */
  32551. y: Vector3;
  32552. /**
  32553. * The z coefficients of the spherical polynomial
  32554. */
  32555. z: Vector3;
  32556. /**
  32557. * The xx coefficients of the spherical polynomial
  32558. */
  32559. xx: Vector3;
  32560. /**
  32561. * The yy coefficients of the spherical polynomial
  32562. */
  32563. yy: Vector3;
  32564. /**
  32565. * The zz coefficients of the spherical polynomial
  32566. */
  32567. zz: Vector3;
  32568. /**
  32569. * The xy coefficients of the spherical polynomial
  32570. */
  32571. xy: Vector3;
  32572. /**
  32573. * The yz coefficients of the spherical polynomial
  32574. */
  32575. yz: Vector3;
  32576. /**
  32577. * The zx coefficients of the spherical polynomial
  32578. */
  32579. zx: Vector3;
  32580. /**
  32581. * Adds an ambient color to the spherical polynomial
  32582. * @param color the color to add
  32583. */
  32584. addAmbient(color: Color3): void;
  32585. /**
  32586. * Scales the spherical polynomial by the given amount
  32587. * @param scale the amount to scale
  32588. */
  32589. scaleInPlace(scale: number): void;
  32590. /**
  32591. * Gets the spherical polynomial from harmonics
  32592. * @param harmonics the spherical harmonics
  32593. * @returns the spherical polynomial
  32594. */
  32595. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32596. /**
  32597. * Constructs a spherical polynomial from an array.
  32598. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32599. * @returns the spherical polynomial
  32600. */
  32601. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32602. }
  32603. }
  32604. declare module "babylonjs/Materials/Textures/internalTexture" {
  32605. import { Observable } from "babylonjs/Misc/observable";
  32606. import { Nullable, int } from "babylonjs/types";
  32607. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32609. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32610. /**
  32611. * Defines the source of the internal texture
  32612. */
  32613. export enum InternalTextureSource {
  32614. /**
  32615. * The source of the texture data is unknown
  32616. */
  32617. Unknown = 0,
  32618. /**
  32619. * Texture data comes from an URL
  32620. */
  32621. Url = 1,
  32622. /**
  32623. * Texture data is only used for temporary storage
  32624. */
  32625. Temp = 2,
  32626. /**
  32627. * Texture data comes from raw data (ArrayBuffer)
  32628. */
  32629. Raw = 3,
  32630. /**
  32631. * Texture content is dynamic (video or dynamic texture)
  32632. */
  32633. Dynamic = 4,
  32634. /**
  32635. * Texture content is generated by rendering to it
  32636. */
  32637. RenderTarget = 5,
  32638. /**
  32639. * Texture content is part of a multi render target process
  32640. */
  32641. MultiRenderTarget = 6,
  32642. /**
  32643. * Texture data comes from a cube data file
  32644. */
  32645. Cube = 7,
  32646. /**
  32647. * Texture data comes from a raw cube data
  32648. */
  32649. CubeRaw = 8,
  32650. /**
  32651. * Texture data come from a prefiltered cube data file
  32652. */
  32653. CubePrefiltered = 9,
  32654. /**
  32655. * Texture content is raw 3D data
  32656. */
  32657. Raw3D = 10,
  32658. /**
  32659. * Texture content is raw 2D array data
  32660. */
  32661. Raw2DArray = 11,
  32662. /**
  32663. * Texture content is a depth texture
  32664. */
  32665. Depth = 12,
  32666. /**
  32667. * Texture data comes from a raw cube data encoded with RGBD
  32668. */
  32669. CubeRawRGBD = 13
  32670. }
  32671. /**
  32672. * Class used to store data associated with WebGL texture data for the engine
  32673. * This class should not be used directly
  32674. */
  32675. export class InternalTexture {
  32676. /** @hidden */
  32677. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32678. /**
  32679. * Defines if the texture is ready
  32680. */
  32681. isReady: boolean;
  32682. /**
  32683. * Defines if the texture is a cube texture
  32684. */
  32685. isCube: boolean;
  32686. /**
  32687. * Defines if the texture contains 3D data
  32688. */
  32689. is3D: boolean;
  32690. /**
  32691. * Defines if the texture contains 2D array data
  32692. */
  32693. is2DArray: boolean;
  32694. /**
  32695. * Defines if the texture contains multiview data
  32696. */
  32697. isMultiview: boolean;
  32698. /**
  32699. * Gets the URL used to load this texture
  32700. */
  32701. url: string;
  32702. /**
  32703. * Gets the sampling mode of the texture
  32704. */
  32705. samplingMode: number;
  32706. /**
  32707. * Gets a boolean indicating if the texture needs mipmaps generation
  32708. */
  32709. generateMipMaps: boolean;
  32710. /**
  32711. * Gets the number of samples used by the texture (WebGL2+ only)
  32712. */
  32713. samples: number;
  32714. /**
  32715. * Gets the type of the texture (int, float...)
  32716. */
  32717. type: number;
  32718. /**
  32719. * Gets the format of the texture (RGB, RGBA...)
  32720. */
  32721. format: number;
  32722. /**
  32723. * Observable called when the texture is loaded
  32724. */
  32725. onLoadedObservable: Observable<InternalTexture>;
  32726. /**
  32727. * Gets the width of the texture
  32728. */
  32729. width: number;
  32730. /**
  32731. * Gets the height of the texture
  32732. */
  32733. height: number;
  32734. /**
  32735. * Gets the depth of the texture
  32736. */
  32737. depth: number;
  32738. /**
  32739. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32740. */
  32741. baseWidth: number;
  32742. /**
  32743. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32744. */
  32745. baseHeight: number;
  32746. /**
  32747. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32748. */
  32749. baseDepth: number;
  32750. /**
  32751. * Gets a boolean indicating if the texture is inverted on Y axis
  32752. */
  32753. invertY: boolean;
  32754. /** @hidden */
  32755. _invertVScale: boolean;
  32756. /** @hidden */
  32757. _associatedChannel: number;
  32758. /** @hidden */
  32759. _source: InternalTextureSource;
  32760. /** @hidden */
  32761. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32762. /** @hidden */
  32763. _bufferView: Nullable<ArrayBufferView>;
  32764. /** @hidden */
  32765. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32766. /** @hidden */
  32767. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32768. /** @hidden */
  32769. _size: number;
  32770. /** @hidden */
  32771. _extension: string;
  32772. /** @hidden */
  32773. _files: Nullable<string[]>;
  32774. /** @hidden */
  32775. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32776. /** @hidden */
  32777. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32778. /** @hidden */
  32779. _framebuffer: Nullable<WebGLFramebuffer>;
  32780. /** @hidden */
  32781. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32782. /** @hidden */
  32783. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32784. /** @hidden */
  32785. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32786. /** @hidden */
  32787. _attachments: Nullable<number[]>;
  32788. /** @hidden */
  32789. _cachedCoordinatesMode: Nullable<number>;
  32790. /** @hidden */
  32791. _cachedWrapU: Nullable<number>;
  32792. /** @hidden */
  32793. _cachedWrapV: Nullable<number>;
  32794. /** @hidden */
  32795. _cachedWrapR: Nullable<number>;
  32796. /** @hidden */
  32797. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32798. /** @hidden */
  32799. _isDisabled: boolean;
  32800. /** @hidden */
  32801. _compression: Nullable<string>;
  32802. /** @hidden */
  32803. _generateStencilBuffer: boolean;
  32804. /** @hidden */
  32805. _generateDepthBuffer: boolean;
  32806. /** @hidden */
  32807. _comparisonFunction: number;
  32808. /** @hidden */
  32809. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32810. /** @hidden */
  32811. _lodGenerationScale: number;
  32812. /** @hidden */
  32813. _lodGenerationOffset: number;
  32814. /** @hidden */
  32815. _colorTextureArray: Nullable<WebGLTexture>;
  32816. /** @hidden */
  32817. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32818. /** @hidden */
  32819. _lodTextureHigh: Nullable<BaseTexture>;
  32820. /** @hidden */
  32821. _lodTextureMid: Nullable<BaseTexture>;
  32822. /** @hidden */
  32823. _lodTextureLow: Nullable<BaseTexture>;
  32824. /** @hidden */
  32825. _isRGBD: boolean;
  32826. /** @hidden */
  32827. _linearSpecularLOD: boolean;
  32828. /** @hidden */
  32829. _irradianceTexture: Nullable<BaseTexture>;
  32830. /** @hidden */
  32831. _webGLTexture: Nullable<WebGLTexture>;
  32832. /** @hidden */
  32833. _references: number;
  32834. private _engine;
  32835. /**
  32836. * Gets the Engine the texture belongs to.
  32837. * @returns The babylon engine
  32838. */
  32839. getEngine(): ThinEngine;
  32840. /**
  32841. * Gets the data source type of the texture
  32842. */
  32843. readonly source: InternalTextureSource;
  32844. /**
  32845. * Creates a new InternalTexture
  32846. * @param engine defines the engine to use
  32847. * @param source defines the type of data that will be used
  32848. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32849. */
  32850. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32851. /**
  32852. * Increments the number of references (ie. the number of Texture that point to it)
  32853. */
  32854. incrementReferences(): void;
  32855. /**
  32856. * Change the size of the texture (not the size of the content)
  32857. * @param width defines the new width
  32858. * @param height defines the new height
  32859. * @param depth defines the new depth (1 by default)
  32860. */
  32861. updateSize(width: int, height: int, depth?: int): void;
  32862. /** @hidden */
  32863. _rebuild(): void;
  32864. /** @hidden */
  32865. _swapAndDie(target: InternalTexture): void;
  32866. /**
  32867. * Dispose the current allocated resources
  32868. */
  32869. dispose(): void;
  32870. }
  32871. }
  32872. declare module "babylonjs/Audio/analyser" {
  32873. import { Scene } from "babylonjs/scene";
  32874. /**
  32875. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32877. */
  32878. export class Analyser {
  32879. /**
  32880. * Gets or sets the smoothing
  32881. * @ignorenaming
  32882. */
  32883. SMOOTHING: number;
  32884. /**
  32885. * Gets or sets the FFT table size
  32886. * @ignorenaming
  32887. */
  32888. FFT_SIZE: number;
  32889. /**
  32890. * Gets or sets the bar graph amplitude
  32891. * @ignorenaming
  32892. */
  32893. BARGRAPHAMPLITUDE: number;
  32894. /**
  32895. * Gets or sets the position of the debug canvas
  32896. * @ignorenaming
  32897. */
  32898. DEBUGCANVASPOS: {
  32899. x: number;
  32900. y: number;
  32901. };
  32902. /**
  32903. * Gets or sets the debug canvas size
  32904. * @ignorenaming
  32905. */
  32906. DEBUGCANVASSIZE: {
  32907. width: number;
  32908. height: number;
  32909. };
  32910. private _byteFreqs;
  32911. private _byteTime;
  32912. private _floatFreqs;
  32913. private _webAudioAnalyser;
  32914. private _debugCanvas;
  32915. private _debugCanvasContext;
  32916. private _scene;
  32917. private _registerFunc;
  32918. private _audioEngine;
  32919. /**
  32920. * Creates a new analyser
  32921. * @param scene defines hosting scene
  32922. */
  32923. constructor(scene: Scene);
  32924. /**
  32925. * Get the number of data values you will have to play with for the visualization
  32926. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32927. * @returns a number
  32928. */
  32929. getFrequencyBinCount(): number;
  32930. /**
  32931. * Gets the current frequency data as a byte array
  32932. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32933. * @returns a Uint8Array
  32934. */
  32935. getByteFrequencyData(): Uint8Array;
  32936. /**
  32937. * Gets the current waveform as a byte array
  32938. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32939. * @returns a Uint8Array
  32940. */
  32941. getByteTimeDomainData(): Uint8Array;
  32942. /**
  32943. * Gets the current frequency data as a float array
  32944. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32945. * @returns a Float32Array
  32946. */
  32947. getFloatFrequencyData(): Float32Array;
  32948. /**
  32949. * Renders the debug canvas
  32950. */
  32951. drawDebugCanvas(): void;
  32952. /**
  32953. * Stops rendering the debug canvas and removes it
  32954. */
  32955. stopDebugCanvas(): void;
  32956. /**
  32957. * Connects two audio nodes
  32958. * @param inputAudioNode defines first node to connect
  32959. * @param outputAudioNode defines second node to connect
  32960. */
  32961. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32962. /**
  32963. * Releases all associated resources
  32964. */
  32965. dispose(): void;
  32966. }
  32967. }
  32968. declare module "babylonjs/Audio/audioEngine" {
  32969. import { IDisposable } from "babylonjs/scene";
  32970. import { Analyser } from "babylonjs/Audio/analyser";
  32971. import { Nullable } from "babylonjs/types";
  32972. import { Observable } from "babylonjs/Misc/observable";
  32973. /**
  32974. * This represents an audio engine and it is responsible
  32975. * to play, synchronize and analyse sounds throughout the application.
  32976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32977. */
  32978. export interface IAudioEngine extends IDisposable {
  32979. /**
  32980. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32981. */
  32982. readonly canUseWebAudio: boolean;
  32983. /**
  32984. * Gets the current AudioContext if available.
  32985. */
  32986. readonly audioContext: Nullable<AudioContext>;
  32987. /**
  32988. * The master gain node defines the global audio volume of your audio engine.
  32989. */
  32990. readonly masterGain: GainNode;
  32991. /**
  32992. * Gets whether or not mp3 are supported by your browser.
  32993. */
  32994. readonly isMP3supported: boolean;
  32995. /**
  32996. * Gets whether or not ogg are supported by your browser.
  32997. */
  32998. readonly isOGGsupported: boolean;
  32999. /**
  33000. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33001. * @ignoreNaming
  33002. */
  33003. WarnedWebAudioUnsupported: boolean;
  33004. /**
  33005. * Defines if the audio engine relies on a custom unlocked button.
  33006. * In this case, the embedded button will not be displayed.
  33007. */
  33008. useCustomUnlockedButton: boolean;
  33009. /**
  33010. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33011. */
  33012. readonly unlocked: boolean;
  33013. /**
  33014. * Event raised when audio has been unlocked on the browser.
  33015. */
  33016. onAudioUnlockedObservable: Observable<AudioEngine>;
  33017. /**
  33018. * Event raised when audio has been locked on the browser.
  33019. */
  33020. onAudioLockedObservable: Observable<AudioEngine>;
  33021. /**
  33022. * Flags the audio engine in Locked state.
  33023. * This happens due to new browser policies preventing audio to autoplay.
  33024. */
  33025. lock(): void;
  33026. /**
  33027. * Unlocks the audio engine once a user action has been done on the dom.
  33028. * This is helpful to resume play once browser policies have been satisfied.
  33029. */
  33030. unlock(): void;
  33031. }
  33032. /**
  33033. * This represents the default audio engine used in babylon.
  33034. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33036. */
  33037. export class AudioEngine implements IAudioEngine {
  33038. private _audioContext;
  33039. private _audioContextInitialized;
  33040. private _muteButton;
  33041. private _hostElement;
  33042. /**
  33043. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33044. */
  33045. canUseWebAudio: boolean;
  33046. /**
  33047. * The master gain node defines the global audio volume of your audio engine.
  33048. */
  33049. masterGain: GainNode;
  33050. /**
  33051. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33052. * @ignoreNaming
  33053. */
  33054. WarnedWebAudioUnsupported: boolean;
  33055. /**
  33056. * Gets whether or not mp3 are supported by your browser.
  33057. */
  33058. isMP3supported: boolean;
  33059. /**
  33060. * Gets whether or not ogg are supported by your browser.
  33061. */
  33062. isOGGsupported: boolean;
  33063. /**
  33064. * Gets whether audio has been unlocked on the device.
  33065. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33066. * a user interaction has happened.
  33067. */
  33068. unlocked: boolean;
  33069. /**
  33070. * Defines if the audio engine relies on a custom unlocked button.
  33071. * In this case, the embedded button will not be displayed.
  33072. */
  33073. useCustomUnlockedButton: boolean;
  33074. /**
  33075. * Event raised when audio has been unlocked on the browser.
  33076. */
  33077. onAudioUnlockedObservable: Observable<AudioEngine>;
  33078. /**
  33079. * Event raised when audio has been locked on the browser.
  33080. */
  33081. onAudioLockedObservable: Observable<AudioEngine>;
  33082. /**
  33083. * Gets the current AudioContext if available.
  33084. */
  33085. readonly audioContext: Nullable<AudioContext>;
  33086. private _connectedAnalyser;
  33087. /**
  33088. * Instantiates a new audio engine.
  33089. *
  33090. * There should be only one per page as some browsers restrict the number
  33091. * of audio contexts you can create.
  33092. * @param hostElement defines the host element where to display the mute icon if necessary
  33093. */
  33094. constructor(hostElement?: Nullable<HTMLElement>);
  33095. /**
  33096. * Flags the audio engine in Locked state.
  33097. * This happens due to new browser policies preventing audio to autoplay.
  33098. */
  33099. lock(): void;
  33100. /**
  33101. * Unlocks the audio engine once a user action has been done on the dom.
  33102. * This is helpful to resume play once browser policies have been satisfied.
  33103. */
  33104. unlock(): void;
  33105. private _resumeAudioContext;
  33106. private _initializeAudioContext;
  33107. private _tryToRun;
  33108. private _triggerRunningState;
  33109. private _triggerSuspendedState;
  33110. private _displayMuteButton;
  33111. private _moveButtonToTopLeft;
  33112. private _onResize;
  33113. private _hideMuteButton;
  33114. /**
  33115. * Destroy and release the resources associated with the audio ccontext.
  33116. */
  33117. dispose(): void;
  33118. /**
  33119. * Gets the global volume sets on the master gain.
  33120. * @returns the global volume if set or -1 otherwise
  33121. */
  33122. getGlobalVolume(): number;
  33123. /**
  33124. * Sets the global volume of your experience (sets on the master gain).
  33125. * @param newVolume Defines the new global volume of the application
  33126. */
  33127. setGlobalVolume(newVolume: number): void;
  33128. /**
  33129. * Connect the audio engine to an audio analyser allowing some amazing
  33130. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33132. * @param analyser The analyser to connect to the engine
  33133. */
  33134. connectToAnalyser(analyser: Analyser): void;
  33135. }
  33136. }
  33137. declare module "babylonjs/Loading/loadingScreen" {
  33138. /**
  33139. * Interface used to present a loading screen while loading a scene
  33140. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33141. */
  33142. export interface ILoadingScreen {
  33143. /**
  33144. * Function called to display the loading screen
  33145. */
  33146. displayLoadingUI: () => void;
  33147. /**
  33148. * Function called to hide the loading screen
  33149. */
  33150. hideLoadingUI: () => void;
  33151. /**
  33152. * Gets or sets the color to use for the background
  33153. */
  33154. loadingUIBackgroundColor: string;
  33155. /**
  33156. * Gets or sets the text to display while loading
  33157. */
  33158. loadingUIText: string;
  33159. }
  33160. /**
  33161. * Class used for the default loading screen
  33162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33163. */
  33164. export class DefaultLoadingScreen implements ILoadingScreen {
  33165. private _renderingCanvas;
  33166. private _loadingText;
  33167. private _loadingDivBackgroundColor;
  33168. private _loadingDiv;
  33169. private _loadingTextDiv;
  33170. /** Gets or sets the logo url to use for the default loading screen */
  33171. static DefaultLogoUrl: string;
  33172. /** Gets or sets the spinner url to use for the default loading screen */
  33173. static DefaultSpinnerUrl: string;
  33174. /**
  33175. * Creates a new default loading screen
  33176. * @param _renderingCanvas defines the canvas used to render the scene
  33177. * @param _loadingText defines the default text to display
  33178. * @param _loadingDivBackgroundColor defines the default background color
  33179. */
  33180. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33181. /**
  33182. * Function called to display the loading screen
  33183. */
  33184. displayLoadingUI(): void;
  33185. /**
  33186. * Function called to hide the loading screen
  33187. */
  33188. hideLoadingUI(): void;
  33189. /**
  33190. * Gets or sets the text to display while loading
  33191. */
  33192. loadingUIText: string;
  33193. /**
  33194. * Gets or sets the color to use for the background
  33195. */
  33196. loadingUIBackgroundColor: string;
  33197. private _resizeLoadingUI;
  33198. }
  33199. }
  33200. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33201. /**
  33202. * Interface for any object that can request an animation frame
  33203. */
  33204. export interface ICustomAnimationFrameRequester {
  33205. /**
  33206. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33207. */
  33208. renderFunction?: Function;
  33209. /**
  33210. * Called to request the next frame to render to
  33211. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33212. */
  33213. requestAnimationFrame: Function;
  33214. /**
  33215. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33216. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33217. */
  33218. requestID?: number;
  33219. }
  33220. }
  33221. declare module "babylonjs/Misc/performanceMonitor" {
  33222. /**
  33223. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33224. */
  33225. export class PerformanceMonitor {
  33226. private _enabled;
  33227. private _rollingFrameTime;
  33228. private _lastFrameTimeMs;
  33229. /**
  33230. * constructor
  33231. * @param frameSampleSize The number of samples required to saturate the sliding window
  33232. */
  33233. constructor(frameSampleSize?: number);
  33234. /**
  33235. * Samples current frame
  33236. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33237. */
  33238. sampleFrame(timeMs?: number): void;
  33239. /**
  33240. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33241. */
  33242. readonly averageFrameTime: number;
  33243. /**
  33244. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33245. */
  33246. readonly averageFrameTimeVariance: number;
  33247. /**
  33248. * Returns the frame time of the most recent frame
  33249. */
  33250. readonly instantaneousFrameTime: number;
  33251. /**
  33252. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33253. */
  33254. readonly averageFPS: number;
  33255. /**
  33256. * Returns the average framerate in frames per second using the most recent frame time
  33257. */
  33258. readonly instantaneousFPS: number;
  33259. /**
  33260. * Returns true if enough samples have been taken to completely fill the sliding window
  33261. */
  33262. readonly isSaturated: boolean;
  33263. /**
  33264. * Enables contributions to the sliding window sample set
  33265. */
  33266. enable(): void;
  33267. /**
  33268. * Disables contributions to the sliding window sample set
  33269. * Samples will not be interpolated over the disabled period
  33270. */
  33271. disable(): void;
  33272. /**
  33273. * Returns true if sampling is enabled
  33274. */
  33275. readonly isEnabled: boolean;
  33276. /**
  33277. * Resets performance monitor
  33278. */
  33279. reset(): void;
  33280. }
  33281. /**
  33282. * RollingAverage
  33283. *
  33284. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33285. */
  33286. export class RollingAverage {
  33287. /**
  33288. * Current average
  33289. */
  33290. average: number;
  33291. /**
  33292. * Current variance
  33293. */
  33294. variance: number;
  33295. protected _samples: Array<number>;
  33296. protected _sampleCount: number;
  33297. protected _pos: number;
  33298. protected _m2: number;
  33299. /**
  33300. * constructor
  33301. * @param length The number of samples required to saturate the sliding window
  33302. */
  33303. constructor(length: number);
  33304. /**
  33305. * Adds a sample to the sample set
  33306. * @param v The sample value
  33307. */
  33308. add(v: number): void;
  33309. /**
  33310. * Returns previously added values or null if outside of history or outside the sliding window domain
  33311. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33312. * @return Value previously recorded with add() or null if outside of range
  33313. */
  33314. history(i: number): number;
  33315. /**
  33316. * Returns true if enough samples have been taken to completely fill the sliding window
  33317. * @return true if sample-set saturated
  33318. */
  33319. isSaturated(): boolean;
  33320. /**
  33321. * Resets the rolling average (equivalent to 0 samples taken so far)
  33322. */
  33323. reset(): void;
  33324. /**
  33325. * Wraps a value around the sample range boundaries
  33326. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33327. * @return Wrapped position in sample range
  33328. */
  33329. protected _wrapPosition(i: number): number;
  33330. }
  33331. }
  33332. declare module "babylonjs/Misc/perfCounter" {
  33333. /**
  33334. * This class is used to track a performance counter which is number based.
  33335. * The user has access to many properties which give statistics of different nature.
  33336. *
  33337. * The implementer can track two kinds of Performance Counter: time and count.
  33338. * 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.
  33339. * 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.
  33340. */
  33341. export class PerfCounter {
  33342. /**
  33343. * Gets or sets a global boolean to turn on and off all the counters
  33344. */
  33345. static Enabled: boolean;
  33346. /**
  33347. * Returns the smallest value ever
  33348. */
  33349. readonly min: number;
  33350. /**
  33351. * Returns the biggest value ever
  33352. */
  33353. readonly max: number;
  33354. /**
  33355. * Returns the average value since the performance counter is running
  33356. */
  33357. readonly average: number;
  33358. /**
  33359. * Returns the average value of the last second the counter was monitored
  33360. */
  33361. readonly lastSecAverage: number;
  33362. /**
  33363. * Returns the current value
  33364. */
  33365. readonly current: number;
  33366. /**
  33367. * Gets the accumulated total
  33368. */
  33369. readonly total: number;
  33370. /**
  33371. * Gets the total value count
  33372. */
  33373. readonly count: number;
  33374. /**
  33375. * Creates a new counter
  33376. */
  33377. constructor();
  33378. /**
  33379. * Call this method to start monitoring a new frame.
  33380. * 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.
  33381. */
  33382. fetchNewFrame(): void;
  33383. /**
  33384. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33385. * @param newCount the count value to add to the monitored count
  33386. * @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.
  33387. */
  33388. addCount(newCount: number, fetchResult: boolean): void;
  33389. /**
  33390. * Start monitoring this performance counter
  33391. */
  33392. beginMonitoring(): void;
  33393. /**
  33394. * Compute the time lapsed since the previous beginMonitoring() call.
  33395. * @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
  33396. */
  33397. endMonitoring(newFrame?: boolean): void;
  33398. private _fetchResult;
  33399. private _startMonitoringTime;
  33400. private _min;
  33401. private _max;
  33402. private _average;
  33403. private _current;
  33404. private _totalValueCount;
  33405. private _totalAccumulated;
  33406. private _lastSecAverage;
  33407. private _lastSecAccumulated;
  33408. private _lastSecTime;
  33409. private _lastSecValueCount;
  33410. }
  33411. }
  33412. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33413. module "babylonjs/Engines/thinEngine" {
  33414. interface ThinEngine {
  33415. /**
  33416. * Sets alpha constants used by some alpha blending modes
  33417. * @param r defines the red component
  33418. * @param g defines the green component
  33419. * @param b defines the blue component
  33420. * @param a defines the alpha component
  33421. */
  33422. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33423. /**
  33424. * Sets the current alpha mode
  33425. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33426. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33428. */
  33429. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33430. /**
  33431. * Gets the current alpha mode
  33432. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33433. * @returns the current alpha mode
  33434. */
  33435. getAlphaMode(): number;
  33436. /**
  33437. * Sets the current alpha equation
  33438. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33439. */
  33440. setAlphaEquation(equation: number): void;
  33441. /**
  33442. * Gets the current alpha equation.
  33443. * @returns the current alpha equation
  33444. */
  33445. getAlphaEquation(): number;
  33446. }
  33447. }
  33448. }
  33449. declare module "babylonjs/Engines/engine" {
  33450. import { Observable } from "babylonjs/Misc/observable";
  33451. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33452. import { Scene } from "babylonjs/scene";
  33453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33454. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33455. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33456. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33457. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33458. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33459. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33460. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33461. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33462. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33463. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33464. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33465. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33466. import "babylonjs/Engines/Extensions/engine.alpha";
  33467. import { Material } from "babylonjs/Materials/material";
  33468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33469. /**
  33470. * Defines the interface used by display changed events
  33471. */
  33472. export interface IDisplayChangedEventArgs {
  33473. /** Gets the vrDisplay object (if any) */
  33474. vrDisplay: Nullable<any>;
  33475. /** Gets a boolean indicating if webVR is supported */
  33476. vrSupported: boolean;
  33477. }
  33478. /**
  33479. * Defines the interface used by objects containing a viewport (like a camera)
  33480. */
  33481. interface IViewportOwnerLike {
  33482. /**
  33483. * Gets or sets the viewport
  33484. */
  33485. viewport: IViewportLike;
  33486. }
  33487. /**
  33488. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33489. */
  33490. export class Engine extends ThinEngine {
  33491. /** Defines that alpha blending is disabled */
  33492. static readonly ALPHA_DISABLE: number;
  33493. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33494. static readonly ALPHA_ADD: number;
  33495. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33496. static readonly ALPHA_COMBINE: number;
  33497. /** Defines that alpha blending to DEST - SRC * DEST */
  33498. static readonly ALPHA_SUBTRACT: number;
  33499. /** Defines that alpha blending to SRC * DEST */
  33500. static readonly ALPHA_MULTIPLY: number;
  33501. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33502. static readonly ALPHA_MAXIMIZED: number;
  33503. /** Defines that alpha blending to SRC + DEST */
  33504. static readonly ALPHA_ONEONE: number;
  33505. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33506. static readonly ALPHA_PREMULTIPLIED: number;
  33507. /**
  33508. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33509. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33510. */
  33511. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33512. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33513. static readonly ALPHA_INTERPOLATE: number;
  33514. /**
  33515. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33516. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33517. */
  33518. static readonly ALPHA_SCREENMODE: number;
  33519. /** Defines that the ressource is not delayed*/
  33520. static readonly DELAYLOADSTATE_NONE: number;
  33521. /** Defines that the ressource was successfully delay loaded */
  33522. static readonly DELAYLOADSTATE_LOADED: number;
  33523. /** Defines that the ressource is currently delay loading */
  33524. static readonly DELAYLOADSTATE_LOADING: number;
  33525. /** Defines that the ressource is delayed and has not started loading */
  33526. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33528. static readonly NEVER: number;
  33529. /** 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 */
  33530. static readonly ALWAYS: number;
  33531. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33532. static readonly LESS: number;
  33533. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33534. static readonly EQUAL: number;
  33535. /** 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 */
  33536. static readonly LEQUAL: number;
  33537. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33538. static readonly GREATER: number;
  33539. /** 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 */
  33540. static readonly GEQUAL: number;
  33541. /** 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 */
  33542. static readonly NOTEQUAL: number;
  33543. /** Passed to stencilOperation to specify that stencil value must be kept */
  33544. static readonly KEEP: number;
  33545. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33546. static readonly REPLACE: number;
  33547. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33548. static readonly INCR: number;
  33549. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33550. static readonly DECR: number;
  33551. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33552. static readonly INVERT: number;
  33553. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33554. static readonly INCR_WRAP: number;
  33555. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33556. static readonly DECR_WRAP: number;
  33557. /** Texture is not repeating outside of 0..1 UVs */
  33558. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33559. /** Texture is repeating outside of 0..1 UVs */
  33560. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33561. /** Texture is repeating and mirrored */
  33562. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33563. /** ALPHA */
  33564. static readonly TEXTUREFORMAT_ALPHA: number;
  33565. /** LUMINANCE */
  33566. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33567. /** LUMINANCE_ALPHA */
  33568. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33569. /** RGB */
  33570. static readonly TEXTUREFORMAT_RGB: number;
  33571. /** RGBA */
  33572. static readonly TEXTUREFORMAT_RGBA: number;
  33573. /** RED */
  33574. static readonly TEXTUREFORMAT_RED: number;
  33575. /** RED (2nd reference) */
  33576. static readonly TEXTUREFORMAT_R: number;
  33577. /** RG */
  33578. static readonly TEXTUREFORMAT_RG: number;
  33579. /** RED_INTEGER */
  33580. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33581. /** RED_INTEGER (2nd reference) */
  33582. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33583. /** RG_INTEGER */
  33584. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33585. /** RGB_INTEGER */
  33586. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33587. /** RGBA_INTEGER */
  33588. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33589. /** UNSIGNED_BYTE */
  33590. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33591. /** UNSIGNED_BYTE (2nd reference) */
  33592. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33593. /** FLOAT */
  33594. static readonly TEXTURETYPE_FLOAT: number;
  33595. /** HALF_FLOAT */
  33596. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33597. /** BYTE */
  33598. static readonly TEXTURETYPE_BYTE: number;
  33599. /** SHORT */
  33600. static readonly TEXTURETYPE_SHORT: number;
  33601. /** UNSIGNED_SHORT */
  33602. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33603. /** INT */
  33604. static readonly TEXTURETYPE_INT: number;
  33605. /** UNSIGNED_INT */
  33606. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33607. /** UNSIGNED_SHORT_4_4_4_4 */
  33608. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33609. /** UNSIGNED_SHORT_5_5_5_1 */
  33610. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33611. /** UNSIGNED_SHORT_5_6_5 */
  33612. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33613. /** UNSIGNED_INT_2_10_10_10_REV */
  33614. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33615. /** UNSIGNED_INT_24_8 */
  33616. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33617. /** UNSIGNED_INT_10F_11F_11F_REV */
  33618. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33619. /** UNSIGNED_INT_5_9_9_9_REV */
  33620. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33621. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33622. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33623. /** nearest is mag = nearest and min = nearest and mip = linear */
  33624. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33625. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33626. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33627. /** Trilinear is mag = linear and min = linear and mip = linear */
  33628. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33629. /** nearest is mag = nearest and min = nearest and mip = linear */
  33630. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33631. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33632. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33633. /** Trilinear is mag = linear and min = linear and mip = linear */
  33634. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33635. /** mag = nearest and min = nearest and mip = nearest */
  33636. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33637. /** mag = nearest and min = linear and mip = nearest */
  33638. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33639. /** mag = nearest and min = linear and mip = linear */
  33640. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33641. /** mag = nearest and min = linear and mip = none */
  33642. static readonly TEXTURE_NEAREST_LINEAR: number;
  33643. /** mag = nearest and min = nearest and mip = none */
  33644. static readonly TEXTURE_NEAREST_NEAREST: number;
  33645. /** mag = linear and min = nearest and mip = nearest */
  33646. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33647. /** mag = linear and min = nearest and mip = linear */
  33648. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33649. /** mag = linear and min = linear and mip = none */
  33650. static readonly TEXTURE_LINEAR_LINEAR: number;
  33651. /** mag = linear and min = nearest and mip = none */
  33652. static readonly TEXTURE_LINEAR_NEAREST: number;
  33653. /** Explicit coordinates mode */
  33654. static readonly TEXTURE_EXPLICIT_MODE: number;
  33655. /** Spherical coordinates mode */
  33656. static readonly TEXTURE_SPHERICAL_MODE: number;
  33657. /** Planar coordinates mode */
  33658. static readonly TEXTURE_PLANAR_MODE: number;
  33659. /** Cubic coordinates mode */
  33660. static readonly TEXTURE_CUBIC_MODE: number;
  33661. /** Projection coordinates mode */
  33662. static readonly TEXTURE_PROJECTION_MODE: number;
  33663. /** Skybox coordinates mode */
  33664. static readonly TEXTURE_SKYBOX_MODE: number;
  33665. /** Inverse Cubic coordinates mode */
  33666. static readonly TEXTURE_INVCUBIC_MODE: number;
  33667. /** Equirectangular coordinates mode */
  33668. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33669. /** Equirectangular Fixed coordinates mode */
  33670. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33671. /** Equirectangular Fixed Mirrored coordinates mode */
  33672. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33673. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33674. static readonly SCALEMODE_FLOOR: number;
  33675. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33676. static readonly SCALEMODE_NEAREST: number;
  33677. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33678. static readonly SCALEMODE_CEILING: number;
  33679. /**
  33680. * Returns the current npm package of the sdk
  33681. */
  33682. static readonly NpmPackage: string;
  33683. /**
  33684. * Returns the current version of the framework
  33685. */
  33686. static readonly Version: string;
  33687. /** Gets the list of created engines */
  33688. static readonly Instances: Engine[];
  33689. /**
  33690. * Gets the latest created engine
  33691. */
  33692. static readonly LastCreatedEngine: Nullable<Engine>;
  33693. /**
  33694. * Gets the latest created scene
  33695. */
  33696. static readonly LastCreatedScene: Nullable<Scene>;
  33697. /**
  33698. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33699. * @param flag defines which part of the materials must be marked as dirty
  33700. * @param predicate defines a predicate used to filter which materials should be affected
  33701. */
  33702. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33703. /**
  33704. * Method called to create the default loading screen.
  33705. * This can be overriden in your own app.
  33706. * @param canvas The rendering canvas element
  33707. * @returns The loading screen
  33708. */
  33709. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33710. /**
  33711. * Method called to create the default rescale post process on each engine.
  33712. */
  33713. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33714. /**
  33715. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33716. **/
  33717. enableOfflineSupport: boolean;
  33718. /**
  33719. * 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)
  33720. **/
  33721. disableManifestCheck: boolean;
  33722. /**
  33723. * Gets the list of created scenes
  33724. */
  33725. scenes: Scene[];
  33726. /**
  33727. * Event raised when a new scene is created
  33728. */
  33729. onNewSceneAddedObservable: Observable<Scene>;
  33730. /**
  33731. * Gets the list of created postprocesses
  33732. */
  33733. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33734. /**
  33735. * Gets a boolean indicating if the pointer is currently locked
  33736. */
  33737. isPointerLock: boolean;
  33738. /**
  33739. * Observable event triggered each time the rendering canvas is resized
  33740. */
  33741. onResizeObservable: Observable<Engine>;
  33742. /**
  33743. * Observable event triggered each time the canvas loses focus
  33744. */
  33745. onCanvasBlurObservable: Observable<Engine>;
  33746. /**
  33747. * Observable event triggered each time the canvas gains focus
  33748. */
  33749. onCanvasFocusObservable: Observable<Engine>;
  33750. /**
  33751. * Observable event triggered each time the canvas receives pointerout event
  33752. */
  33753. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33754. /**
  33755. * Observable raised when the engine begins a new frame
  33756. */
  33757. onBeginFrameObservable: Observable<Engine>;
  33758. /**
  33759. * If set, will be used to request the next animation frame for the render loop
  33760. */
  33761. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33762. /**
  33763. * Observable raised when the engine ends the current frame
  33764. */
  33765. onEndFrameObservable: Observable<Engine>;
  33766. /**
  33767. * Observable raised when the engine is about to compile a shader
  33768. */
  33769. onBeforeShaderCompilationObservable: Observable<Engine>;
  33770. /**
  33771. * Observable raised when the engine has jsut compiled a shader
  33772. */
  33773. onAfterShaderCompilationObservable: Observable<Engine>;
  33774. /**
  33775. * Gets the audio engine
  33776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33777. * @ignorenaming
  33778. */
  33779. static audioEngine: IAudioEngine;
  33780. /**
  33781. * Default AudioEngine factory responsible of creating the Audio Engine.
  33782. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33783. */
  33784. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33785. /**
  33786. * Default offline support factory responsible of creating a tool used to store data locally.
  33787. * By default, this will create a Database object if the workload has been embedded.
  33788. */
  33789. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33790. private _loadingScreen;
  33791. private _pointerLockRequested;
  33792. private _dummyFramebuffer;
  33793. private _rescalePostProcess;
  33794. private _deterministicLockstep;
  33795. private _lockstepMaxSteps;
  33796. private _timeStep;
  33797. protected readonly _supportsHardwareTextureRescaling: boolean;
  33798. private _fps;
  33799. private _deltaTime;
  33800. /** @hidden */
  33801. _drawCalls: PerfCounter;
  33802. /**
  33803. * Turn this value on if you want to pause FPS computation when in background
  33804. */
  33805. disablePerformanceMonitorInBackground: boolean;
  33806. private _performanceMonitor;
  33807. /**
  33808. * Gets the performance monitor attached to this engine
  33809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33810. */
  33811. readonly performanceMonitor: PerformanceMonitor;
  33812. private _onFocus;
  33813. private _onBlur;
  33814. private _onCanvasPointerOut;
  33815. private _onCanvasBlur;
  33816. private _onCanvasFocus;
  33817. private _onFullscreenChange;
  33818. private _onPointerLockChange;
  33819. /**
  33820. * Gets the HTML element used to attach event listeners
  33821. * @returns a HTML element
  33822. */
  33823. getInputElement(): Nullable<HTMLElement>;
  33824. /**
  33825. * Creates a new engine
  33826. * @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
  33827. * @param antialias defines enable antialiasing (default: false)
  33828. * @param options defines further options to be sent to the getContext() function
  33829. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33830. */
  33831. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33832. /**
  33833. * Gets current aspect ratio
  33834. * @param viewportOwner defines the camera to use to get the aspect ratio
  33835. * @param useScreen defines if screen size must be used (or the current render target if any)
  33836. * @returns a number defining the aspect ratio
  33837. */
  33838. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33839. /**
  33840. * Gets current screen aspect ratio
  33841. * @returns a number defining the aspect ratio
  33842. */
  33843. getScreenAspectRatio(): number;
  33844. /**
  33845. * Gets the client rect of the HTML canvas attached with the current webGL context
  33846. * @returns a client rectanglee
  33847. */
  33848. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33849. /**
  33850. * Gets the client rect of the HTML element used for events
  33851. * @returns a client rectanglee
  33852. */
  33853. getInputElementClientRect(): Nullable<ClientRect>;
  33854. /**
  33855. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33857. * @returns true if engine is in deterministic lock step mode
  33858. */
  33859. isDeterministicLockStep(): boolean;
  33860. /**
  33861. * Gets the max steps when engine is running in deterministic lock step
  33862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33863. * @returns the max steps
  33864. */
  33865. getLockstepMaxSteps(): number;
  33866. /**
  33867. * Returns the time in ms between steps when using deterministic lock step.
  33868. * @returns time step in (ms)
  33869. */
  33870. getTimeStep(): number;
  33871. /**
  33872. * Force the mipmap generation for the given render target texture
  33873. * @param texture defines the render target texture to use
  33874. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33875. */
  33876. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33877. /** States */
  33878. /**
  33879. * Set various states to the webGL context
  33880. * @param culling defines backface culling state
  33881. * @param zOffset defines the value to apply to zOffset (0 by default)
  33882. * @param force defines if states must be applied even if cache is up to date
  33883. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33884. */
  33885. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33886. /**
  33887. * Set the z offset to apply to current rendering
  33888. * @param value defines the offset to apply
  33889. */
  33890. setZOffset(value: number): void;
  33891. /**
  33892. * Gets the current value of the zOffset
  33893. * @returns the current zOffset state
  33894. */
  33895. getZOffset(): number;
  33896. /**
  33897. * Enable or disable depth buffering
  33898. * @param enable defines the state to set
  33899. */
  33900. setDepthBuffer(enable: boolean): void;
  33901. /**
  33902. * Gets a boolean indicating if depth writing is enabled
  33903. * @returns the current depth writing state
  33904. */
  33905. getDepthWrite(): boolean;
  33906. /**
  33907. * Enable or disable depth writing
  33908. * @param enable defines the state to set
  33909. */
  33910. setDepthWrite(enable: boolean): void;
  33911. /**
  33912. * Gets a boolean indicating if stencil buffer is enabled
  33913. * @returns the current stencil buffer state
  33914. */
  33915. getStencilBuffer(): boolean;
  33916. /**
  33917. * Enable or disable the stencil buffer
  33918. * @param enable defines if the stencil buffer must be enabled or disabled
  33919. */
  33920. setStencilBuffer(enable: boolean): void;
  33921. /**
  33922. * Gets the current stencil mask
  33923. * @returns a number defining the new stencil mask to use
  33924. */
  33925. getStencilMask(): number;
  33926. /**
  33927. * Sets the current stencil mask
  33928. * @param mask defines the new stencil mask to use
  33929. */
  33930. setStencilMask(mask: number): void;
  33931. /**
  33932. * Gets the current stencil function
  33933. * @returns a number defining the stencil function to use
  33934. */
  33935. getStencilFunction(): number;
  33936. /**
  33937. * Gets the current stencil reference value
  33938. * @returns a number defining the stencil reference value to use
  33939. */
  33940. getStencilFunctionReference(): number;
  33941. /**
  33942. * Gets the current stencil mask
  33943. * @returns a number defining the stencil mask to use
  33944. */
  33945. getStencilFunctionMask(): number;
  33946. /**
  33947. * Sets the current stencil function
  33948. * @param stencilFunc defines the new stencil function to use
  33949. */
  33950. setStencilFunction(stencilFunc: number): void;
  33951. /**
  33952. * Sets the current stencil reference
  33953. * @param reference defines the new stencil reference to use
  33954. */
  33955. setStencilFunctionReference(reference: number): void;
  33956. /**
  33957. * Sets the current stencil mask
  33958. * @param mask defines the new stencil mask to use
  33959. */
  33960. setStencilFunctionMask(mask: number): void;
  33961. /**
  33962. * Gets the current stencil operation when stencil fails
  33963. * @returns a number defining stencil operation to use when stencil fails
  33964. */
  33965. getStencilOperationFail(): number;
  33966. /**
  33967. * Gets the current stencil operation when depth fails
  33968. * @returns a number defining stencil operation to use when depth fails
  33969. */
  33970. getStencilOperationDepthFail(): number;
  33971. /**
  33972. * Gets the current stencil operation when stencil passes
  33973. * @returns a number defining stencil operation to use when stencil passes
  33974. */
  33975. getStencilOperationPass(): number;
  33976. /**
  33977. * Sets the stencil operation to use when stencil fails
  33978. * @param operation defines the stencil operation to use when stencil fails
  33979. */
  33980. setStencilOperationFail(operation: number): void;
  33981. /**
  33982. * Sets the stencil operation to use when depth fails
  33983. * @param operation defines the stencil operation to use when depth fails
  33984. */
  33985. setStencilOperationDepthFail(operation: number): void;
  33986. /**
  33987. * Sets the stencil operation to use when stencil passes
  33988. * @param operation defines the stencil operation to use when stencil passes
  33989. */
  33990. setStencilOperationPass(operation: number): void;
  33991. /**
  33992. * Sets a boolean indicating if the dithering state is enabled or disabled
  33993. * @param value defines the dithering state
  33994. */
  33995. setDitheringState(value: boolean): void;
  33996. /**
  33997. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33998. * @param value defines the rasterizer state
  33999. */
  34000. setRasterizerState(value: boolean): void;
  34001. /**
  34002. * Gets the current depth function
  34003. * @returns a number defining the depth function
  34004. */
  34005. getDepthFunction(): Nullable<number>;
  34006. /**
  34007. * Sets the current depth function
  34008. * @param depthFunc defines the function to use
  34009. */
  34010. setDepthFunction(depthFunc: number): void;
  34011. /**
  34012. * Sets the current depth function to GREATER
  34013. */
  34014. setDepthFunctionToGreater(): void;
  34015. /**
  34016. * Sets the current depth function to GEQUAL
  34017. */
  34018. setDepthFunctionToGreaterOrEqual(): void;
  34019. /**
  34020. * Sets the current depth function to LESS
  34021. */
  34022. setDepthFunctionToLess(): void;
  34023. /**
  34024. * Sets the current depth function to LEQUAL
  34025. */
  34026. setDepthFunctionToLessOrEqual(): void;
  34027. private _cachedStencilBuffer;
  34028. private _cachedStencilFunction;
  34029. private _cachedStencilMask;
  34030. private _cachedStencilOperationPass;
  34031. private _cachedStencilOperationFail;
  34032. private _cachedStencilOperationDepthFail;
  34033. private _cachedStencilReference;
  34034. /**
  34035. * Caches the the state of the stencil buffer
  34036. */
  34037. cacheStencilState(): void;
  34038. /**
  34039. * Restores the state of the stencil buffer
  34040. */
  34041. restoreStencilState(): void;
  34042. /**
  34043. * Directly set the WebGL Viewport
  34044. * @param x defines the x coordinate of the viewport (in screen space)
  34045. * @param y defines the y coordinate of the viewport (in screen space)
  34046. * @param width defines the width of the viewport (in screen space)
  34047. * @param height defines the height of the viewport (in screen space)
  34048. * @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
  34049. */
  34050. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34051. /**
  34052. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34053. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34054. * @param y defines the y-coordinate of the corner of the clear rectangle
  34055. * @param width defines the width of the clear rectangle
  34056. * @param height defines the height of the clear rectangle
  34057. * @param clearColor defines the clear color
  34058. */
  34059. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34060. /**
  34061. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34062. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34063. * @param y defines the y-coordinate of the corner of the clear rectangle
  34064. * @param width defines the width of the clear rectangle
  34065. * @param height defines the height of the clear rectangle
  34066. */
  34067. enableScissor(x: number, y: number, width: number, height: number): void;
  34068. /**
  34069. * Disable previously set scissor test rectangle
  34070. */
  34071. disableScissor(): void;
  34072. protected _reportDrawCall(): void;
  34073. /**
  34074. * Initializes a webVR display and starts listening to display change events
  34075. * The onVRDisplayChangedObservable will be notified upon these changes
  34076. * @returns The onVRDisplayChangedObservable
  34077. */
  34078. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34079. /** @hidden */
  34080. _prepareVRComponent(): void;
  34081. /** @hidden */
  34082. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34083. /** @hidden */
  34084. _submitVRFrame(): void;
  34085. /**
  34086. * Call this function to leave webVR mode
  34087. * Will do nothing if webVR is not supported or if there is no webVR device
  34088. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34089. */
  34090. disableVR(): void;
  34091. /**
  34092. * Gets a boolean indicating that the system is in VR mode and is presenting
  34093. * @returns true if VR mode is engaged
  34094. */
  34095. isVRPresenting(): boolean;
  34096. /** @hidden */
  34097. _requestVRFrame(): void;
  34098. /** @hidden */
  34099. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34100. /**
  34101. * Gets the source code of the vertex shader associated with a specific webGL program
  34102. * @param program defines the program to use
  34103. * @returns a string containing the source code of the vertex shader associated with the program
  34104. */
  34105. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34106. /**
  34107. * Gets the source code of the fragment shader associated with a specific webGL program
  34108. * @param program defines the program to use
  34109. * @returns a string containing the source code of the fragment shader associated with the program
  34110. */
  34111. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34112. /**
  34113. * Sets a depth stencil texture from a render target to the according uniform.
  34114. * @param channel The texture channel
  34115. * @param uniform The uniform to set
  34116. * @param texture The render target texture containing the depth stencil texture to apply
  34117. */
  34118. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34119. /**
  34120. * Sets a texture to the webGL context from a postprocess
  34121. * @param channel defines the channel to use
  34122. * @param postProcess defines the source postprocess
  34123. */
  34124. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34125. /**
  34126. * Binds the output of the passed in post process to the texture channel specified
  34127. * @param channel The channel the texture should be bound to
  34128. * @param postProcess The post process which's output should be bound
  34129. */
  34130. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34131. /** @hidden */
  34132. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34133. protected _rebuildBuffers(): void;
  34134. /** @hidden */
  34135. _renderFrame(): void;
  34136. _renderLoop(): void;
  34137. /** @hidden */
  34138. _renderViews(): boolean;
  34139. /**
  34140. * Toggle full screen mode
  34141. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34142. */
  34143. switchFullscreen(requestPointerLock: boolean): void;
  34144. /**
  34145. * Enters full screen mode
  34146. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34147. */
  34148. enterFullscreen(requestPointerLock: boolean): void;
  34149. /**
  34150. * Exits full screen mode
  34151. */
  34152. exitFullscreen(): void;
  34153. /**
  34154. * Enters Pointerlock mode
  34155. */
  34156. enterPointerlock(): void;
  34157. /**
  34158. * Exits Pointerlock mode
  34159. */
  34160. exitPointerlock(): void;
  34161. /**
  34162. * Begin a new frame
  34163. */
  34164. beginFrame(): void;
  34165. /**
  34166. * Enf the current frame
  34167. */
  34168. endFrame(): void;
  34169. resize(): void;
  34170. /**
  34171. * Set the compressed texture format to use, based on the formats you have, and the formats
  34172. * supported by the hardware / browser.
  34173. *
  34174. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34175. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34176. * to API arguments needed to compressed textures. This puts the burden on the container
  34177. * generator to house the arcane code for determining these for current & future formats.
  34178. *
  34179. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34180. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34181. *
  34182. * Note: The result of this call is not taken into account when a texture is base64.
  34183. *
  34184. * @param formatsAvailable defines the list of those format families you have created
  34185. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34186. *
  34187. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34188. * @returns The extension selected.
  34189. */
  34190. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34191. /**
  34192. * Set the compressed texture extensions or file names to skip.
  34193. *
  34194. * @param skippedFiles defines the list of those texture files you want to skip
  34195. * Example: [".dds", ".env", "myfile.png"]
  34196. */
  34197. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34198. /**
  34199. * Force a specific size of the canvas
  34200. * @param width defines the new canvas' width
  34201. * @param height defines the new canvas' height
  34202. */
  34203. setSize(width: number, height: number): void;
  34204. /**
  34205. * Updates a dynamic vertex buffer.
  34206. * @param vertexBuffer the vertex buffer to update
  34207. * @param data the data used to update the vertex buffer
  34208. * @param byteOffset the byte offset of the data
  34209. * @param byteLength the byte length of the data
  34210. */
  34211. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34212. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34213. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34214. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34215. _releaseTexture(texture: InternalTexture): void;
  34216. /**
  34217. * @hidden
  34218. * Rescales a texture
  34219. * @param source input texutre
  34220. * @param destination destination texture
  34221. * @param scene scene to use to render the resize
  34222. * @param internalFormat format to use when resizing
  34223. * @param onComplete callback to be called when resize has completed
  34224. */
  34225. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34226. /**
  34227. * Gets the current framerate
  34228. * @returns a number representing the framerate
  34229. */
  34230. getFps(): number;
  34231. /**
  34232. * Gets the time spent between current and previous frame
  34233. * @returns a number representing the delta time in ms
  34234. */
  34235. getDeltaTime(): number;
  34236. private _measureFps;
  34237. /** @hidden */
  34238. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34239. /**
  34240. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34241. * @param renderTarget The render target to set the frame buffer for
  34242. */
  34243. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34244. /**
  34245. * Update a dynamic index buffer
  34246. * @param indexBuffer defines the target index buffer
  34247. * @param indices defines the data to update
  34248. * @param offset defines the offset in the target index buffer where update should start
  34249. */
  34250. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34251. /**
  34252. * Updates the sample count of a render target texture
  34253. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34254. * @param texture defines the texture to update
  34255. * @param samples defines the sample count to set
  34256. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34257. */
  34258. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34259. /**
  34260. * Updates a depth texture Comparison Mode and Function.
  34261. * If the comparison Function is equal to 0, the mode will be set to none.
  34262. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34263. * @param texture The texture to set the comparison function for
  34264. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34265. */
  34266. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34267. /**
  34268. * Creates a webGL buffer to use with instanciation
  34269. * @param capacity defines the size of the buffer
  34270. * @returns the webGL buffer
  34271. */
  34272. createInstancesBuffer(capacity: number): DataBuffer;
  34273. /**
  34274. * Delete a webGL buffer used with instanciation
  34275. * @param buffer defines the webGL buffer to delete
  34276. */
  34277. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34278. /** @hidden */
  34279. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34280. dispose(): void;
  34281. private _disableTouchAction;
  34282. /**
  34283. * Display the loading screen
  34284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34285. */
  34286. displayLoadingUI(): void;
  34287. /**
  34288. * Hide the loading screen
  34289. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34290. */
  34291. hideLoadingUI(): void;
  34292. /**
  34293. * Gets the current loading screen object
  34294. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34295. */
  34296. /**
  34297. * Sets the current loading screen object
  34298. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34299. */
  34300. loadingScreen: ILoadingScreen;
  34301. /**
  34302. * Sets the current loading screen text
  34303. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34304. */
  34305. loadingUIText: string;
  34306. /**
  34307. * Sets the current loading screen background color
  34308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34309. */
  34310. loadingUIBackgroundColor: string;
  34311. /** Pointerlock and fullscreen */
  34312. /**
  34313. * Ask the browser to promote the current element to pointerlock mode
  34314. * @param element defines the DOM element to promote
  34315. */
  34316. static _RequestPointerlock(element: HTMLElement): void;
  34317. /**
  34318. * Asks the browser to exit pointerlock mode
  34319. */
  34320. static _ExitPointerlock(): void;
  34321. /**
  34322. * Ask the browser to promote the current element to fullscreen rendering mode
  34323. * @param element defines the DOM element to promote
  34324. */
  34325. static _RequestFullscreen(element: HTMLElement): void;
  34326. /**
  34327. * Asks the browser to exit fullscreen mode
  34328. */
  34329. static _ExitFullscreen(): void;
  34330. }
  34331. }
  34332. declare module "babylonjs/Engines/engineStore" {
  34333. import { Nullable } from "babylonjs/types";
  34334. import { Engine } from "babylonjs/Engines/engine";
  34335. import { Scene } from "babylonjs/scene";
  34336. /**
  34337. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34338. * during the life time of the application.
  34339. */
  34340. export class EngineStore {
  34341. /** Gets the list of created engines */
  34342. static Instances: import("babylonjs/Engines/engine").Engine[];
  34343. /** @hidden */
  34344. static _LastCreatedScene: Nullable<Scene>;
  34345. /**
  34346. * Gets the latest created engine
  34347. */
  34348. static readonly LastCreatedEngine: Nullable<Engine>;
  34349. /**
  34350. * Gets the latest created scene
  34351. */
  34352. static readonly LastCreatedScene: Nullable<Scene>;
  34353. /**
  34354. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34355. * @ignorenaming
  34356. */
  34357. static UseFallbackTexture: boolean;
  34358. /**
  34359. * Texture content used if a texture cannot loaded
  34360. * @ignorenaming
  34361. */
  34362. static FallbackTexture: string;
  34363. }
  34364. }
  34365. declare module "babylonjs/Misc/promise" {
  34366. /**
  34367. * Helper class that provides a small promise polyfill
  34368. */
  34369. export class PromisePolyfill {
  34370. /**
  34371. * Static function used to check if the polyfill is required
  34372. * If this is the case then the function will inject the polyfill to window.Promise
  34373. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34374. */
  34375. static Apply(force?: boolean): void;
  34376. }
  34377. }
  34378. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34379. /**
  34380. * Interface for screenshot methods with describe argument called `size` as object with options
  34381. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34382. */
  34383. export interface IScreenshotSize {
  34384. /**
  34385. * number in pixels for canvas height
  34386. */
  34387. height?: number;
  34388. /**
  34389. * multiplier allowing render at a higher or lower resolution
  34390. * If value is defined then height and width will be ignored and taken from camera
  34391. */
  34392. precision?: number;
  34393. /**
  34394. * number in pixels for canvas width
  34395. */
  34396. width?: number;
  34397. }
  34398. }
  34399. declare module "babylonjs/Misc/tools" {
  34400. import { Nullable, float } from "babylonjs/types";
  34401. import { DomManagement } from "babylonjs/Misc/domManagement";
  34402. import { WebRequest } from "babylonjs/Misc/webRequest";
  34403. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34404. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34405. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34406. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34407. import { Camera } from "babylonjs/Cameras/camera";
  34408. import { Engine } from "babylonjs/Engines/engine";
  34409. interface IColor4Like {
  34410. r: float;
  34411. g: float;
  34412. b: float;
  34413. a: float;
  34414. }
  34415. /**
  34416. * Class containing a set of static utilities functions
  34417. */
  34418. export class Tools {
  34419. /**
  34420. * Gets or sets the base URL to use to load assets
  34421. */
  34422. static BaseUrl: string;
  34423. /**
  34424. * Enable/Disable Custom HTTP Request Headers globally.
  34425. * default = false
  34426. * @see CustomRequestHeaders
  34427. */
  34428. static UseCustomRequestHeaders: boolean;
  34429. /**
  34430. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34431. * i.e. when loading files, where the server/service expects an Authorization header
  34432. */
  34433. static CustomRequestHeaders: {
  34434. [key: string]: string;
  34435. };
  34436. /**
  34437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34438. */
  34439. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34440. /**
  34441. * Default behaviour for cors in the application.
  34442. * It can be a string if the expected behavior is identical in the entire app.
  34443. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34444. */
  34445. static CorsBehavior: string | ((url: string | string[]) => string);
  34446. /**
  34447. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34448. * @ignorenaming
  34449. */
  34450. static UseFallbackTexture: boolean;
  34451. /**
  34452. * Use this object to register external classes like custom textures or material
  34453. * to allow the laoders to instantiate them
  34454. */
  34455. static RegisteredExternalClasses: {
  34456. [key: string]: Object;
  34457. };
  34458. /**
  34459. * Texture content used if a texture cannot loaded
  34460. * @ignorenaming
  34461. */
  34462. static fallbackTexture: string;
  34463. /**
  34464. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34465. * @param u defines the coordinate on X axis
  34466. * @param v defines the coordinate on Y axis
  34467. * @param width defines the width of the source data
  34468. * @param height defines the height of the source data
  34469. * @param pixels defines the source byte array
  34470. * @param color defines the output color
  34471. */
  34472. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34473. /**
  34474. * Interpolates between a and b via alpha
  34475. * @param a The lower value (returned when alpha = 0)
  34476. * @param b The upper value (returned when alpha = 1)
  34477. * @param alpha The interpolation-factor
  34478. * @return The mixed value
  34479. */
  34480. static Mix(a: number, b: number, alpha: number): number;
  34481. /**
  34482. * Tries to instantiate a new object from a given class name
  34483. * @param className defines the class name to instantiate
  34484. * @returns the new object or null if the system was not able to do the instantiation
  34485. */
  34486. static Instantiate(className: string): any;
  34487. /**
  34488. * Provides a slice function that will work even on IE
  34489. * @param data defines the array to slice
  34490. * @param start defines the start of the data (optional)
  34491. * @param end defines the end of the data (optional)
  34492. * @returns the new sliced array
  34493. */
  34494. static Slice<T>(data: T, start?: number, end?: number): T;
  34495. /**
  34496. * Polyfill for setImmediate
  34497. * @param action defines the action to execute after the current execution block
  34498. */
  34499. static SetImmediate(action: () => void): void;
  34500. /**
  34501. * Function indicating if a number is an exponent of 2
  34502. * @param value defines the value to test
  34503. * @returns true if the value is an exponent of 2
  34504. */
  34505. static IsExponentOfTwo(value: number): boolean;
  34506. private static _tmpFloatArray;
  34507. /**
  34508. * Returns the nearest 32-bit single precision float representation of a Number
  34509. * @param value A Number. If the parameter is of a different type, it will get converted
  34510. * to a number or to NaN if it cannot be converted
  34511. * @returns number
  34512. */
  34513. static FloatRound(value: number): number;
  34514. /**
  34515. * Extracts the filename from a path
  34516. * @param path defines the path to use
  34517. * @returns the filename
  34518. */
  34519. static GetFilename(path: string): string;
  34520. /**
  34521. * Extracts the "folder" part of a path (everything before the filename).
  34522. * @param uri The URI to extract the info from
  34523. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34524. * @returns The "folder" part of the path
  34525. */
  34526. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34527. /**
  34528. * Extracts text content from a DOM element hierarchy
  34529. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34530. */
  34531. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34532. /**
  34533. * Convert an angle in radians to degrees
  34534. * @param angle defines the angle to convert
  34535. * @returns the angle in degrees
  34536. */
  34537. static ToDegrees(angle: number): number;
  34538. /**
  34539. * Convert an angle in degrees to radians
  34540. * @param angle defines the angle to convert
  34541. * @returns the angle in radians
  34542. */
  34543. static ToRadians(angle: number): number;
  34544. /**
  34545. * Returns an array if obj is not an array
  34546. * @param obj defines the object to evaluate as an array
  34547. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34548. * @returns either obj directly if obj is an array or a new array containing obj
  34549. */
  34550. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34551. /**
  34552. * Gets the pointer prefix to use
  34553. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34554. */
  34555. static GetPointerPrefix(): string;
  34556. /**
  34557. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34558. * @param url define the url we are trying
  34559. * @param element define the dom element where to configure the cors policy
  34560. */
  34561. static SetCorsBehavior(url: string | string[], element: {
  34562. crossOrigin: string | null;
  34563. }): void;
  34564. /**
  34565. * Removes unwanted characters from an url
  34566. * @param url defines the url to clean
  34567. * @returns the cleaned url
  34568. */
  34569. static CleanUrl(url: string): string;
  34570. /**
  34571. * Gets or sets a function used to pre-process url before using them to load assets
  34572. */
  34573. static PreprocessUrl: (url: string) => string;
  34574. /**
  34575. * Loads an image as an HTMLImageElement.
  34576. * @param input url string, ArrayBuffer, or Blob to load
  34577. * @param onLoad callback called when the image successfully loads
  34578. * @param onError callback called when the image fails to load
  34579. * @param offlineProvider offline provider for caching
  34580. * @param mimeType optional mime type
  34581. * @returns the HTMLImageElement of the loaded image
  34582. */
  34583. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34584. /**
  34585. * Loads a file from a url
  34586. * @param url url string, ArrayBuffer, or Blob to load
  34587. * @param onSuccess callback called when the file successfully loads
  34588. * @param onProgress callback called while file is loading (if the server supports this mode)
  34589. * @param offlineProvider defines the offline provider for caching
  34590. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34591. * @param onError callback called when the file fails to load
  34592. * @returns a file request object
  34593. */
  34594. 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;
  34595. /**
  34596. * Loads a file from a url
  34597. * @param url the file url to load
  34598. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34599. */
  34600. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34601. /**
  34602. * Load a script (identified by an url). When the url returns, the
  34603. * content of this file is added into a new script element, attached to the DOM (body element)
  34604. * @param scriptUrl defines the url of the script to laod
  34605. * @param onSuccess defines the callback called when the script is loaded
  34606. * @param onError defines the callback to call if an error occurs
  34607. * @param scriptId defines the id of the script element
  34608. */
  34609. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34610. /**
  34611. * Load an asynchronous script (identified by an url). When the url returns, the
  34612. * content of this file is added into a new script element, attached to the DOM (body element)
  34613. * @param scriptUrl defines the url of the script to laod
  34614. * @param scriptId defines the id of the script element
  34615. * @returns a promise request object
  34616. */
  34617. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34618. /**
  34619. * Loads a file from a blob
  34620. * @param fileToLoad defines the blob to use
  34621. * @param callback defines the callback to call when data is loaded
  34622. * @param progressCallback defines the callback to call during loading process
  34623. * @returns a file request object
  34624. */
  34625. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34626. /**
  34627. * Reads a file from a File object
  34628. * @param file defines the file to load
  34629. * @param onSuccess defines the callback to call when data is loaded
  34630. * @param onProgress defines the callback to call during loading process
  34631. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34632. * @param onError defines the callback to call when an error occurs
  34633. * @returns a file request object
  34634. */
  34635. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34636. /**
  34637. * Creates a data url from a given string content
  34638. * @param content defines the content to convert
  34639. * @returns the new data url link
  34640. */
  34641. static FileAsURL(content: string): string;
  34642. /**
  34643. * Format the given number to a specific decimal format
  34644. * @param value defines the number to format
  34645. * @param decimals defines the number of decimals to use
  34646. * @returns the formatted string
  34647. */
  34648. static Format(value: number, decimals?: number): string;
  34649. /**
  34650. * Tries to copy an object by duplicating every property
  34651. * @param source defines the source object
  34652. * @param destination defines the target object
  34653. * @param doNotCopyList defines a list of properties to avoid
  34654. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34655. */
  34656. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34657. /**
  34658. * Gets a boolean indicating if the given object has no own property
  34659. * @param obj defines the object to test
  34660. * @returns true if object has no own property
  34661. */
  34662. static IsEmpty(obj: any): boolean;
  34663. /**
  34664. * Function used to register events at window level
  34665. * @param windowElement defines the Window object to use
  34666. * @param events defines the events to register
  34667. */
  34668. static RegisterTopRootEvents(windowElement: Window, events: {
  34669. name: string;
  34670. handler: Nullable<(e: FocusEvent) => any>;
  34671. }[]): void;
  34672. /**
  34673. * Function used to unregister events from window level
  34674. * @param windowElement defines the Window object to use
  34675. * @param events defines the events to unregister
  34676. */
  34677. static UnregisterTopRootEvents(windowElement: Window, events: {
  34678. name: string;
  34679. handler: Nullable<(e: FocusEvent) => any>;
  34680. }[]): void;
  34681. /**
  34682. * @ignore
  34683. */
  34684. static _ScreenshotCanvas: HTMLCanvasElement;
  34685. /**
  34686. * Dumps the current bound framebuffer
  34687. * @param width defines the rendering width
  34688. * @param height defines the rendering height
  34689. * @param engine defines the hosting engine
  34690. * @param successCallback defines the callback triggered once the data are available
  34691. * @param mimeType defines the mime type of the result
  34692. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34693. */
  34694. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34695. /**
  34696. * Converts the canvas data to blob.
  34697. * This acts as a polyfill for browsers not supporting the to blob function.
  34698. * @param canvas Defines the canvas to extract the data from
  34699. * @param successCallback Defines the callback triggered once the data are available
  34700. * @param mimeType Defines the mime type of the result
  34701. */
  34702. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34703. /**
  34704. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34705. * @param successCallback defines the callback triggered once the data are available
  34706. * @param mimeType defines the mime type of the result
  34707. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34708. */
  34709. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34710. /**
  34711. * Downloads a blob in the browser
  34712. * @param blob defines the blob to download
  34713. * @param fileName defines the name of the downloaded file
  34714. */
  34715. static Download(blob: Blob, fileName: string): void;
  34716. /**
  34717. * Captures a screenshot of the current rendering
  34718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34719. * @param engine defines the rendering engine
  34720. * @param camera defines the source camera
  34721. * @param size This parameter can be set to a single number or to an object with the
  34722. * following (optional) properties: precision, width, height. If a single number is passed,
  34723. * it will be used for both width and height. If an object is passed, the screenshot size
  34724. * will be derived from the parameters. The precision property is a multiplier allowing
  34725. * rendering at a higher or lower resolution
  34726. * @param successCallback defines the callback receives a single parameter which contains the
  34727. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34728. * src parameter of an <img> to display it
  34729. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34730. * Check your browser for supported MIME types
  34731. */
  34732. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34733. /**
  34734. * Captures a screenshot of the current rendering
  34735. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34736. * @param engine defines the rendering engine
  34737. * @param camera defines the source camera
  34738. * @param size This parameter can be set to a single number or to an object with the
  34739. * following (optional) properties: precision, width, height. If a single number is passed,
  34740. * it will be used for both width and height. If an object is passed, the screenshot size
  34741. * will be derived from the parameters. The precision property is a multiplier allowing
  34742. * rendering at a higher or lower resolution
  34743. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34744. * Check your browser for supported MIME types
  34745. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34746. * to the src parameter of an <img> to display it
  34747. */
  34748. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34749. /**
  34750. * Generates an image screenshot from the specified camera.
  34751. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34752. * @param engine The engine to use for rendering
  34753. * @param camera The camera to use for rendering
  34754. * @param size This parameter can be set to a single number or to an object with the
  34755. * following (optional) properties: precision, width, height. If a single number is passed,
  34756. * it will be used for both width and height. If an object is passed, the screenshot size
  34757. * will be derived from the parameters. The precision property is a multiplier allowing
  34758. * rendering at a higher or lower resolution
  34759. * @param successCallback The callback receives a single parameter which contains the
  34760. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34761. * src parameter of an <img> to display it
  34762. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34763. * Check your browser for supported MIME types
  34764. * @param samples Texture samples (default: 1)
  34765. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34766. * @param fileName A name for for the downloaded file.
  34767. */
  34768. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34769. /**
  34770. * Generates an image screenshot from the specified camera.
  34771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34772. * @param engine The engine to use for rendering
  34773. * @param camera The camera to use for rendering
  34774. * @param size This parameter can be set to a single number or to an object with the
  34775. * following (optional) properties: precision, width, height. If a single number is passed,
  34776. * it will be used for both width and height. If an object is passed, the screenshot size
  34777. * will be derived from the parameters. The precision property is a multiplier allowing
  34778. * rendering at a higher or lower resolution
  34779. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34780. * Check your browser for supported MIME types
  34781. * @param samples Texture samples (default: 1)
  34782. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34783. * @param fileName A name for for the downloaded file.
  34784. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34785. * to the src parameter of an <img> to display it
  34786. */
  34787. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34788. /**
  34789. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34790. * Be aware Math.random() could cause collisions, but:
  34791. * "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"
  34792. * @returns a pseudo random id
  34793. */
  34794. static RandomId(): string;
  34795. /**
  34796. * Test if the given uri is a base64 string
  34797. * @param uri The uri to test
  34798. * @return True if the uri is a base64 string or false otherwise
  34799. */
  34800. static IsBase64(uri: string): boolean;
  34801. /**
  34802. * Decode the given base64 uri.
  34803. * @param uri The uri to decode
  34804. * @return The decoded base64 data.
  34805. */
  34806. static DecodeBase64(uri: string): ArrayBuffer;
  34807. /**
  34808. * Gets the absolute url.
  34809. * @param url the input url
  34810. * @return the absolute url
  34811. */
  34812. static GetAbsoluteUrl(url: string): string;
  34813. /**
  34814. * No log
  34815. */
  34816. static readonly NoneLogLevel: number;
  34817. /**
  34818. * Only message logs
  34819. */
  34820. static readonly MessageLogLevel: number;
  34821. /**
  34822. * Only warning logs
  34823. */
  34824. static readonly WarningLogLevel: number;
  34825. /**
  34826. * Only error logs
  34827. */
  34828. static readonly ErrorLogLevel: number;
  34829. /**
  34830. * All logs
  34831. */
  34832. static readonly AllLogLevel: number;
  34833. /**
  34834. * Gets a value indicating the number of loading errors
  34835. * @ignorenaming
  34836. */
  34837. static readonly errorsCount: number;
  34838. /**
  34839. * Callback called when a new log is added
  34840. */
  34841. static OnNewCacheEntry: (entry: string) => void;
  34842. /**
  34843. * Log a message to the console
  34844. * @param message defines the message to log
  34845. */
  34846. static Log(message: string): void;
  34847. /**
  34848. * Write a warning message to the console
  34849. * @param message defines the message to log
  34850. */
  34851. static Warn(message: string): void;
  34852. /**
  34853. * Write an error message to the console
  34854. * @param message defines the message to log
  34855. */
  34856. static Error(message: string): void;
  34857. /**
  34858. * Gets current log cache (list of logs)
  34859. */
  34860. static readonly LogCache: string;
  34861. /**
  34862. * Clears the log cache
  34863. */
  34864. static ClearLogCache(): void;
  34865. /**
  34866. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34867. */
  34868. static LogLevels: number;
  34869. /**
  34870. * Checks if the window object exists
  34871. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34872. */
  34873. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34874. /**
  34875. * No performance log
  34876. */
  34877. static readonly PerformanceNoneLogLevel: number;
  34878. /**
  34879. * Use user marks to log performance
  34880. */
  34881. static readonly PerformanceUserMarkLogLevel: number;
  34882. /**
  34883. * Log performance to the console
  34884. */
  34885. static readonly PerformanceConsoleLogLevel: number;
  34886. private static _performance;
  34887. /**
  34888. * Sets the current performance log level
  34889. */
  34890. static PerformanceLogLevel: number;
  34891. private static _StartPerformanceCounterDisabled;
  34892. private static _EndPerformanceCounterDisabled;
  34893. private static _StartUserMark;
  34894. private static _EndUserMark;
  34895. private static _StartPerformanceConsole;
  34896. private static _EndPerformanceConsole;
  34897. /**
  34898. * Starts a performance counter
  34899. */
  34900. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34901. /**
  34902. * Ends a specific performance coutner
  34903. */
  34904. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34905. /**
  34906. * Gets either window.performance.now() if supported or Date.now() else
  34907. */
  34908. static readonly Now: number;
  34909. /**
  34910. * This method will return the name of the class used to create the instance of the given object.
  34911. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34912. * @param object the object to get the class name from
  34913. * @param isType defines if the object is actually a type
  34914. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34915. */
  34916. static GetClassName(object: any, isType?: boolean): string;
  34917. /**
  34918. * Gets the first element of an array satisfying a given predicate
  34919. * @param array defines the array to browse
  34920. * @param predicate defines the predicate to use
  34921. * @returns null if not found or the element
  34922. */
  34923. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34924. /**
  34925. * This method will return the name of the full name of the class, including its owning module (if any).
  34926. * 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).
  34927. * @param object the object to get the class name from
  34928. * @param isType defines if the object is actually a type
  34929. * @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.
  34930. * @ignorenaming
  34931. */
  34932. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34933. /**
  34934. * Returns a promise that resolves after the given amount of time.
  34935. * @param delay Number of milliseconds to delay
  34936. * @returns Promise that resolves after the given amount of time
  34937. */
  34938. static DelayAsync(delay: number): Promise<void>;
  34939. }
  34940. /**
  34941. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34942. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34943. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34944. * @param name The name of the class, case should be preserved
  34945. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34946. */
  34947. export function className(name: string, module?: string): (target: Object) => void;
  34948. /**
  34949. * An implementation of a loop for asynchronous functions.
  34950. */
  34951. export class AsyncLoop {
  34952. /**
  34953. * Defines the number of iterations for the loop
  34954. */
  34955. iterations: number;
  34956. /**
  34957. * Defines the current index of the loop.
  34958. */
  34959. index: number;
  34960. private _done;
  34961. private _fn;
  34962. private _successCallback;
  34963. /**
  34964. * Constructor.
  34965. * @param iterations the number of iterations.
  34966. * @param func the function to run each iteration
  34967. * @param successCallback the callback that will be called upon succesful execution
  34968. * @param offset starting offset.
  34969. */
  34970. constructor(
  34971. /**
  34972. * Defines the number of iterations for the loop
  34973. */
  34974. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34975. /**
  34976. * Execute the next iteration. Must be called after the last iteration was finished.
  34977. */
  34978. executeNext(): void;
  34979. /**
  34980. * Break the loop and run the success callback.
  34981. */
  34982. breakLoop(): void;
  34983. /**
  34984. * Create and run an async loop.
  34985. * @param iterations the number of iterations.
  34986. * @param fn the function to run each iteration
  34987. * @param successCallback the callback that will be called upon succesful execution
  34988. * @param offset starting offset.
  34989. * @returns the created async loop object
  34990. */
  34991. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34992. /**
  34993. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34994. * @param iterations total number of iterations
  34995. * @param syncedIterations number of synchronous iterations in each async iteration.
  34996. * @param fn the function to call each iteration.
  34997. * @param callback a success call back that will be called when iterating stops.
  34998. * @param breakFunction a break condition (optional)
  34999. * @param timeout timeout settings for the setTimeout function. default - 0.
  35000. * @returns the created async loop object
  35001. */
  35002. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35003. }
  35004. }
  35005. declare module "babylonjs/Misc/stringDictionary" {
  35006. import { Nullable } from "babylonjs/types";
  35007. /**
  35008. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35009. * The underlying implementation relies on an associative array to ensure the best performances.
  35010. * The value can be anything including 'null' but except 'undefined'
  35011. */
  35012. export class StringDictionary<T> {
  35013. /**
  35014. * This will clear this dictionary and copy the content from the 'source' one.
  35015. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35016. * @param source the dictionary to take the content from and copy to this dictionary
  35017. */
  35018. copyFrom(source: StringDictionary<T>): void;
  35019. /**
  35020. * Get a value based from its key
  35021. * @param key the given key to get the matching value from
  35022. * @return the value if found, otherwise undefined is returned
  35023. */
  35024. get(key: string): T | undefined;
  35025. /**
  35026. * Get a value from its key or add it if it doesn't exist.
  35027. * This method will ensure you that a given key/data will be present in the dictionary.
  35028. * @param key the given key to get the matching value from
  35029. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35030. * The factory will only be invoked if there's no data for the given key.
  35031. * @return the value corresponding to the key.
  35032. */
  35033. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35034. /**
  35035. * Get a value from its key if present in the dictionary otherwise add it
  35036. * @param key the key to get the value from
  35037. * @param val if there's no such key/value pair in the dictionary add it with this value
  35038. * @return the value corresponding to the key
  35039. */
  35040. getOrAdd(key: string, val: T): T;
  35041. /**
  35042. * Check if there's a given key in the dictionary
  35043. * @param key the key to check for
  35044. * @return true if the key is present, false otherwise
  35045. */
  35046. contains(key: string): boolean;
  35047. /**
  35048. * Add a new key and its corresponding value
  35049. * @param key the key to add
  35050. * @param value the value corresponding to the key
  35051. * @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
  35052. */
  35053. add(key: string, value: T): boolean;
  35054. /**
  35055. * Update a specific value associated to a key
  35056. * @param key defines the key to use
  35057. * @param value defines the value to store
  35058. * @returns true if the value was updated (or false if the key was not found)
  35059. */
  35060. set(key: string, value: T): boolean;
  35061. /**
  35062. * Get the element of the given key and remove it from the dictionary
  35063. * @param key defines the key to search
  35064. * @returns the value associated with the key or null if not found
  35065. */
  35066. getAndRemove(key: string): Nullable<T>;
  35067. /**
  35068. * Remove a key/value from the dictionary.
  35069. * @param key the key to remove
  35070. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35071. */
  35072. remove(key: string): boolean;
  35073. /**
  35074. * Clear the whole content of the dictionary
  35075. */
  35076. clear(): void;
  35077. /**
  35078. * Gets the current count
  35079. */
  35080. readonly count: number;
  35081. /**
  35082. * Execute a callback on each key/val of the dictionary.
  35083. * Note that you can remove any element in this dictionary in the callback implementation
  35084. * @param callback the callback to execute on a given key/value pair
  35085. */
  35086. forEach(callback: (key: string, val: T) => void): void;
  35087. /**
  35088. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35089. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35090. * Note that you can remove any element in this dictionary in the callback implementation
  35091. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35092. * @returns the first item
  35093. */
  35094. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35095. private _count;
  35096. private _data;
  35097. }
  35098. }
  35099. declare module "babylonjs/Collisions/collisionCoordinator" {
  35100. import { Nullable } from "babylonjs/types";
  35101. import { Scene } from "babylonjs/scene";
  35102. import { Vector3 } from "babylonjs/Maths/math.vector";
  35103. import { Collider } from "babylonjs/Collisions/collider";
  35104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35105. /** @hidden */
  35106. export interface ICollisionCoordinator {
  35107. createCollider(): Collider;
  35108. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35109. init(scene: Scene): void;
  35110. }
  35111. /** @hidden */
  35112. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35113. private _scene;
  35114. private _scaledPosition;
  35115. private _scaledVelocity;
  35116. private _finalPosition;
  35117. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35118. createCollider(): Collider;
  35119. init(scene: Scene): void;
  35120. private _collideWithWorld;
  35121. }
  35122. }
  35123. declare module "babylonjs/Inputs/scene.inputManager" {
  35124. import { Nullable } from "babylonjs/types";
  35125. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35126. import { Vector2 } from "babylonjs/Maths/math.vector";
  35127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35128. import { Scene } from "babylonjs/scene";
  35129. /**
  35130. * Class used to manage all inputs for the scene.
  35131. */
  35132. export class InputManager {
  35133. /** The distance in pixel that you have to move to prevent some events */
  35134. static DragMovementThreshold: number;
  35135. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35136. static LongPressDelay: number;
  35137. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35138. static DoubleClickDelay: number;
  35139. /** If you need to check double click without raising a single click at first click, enable this flag */
  35140. static ExclusiveDoubleClickMode: boolean;
  35141. private _wheelEventName;
  35142. private _onPointerMove;
  35143. private _onPointerDown;
  35144. private _onPointerUp;
  35145. private _initClickEvent;
  35146. private _initActionManager;
  35147. private _delayedSimpleClick;
  35148. private _delayedSimpleClickTimeout;
  35149. private _previousDelayedSimpleClickTimeout;
  35150. private _meshPickProceed;
  35151. private _previousButtonPressed;
  35152. private _currentPickResult;
  35153. private _previousPickResult;
  35154. private _totalPointersPressed;
  35155. private _doubleClickOccured;
  35156. private _pointerOverMesh;
  35157. private _pickedDownMesh;
  35158. private _pickedUpMesh;
  35159. private _pointerX;
  35160. private _pointerY;
  35161. private _unTranslatedPointerX;
  35162. private _unTranslatedPointerY;
  35163. private _startingPointerPosition;
  35164. private _previousStartingPointerPosition;
  35165. private _startingPointerTime;
  35166. private _previousStartingPointerTime;
  35167. private _pointerCaptures;
  35168. private _onKeyDown;
  35169. private _onKeyUp;
  35170. private _onCanvasFocusObserver;
  35171. private _onCanvasBlurObserver;
  35172. private _scene;
  35173. /**
  35174. * Creates a new InputManager
  35175. * @param scene defines the hosting scene
  35176. */
  35177. constructor(scene: Scene);
  35178. /**
  35179. * Gets the mesh that is currently under the pointer
  35180. */
  35181. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35182. /**
  35183. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35184. */
  35185. readonly unTranslatedPointer: Vector2;
  35186. /**
  35187. * Gets or sets the current on-screen X position of the pointer
  35188. */
  35189. pointerX: number;
  35190. /**
  35191. * Gets or sets the current on-screen Y position of the pointer
  35192. */
  35193. pointerY: number;
  35194. private _updatePointerPosition;
  35195. private _processPointerMove;
  35196. private _setRayOnPointerInfo;
  35197. private _checkPrePointerObservable;
  35198. /**
  35199. * Use this method to simulate a pointer move on a mesh
  35200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35203. */
  35204. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35205. /**
  35206. * Use this method to simulate a pointer down on a mesh
  35207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35210. */
  35211. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35212. private _processPointerDown;
  35213. /** @hidden */
  35214. _isPointerSwiping(): boolean;
  35215. /**
  35216. * Use this method to simulate a pointer up on a mesh
  35217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35220. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35221. */
  35222. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35223. private _processPointerUp;
  35224. /**
  35225. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35226. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35227. * @returns true if the pointer was captured
  35228. */
  35229. isPointerCaptured(pointerId?: number): boolean;
  35230. /**
  35231. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35232. * @param attachUp defines if you want to attach events to pointerup
  35233. * @param attachDown defines if you want to attach events to pointerdown
  35234. * @param attachMove defines if you want to attach events to pointermove
  35235. */
  35236. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35237. /**
  35238. * Detaches all event handlers
  35239. */
  35240. detachControl(): void;
  35241. /**
  35242. * Force the value of meshUnderPointer
  35243. * @param mesh defines the mesh to use
  35244. */
  35245. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35246. /**
  35247. * Gets the mesh under the pointer
  35248. * @returns a Mesh or null if no mesh is under the pointer
  35249. */
  35250. getPointerOverMesh(): Nullable<AbstractMesh>;
  35251. }
  35252. }
  35253. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35254. /**
  35255. * Helper class used to generate session unique ID
  35256. */
  35257. export class UniqueIdGenerator {
  35258. private static _UniqueIdCounter;
  35259. /**
  35260. * Gets an unique (relatively to the current scene) Id
  35261. */
  35262. static readonly UniqueId: number;
  35263. }
  35264. }
  35265. declare module "babylonjs/Animations/animationGroup" {
  35266. import { Animatable } from "babylonjs/Animations/animatable";
  35267. import { Animation } from "babylonjs/Animations/animation";
  35268. import { Scene, IDisposable } from "babylonjs/scene";
  35269. import { Observable } from "babylonjs/Misc/observable";
  35270. import { Nullable } from "babylonjs/types";
  35271. import "babylonjs/Animations/animatable";
  35272. /**
  35273. * This class defines the direct association between an animation and a target
  35274. */
  35275. export class TargetedAnimation {
  35276. /**
  35277. * Animation to perform
  35278. */
  35279. animation: Animation;
  35280. /**
  35281. * Target to animate
  35282. */
  35283. target: any;
  35284. /**
  35285. * Serialize the object
  35286. * @returns the JSON object representing the current entity
  35287. */
  35288. serialize(): any;
  35289. }
  35290. /**
  35291. * Use this class to create coordinated animations on multiple targets
  35292. */
  35293. export class AnimationGroup implements IDisposable {
  35294. /** The name of the animation group */
  35295. name: string;
  35296. private _scene;
  35297. private _targetedAnimations;
  35298. private _animatables;
  35299. private _from;
  35300. private _to;
  35301. private _isStarted;
  35302. private _isPaused;
  35303. private _speedRatio;
  35304. private _loopAnimation;
  35305. /**
  35306. * Gets or sets the unique id of the node
  35307. */
  35308. uniqueId: number;
  35309. /**
  35310. * This observable will notify when one animation have ended
  35311. */
  35312. onAnimationEndObservable: Observable<TargetedAnimation>;
  35313. /**
  35314. * Observer raised when one animation loops
  35315. */
  35316. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35317. /**
  35318. * Observer raised when all animations have looped
  35319. */
  35320. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35321. /**
  35322. * This observable will notify when all animations have ended.
  35323. */
  35324. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35325. /**
  35326. * This observable will notify when all animations have paused.
  35327. */
  35328. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35329. /**
  35330. * This observable will notify when all animations are playing.
  35331. */
  35332. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35333. /**
  35334. * Gets the first frame
  35335. */
  35336. readonly from: number;
  35337. /**
  35338. * Gets the last frame
  35339. */
  35340. readonly to: number;
  35341. /**
  35342. * Define if the animations are started
  35343. */
  35344. readonly isStarted: boolean;
  35345. /**
  35346. * Gets a value indicating that the current group is playing
  35347. */
  35348. readonly isPlaying: boolean;
  35349. /**
  35350. * Gets or sets the speed ratio to use for all animations
  35351. */
  35352. /**
  35353. * Gets or sets the speed ratio to use for all animations
  35354. */
  35355. speedRatio: number;
  35356. /**
  35357. * Gets or sets if all animations should loop or not
  35358. */
  35359. loopAnimation: boolean;
  35360. /**
  35361. * Gets the targeted animations for this animation group
  35362. */
  35363. readonly targetedAnimations: Array<TargetedAnimation>;
  35364. /**
  35365. * returning the list of animatables controlled by this animation group.
  35366. */
  35367. readonly animatables: Array<Animatable>;
  35368. /**
  35369. * Instantiates a new Animation Group.
  35370. * This helps managing several animations at once.
  35371. * @see http://doc.babylonjs.com/how_to/group
  35372. * @param name Defines the name of the group
  35373. * @param scene Defines the scene the group belongs to
  35374. */
  35375. constructor(
  35376. /** The name of the animation group */
  35377. name: string, scene?: Nullable<Scene>);
  35378. /**
  35379. * Add an animation (with its target) in the group
  35380. * @param animation defines the animation we want to add
  35381. * @param target defines the target of the animation
  35382. * @returns the TargetedAnimation object
  35383. */
  35384. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35385. /**
  35386. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35387. * It can add constant keys at begin or end
  35388. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35389. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35390. * @returns the animation group
  35391. */
  35392. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35393. private _animationLoopCount;
  35394. private _animationLoopFlags;
  35395. private _processLoop;
  35396. /**
  35397. * Start all animations on given targets
  35398. * @param loop defines if animations must loop
  35399. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35400. * @param from defines the from key (optional)
  35401. * @param to defines the to key (optional)
  35402. * @returns the current animation group
  35403. */
  35404. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35405. /**
  35406. * Pause all animations
  35407. * @returns the animation group
  35408. */
  35409. pause(): AnimationGroup;
  35410. /**
  35411. * Play all animations to initial state
  35412. * This function will start() the animations if they were not started or will restart() them if they were paused
  35413. * @param loop defines if animations must loop
  35414. * @returns the animation group
  35415. */
  35416. play(loop?: boolean): AnimationGroup;
  35417. /**
  35418. * Reset all animations to initial state
  35419. * @returns the animation group
  35420. */
  35421. reset(): AnimationGroup;
  35422. /**
  35423. * Restart animations from key 0
  35424. * @returns the animation group
  35425. */
  35426. restart(): AnimationGroup;
  35427. /**
  35428. * Stop all animations
  35429. * @returns the animation group
  35430. */
  35431. stop(): AnimationGroup;
  35432. /**
  35433. * Set animation weight for all animatables
  35434. * @param weight defines the weight to use
  35435. * @return the animationGroup
  35436. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35437. */
  35438. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35439. /**
  35440. * Synchronize and normalize all animatables with a source animatable
  35441. * @param root defines the root animatable to synchronize with
  35442. * @return the animationGroup
  35443. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35444. */
  35445. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35446. /**
  35447. * Goes to a specific frame in this animation group
  35448. * @param frame the frame number to go to
  35449. * @return the animationGroup
  35450. */
  35451. goToFrame(frame: number): AnimationGroup;
  35452. /**
  35453. * Dispose all associated resources
  35454. */
  35455. dispose(): void;
  35456. private _checkAnimationGroupEnded;
  35457. /**
  35458. * Clone the current animation group and returns a copy
  35459. * @param newName defines the name of the new group
  35460. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35461. * @returns the new aniamtion group
  35462. */
  35463. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35464. /**
  35465. * Serializes the animationGroup to an object
  35466. * @returns Serialized object
  35467. */
  35468. serialize(): any;
  35469. /**
  35470. * Returns a new AnimationGroup object parsed from the source provided.
  35471. * @param parsedAnimationGroup defines the source
  35472. * @param scene defines the scene that will receive the animationGroup
  35473. * @returns a new AnimationGroup
  35474. */
  35475. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35476. /**
  35477. * Returns the string "AnimationGroup"
  35478. * @returns "AnimationGroup"
  35479. */
  35480. getClassName(): string;
  35481. /**
  35482. * Creates a detailled string about the object
  35483. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35484. * @returns a string representing the object
  35485. */
  35486. toString(fullDetails?: boolean): string;
  35487. }
  35488. }
  35489. declare module "babylonjs/scene" {
  35490. import { Nullable } from "babylonjs/types";
  35491. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35492. import { Observable } from "babylonjs/Misc/observable";
  35493. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35494. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35495. import { Geometry } from "babylonjs/Meshes/geometry";
  35496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35499. import { Mesh } from "babylonjs/Meshes/mesh";
  35500. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35501. import { Bone } from "babylonjs/Bones/bone";
  35502. import { Skeleton } from "babylonjs/Bones/skeleton";
  35503. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35504. import { Camera } from "babylonjs/Cameras/camera";
  35505. import { AbstractScene } from "babylonjs/abstractScene";
  35506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35507. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35508. import { Material } from "babylonjs/Materials/material";
  35509. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35510. import { Effect } from "babylonjs/Materials/effect";
  35511. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35512. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35513. import { Light } from "babylonjs/Lights/light";
  35514. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35515. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35516. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35517. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35518. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35519. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35520. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35521. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35522. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35523. import { Engine } from "babylonjs/Engines/engine";
  35524. import { Node } from "babylonjs/node";
  35525. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35526. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35527. import { WebRequest } from "babylonjs/Misc/webRequest";
  35528. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35529. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35530. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35531. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35532. import { Plane } from "babylonjs/Maths/math.plane";
  35533. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35534. import { Ray } from "babylonjs/Culling/ray";
  35535. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35536. import { Animation } from "babylonjs/Animations/animation";
  35537. import { Animatable } from "babylonjs/Animations/animatable";
  35538. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35539. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35540. import { Collider } from "babylonjs/Collisions/collider";
  35541. /**
  35542. * Define an interface for all classes that will hold resources
  35543. */
  35544. export interface IDisposable {
  35545. /**
  35546. * Releases all held resources
  35547. */
  35548. dispose(): void;
  35549. }
  35550. /** Interface defining initialization parameters for Scene class */
  35551. export interface SceneOptions {
  35552. /**
  35553. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35554. * It will improve performance when the number of geometries becomes important.
  35555. */
  35556. useGeometryUniqueIdsMap?: boolean;
  35557. /**
  35558. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35559. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35560. */
  35561. useMaterialMeshMap?: boolean;
  35562. /**
  35563. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35564. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35565. */
  35566. useClonedMeshhMap?: boolean;
  35567. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35568. virtual?: boolean;
  35569. }
  35570. /**
  35571. * Represents a scene to be rendered by the engine.
  35572. * @see http://doc.babylonjs.com/features/scene
  35573. */
  35574. export class Scene extends AbstractScene implements IAnimatable {
  35575. /** The fog is deactivated */
  35576. static readonly FOGMODE_NONE: number;
  35577. /** The fog density is following an exponential function */
  35578. static readonly FOGMODE_EXP: number;
  35579. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35580. static readonly FOGMODE_EXP2: number;
  35581. /** The fog density is following a linear function. */
  35582. static readonly FOGMODE_LINEAR: number;
  35583. /**
  35584. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35585. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35586. */
  35587. static MinDeltaTime: number;
  35588. /**
  35589. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35590. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35591. */
  35592. static MaxDeltaTime: number;
  35593. /**
  35594. * Factory used to create the default material.
  35595. * @param name The name of the material to create
  35596. * @param scene The scene to create the material for
  35597. * @returns The default material
  35598. */
  35599. static DefaultMaterialFactory(scene: Scene): Material;
  35600. /**
  35601. * Factory used to create the a collision coordinator.
  35602. * @returns The collision coordinator
  35603. */
  35604. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35605. /** @hidden */
  35606. _inputManager: InputManager;
  35607. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35608. cameraToUseForPointers: Nullable<Camera>;
  35609. /** @hidden */
  35610. readonly _isScene: boolean;
  35611. /**
  35612. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35613. */
  35614. autoClear: boolean;
  35615. /**
  35616. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35617. */
  35618. autoClearDepthAndStencil: boolean;
  35619. /**
  35620. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35621. */
  35622. clearColor: Color4;
  35623. /**
  35624. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35625. */
  35626. ambientColor: Color3;
  35627. /**
  35628. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35629. * It should only be one of the following (if not the default embedded one):
  35630. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35631. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35632. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35633. * The material properties need to be setup according to the type of texture in use.
  35634. */
  35635. environmentBRDFTexture: BaseTexture;
  35636. /** @hidden */
  35637. protected _environmentTexture: Nullable<BaseTexture>;
  35638. /**
  35639. * Texture used in all pbr material as the reflection texture.
  35640. * As in the majority of the scene they are the same (exception for multi room and so on),
  35641. * this is easier to reference from here than from all the materials.
  35642. */
  35643. /**
  35644. * Texture used in all pbr material as the reflection texture.
  35645. * As in the majority of the scene they are the same (exception for multi room and so on),
  35646. * this is easier to set here than in all the materials.
  35647. */
  35648. environmentTexture: Nullable<BaseTexture>;
  35649. /** @hidden */
  35650. protected _environmentIntensity: number;
  35651. /**
  35652. * Intensity of the environment in all pbr material.
  35653. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35654. * As in the majority of the scene they are the same (exception for multi room and so on),
  35655. * this is easier to reference from here than from all the materials.
  35656. */
  35657. /**
  35658. * Intensity of the environment in all pbr material.
  35659. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35660. * As in the majority of the scene they are the same (exception for multi room and so on),
  35661. * this is easier to set here than in all the materials.
  35662. */
  35663. environmentIntensity: number;
  35664. /** @hidden */
  35665. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35666. /**
  35667. * Default image processing configuration used either in the rendering
  35668. * Forward main pass or through the imageProcessingPostProcess if present.
  35669. * As in the majority of the scene they are the same (exception for multi camera),
  35670. * this is easier to reference from here than from all the materials and post process.
  35671. *
  35672. * No setter as we it is a shared configuration, you can set the values instead.
  35673. */
  35674. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35675. private _forceWireframe;
  35676. /**
  35677. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35678. */
  35679. forceWireframe: boolean;
  35680. private _forcePointsCloud;
  35681. /**
  35682. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35683. */
  35684. forcePointsCloud: boolean;
  35685. /**
  35686. * Gets or sets the active clipplane 1
  35687. */
  35688. clipPlane: Nullable<Plane>;
  35689. /**
  35690. * Gets or sets the active clipplane 2
  35691. */
  35692. clipPlane2: Nullable<Plane>;
  35693. /**
  35694. * Gets or sets the active clipplane 3
  35695. */
  35696. clipPlane3: Nullable<Plane>;
  35697. /**
  35698. * Gets or sets the active clipplane 4
  35699. */
  35700. clipPlane4: Nullable<Plane>;
  35701. /**
  35702. * Gets or sets a boolean indicating if animations are enabled
  35703. */
  35704. animationsEnabled: boolean;
  35705. private _animationPropertiesOverride;
  35706. /**
  35707. * Gets or sets the animation properties override
  35708. */
  35709. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35710. /**
  35711. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35712. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35713. */
  35714. useConstantAnimationDeltaTime: boolean;
  35715. /**
  35716. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35717. * Please note that it requires to run a ray cast through the scene on every frame
  35718. */
  35719. constantlyUpdateMeshUnderPointer: boolean;
  35720. /**
  35721. * Defines the HTML cursor to use when hovering over interactive elements
  35722. */
  35723. hoverCursor: string;
  35724. /**
  35725. * Defines the HTML default cursor to use (empty by default)
  35726. */
  35727. defaultCursor: string;
  35728. /**
  35729. * Defines wether cursors are handled by the scene.
  35730. */
  35731. doNotHandleCursors: boolean;
  35732. /**
  35733. * This is used to call preventDefault() on pointer down
  35734. * in order to block unwanted artifacts like system double clicks
  35735. */
  35736. preventDefaultOnPointerDown: boolean;
  35737. /**
  35738. * This is used to call preventDefault() on pointer up
  35739. * in order to block unwanted artifacts like system double clicks
  35740. */
  35741. preventDefaultOnPointerUp: boolean;
  35742. /**
  35743. * Gets or sets user defined metadata
  35744. */
  35745. metadata: any;
  35746. /**
  35747. * For internal use only. Please do not use.
  35748. */
  35749. reservedDataStore: any;
  35750. /**
  35751. * Gets the name of the plugin used to load this scene (null by default)
  35752. */
  35753. loadingPluginName: string;
  35754. /**
  35755. * Use this array to add regular expressions used to disable offline support for specific urls
  35756. */
  35757. disableOfflineSupportExceptionRules: RegExp[];
  35758. /**
  35759. * An event triggered when the scene is disposed.
  35760. */
  35761. onDisposeObservable: Observable<Scene>;
  35762. private _onDisposeObserver;
  35763. /** Sets a function to be executed when this scene is disposed. */
  35764. onDispose: () => void;
  35765. /**
  35766. * An event triggered before rendering the scene (right after animations and physics)
  35767. */
  35768. onBeforeRenderObservable: Observable<Scene>;
  35769. private _onBeforeRenderObserver;
  35770. /** Sets a function to be executed before rendering this scene */
  35771. beforeRender: Nullable<() => void>;
  35772. /**
  35773. * An event triggered after rendering the scene
  35774. */
  35775. onAfterRenderObservable: Observable<Scene>;
  35776. /**
  35777. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35778. */
  35779. onAfterRenderCameraObservable: Observable<Camera>;
  35780. private _onAfterRenderObserver;
  35781. /** Sets a function to be executed after rendering this scene */
  35782. afterRender: Nullable<() => void>;
  35783. /**
  35784. * An event triggered before animating the scene
  35785. */
  35786. onBeforeAnimationsObservable: Observable<Scene>;
  35787. /**
  35788. * An event triggered after animations processing
  35789. */
  35790. onAfterAnimationsObservable: Observable<Scene>;
  35791. /**
  35792. * An event triggered before draw calls are ready to be sent
  35793. */
  35794. onBeforeDrawPhaseObservable: Observable<Scene>;
  35795. /**
  35796. * An event triggered after draw calls have been sent
  35797. */
  35798. onAfterDrawPhaseObservable: Observable<Scene>;
  35799. /**
  35800. * An event triggered when the scene is ready
  35801. */
  35802. onReadyObservable: Observable<Scene>;
  35803. /**
  35804. * An event triggered before rendering a camera
  35805. */
  35806. onBeforeCameraRenderObservable: Observable<Camera>;
  35807. private _onBeforeCameraRenderObserver;
  35808. /** Sets a function to be executed before rendering a camera*/
  35809. beforeCameraRender: () => void;
  35810. /**
  35811. * An event triggered after rendering a camera
  35812. */
  35813. onAfterCameraRenderObservable: Observable<Camera>;
  35814. private _onAfterCameraRenderObserver;
  35815. /** Sets a function to be executed after rendering a camera*/
  35816. afterCameraRender: () => void;
  35817. /**
  35818. * An event triggered when active meshes evaluation is about to start
  35819. */
  35820. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35821. /**
  35822. * An event triggered when active meshes evaluation is done
  35823. */
  35824. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35825. /**
  35826. * An event triggered when particles rendering is about to start
  35827. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35828. */
  35829. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35830. /**
  35831. * An event triggered when particles rendering is done
  35832. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35833. */
  35834. onAfterParticlesRenderingObservable: Observable<Scene>;
  35835. /**
  35836. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35837. */
  35838. onDataLoadedObservable: Observable<Scene>;
  35839. /**
  35840. * An event triggered when a camera is created
  35841. */
  35842. onNewCameraAddedObservable: Observable<Camera>;
  35843. /**
  35844. * An event triggered when a camera is removed
  35845. */
  35846. onCameraRemovedObservable: Observable<Camera>;
  35847. /**
  35848. * An event triggered when a light is created
  35849. */
  35850. onNewLightAddedObservable: Observable<Light>;
  35851. /**
  35852. * An event triggered when a light is removed
  35853. */
  35854. onLightRemovedObservable: Observable<Light>;
  35855. /**
  35856. * An event triggered when a geometry is created
  35857. */
  35858. onNewGeometryAddedObservable: Observable<Geometry>;
  35859. /**
  35860. * An event triggered when a geometry is removed
  35861. */
  35862. onGeometryRemovedObservable: Observable<Geometry>;
  35863. /**
  35864. * An event triggered when a transform node is created
  35865. */
  35866. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35867. /**
  35868. * An event triggered when a transform node is removed
  35869. */
  35870. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35871. /**
  35872. * An event triggered when a mesh is created
  35873. */
  35874. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35875. /**
  35876. * An event triggered when a mesh is removed
  35877. */
  35878. onMeshRemovedObservable: Observable<AbstractMesh>;
  35879. /**
  35880. * An event triggered when a skeleton is created
  35881. */
  35882. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35883. /**
  35884. * An event triggered when a skeleton is removed
  35885. */
  35886. onSkeletonRemovedObservable: Observable<Skeleton>;
  35887. /**
  35888. * An event triggered when a material is created
  35889. */
  35890. onNewMaterialAddedObservable: Observable<Material>;
  35891. /**
  35892. * An event triggered when a material is removed
  35893. */
  35894. onMaterialRemovedObservable: Observable<Material>;
  35895. /**
  35896. * An event triggered when a texture is created
  35897. */
  35898. onNewTextureAddedObservable: Observable<BaseTexture>;
  35899. /**
  35900. * An event triggered when a texture is removed
  35901. */
  35902. onTextureRemovedObservable: Observable<BaseTexture>;
  35903. /**
  35904. * An event triggered when render targets are about to be rendered
  35905. * Can happen multiple times per frame.
  35906. */
  35907. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35908. /**
  35909. * An event triggered when render targets were rendered.
  35910. * Can happen multiple times per frame.
  35911. */
  35912. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35913. /**
  35914. * An event triggered before calculating deterministic simulation step
  35915. */
  35916. onBeforeStepObservable: Observable<Scene>;
  35917. /**
  35918. * An event triggered after calculating deterministic simulation step
  35919. */
  35920. onAfterStepObservable: Observable<Scene>;
  35921. /**
  35922. * An event triggered when the activeCamera property is updated
  35923. */
  35924. onActiveCameraChanged: Observable<Scene>;
  35925. /**
  35926. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35927. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35928. * 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)
  35929. */
  35930. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35931. /**
  35932. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35933. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35934. * 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)
  35935. */
  35936. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35937. /**
  35938. * This Observable will when a mesh has been imported into the scene.
  35939. */
  35940. onMeshImportedObservable: Observable<AbstractMesh>;
  35941. /**
  35942. * This Observable will when an animation file has been imported into the scene.
  35943. */
  35944. onAnimationFileImportedObservable: Observable<Scene>;
  35945. /**
  35946. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35947. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35948. */
  35949. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35950. /** @hidden */
  35951. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35952. /**
  35953. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35954. */
  35955. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35956. /**
  35957. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35958. */
  35959. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35960. /**
  35961. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35962. */
  35963. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35964. /** Callback called when a pointer move is detected */
  35965. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35966. /** Callback called when a pointer down is detected */
  35967. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35968. /** Callback called when a pointer up is detected */
  35969. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35970. /** Callback called when a pointer pick is detected */
  35971. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35972. /**
  35973. * 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).
  35974. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35975. */
  35976. onPrePointerObservable: Observable<PointerInfoPre>;
  35977. /**
  35978. * Observable event triggered each time an input event is received from the rendering canvas
  35979. */
  35980. onPointerObservable: Observable<PointerInfo>;
  35981. /**
  35982. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35983. */
  35984. readonly unTranslatedPointer: Vector2;
  35985. /**
  35986. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35987. */
  35988. static DragMovementThreshold: number;
  35989. /**
  35990. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35991. */
  35992. static LongPressDelay: number;
  35993. /**
  35994. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35995. */
  35996. static DoubleClickDelay: number;
  35997. /** If you need to check double click without raising a single click at first click, enable this flag */
  35998. static ExclusiveDoubleClickMode: boolean;
  35999. /** @hidden */
  36000. _mirroredCameraPosition: Nullable<Vector3>;
  36001. /**
  36002. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36003. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36004. */
  36005. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36006. /**
  36007. * Observable event triggered each time an keyboard event is received from the hosting window
  36008. */
  36009. onKeyboardObservable: Observable<KeyboardInfo>;
  36010. private _useRightHandedSystem;
  36011. /**
  36012. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36013. */
  36014. useRightHandedSystem: boolean;
  36015. private _timeAccumulator;
  36016. private _currentStepId;
  36017. private _currentInternalStep;
  36018. /**
  36019. * Sets the step Id used by deterministic lock step
  36020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36021. * @param newStepId defines the step Id
  36022. */
  36023. setStepId(newStepId: number): void;
  36024. /**
  36025. * Gets the step Id used by deterministic lock step
  36026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36027. * @returns the step Id
  36028. */
  36029. getStepId(): number;
  36030. /**
  36031. * Gets the internal step used by deterministic lock step
  36032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36033. * @returns the internal step
  36034. */
  36035. getInternalStep(): number;
  36036. private _fogEnabled;
  36037. /**
  36038. * Gets or sets a boolean indicating if fog is enabled on this scene
  36039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36040. * (Default is true)
  36041. */
  36042. fogEnabled: boolean;
  36043. private _fogMode;
  36044. /**
  36045. * Gets or sets the fog mode to use
  36046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36047. * | mode | value |
  36048. * | --- | --- |
  36049. * | FOGMODE_NONE | 0 |
  36050. * | FOGMODE_EXP | 1 |
  36051. * | FOGMODE_EXP2 | 2 |
  36052. * | FOGMODE_LINEAR | 3 |
  36053. */
  36054. fogMode: number;
  36055. /**
  36056. * Gets or sets the fog color to use
  36057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36058. * (Default is Color3(0.2, 0.2, 0.3))
  36059. */
  36060. fogColor: Color3;
  36061. /**
  36062. * Gets or sets the fog density to use
  36063. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36064. * (Default is 0.1)
  36065. */
  36066. fogDensity: number;
  36067. /**
  36068. * Gets or sets the fog start distance to use
  36069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36070. * (Default is 0)
  36071. */
  36072. fogStart: number;
  36073. /**
  36074. * Gets or sets the fog end distance to use
  36075. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36076. * (Default is 1000)
  36077. */
  36078. fogEnd: number;
  36079. private _shadowsEnabled;
  36080. /**
  36081. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36082. */
  36083. shadowsEnabled: boolean;
  36084. private _lightsEnabled;
  36085. /**
  36086. * Gets or sets a boolean indicating if lights are enabled on this scene
  36087. */
  36088. lightsEnabled: boolean;
  36089. /** All of the active cameras added to this scene. */
  36090. activeCameras: Camera[];
  36091. /** @hidden */
  36092. _activeCamera: Nullable<Camera>;
  36093. /** Gets or sets the current active camera */
  36094. activeCamera: Nullable<Camera>;
  36095. private _defaultMaterial;
  36096. /** The default material used on meshes when no material is affected */
  36097. /** The default material used on meshes when no material is affected */
  36098. defaultMaterial: Material;
  36099. private _texturesEnabled;
  36100. /**
  36101. * Gets or sets a boolean indicating if textures are enabled on this scene
  36102. */
  36103. texturesEnabled: boolean;
  36104. /**
  36105. * Gets or sets a boolean indicating if particles are enabled on this scene
  36106. */
  36107. particlesEnabled: boolean;
  36108. /**
  36109. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36110. */
  36111. spritesEnabled: boolean;
  36112. private _skeletonsEnabled;
  36113. /**
  36114. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36115. */
  36116. skeletonsEnabled: boolean;
  36117. /**
  36118. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36119. */
  36120. lensFlaresEnabled: boolean;
  36121. /**
  36122. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36124. */
  36125. collisionsEnabled: boolean;
  36126. private _collisionCoordinator;
  36127. /** @hidden */
  36128. readonly collisionCoordinator: ICollisionCoordinator;
  36129. /**
  36130. * Defines the gravity applied to this scene (used only for collisions)
  36131. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36132. */
  36133. gravity: Vector3;
  36134. /**
  36135. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36136. */
  36137. postProcessesEnabled: boolean;
  36138. /**
  36139. * The list of postprocesses added to the scene
  36140. */
  36141. postProcesses: PostProcess[];
  36142. /**
  36143. * Gets the current postprocess manager
  36144. */
  36145. postProcessManager: PostProcessManager;
  36146. /**
  36147. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36148. */
  36149. renderTargetsEnabled: boolean;
  36150. /**
  36151. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36152. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36153. */
  36154. dumpNextRenderTargets: boolean;
  36155. /**
  36156. * The list of user defined render targets added to the scene
  36157. */
  36158. customRenderTargets: RenderTargetTexture[];
  36159. /**
  36160. * Defines if texture loading must be delayed
  36161. * If true, textures will only be loaded when they need to be rendered
  36162. */
  36163. useDelayedTextureLoading: boolean;
  36164. /**
  36165. * Gets the list of meshes imported to the scene through SceneLoader
  36166. */
  36167. importedMeshesFiles: String[];
  36168. /**
  36169. * Gets or sets a boolean indicating if probes are enabled on this scene
  36170. */
  36171. probesEnabled: boolean;
  36172. /**
  36173. * Gets or sets the current offline provider to use to store scene data
  36174. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36175. */
  36176. offlineProvider: IOfflineProvider;
  36177. /**
  36178. * Gets or sets the action manager associated with the scene
  36179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36180. */
  36181. actionManager: AbstractActionManager;
  36182. private _meshesForIntersections;
  36183. /**
  36184. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36185. */
  36186. proceduralTexturesEnabled: boolean;
  36187. private _engine;
  36188. private _totalVertices;
  36189. /** @hidden */
  36190. _activeIndices: PerfCounter;
  36191. /** @hidden */
  36192. _activeParticles: PerfCounter;
  36193. /** @hidden */
  36194. _activeBones: PerfCounter;
  36195. private _animationRatio;
  36196. /** @hidden */
  36197. _animationTimeLast: number;
  36198. /** @hidden */
  36199. _animationTime: number;
  36200. /**
  36201. * Gets or sets a general scale for animation speed
  36202. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36203. */
  36204. animationTimeScale: number;
  36205. /** @hidden */
  36206. _cachedMaterial: Nullable<Material>;
  36207. /** @hidden */
  36208. _cachedEffect: Nullable<Effect>;
  36209. /** @hidden */
  36210. _cachedVisibility: Nullable<number>;
  36211. private _renderId;
  36212. private _frameId;
  36213. private _executeWhenReadyTimeoutId;
  36214. private _intermediateRendering;
  36215. private _viewUpdateFlag;
  36216. private _projectionUpdateFlag;
  36217. /** @hidden */
  36218. _toBeDisposed: Nullable<IDisposable>[];
  36219. private _activeRequests;
  36220. /** @hidden */
  36221. _pendingData: any[];
  36222. private _isDisposed;
  36223. /**
  36224. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36225. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36226. */
  36227. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36228. private _activeMeshes;
  36229. private _processedMaterials;
  36230. private _renderTargets;
  36231. /** @hidden */
  36232. _activeParticleSystems: SmartArray<IParticleSystem>;
  36233. private _activeSkeletons;
  36234. private _softwareSkinnedMeshes;
  36235. private _renderingManager;
  36236. /** @hidden */
  36237. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36238. private _transformMatrix;
  36239. private _sceneUbo;
  36240. /** @hidden */
  36241. _viewMatrix: Matrix;
  36242. private _projectionMatrix;
  36243. /** @hidden */
  36244. _forcedViewPosition: Nullable<Vector3>;
  36245. /** @hidden */
  36246. _frustumPlanes: Plane[];
  36247. /**
  36248. * Gets the list of frustum planes (built from the active camera)
  36249. */
  36250. readonly frustumPlanes: Plane[];
  36251. /**
  36252. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36253. * This is useful if there are more lights that the maximum simulteanous authorized
  36254. */
  36255. requireLightSorting: boolean;
  36256. /** @hidden */
  36257. readonly useMaterialMeshMap: boolean;
  36258. /** @hidden */
  36259. readonly useClonedMeshhMap: boolean;
  36260. private _externalData;
  36261. private _uid;
  36262. /**
  36263. * @hidden
  36264. * Backing store of defined scene components.
  36265. */
  36266. _components: ISceneComponent[];
  36267. /**
  36268. * @hidden
  36269. * Backing store of defined scene components.
  36270. */
  36271. _serializableComponents: ISceneSerializableComponent[];
  36272. /**
  36273. * List of components to register on the next registration step.
  36274. */
  36275. private _transientComponents;
  36276. /**
  36277. * Registers the transient components if needed.
  36278. */
  36279. private _registerTransientComponents;
  36280. /**
  36281. * @hidden
  36282. * Add a component to the scene.
  36283. * Note that the ccomponent could be registered on th next frame if this is called after
  36284. * the register component stage.
  36285. * @param component Defines the component to add to the scene
  36286. */
  36287. _addComponent(component: ISceneComponent): void;
  36288. /**
  36289. * @hidden
  36290. * Gets a component from the scene.
  36291. * @param name defines the name of the component to retrieve
  36292. * @returns the component or null if not present
  36293. */
  36294. _getComponent(name: string): Nullable<ISceneComponent>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening before camera updates.
  36298. */
  36299. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening before clear the canvas.
  36303. */
  36304. _beforeClearStage: Stage<SimpleStageAction>;
  36305. /**
  36306. * @hidden
  36307. * Defines the actions when collecting render targets for the frame.
  36308. */
  36309. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36310. /**
  36311. * @hidden
  36312. * Defines the actions happening for one camera in the frame.
  36313. */
  36314. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36315. /**
  36316. * @hidden
  36317. * Defines the actions happening during the per mesh ready checks.
  36318. */
  36319. _isReadyForMeshStage: Stage<MeshStageAction>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening before evaluate active mesh checks.
  36323. */
  36324. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening during the evaluate sub mesh checks.
  36328. */
  36329. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions happening during the active mesh stage.
  36333. */
  36334. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36335. /**
  36336. * @hidden
  36337. * Defines the actions happening during the per camera render target step.
  36338. */
  36339. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36340. /**
  36341. * @hidden
  36342. * Defines the actions happening just before the active camera is drawing.
  36343. */
  36344. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36345. /**
  36346. * @hidden
  36347. * Defines the actions happening just before a render target is drawing.
  36348. */
  36349. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36350. /**
  36351. * @hidden
  36352. * Defines the actions happening just before a rendering group is drawing.
  36353. */
  36354. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36355. /**
  36356. * @hidden
  36357. * Defines the actions happening just before a mesh is drawing.
  36358. */
  36359. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36360. /**
  36361. * @hidden
  36362. * Defines the actions happening just after a mesh has been drawn.
  36363. */
  36364. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36365. /**
  36366. * @hidden
  36367. * Defines the actions happening just after a rendering group has been drawn.
  36368. */
  36369. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36370. /**
  36371. * @hidden
  36372. * Defines the actions happening just after the active camera has been drawn.
  36373. */
  36374. _afterCameraDrawStage: Stage<CameraStageAction>;
  36375. /**
  36376. * @hidden
  36377. * Defines the actions happening just after a render target has been drawn.
  36378. */
  36379. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36380. /**
  36381. * @hidden
  36382. * Defines the actions happening just after rendering all cameras and computing intersections.
  36383. */
  36384. _afterRenderStage: Stage<SimpleStageAction>;
  36385. /**
  36386. * @hidden
  36387. * Defines the actions happening when a pointer move event happens.
  36388. */
  36389. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36390. /**
  36391. * @hidden
  36392. * Defines the actions happening when a pointer down event happens.
  36393. */
  36394. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36395. /**
  36396. * @hidden
  36397. * Defines the actions happening when a pointer up event happens.
  36398. */
  36399. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36400. /**
  36401. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36402. */
  36403. private geometriesByUniqueId;
  36404. /**
  36405. * Creates a new Scene
  36406. * @param engine defines the engine to use to render this scene
  36407. * @param options defines the scene options
  36408. */
  36409. constructor(engine: Engine, options?: SceneOptions);
  36410. /**
  36411. * Gets a string idenfifying the name of the class
  36412. * @returns "Scene" string
  36413. */
  36414. getClassName(): string;
  36415. private _defaultMeshCandidates;
  36416. /**
  36417. * @hidden
  36418. */
  36419. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36420. private _defaultSubMeshCandidates;
  36421. /**
  36422. * @hidden
  36423. */
  36424. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36425. /**
  36426. * Sets the default candidate providers for the scene.
  36427. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36428. * and getCollidingSubMeshCandidates to their default function
  36429. */
  36430. setDefaultCandidateProviders(): void;
  36431. /**
  36432. * Gets the mesh that is currently under the pointer
  36433. */
  36434. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36435. /**
  36436. * Gets or sets the current on-screen X position of the pointer
  36437. */
  36438. pointerX: number;
  36439. /**
  36440. * Gets or sets the current on-screen Y position of the pointer
  36441. */
  36442. pointerY: number;
  36443. /**
  36444. * Gets the cached material (ie. the latest rendered one)
  36445. * @returns the cached material
  36446. */
  36447. getCachedMaterial(): Nullable<Material>;
  36448. /**
  36449. * Gets the cached effect (ie. the latest rendered one)
  36450. * @returns the cached effect
  36451. */
  36452. getCachedEffect(): Nullable<Effect>;
  36453. /**
  36454. * Gets the cached visibility state (ie. the latest rendered one)
  36455. * @returns the cached visibility state
  36456. */
  36457. getCachedVisibility(): Nullable<number>;
  36458. /**
  36459. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36460. * @param material defines the current material
  36461. * @param effect defines the current effect
  36462. * @param visibility defines the current visibility state
  36463. * @returns true if one parameter is not cached
  36464. */
  36465. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36466. /**
  36467. * Gets the engine associated with the scene
  36468. * @returns an Engine
  36469. */
  36470. getEngine(): Engine;
  36471. /**
  36472. * Gets the total number of vertices rendered per frame
  36473. * @returns the total number of vertices rendered per frame
  36474. */
  36475. getTotalVertices(): number;
  36476. /**
  36477. * Gets the performance counter for total vertices
  36478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36479. */
  36480. readonly totalVerticesPerfCounter: PerfCounter;
  36481. /**
  36482. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36483. * @returns the total number of active indices rendered per frame
  36484. */
  36485. getActiveIndices(): number;
  36486. /**
  36487. * Gets the performance counter for active indices
  36488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36489. */
  36490. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36491. /**
  36492. * Gets the total number of active particles rendered per frame
  36493. * @returns the total number of active particles rendered per frame
  36494. */
  36495. getActiveParticles(): number;
  36496. /**
  36497. * Gets the performance counter for active particles
  36498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36499. */
  36500. readonly activeParticlesPerfCounter: PerfCounter;
  36501. /**
  36502. * Gets the total number of active bones rendered per frame
  36503. * @returns the total number of active bones rendered per frame
  36504. */
  36505. getActiveBones(): number;
  36506. /**
  36507. * Gets the performance counter for active bones
  36508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36509. */
  36510. readonly activeBonesPerfCounter: PerfCounter;
  36511. /**
  36512. * Gets the array of active meshes
  36513. * @returns an array of AbstractMesh
  36514. */
  36515. getActiveMeshes(): SmartArray<AbstractMesh>;
  36516. /**
  36517. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36518. * @returns a number
  36519. */
  36520. getAnimationRatio(): number;
  36521. /**
  36522. * Gets an unique Id for the current render phase
  36523. * @returns a number
  36524. */
  36525. getRenderId(): number;
  36526. /**
  36527. * Gets an unique Id for the current frame
  36528. * @returns a number
  36529. */
  36530. getFrameId(): number;
  36531. /** Call this function if you want to manually increment the render Id*/
  36532. incrementRenderId(): void;
  36533. private _createUbo;
  36534. /**
  36535. * Use this method to simulate a pointer move on a mesh
  36536. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36537. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36538. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36539. * @returns the current scene
  36540. */
  36541. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36542. /**
  36543. * Use this method to simulate a pointer down on a mesh
  36544. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36545. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36546. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36547. * @returns the current scene
  36548. */
  36549. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36550. /**
  36551. * Use this method to simulate a pointer up on a mesh
  36552. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36553. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36554. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36555. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36556. * @returns the current scene
  36557. */
  36558. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36559. /**
  36560. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36561. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36562. * @returns true if the pointer was captured
  36563. */
  36564. isPointerCaptured(pointerId?: number): boolean;
  36565. /**
  36566. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36567. * @param attachUp defines if you want to attach events to pointerup
  36568. * @param attachDown defines if you want to attach events to pointerdown
  36569. * @param attachMove defines if you want to attach events to pointermove
  36570. */
  36571. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36572. /** Detaches all event handlers*/
  36573. detachControl(): void;
  36574. /**
  36575. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36576. * Delay loaded resources are not taking in account
  36577. * @return true if all required resources are ready
  36578. */
  36579. isReady(): boolean;
  36580. /** Resets all cached information relative to material (including effect and visibility) */
  36581. resetCachedMaterial(): void;
  36582. /**
  36583. * Registers a function to be called before every frame render
  36584. * @param func defines the function to register
  36585. */
  36586. registerBeforeRender(func: () => void): void;
  36587. /**
  36588. * Unregisters a function called before every frame render
  36589. * @param func defines the function to unregister
  36590. */
  36591. unregisterBeforeRender(func: () => void): void;
  36592. /**
  36593. * Registers a function to be called after every frame render
  36594. * @param func defines the function to register
  36595. */
  36596. registerAfterRender(func: () => void): void;
  36597. /**
  36598. * Unregisters a function called after every frame render
  36599. * @param func defines the function to unregister
  36600. */
  36601. unregisterAfterRender(func: () => void): void;
  36602. private _executeOnceBeforeRender;
  36603. /**
  36604. * The provided function will run before render once and will be disposed afterwards.
  36605. * A timeout delay can be provided so that the function will be executed in N ms.
  36606. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36607. * @param func The function to be executed.
  36608. * @param timeout optional delay in ms
  36609. */
  36610. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36611. /** @hidden */
  36612. _addPendingData(data: any): void;
  36613. /** @hidden */
  36614. _removePendingData(data: any): void;
  36615. /**
  36616. * Returns the number of items waiting to be loaded
  36617. * @returns the number of items waiting to be loaded
  36618. */
  36619. getWaitingItemsCount(): number;
  36620. /**
  36621. * Returns a boolean indicating if the scene is still loading data
  36622. */
  36623. readonly isLoading: boolean;
  36624. /**
  36625. * Registers a function to be executed when the scene is ready
  36626. * @param {Function} func - the function to be executed
  36627. */
  36628. executeWhenReady(func: () => void): void;
  36629. /**
  36630. * Returns a promise that resolves when the scene is ready
  36631. * @returns A promise that resolves when the scene is ready
  36632. */
  36633. whenReadyAsync(): Promise<void>;
  36634. /** @hidden */
  36635. _checkIsReady(): void;
  36636. /**
  36637. * Gets all animatable attached to the scene
  36638. */
  36639. readonly animatables: Animatable[];
  36640. /**
  36641. * Resets the last animation time frame.
  36642. * Useful to override when animations start running when loading a scene for the first time.
  36643. */
  36644. resetLastAnimationTimeFrame(): void;
  36645. /**
  36646. * Gets the current view matrix
  36647. * @returns a Matrix
  36648. */
  36649. getViewMatrix(): Matrix;
  36650. /**
  36651. * Gets the current projection matrix
  36652. * @returns a Matrix
  36653. */
  36654. getProjectionMatrix(): Matrix;
  36655. /**
  36656. * Gets the current transform matrix
  36657. * @returns a Matrix made of View * Projection
  36658. */
  36659. getTransformMatrix(): Matrix;
  36660. /**
  36661. * Sets the current transform matrix
  36662. * @param viewL defines the View matrix to use
  36663. * @param projectionL defines the Projection matrix to use
  36664. * @param viewR defines the right View matrix to use (if provided)
  36665. * @param projectionR defines the right Projection matrix to use (if provided)
  36666. */
  36667. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36668. /**
  36669. * Gets the uniform buffer used to store scene data
  36670. * @returns a UniformBuffer
  36671. */
  36672. getSceneUniformBuffer(): UniformBuffer;
  36673. /**
  36674. * Gets an unique (relatively to the current scene) Id
  36675. * @returns an unique number for the scene
  36676. */
  36677. getUniqueId(): number;
  36678. /**
  36679. * Add a mesh to the list of scene's meshes
  36680. * @param newMesh defines the mesh to add
  36681. * @param recursive if all child meshes should also be added to the scene
  36682. */
  36683. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36684. /**
  36685. * Remove a mesh for the list of scene's meshes
  36686. * @param toRemove defines the mesh to remove
  36687. * @param recursive if all child meshes should also be removed from the scene
  36688. * @returns the index where the mesh was in the mesh list
  36689. */
  36690. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36691. /**
  36692. * Add a transform node to the list of scene's transform nodes
  36693. * @param newTransformNode defines the transform node to add
  36694. */
  36695. addTransformNode(newTransformNode: TransformNode): void;
  36696. /**
  36697. * Remove a transform node for the list of scene's transform nodes
  36698. * @param toRemove defines the transform node to remove
  36699. * @returns the index where the transform node was in the transform node list
  36700. */
  36701. removeTransformNode(toRemove: TransformNode): number;
  36702. /**
  36703. * Remove a skeleton for the list of scene's skeletons
  36704. * @param toRemove defines the skeleton to remove
  36705. * @returns the index where the skeleton was in the skeleton list
  36706. */
  36707. removeSkeleton(toRemove: Skeleton): number;
  36708. /**
  36709. * Remove a morph target for the list of scene's morph targets
  36710. * @param toRemove defines the morph target to remove
  36711. * @returns the index where the morph target was in the morph target list
  36712. */
  36713. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36714. /**
  36715. * Remove a light for the list of scene's lights
  36716. * @param toRemove defines the light to remove
  36717. * @returns the index where the light was in the light list
  36718. */
  36719. removeLight(toRemove: Light): number;
  36720. /**
  36721. * Remove a camera for the list of scene's cameras
  36722. * @param toRemove defines the camera to remove
  36723. * @returns the index where the camera was in the camera list
  36724. */
  36725. removeCamera(toRemove: Camera): number;
  36726. /**
  36727. * Remove a particle system for the list of scene's particle systems
  36728. * @param toRemove defines the particle system to remove
  36729. * @returns the index where the particle system was in the particle system list
  36730. */
  36731. removeParticleSystem(toRemove: IParticleSystem): number;
  36732. /**
  36733. * Remove a animation for the list of scene's animations
  36734. * @param toRemove defines the animation to remove
  36735. * @returns the index where the animation was in the animation list
  36736. */
  36737. removeAnimation(toRemove: Animation): number;
  36738. /**
  36739. * Will stop the animation of the given target
  36740. * @param target - the target
  36741. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36742. * @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)
  36743. */
  36744. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36745. /**
  36746. * Removes the given animation group from this scene.
  36747. * @param toRemove The animation group to remove
  36748. * @returns The index of the removed animation group
  36749. */
  36750. removeAnimationGroup(toRemove: AnimationGroup): number;
  36751. /**
  36752. * Removes the given multi-material from this scene.
  36753. * @param toRemove The multi-material to remove
  36754. * @returns The index of the removed multi-material
  36755. */
  36756. removeMultiMaterial(toRemove: MultiMaterial): number;
  36757. /**
  36758. * Removes the given material from this scene.
  36759. * @param toRemove The material to remove
  36760. * @returns The index of the removed material
  36761. */
  36762. removeMaterial(toRemove: Material): number;
  36763. /**
  36764. * Removes the given action manager from this scene.
  36765. * @param toRemove The action manager to remove
  36766. * @returns The index of the removed action manager
  36767. */
  36768. removeActionManager(toRemove: AbstractActionManager): number;
  36769. /**
  36770. * Removes the given texture from this scene.
  36771. * @param toRemove The texture to remove
  36772. * @returns The index of the removed texture
  36773. */
  36774. removeTexture(toRemove: BaseTexture): number;
  36775. /**
  36776. * Adds the given light to this scene
  36777. * @param newLight The light to add
  36778. */
  36779. addLight(newLight: Light): void;
  36780. /**
  36781. * Sorts the list list based on light priorities
  36782. */
  36783. sortLightsByPriority(): void;
  36784. /**
  36785. * Adds the given camera to this scene
  36786. * @param newCamera The camera to add
  36787. */
  36788. addCamera(newCamera: Camera): void;
  36789. /**
  36790. * Adds the given skeleton to this scene
  36791. * @param newSkeleton The skeleton to add
  36792. */
  36793. addSkeleton(newSkeleton: Skeleton): void;
  36794. /**
  36795. * Adds the given particle system to this scene
  36796. * @param newParticleSystem The particle system to add
  36797. */
  36798. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36799. /**
  36800. * Adds the given animation to this scene
  36801. * @param newAnimation The animation to add
  36802. */
  36803. addAnimation(newAnimation: Animation): void;
  36804. /**
  36805. * Adds the given animation group to this scene.
  36806. * @param newAnimationGroup The animation group to add
  36807. */
  36808. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36809. /**
  36810. * Adds the given multi-material to this scene
  36811. * @param newMultiMaterial The multi-material to add
  36812. */
  36813. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36814. /**
  36815. * Adds the given material to this scene
  36816. * @param newMaterial The material to add
  36817. */
  36818. addMaterial(newMaterial: Material): void;
  36819. /**
  36820. * Adds the given morph target to this scene
  36821. * @param newMorphTargetManager The morph target to add
  36822. */
  36823. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36824. /**
  36825. * Adds the given geometry to this scene
  36826. * @param newGeometry The geometry to add
  36827. */
  36828. addGeometry(newGeometry: Geometry): void;
  36829. /**
  36830. * Adds the given action manager to this scene
  36831. * @param newActionManager The action manager to add
  36832. */
  36833. addActionManager(newActionManager: AbstractActionManager): void;
  36834. /**
  36835. * Adds the given texture to this scene.
  36836. * @param newTexture The texture to add
  36837. */
  36838. addTexture(newTexture: BaseTexture): void;
  36839. /**
  36840. * Switch active camera
  36841. * @param newCamera defines the new active camera
  36842. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36843. */
  36844. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36845. /**
  36846. * sets the active camera of the scene using its ID
  36847. * @param id defines the camera's ID
  36848. * @return the new active camera or null if none found.
  36849. */
  36850. setActiveCameraByID(id: string): Nullable<Camera>;
  36851. /**
  36852. * sets the active camera of the scene using its name
  36853. * @param name defines the camera's name
  36854. * @returns the new active camera or null if none found.
  36855. */
  36856. setActiveCameraByName(name: string): Nullable<Camera>;
  36857. /**
  36858. * get an animation group using its name
  36859. * @param name defines the material's name
  36860. * @return the animation group or null if none found.
  36861. */
  36862. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36863. /**
  36864. * Get a material using its unique id
  36865. * @param uniqueId defines the material's unique id
  36866. * @return the material or null if none found.
  36867. */
  36868. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36869. /**
  36870. * get a material using its id
  36871. * @param id defines the material's ID
  36872. * @return the material or null if none found.
  36873. */
  36874. getMaterialByID(id: string): Nullable<Material>;
  36875. /**
  36876. * Gets a the last added material using a given id
  36877. * @param id defines the material's ID
  36878. * @return the last material with the given id or null if none found.
  36879. */
  36880. getLastMaterialByID(id: string): Nullable<Material>;
  36881. /**
  36882. * Gets a material using its name
  36883. * @param name defines the material's name
  36884. * @return the material or null if none found.
  36885. */
  36886. getMaterialByName(name: string): Nullable<Material>;
  36887. /**
  36888. * Get a texture using its unique id
  36889. * @param uniqueId defines the texture's unique id
  36890. * @return the texture or null if none found.
  36891. */
  36892. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36893. /**
  36894. * Gets a camera using its id
  36895. * @param id defines the id to look for
  36896. * @returns the camera or null if not found
  36897. */
  36898. getCameraByID(id: string): Nullable<Camera>;
  36899. /**
  36900. * Gets a camera using its unique id
  36901. * @param uniqueId defines the unique id to look for
  36902. * @returns the camera or null if not found
  36903. */
  36904. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36905. /**
  36906. * Gets a camera using its name
  36907. * @param name defines the camera's name
  36908. * @return the camera or null if none found.
  36909. */
  36910. getCameraByName(name: string): Nullable<Camera>;
  36911. /**
  36912. * Gets a bone using its id
  36913. * @param id defines the bone's id
  36914. * @return the bone or null if not found
  36915. */
  36916. getBoneByID(id: string): Nullable<Bone>;
  36917. /**
  36918. * Gets a bone using its id
  36919. * @param name defines the bone's name
  36920. * @return the bone or null if not found
  36921. */
  36922. getBoneByName(name: string): Nullable<Bone>;
  36923. /**
  36924. * Gets a light node using its name
  36925. * @param name defines the the light's name
  36926. * @return the light or null if none found.
  36927. */
  36928. getLightByName(name: string): Nullable<Light>;
  36929. /**
  36930. * Gets a light node using its id
  36931. * @param id defines the light's id
  36932. * @return the light or null if none found.
  36933. */
  36934. getLightByID(id: string): Nullable<Light>;
  36935. /**
  36936. * Gets a light node using its scene-generated unique ID
  36937. * @param uniqueId defines the light's unique id
  36938. * @return the light or null if none found.
  36939. */
  36940. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36941. /**
  36942. * Gets a particle system by id
  36943. * @param id defines the particle system id
  36944. * @return the corresponding system or null if none found
  36945. */
  36946. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36947. /**
  36948. * Gets a geometry using its ID
  36949. * @param id defines the geometry's id
  36950. * @return the geometry or null if none found.
  36951. */
  36952. getGeometryByID(id: string): Nullable<Geometry>;
  36953. private _getGeometryByUniqueID;
  36954. /**
  36955. * Add a new geometry to this scene
  36956. * @param geometry defines the geometry to be added to the scene.
  36957. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36958. * @return a boolean defining if the geometry was added or not
  36959. */
  36960. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36961. /**
  36962. * Removes an existing geometry
  36963. * @param geometry defines the geometry to be removed from the scene
  36964. * @return a boolean defining if the geometry was removed or not
  36965. */
  36966. removeGeometry(geometry: Geometry): boolean;
  36967. /**
  36968. * Gets the list of geometries attached to the scene
  36969. * @returns an array of Geometry
  36970. */
  36971. getGeometries(): Geometry[];
  36972. /**
  36973. * Gets the first added mesh found of a given ID
  36974. * @param id defines the id to search for
  36975. * @return the mesh found or null if not found at all
  36976. */
  36977. getMeshByID(id: string): Nullable<AbstractMesh>;
  36978. /**
  36979. * Gets a list of meshes using their id
  36980. * @param id defines the id to search for
  36981. * @returns a list of meshes
  36982. */
  36983. getMeshesByID(id: string): Array<AbstractMesh>;
  36984. /**
  36985. * Gets the first added transform node found of a given ID
  36986. * @param id defines the id to search for
  36987. * @return the found transform node or null if not found at all.
  36988. */
  36989. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36990. /**
  36991. * Gets a transform node with its auto-generated unique id
  36992. * @param uniqueId efines the unique id to search for
  36993. * @return the found transform node or null if not found at all.
  36994. */
  36995. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36996. /**
  36997. * Gets a list of transform nodes using their id
  36998. * @param id defines the id to search for
  36999. * @returns a list of transform nodes
  37000. */
  37001. getTransformNodesByID(id: string): Array<TransformNode>;
  37002. /**
  37003. * Gets a mesh with its auto-generated unique id
  37004. * @param uniqueId defines the unique id to search for
  37005. * @return the found mesh or null if not found at all.
  37006. */
  37007. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37008. /**
  37009. * Gets a the last added mesh using a given id
  37010. * @param id defines the id to search for
  37011. * @return the found mesh or null if not found at all.
  37012. */
  37013. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37014. /**
  37015. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37016. * @param id defines the id to search for
  37017. * @return the found node or null if not found at all
  37018. */
  37019. getLastEntryByID(id: string): Nullable<Node>;
  37020. /**
  37021. * Gets a node (Mesh, Camera, Light) using a given id
  37022. * @param id defines the id to search for
  37023. * @return the found node or null if not found at all
  37024. */
  37025. getNodeByID(id: string): Nullable<Node>;
  37026. /**
  37027. * Gets a node (Mesh, Camera, Light) using a given name
  37028. * @param name defines the name to search for
  37029. * @return the found node or null if not found at all.
  37030. */
  37031. getNodeByName(name: string): Nullable<Node>;
  37032. /**
  37033. * Gets a mesh using a given name
  37034. * @param name defines the name to search for
  37035. * @return the found mesh or null if not found at all.
  37036. */
  37037. getMeshByName(name: string): Nullable<AbstractMesh>;
  37038. /**
  37039. * Gets a transform node using a given name
  37040. * @param name defines the name to search for
  37041. * @return the found transform node or null if not found at all.
  37042. */
  37043. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37044. /**
  37045. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37046. * @param id defines the id to search for
  37047. * @return the found skeleton or null if not found at all.
  37048. */
  37049. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37050. /**
  37051. * Gets a skeleton using a given auto generated unique id
  37052. * @param uniqueId defines the unique id to search for
  37053. * @return the found skeleton or null if not found at all.
  37054. */
  37055. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37056. /**
  37057. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37058. * @param id defines the id to search for
  37059. * @return the found skeleton or null if not found at all.
  37060. */
  37061. getSkeletonById(id: string): Nullable<Skeleton>;
  37062. /**
  37063. * Gets a skeleton using a given name
  37064. * @param name defines the name to search for
  37065. * @return the found skeleton or null if not found at all.
  37066. */
  37067. getSkeletonByName(name: string): Nullable<Skeleton>;
  37068. /**
  37069. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37070. * @param id defines the id to search for
  37071. * @return the found morph target manager or null if not found at all.
  37072. */
  37073. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37074. /**
  37075. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37076. * @param id defines the id to search for
  37077. * @return the found morph target or null if not found at all.
  37078. */
  37079. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37080. /**
  37081. * Gets a boolean indicating if the given mesh is active
  37082. * @param mesh defines the mesh to look for
  37083. * @returns true if the mesh is in the active list
  37084. */
  37085. isActiveMesh(mesh: AbstractMesh): boolean;
  37086. /**
  37087. * Return a unique id as a string which can serve as an identifier for the scene
  37088. */
  37089. readonly uid: string;
  37090. /**
  37091. * Add an externaly attached data from its key.
  37092. * This method call will fail and return false, if such key already exists.
  37093. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37094. * @param key the unique key that identifies the data
  37095. * @param data the data object to associate to the key for this Engine instance
  37096. * @return true if no such key were already present and the data was added successfully, false otherwise
  37097. */
  37098. addExternalData<T>(key: string, data: T): boolean;
  37099. /**
  37100. * Get an externaly attached data from its key
  37101. * @param key the unique key that identifies the data
  37102. * @return the associated data, if present (can be null), or undefined if not present
  37103. */
  37104. getExternalData<T>(key: string): Nullable<T>;
  37105. /**
  37106. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37107. * @param key the unique key that identifies the data
  37108. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37109. * @return the associated data, can be null if the factory returned null.
  37110. */
  37111. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37112. /**
  37113. * Remove an externaly attached data from the Engine instance
  37114. * @param key the unique key that identifies the data
  37115. * @return true if the data was successfully removed, false if it doesn't exist
  37116. */
  37117. removeExternalData(key: string): boolean;
  37118. private _evaluateSubMesh;
  37119. /**
  37120. * Clear the processed materials smart array preventing retention point in material dispose.
  37121. */
  37122. freeProcessedMaterials(): void;
  37123. private _preventFreeActiveMeshesAndRenderingGroups;
  37124. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37125. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37126. * when disposing several meshes in a row or a hierarchy of meshes.
  37127. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37128. */
  37129. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37130. /**
  37131. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37132. */
  37133. freeActiveMeshes(): void;
  37134. /**
  37135. * Clear the info related to rendering groups preventing retention points during dispose.
  37136. */
  37137. freeRenderingGroups(): void;
  37138. /** @hidden */
  37139. _isInIntermediateRendering(): boolean;
  37140. /**
  37141. * Lambda returning the list of potentially active meshes.
  37142. */
  37143. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37144. /**
  37145. * Lambda returning the list of potentially active sub meshes.
  37146. */
  37147. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37148. /**
  37149. * Lambda returning the list of potentially intersecting sub meshes.
  37150. */
  37151. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37152. /**
  37153. * Lambda returning the list of potentially colliding sub meshes.
  37154. */
  37155. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37156. private _activeMeshesFrozen;
  37157. private _skipEvaluateActiveMeshesCompletely;
  37158. /**
  37159. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37160. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37161. * @returns the current scene
  37162. */
  37163. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37164. /**
  37165. * Use this function to restart evaluating active meshes on every frame
  37166. * @returns the current scene
  37167. */
  37168. unfreezeActiveMeshes(): Scene;
  37169. private _evaluateActiveMeshes;
  37170. private _activeMesh;
  37171. /**
  37172. * Update the transform matrix to update from the current active camera
  37173. * @param force defines a boolean used to force the update even if cache is up to date
  37174. */
  37175. updateTransformMatrix(force?: boolean): void;
  37176. private _bindFrameBuffer;
  37177. /** @hidden */
  37178. _allowPostProcessClearColor: boolean;
  37179. /** @hidden */
  37180. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37181. private _processSubCameras;
  37182. private _checkIntersections;
  37183. /** @hidden */
  37184. _advancePhysicsEngineStep(step: number): void;
  37185. /**
  37186. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37187. */
  37188. getDeterministicFrameTime: () => number;
  37189. /** @hidden */
  37190. _animate(): void;
  37191. /** Execute all animations (for a frame) */
  37192. animate(): void;
  37193. /**
  37194. * Render the scene
  37195. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37196. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37197. */
  37198. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37199. /**
  37200. * Freeze all materials
  37201. * A frozen material will not be updatable but should be faster to render
  37202. */
  37203. freezeMaterials(): void;
  37204. /**
  37205. * Unfreeze all materials
  37206. * A frozen material will not be updatable but should be faster to render
  37207. */
  37208. unfreezeMaterials(): void;
  37209. /**
  37210. * Releases all held ressources
  37211. */
  37212. dispose(): void;
  37213. /**
  37214. * Gets if the scene is already disposed
  37215. */
  37216. readonly isDisposed: boolean;
  37217. /**
  37218. * Call this function to reduce memory footprint of the scene.
  37219. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37220. */
  37221. clearCachedVertexData(): void;
  37222. /**
  37223. * This function will remove the local cached buffer data from texture.
  37224. * It will save memory but will prevent the texture from being rebuilt
  37225. */
  37226. cleanCachedTextureBuffer(): void;
  37227. /**
  37228. * Get the world extend vectors with an optional filter
  37229. *
  37230. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37231. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37232. */
  37233. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37234. min: Vector3;
  37235. max: Vector3;
  37236. };
  37237. /**
  37238. * Creates a ray that can be used to pick in the scene
  37239. * @param x defines the x coordinate of the origin (on-screen)
  37240. * @param y defines the y coordinate of the origin (on-screen)
  37241. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37242. * @param camera defines the camera to use for the picking
  37243. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37244. * @returns a Ray
  37245. */
  37246. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37247. /**
  37248. * Creates a ray that can be used to pick in the scene
  37249. * @param x defines the x coordinate of the origin (on-screen)
  37250. * @param y defines the y coordinate of the origin (on-screen)
  37251. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37252. * @param result defines the ray where to store the picking ray
  37253. * @param camera defines the camera to use for the picking
  37254. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37255. * @returns the current scene
  37256. */
  37257. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37258. /**
  37259. * Creates a ray that can be used to pick in the scene
  37260. * @param x defines the x coordinate of the origin (on-screen)
  37261. * @param y defines the y coordinate of the origin (on-screen)
  37262. * @param camera defines the camera to use for the picking
  37263. * @returns a Ray
  37264. */
  37265. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37266. /**
  37267. * Creates a ray that can be used to pick in the scene
  37268. * @param x defines the x coordinate of the origin (on-screen)
  37269. * @param y defines the y coordinate of the origin (on-screen)
  37270. * @param result defines the ray where to store the picking ray
  37271. * @param camera defines the camera to use for the picking
  37272. * @returns the current scene
  37273. */
  37274. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37275. /** Launch a ray to try to pick a mesh in the scene
  37276. * @param x position on screen
  37277. * @param y position on screen
  37278. * @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
  37279. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37280. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37282. * @returns a PickingInfo
  37283. */
  37284. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37285. /** Use the given ray to pick a mesh in the scene
  37286. * @param ray The ray to use to pick meshes
  37287. * @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
  37288. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37289. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37290. * @returns a PickingInfo
  37291. */
  37292. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37293. /**
  37294. * Launch a ray to try to pick a mesh in the scene
  37295. * @param x X position on screen
  37296. * @param y Y position on screen
  37297. * @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
  37298. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37300. * @returns an array of PickingInfo
  37301. */
  37302. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37303. /**
  37304. * Launch a ray to try to pick a mesh in the scene
  37305. * @param ray Ray to use
  37306. * @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
  37307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37308. * @returns an array of PickingInfo
  37309. */
  37310. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37311. /**
  37312. * Force the value of meshUnderPointer
  37313. * @param mesh defines the mesh to use
  37314. */
  37315. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37316. /**
  37317. * Gets the mesh under the pointer
  37318. * @returns a Mesh or null if no mesh is under the pointer
  37319. */
  37320. getPointerOverMesh(): Nullable<AbstractMesh>;
  37321. /** @hidden */
  37322. _rebuildGeometries(): void;
  37323. /** @hidden */
  37324. _rebuildTextures(): void;
  37325. private _getByTags;
  37326. /**
  37327. * Get a list of meshes by tags
  37328. * @param tagsQuery defines the tags query to use
  37329. * @param forEach defines a predicate used to filter results
  37330. * @returns an array of Mesh
  37331. */
  37332. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37333. /**
  37334. * Get a list of cameras by tags
  37335. * @param tagsQuery defines the tags query to use
  37336. * @param forEach defines a predicate used to filter results
  37337. * @returns an array of Camera
  37338. */
  37339. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37340. /**
  37341. * Get a list of lights by tags
  37342. * @param tagsQuery defines the tags query to use
  37343. * @param forEach defines a predicate used to filter results
  37344. * @returns an array of Light
  37345. */
  37346. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37347. /**
  37348. * Get a list of materials by tags
  37349. * @param tagsQuery defines the tags query to use
  37350. * @param forEach defines a predicate used to filter results
  37351. * @returns an array of Material
  37352. */
  37353. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37354. /**
  37355. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37356. * This allowed control for front to back rendering or reversly depending of the special needs.
  37357. *
  37358. * @param renderingGroupId The rendering group id corresponding to its index
  37359. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37360. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37361. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37362. */
  37363. 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;
  37364. /**
  37365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37366. *
  37367. * @param renderingGroupId The rendering group id corresponding to its index
  37368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37369. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37370. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37371. */
  37372. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37373. /**
  37374. * Gets the current auto clear configuration for one rendering group of the rendering
  37375. * manager.
  37376. * @param index the rendering group index to get the information for
  37377. * @returns The auto clear setup for the requested rendering group
  37378. */
  37379. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37380. private _blockMaterialDirtyMechanism;
  37381. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37382. blockMaterialDirtyMechanism: boolean;
  37383. /**
  37384. * Will flag all materials as dirty to trigger new shader compilation
  37385. * @param flag defines the flag used to specify which material part must be marked as dirty
  37386. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37387. */
  37388. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37389. /** @hidden */
  37390. _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;
  37391. /** @hidden */
  37392. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37393. /** @hidden */
  37394. _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;
  37395. /** @hidden */
  37396. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37397. /** @hidden */
  37398. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37399. /** @hidden */
  37400. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37401. }
  37402. }
  37403. declare module "babylonjs/assetContainer" {
  37404. import { AbstractScene } from "babylonjs/abstractScene";
  37405. import { Scene } from "babylonjs/scene";
  37406. import { Mesh } from "babylonjs/Meshes/mesh";
  37407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37408. import { Skeleton } from "babylonjs/Bones/skeleton";
  37409. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37410. import { Animatable } from "babylonjs/Animations/animatable";
  37411. import { Nullable } from "babylonjs/types";
  37412. import { Node } from "babylonjs/node";
  37413. /**
  37414. * Set of assets to keep when moving a scene into an asset container.
  37415. */
  37416. export class KeepAssets extends AbstractScene {
  37417. }
  37418. /**
  37419. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37420. */
  37421. export class InstantiatedEntries {
  37422. /**
  37423. * List of new root nodes (eg. nodes with no parent)
  37424. */
  37425. rootNodes: TransformNode[];
  37426. /**
  37427. * List of new skeletons
  37428. */
  37429. skeletons: Skeleton[];
  37430. /**
  37431. * List of new animation groups
  37432. */
  37433. animationGroups: AnimationGroup[];
  37434. }
  37435. /**
  37436. * Container with a set of assets that can be added or removed from a scene.
  37437. */
  37438. export class AssetContainer extends AbstractScene {
  37439. /**
  37440. * The scene the AssetContainer belongs to.
  37441. */
  37442. scene: Scene;
  37443. /**
  37444. * Instantiates an AssetContainer.
  37445. * @param scene The scene the AssetContainer belongs to.
  37446. */
  37447. constructor(scene: Scene);
  37448. /**
  37449. * Instantiate or clone all meshes and add the new ones to the scene.
  37450. * Skeletons and animation groups will all be cloned
  37451. * @param nameFunction defines an optional function used to get new names for clones
  37452. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37453. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37454. */
  37455. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37456. /**
  37457. * Adds all the assets from the container to the scene.
  37458. */
  37459. addAllToScene(): void;
  37460. /**
  37461. * Removes all the assets in the container from the scene
  37462. */
  37463. removeAllFromScene(): void;
  37464. /**
  37465. * Disposes all the assets in the container
  37466. */
  37467. dispose(): void;
  37468. private _moveAssets;
  37469. /**
  37470. * Removes all the assets contained in the scene and adds them to the container.
  37471. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37472. */
  37473. moveAllFromScene(keepAssets?: KeepAssets): void;
  37474. /**
  37475. * 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.
  37476. * @returns the root mesh
  37477. */
  37478. createRootMesh(): Mesh;
  37479. /**
  37480. * Merge animations from this asset container into a scene
  37481. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37482. * @param animatables set of animatables to retarget to a node from the scene
  37483. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37484. */
  37485. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37486. }
  37487. }
  37488. declare module "babylonjs/abstractScene" {
  37489. import { Scene } from "babylonjs/scene";
  37490. import { Nullable } from "babylonjs/types";
  37491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37493. import { Geometry } from "babylonjs/Meshes/geometry";
  37494. import { Skeleton } from "babylonjs/Bones/skeleton";
  37495. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37496. import { AssetContainer } from "babylonjs/assetContainer";
  37497. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37498. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37500. import { Material } from "babylonjs/Materials/material";
  37501. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37502. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37503. import { Camera } from "babylonjs/Cameras/camera";
  37504. import { Light } from "babylonjs/Lights/light";
  37505. import { Node } from "babylonjs/node";
  37506. import { Animation } from "babylonjs/Animations/animation";
  37507. /**
  37508. * Defines how the parser contract is defined.
  37509. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37510. */
  37511. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37512. /**
  37513. * Defines how the individual parser contract is defined.
  37514. * These parser can parse an individual asset
  37515. */
  37516. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37517. /**
  37518. * Base class of the scene acting as a container for the different elements composing a scene.
  37519. * This class is dynamically extended by the different components of the scene increasing
  37520. * flexibility and reducing coupling
  37521. */
  37522. export abstract class AbstractScene {
  37523. /**
  37524. * Stores the list of available parsers in the application.
  37525. */
  37526. private static _BabylonFileParsers;
  37527. /**
  37528. * Stores the list of available individual parsers in the application.
  37529. */
  37530. private static _IndividualBabylonFileParsers;
  37531. /**
  37532. * Adds a parser in the list of available ones
  37533. * @param name Defines the name of the parser
  37534. * @param parser Defines the parser to add
  37535. */
  37536. static AddParser(name: string, parser: BabylonFileParser): void;
  37537. /**
  37538. * Gets a general parser from the list of avaialble ones
  37539. * @param name Defines the name of the parser
  37540. * @returns the requested parser or null
  37541. */
  37542. static GetParser(name: string): Nullable<BabylonFileParser>;
  37543. /**
  37544. * Adds n individual parser in the list of available ones
  37545. * @param name Defines the name of the parser
  37546. * @param parser Defines the parser to add
  37547. */
  37548. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37549. /**
  37550. * Gets an individual parser from the list of avaialble ones
  37551. * @param name Defines the name of the parser
  37552. * @returns the requested parser or null
  37553. */
  37554. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37555. /**
  37556. * Parser json data and populate both a scene and its associated container object
  37557. * @param jsonData Defines the data to parse
  37558. * @param scene Defines the scene to parse the data for
  37559. * @param container Defines the container attached to the parsing sequence
  37560. * @param rootUrl Defines the root url of the data
  37561. */
  37562. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37563. /**
  37564. * Gets the list of root nodes (ie. nodes with no parent)
  37565. */
  37566. rootNodes: Node[];
  37567. /** All of the cameras added to this scene
  37568. * @see http://doc.babylonjs.com/babylon101/cameras
  37569. */
  37570. cameras: Camera[];
  37571. /**
  37572. * All of the lights added to this scene
  37573. * @see http://doc.babylonjs.com/babylon101/lights
  37574. */
  37575. lights: Light[];
  37576. /**
  37577. * All of the (abstract) meshes added to this scene
  37578. */
  37579. meshes: AbstractMesh[];
  37580. /**
  37581. * The list of skeletons added to the scene
  37582. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37583. */
  37584. skeletons: Skeleton[];
  37585. /**
  37586. * All of the particle systems added to this scene
  37587. * @see http://doc.babylonjs.com/babylon101/particles
  37588. */
  37589. particleSystems: IParticleSystem[];
  37590. /**
  37591. * Gets a list of Animations associated with the scene
  37592. */
  37593. animations: Animation[];
  37594. /**
  37595. * All of the animation groups added to this scene
  37596. * @see http://doc.babylonjs.com/how_to/group
  37597. */
  37598. animationGroups: AnimationGroup[];
  37599. /**
  37600. * All of the multi-materials added to this scene
  37601. * @see http://doc.babylonjs.com/how_to/multi_materials
  37602. */
  37603. multiMaterials: MultiMaterial[];
  37604. /**
  37605. * All of the materials added to this scene
  37606. * In the context of a Scene, it is not supposed to be modified manually.
  37607. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37608. * Note also that the order of the Material within the array is not significant and might change.
  37609. * @see http://doc.babylonjs.com/babylon101/materials
  37610. */
  37611. materials: Material[];
  37612. /**
  37613. * The list of morph target managers added to the scene
  37614. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37615. */
  37616. morphTargetManagers: MorphTargetManager[];
  37617. /**
  37618. * The list of geometries used in the scene.
  37619. */
  37620. geometries: Geometry[];
  37621. /**
  37622. * All of the tranform nodes added to this scene
  37623. * In the context of a Scene, it is not supposed to be modified manually.
  37624. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37625. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37626. * @see http://doc.babylonjs.com/how_to/transformnode
  37627. */
  37628. transformNodes: TransformNode[];
  37629. /**
  37630. * ActionManagers available on the scene.
  37631. */
  37632. actionManagers: AbstractActionManager[];
  37633. /**
  37634. * Textures to keep.
  37635. */
  37636. textures: BaseTexture[];
  37637. /**
  37638. * Environment texture for the scene
  37639. */
  37640. environmentTexture: Nullable<BaseTexture>;
  37641. /**
  37642. * @returns all meshes, lights, cameras, transformNodes and bones
  37643. */
  37644. getNodes(): Array<Node>;
  37645. }
  37646. }
  37647. declare module "babylonjs/Audio/sound" {
  37648. import { Observable } from "babylonjs/Misc/observable";
  37649. import { Vector3 } from "babylonjs/Maths/math.vector";
  37650. import { Nullable } from "babylonjs/types";
  37651. import { Scene } from "babylonjs/scene";
  37652. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37653. /**
  37654. * Interface used to define options for Sound class
  37655. */
  37656. export interface ISoundOptions {
  37657. /**
  37658. * Does the sound autoplay once loaded.
  37659. */
  37660. autoplay?: boolean;
  37661. /**
  37662. * Does the sound loop after it finishes playing once.
  37663. */
  37664. loop?: boolean;
  37665. /**
  37666. * Sound's volume
  37667. */
  37668. volume?: number;
  37669. /**
  37670. * Is it a spatial sound?
  37671. */
  37672. spatialSound?: boolean;
  37673. /**
  37674. * Maximum distance to hear that sound
  37675. */
  37676. maxDistance?: number;
  37677. /**
  37678. * Uses user defined attenuation function
  37679. */
  37680. useCustomAttenuation?: boolean;
  37681. /**
  37682. * Define the roll off factor of spatial sounds.
  37683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37684. */
  37685. rolloffFactor?: number;
  37686. /**
  37687. * Define the reference distance the sound should be heard perfectly.
  37688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37689. */
  37690. refDistance?: number;
  37691. /**
  37692. * Define the distance attenuation model the sound will follow.
  37693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37694. */
  37695. distanceModel?: string;
  37696. /**
  37697. * Defines the playback speed (1 by default)
  37698. */
  37699. playbackRate?: number;
  37700. /**
  37701. * Defines if the sound is from a streaming source
  37702. */
  37703. streaming?: boolean;
  37704. /**
  37705. * Defines an optional length (in seconds) inside the sound file
  37706. */
  37707. length?: number;
  37708. /**
  37709. * Defines an optional offset (in seconds) inside the sound file
  37710. */
  37711. offset?: number;
  37712. /**
  37713. * If true, URLs will not be required to state the audio file codec to use.
  37714. */
  37715. skipCodecCheck?: boolean;
  37716. }
  37717. /**
  37718. * Defines a sound that can be played in the application.
  37719. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37721. */
  37722. export class Sound {
  37723. /**
  37724. * The name of the sound in the scene.
  37725. */
  37726. name: string;
  37727. /**
  37728. * Does the sound autoplay once loaded.
  37729. */
  37730. autoplay: boolean;
  37731. /**
  37732. * Does the sound loop after it finishes playing once.
  37733. */
  37734. loop: boolean;
  37735. /**
  37736. * Does the sound use a custom attenuation curve to simulate the falloff
  37737. * happening when the source gets further away from the camera.
  37738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37739. */
  37740. useCustomAttenuation: boolean;
  37741. /**
  37742. * The sound track id this sound belongs to.
  37743. */
  37744. soundTrackId: number;
  37745. /**
  37746. * Is this sound currently played.
  37747. */
  37748. isPlaying: boolean;
  37749. /**
  37750. * Is this sound currently paused.
  37751. */
  37752. isPaused: boolean;
  37753. /**
  37754. * Does this sound enables spatial sound.
  37755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37756. */
  37757. spatialSound: boolean;
  37758. /**
  37759. * Define the reference distance the sound should be heard perfectly.
  37760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37761. */
  37762. refDistance: number;
  37763. /**
  37764. * Define the roll off factor of spatial sounds.
  37765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37766. */
  37767. rolloffFactor: number;
  37768. /**
  37769. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37771. */
  37772. maxDistance: number;
  37773. /**
  37774. * Define the distance attenuation model the sound will follow.
  37775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37776. */
  37777. distanceModel: string;
  37778. /**
  37779. * @hidden
  37780. * Back Compat
  37781. **/
  37782. onended: () => any;
  37783. /**
  37784. * Observable event when the current playing sound finishes.
  37785. */
  37786. onEndedObservable: Observable<Sound>;
  37787. private _panningModel;
  37788. private _playbackRate;
  37789. private _streaming;
  37790. private _startTime;
  37791. private _startOffset;
  37792. private _position;
  37793. /** @hidden */
  37794. _positionInEmitterSpace: boolean;
  37795. private _localDirection;
  37796. private _volume;
  37797. private _isReadyToPlay;
  37798. private _isDirectional;
  37799. private _readyToPlayCallback;
  37800. private _audioBuffer;
  37801. private _soundSource;
  37802. private _streamingSource;
  37803. private _soundPanner;
  37804. private _soundGain;
  37805. private _inputAudioNode;
  37806. private _outputAudioNode;
  37807. private _coneInnerAngle;
  37808. private _coneOuterAngle;
  37809. private _coneOuterGain;
  37810. private _scene;
  37811. private _connectedTransformNode;
  37812. private _customAttenuationFunction;
  37813. private _registerFunc;
  37814. private _isOutputConnected;
  37815. private _htmlAudioElement;
  37816. private _urlType;
  37817. private _length?;
  37818. private _offset?;
  37819. /** @hidden */
  37820. static _SceneComponentInitialization: (scene: Scene) => void;
  37821. /**
  37822. * Create a sound and attach it to a scene
  37823. * @param name Name of your sound
  37824. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37825. * @param scene defines the scene the sound belongs to
  37826. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37827. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37828. */
  37829. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37830. /**
  37831. * Release the sound and its associated resources
  37832. */
  37833. dispose(): void;
  37834. /**
  37835. * Gets if the sounds is ready to be played or not.
  37836. * @returns true if ready, otherwise false
  37837. */
  37838. isReady(): boolean;
  37839. private _soundLoaded;
  37840. /**
  37841. * Sets the data of the sound from an audiobuffer
  37842. * @param audioBuffer The audioBuffer containing the data
  37843. */
  37844. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37845. /**
  37846. * Updates the current sounds options such as maxdistance, loop...
  37847. * @param options A JSON object containing values named as the object properties
  37848. */
  37849. updateOptions(options: ISoundOptions): void;
  37850. private _createSpatialParameters;
  37851. private _updateSpatialParameters;
  37852. /**
  37853. * Switch the panning model to HRTF:
  37854. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37856. */
  37857. switchPanningModelToHRTF(): void;
  37858. /**
  37859. * Switch the panning model to Equal Power:
  37860. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37862. */
  37863. switchPanningModelToEqualPower(): void;
  37864. private _switchPanningModel;
  37865. /**
  37866. * Connect this sound to a sound track audio node like gain...
  37867. * @param soundTrackAudioNode the sound track audio node to connect to
  37868. */
  37869. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37870. /**
  37871. * Transform this sound into a directional source
  37872. * @param coneInnerAngle Size of the inner cone in degree
  37873. * @param coneOuterAngle Size of the outer cone in degree
  37874. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37875. */
  37876. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37877. /**
  37878. * Gets or sets the inner angle for the directional cone.
  37879. */
  37880. /**
  37881. * Gets or sets the inner angle for the directional cone.
  37882. */
  37883. directionalConeInnerAngle: number;
  37884. /**
  37885. * Gets or sets the outer angle for the directional cone.
  37886. */
  37887. /**
  37888. * Gets or sets the outer angle for the directional cone.
  37889. */
  37890. directionalConeOuterAngle: number;
  37891. /**
  37892. * Sets the position of the emitter if spatial sound is enabled
  37893. * @param newPosition Defines the new posisiton
  37894. */
  37895. setPosition(newPosition: Vector3): void;
  37896. /**
  37897. * Sets the local direction of the emitter if spatial sound is enabled
  37898. * @param newLocalDirection Defines the new local direction
  37899. */
  37900. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37901. private _updateDirection;
  37902. /** @hidden */
  37903. updateDistanceFromListener(): void;
  37904. /**
  37905. * Sets a new custom attenuation function for the sound.
  37906. * @param callback Defines the function used for the attenuation
  37907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37908. */
  37909. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37910. /**
  37911. * Play the sound
  37912. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37913. * @param offset (optional) Start the sound at a specific time in seconds
  37914. * @param length (optional) Sound duration (in seconds)
  37915. */
  37916. play(time?: number, offset?: number, length?: number): void;
  37917. private _onended;
  37918. /**
  37919. * Stop the sound
  37920. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37921. */
  37922. stop(time?: number): void;
  37923. /**
  37924. * Put the sound in pause
  37925. */
  37926. pause(): void;
  37927. /**
  37928. * Sets a dedicated volume for this sounds
  37929. * @param newVolume Define the new volume of the sound
  37930. * @param time Define time for gradual change to new volume
  37931. */
  37932. setVolume(newVolume: number, time?: number): void;
  37933. /**
  37934. * Set the sound play back rate
  37935. * @param newPlaybackRate Define the playback rate the sound should be played at
  37936. */
  37937. setPlaybackRate(newPlaybackRate: number): void;
  37938. /**
  37939. * Gets the volume of the sound.
  37940. * @returns the volume of the sound
  37941. */
  37942. getVolume(): number;
  37943. /**
  37944. * Attach the sound to a dedicated mesh
  37945. * @param transformNode The transform node to connect the sound with
  37946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37947. */
  37948. attachToMesh(transformNode: TransformNode): void;
  37949. /**
  37950. * Detach the sound from the previously attached mesh
  37951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37952. */
  37953. detachFromMesh(): void;
  37954. private _onRegisterAfterWorldMatrixUpdate;
  37955. /**
  37956. * Clone the current sound in the scene.
  37957. * @returns the new sound clone
  37958. */
  37959. clone(): Nullable<Sound>;
  37960. /**
  37961. * Gets the current underlying audio buffer containing the data
  37962. * @returns the audio buffer
  37963. */
  37964. getAudioBuffer(): Nullable<AudioBuffer>;
  37965. /**
  37966. * Serializes the Sound in a JSON representation
  37967. * @returns the JSON representation of the sound
  37968. */
  37969. serialize(): any;
  37970. /**
  37971. * Parse a JSON representation of a sound to innstantiate in a given scene
  37972. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37973. * @param scene Define the scene the new parsed sound should be created in
  37974. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37975. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37976. * @returns the newly parsed sound
  37977. */
  37978. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37979. }
  37980. }
  37981. declare module "babylonjs/Actions/directAudioActions" {
  37982. import { Action } from "babylonjs/Actions/action";
  37983. import { Condition } from "babylonjs/Actions/condition";
  37984. import { Sound } from "babylonjs/Audio/sound";
  37985. /**
  37986. * This defines an action helpful to play a defined sound on a triggered action.
  37987. */
  37988. export class PlaySoundAction extends Action {
  37989. private _sound;
  37990. /**
  37991. * Instantiate the action
  37992. * @param triggerOptions defines the trigger options
  37993. * @param sound defines the sound to play
  37994. * @param condition defines the trigger related conditions
  37995. */
  37996. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37997. /** @hidden */
  37998. _prepare(): void;
  37999. /**
  38000. * Execute the action and play the sound.
  38001. */
  38002. execute(): void;
  38003. /**
  38004. * Serializes the actions and its related information.
  38005. * @param parent defines the object to serialize in
  38006. * @returns the serialized object
  38007. */
  38008. serialize(parent: any): any;
  38009. }
  38010. /**
  38011. * This defines an action helpful to stop a defined sound on a triggered action.
  38012. */
  38013. export class StopSoundAction extends Action {
  38014. private _sound;
  38015. /**
  38016. * Instantiate the action
  38017. * @param triggerOptions defines the trigger options
  38018. * @param sound defines the sound to stop
  38019. * @param condition defines the trigger related conditions
  38020. */
  38021. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38022. /** @hidden */
  38023. _prepare(): void;
  38024. /**
  38025. * Execute the action and stop the sound.
  38026. */
  38027. execute(): void;
  38028. /**
  38029. * Serializes the actions and its related information.
  38030. * @param parent defines the object to serialize in
  38031. * @returns the serialized object
  38032. */
  38033. serialize(parent: any): any;
  38034. }
  38035. }
  38036. declare module "babylonjs/Actions/interpolateValueAction" {
  38037. import { Action } from "babylonjs/Actions/action";
  38038. import { Condition } from "babylonjs/Actions/condition";
  38039. import { Observable } from "babylonjs/Misc/observable";
  38040. /**
  38041. * This defines an action responsible to change the value of a property
  38042. * by interpolating between its current value and the newly set one once triggered.
  38043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38044. */
  38045. export class InterpolateValueAction extends Action {
  38046. /**
  38047. * Defines the path of the property where the value should be interpolated
  38048. */
  38049. propertyPath: string;
  38050. /**
  38051. * Defines the target value at the end of the interpolation.
  38052. */
  38053. value: any;
  38054. /**
  38055. * Defines the time it will take for the property to interpolate to the value.
  38056. */
  38057. duration: number;
  38058. /**
  38059. * Defines if the other scene animations should be stopped when the action has been triggered
  38060. */
  38061. stopOtherAnimations?: boolean;
  38062. /**
  38063. * Defines a callback raised once the interpolation animation has been done.
  38064. */
  38065. onInterpolationDone?: () => void;
  38066. /**
  38067. * Observable triggered once the interpolation animation has been done.
  38068. */
  38069. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38070. private _target;
  38071. private _effectiveTarget;
  38072. private _property;
  38073. /**
  38074. * Instantiate the action
  38075. * @param triggerOptions defines the trigger options
  38076. * @param target defines the object containing the value to interpolate
  38077. * @param propertyPath defines the path to the property in the target object
  38078. * @param value defines the target value at the end of the interpolation
  38079. * @param duration deines the time it will take for the property to interpolate to the value.
  38080. * @param condition defines the trigger related conditions
  38081. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38082. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38083. */
  38084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38085. /** @hidden */
  38086. _prepare(): void;
  38087. /**
  38088. * Execute the action starts the value interpolation.
  38089. */
  38090. execute(): void;
  38091. /**
  38092. * Serializes the actions and its related information.
  38093. * @param parent defines the object to serialize in
  38094. * @returns the serialized object
  38095. */
  38096. serialize(parent: any): any;
  38097. }
  38098. }
  38099. declare module "babylonjs/Actions/index" {
  38100. export * from "babylonjs/Actions/abstractActionManager";
  38101. export * from "babylonjs/Actions/action";
  38102. export * from "babylonjs/Actions/actionEvent";
  38103. export * from "babylonjs/Actions/actionManager";
  38104. export * from "babylonjs/Actions/condition";
  38105. export * from "babylonjs/Actions/directActions";
  38106. export * from "babylonjs/Actions/directAudioActions";
  38107. export * from "babylonjs/Actions/interpolateValueAction";
  38108. }
  38109. declare module "babylonjs/Animations/index" {
  38110. export * from "babylonjs/Animations/animatable";
  38111. export * from "babylonjs/Animations/animation";
  38112. export * from "babylonjs/Animations/animationGroup";
  38113. export * from "babylonjs/Animations/animationPropertiesOverride";
  38114. export * from "babylonjs/Animations/easing";
  38115. export * from "babylonjs/Animations/runtimeAnimation";
  38116. export * from "babylonjs/Animations/animationEvent";
  38117. export * from "babylonjs/Animations/animationGroup";
  38118. export * from "babylonjs/Animations/animationKey";
  38119. export * from "babylonjs/Animations/animationRange";
  38120. export * from "babylonjs/Animations/animatable.interface";
  38121. }
  38122. declare module "babylonjs/Audio/soundTrack" {
  38123. import { Sound } from "babylonjs/Audio/sound";
  38124. import { Analyser } from "babylonjs/Audio/analyser";
  38125. import { Scene } from "babylonjs/scene";
  38126. /**
  38127. * Options allowed during the creation of a sound track.
  38128. */
  38129. export interface ISoundTrackOptions {
  38130. /**
  38131. * The volume the sound track should take during creation
  38132. */
  38133. volume?: number;
  38134. /**
  38135. * Define if the sound track is the main sound track of the scene
  38136. */
  38137. mainTrack?: boolean;
  38138. }
  38139. /**
  38140. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38141. * It will be also used in a future release to apply effects on a specific track.
  38142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38143. */
  38144. export class SoundTrack {
  38145. /**
  38146. * The unique identifier of the sound track in the scene.
  38147. */
  38148. id: number;
  38149. /**
  38150. * The list of sounds included in the sound track.
  38151. */
  38152. soundCollection: Array<Sound>;
  38153. private _outputAudioNode;
  38154. private _scene;
  38155. private _connectedAnalyser;
  38156. private _options;
  38157. private _isInitialized;
  38158. /**
  38159. * Creates a new sound track.
  38160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38161. * @param scene Define the scene the sound track belongs to
  38162. * @param options
  38163. */
  38164. constructor(scene: Scene, options?: ISoundTrackOptions);
  38165. private _initializeSoundTrackAudioGraph;
  38166. /**
  38167. * Release the sound track and its associated resources
  38168. */
  38169. dispose(): void;
  38170. /**
  38171. * Adds a sound to this sound track
  38172. * @param sound define the cound to add
  38173. * @ignoreNaming
  38174. */
  38175. AddSound(sound: Sound): void;
  38176. /**
  38177. * Removes a sound to this sound track
  38178. * @param sound define the cound to remove
  38179. * @ignoreNaming
  38180. */
  38181. RemoveSound(sound: Sound): void;
  38182. /**
  38183. * Set a global volume for the full sound track.
  38184. * @param newVolume Define the new volume of the sound track
  38185. */
  38186. setVolume(newVolume: number): void;
  38187. /**
  38188. * Switch the panning model to HRTF:
  38189. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38191. */
  38192. switchPanningModelToHRTF(): void;
  38193. /**
  38194. * Switch the panning model to Equal Power:
  38195. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38197. */
  38198. switchPanningModelToEqualPower(): void;
  38199. /**
  38200. * Connect the sound track to an audio analyser allowing some amazing
  38201. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38203. * @param analyser The analyser to connect to the engine
  38204. */
  38205. connectToAnalyser(analyser: Analyser): void;
  38206. }
  38207. }
  38208. declare module "babylonjs/Audio/audioSceneComponent" {
  38209. import { Sound } from "babylonjs/Audio/sound";
  38210. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38211. import { Nullable } from "babylonjs/types";
  38212. import { Vector3 } from "babylonjs/Maths/math.vector";
  38213. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38214. import { Scene } from "babylonjs/scene";
  38215. import { AbstractScene } from "babylonjs/abstractScene";
  38216. import "babylonjs/Audio/audioEngine";
  38217. module "babylonjs/abstractScene" {
  38218. interface AbstractScene {
  38219. /**
  38220. * The list of sounds used in the scene.
  38221. */
  38222. sounds: Nullable<Array<Sound>>;
  38223. }
  38224. }
  38225. module "babylonjs/scene" {
  38226. interface Scene {
  38227. /**
  38228. * @hidden
  38229. * Backing field
  38230. */
  38231. _mainSoundTrack: SoundTrack;
  38232. /**
  38233. * The main sound track played by the scene.
  38234. * It cotains your primary collection of sounds.
  38235. */
  38236. mainSoundTrack: SoundTrack;
  38237. /**
  38238. * The list of sound tracks added to the scene
  38239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38240. */
  38241. soundTracks: Nullable<Array<SoundTrack>>;
  38242. /**
  38243. * Gets a sound using a given name
  38244. * @param name defines the name to search for
  38245. * @return the found sound or null if not found at all.
  38246. */
  38247. getSoundByName(name: string): Nullable<Sound>;
  38248. /**
  38249. * Gets or sets if audio support is enabled
  38250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38251. */
  38252. audioEnabled: boolean;
  38253. /**
  38254. * Gets or sets if audio will be output to headphones
  38255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38256. */
  38257. headphone: boolean;
  38258. /**
  38259. * Gets or sets custom audio listener position provider
  38260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38261. */
  38262. audioListenerPositionProvider: Nullable<() => Vector3>;
  38263. /**
  38264. * Gets or sets a refresh rate when using 3D audio positioning
  38265. */
  38266. audioPositioningRefreshRate: number;
  38267. }
  38268. }
  38269. /**
  38270. * Defines the sound scene component responsible to manage any sounds
  38271. * in a given scene.
  38272. */
  38273. export class AudioSceneComponent implements ISceneSerializableComponent {
  38274. /**
  38275. * The component name helpfull to identify the component in the list of scene components.
  38276. */
  38277. readonly name: string;
  38278. /**
  38279. * The scene the component belongs to.
  38280. */
  38281. scene: Scene;
  38282. private _audioEnabled;
  38283. /**
  38284. * Gets whether audio is enabled or not.
  38285. * Please use related enable/disable method to switch state.
  38286. */
  38287. readonly audioEnabled: boolean;
  38288. private _headphone;
  38289. /**
  38290. * Gets whether audio is outputing to headphone or not.
  38291. * Please use the according Switch methods to change output.
  38292. */
  38293. readonly headphone: boolean;
  38294. /**
  38295. * Gets or sets a refresh rate when using 3D audio positioning
  38296. */
  38297. audioPositioningRefreshRate: number;
  38298. private _audioListenerPositionProvider;
  38299. /**
  38300. * Gets the current audio listener position provider
  38301. */
  38302. /**
  38303. * Sets a custom listener position for all sounds in the scene
  38304. * By default, this is the position of the first active camera
  38305. */
  38306. audioListenerPositionProvider: Nullable<() => Vector3>;
  38307. /**
  38308. * Creates a new instance of the component for the given scene
  38309. * @param scene Defines the scene to register the component in
  38310. */
  38311. constructor(scene: Scene);
  38312. /**
  38313. * Registers the component in a given scene
  38314. */
  38315. register(): void;
  38316. /**
  38317. * Rebuilds the elements related to this component in case of
  38318. * context lost for instance.
  38319. */
  38320. rebuild(): void;
  38321. /**
  38322. * Serializes the component data to the specified json object
  38323. * @param serializationObject The object to serialize to
  38324. */
  38325. serialize(serializationObject: any): void;
  38326. /**
  38327. * Adds all the elements from the container to the scene
  38328. * @param container the container holding the elements
  38329. */
  38330. addFromContainer(container: AbstractScene): void;
  38331. /**
  38332. * Removes all the elements in the container from the scene
  38333. * @param container contains the elements to remove
  38334. * @param dispose if the removed element should be disposed (default: false)
  38335. */
  38336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38337. /**
  38338. * Disposes the component and the associated ressources.
  38339. */
  38340. dispose(): void;
  38341. /**
  38342. * Disables audio in the associated scene.
  38343. */
  38344. disableAudio(): void;
  38345. /**
  38346. * Enables audio in the associated scene.
  38347. */
  38348. enableAudio(): void;
  38349. /**
  38350. * Switch audio to headphone output.
  38351. */
  38352. switchAudioModeForHeadphones(): void;
  38353. /**
  38354. * Switch audio to normal speakers.
  38355. */
  38356. switchAudioModeForNormalSpeakers(): void;
  38357. private _cachedCameraDirection;
  38358. private _cachedCameraPosition;
  38359. private _lastCheck;
  38360. private _afterRender;
  38361. }
  38362. }
  38363. declare module "babylonjs/Audio/weightedsound" {
  38364. import { Sound } from "babylonjs/Audio/sound";
  38365. /**
  38366. * Wraps one or more Sound objects and selects one with random weight for playback.
  38367. */
  38368. export class WeightedSound {
  38369. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38370. loop: boolean;
  38371. private _coneInnerAngle;
  38372. private _coneOuterAngle;
  38373. private _volume;
  38374. /** A Sound is currently playing. */
  38375. isPlaying: boolean;
  38376. /** A Sound is currently paused. */
  38377. isPaused: boolean;
  38378. private _sounds;
  38379. private _weights;
  38380. private _currentIndex?;
  38381. /**
  38382. * Creates a new WeightedSound from the list of sounds given.
  38383. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38384. * @param sounds Array of Sounds that will be selected from.
  38385. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38386. */
  38387. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38388. /**
  38389. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38390. */
  38391. /**
  38392. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38393. */
  38394. directionalConeInnerAngle: number;
  38395. /**
  38396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38398. */
  38399. /**
  38400. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38401. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38402. */
  38403. directionalConeOuterAngle: number;
  38404. /**
  38405. * Playback volume.
  38406. */
  38407. /**
  38408. * Playback volume.
  38409. */
  38410. volume: number;
  38411. private _onended;
  38412. /**
  38413. * Suspend playback
  38414. */
  38415. pause(): void;
  38416. /**
  38417. * Stop playback
  38418. */
  38419. stop(): void;
  38420. /**
  38421. * Start playback.
  38422. * @param startOffset Position the clip head at a specific time in seconds.
  38423. */
  38424. play(startOffset?: number): void;
  38425. }
  38426. }
  38427. declare module "babylonjs/Audio/index" {
  38428. export * from "babylonjs/Audio/analyser";
  38429. export * from "babylonjs/Audio/audioEngine";
  38430. export * from "babylonjs/Audio/audioSceneComponent";
  38431. export * from "babylonjs/Audio/sound";
  38432. export * from "babylonjs/Audio/soundTrack";
  38433. export * from "babylonjs/Audio/weightedsound";
  38434. }
  38435. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38436. import { Behavior } from "babylonjs/Behaviors/behavior";
  38437. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38438. import { BackEase } from "babylonjs/Animations/easing";
  38439. /**
  38440. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38441. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38442. */
  38443. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38444. /**
  38445. * Gets the name of the behavior.
  38446. */
  38447. readonly name: string;
  38448. /**
  38449. * The easing function used by animations
  38450. */
  38451. static EasingFunction: BackEase;
  38452. /**
  38453. * The easing mode used by animations
  38454. */
  38455. static EasingMode: number;
  38456. /**
  38457. * The duration of the animation, in milliseconds
  38458. */
  38459. transitionDuration: number;
  38460. /**
  38461. * Length of the distance animated by the transition when lower radius is reached
  38462. */
  38463. lowerRadiusTransitionRange: number;
  38464. /**
  38465. * Length of the distance animated by the transition when upper radius is reached
  38466. */
  38467. upperRadiusTransitionRange: number;
  38468. private _autoTransitionRange;
  38469. /**
  38470. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38471. */
  38472. /**
  38473. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38474. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38475. */
  38476. autoTransitionRange: boolean;
  38477. private _attachedCamera;
  38478. private _onAfterCheckInputsObserver;
  38479. private _onMeshTargetChangedObserver;
  38480. /**
  38481. * Initializes the behavior.
  38482. */
  38483. init(): void;
  38484. /**
  38485. * Attaches the behavior to its arc rotate camera.
  38486. * @param camera Defines the camera to attach the behavior to
  38487. */
  38488. attach(camera: ArcRotateCamera): void;
  38489. /**
  38490. * Detaches the behavior from its current arc rotate camera.
  38491. */
  38492. detach(): void;
  38493. private _radiusIsAnimating;
  38494. private _radiusBounceTransition;
  38495. private _animatables;
  38496. private _cachedWheelPrecision;
  38497. /**
  38498. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38499. * @param radiusLimit The limit to check against.
  38500. * @return Bool to indicate if at limit.
  38501. */
  38502. private _isRadiusAtLimit;
  38503. /**
  38504. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38505. * @param radiusDelta The delta by which to animate to. Can be negative.
  38506. */
  38507. private _applyBoundRadiusAnimation;
  38508. /**
  38509. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38510. */
  38511. protected _clearAnimationLocks(): void;
  38512. /**
  38513. * Stops and removes all animations that have been applied to the camera
  38514. */
  38515. stopAllAnimations(): void;
  38516. }
  38517. }
  38518. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38519. import { Behavior } from "babylonjs/Behaviors/behavior";
  38520. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38521. import { ExponentialEase } from "babylonjs/Animations/easing";
  38522. import { Nullable } from "babylonjs/types";
  38523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38524. import { Vector3 } from "babylonjs/Maths/math.vector";
  38525. /**
  38526. * 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.
  38527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38528. */
  38529. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38530. /**
  38531. * Gets the name of the behavior.
  38532. */
  38533. readonly name: string;
  38534. private _mode;
  38535. private _radiusScale;
  38536. private _positionScale;
  38537. private _defaultElevation;
  38538. private _elevationReturnTime;
  38539. private _elevationReturnWaitTime;
  38540. private _zoomStopsAnimation;
  38541. private _framingTime;
  38542. /**
  38543. * The easing function used by animations
  38544. */
  38545. static EasingFunction: ExponentialEase;
  38546. /**
  38547. * The easing mode used by animations
  38548. */
  38549. static EasingMode: number;
  38550. /**
  38551. * Sets the current mode used by the behavior
  38552. */
  38553. /**
  38554. * Gets current mode used by the behavior.
  38555. */
  38556. mode: number;
  38557. /**
  38558. * Sets the scale applied to the radius (1 by default)
  38559. */
  38560. /**
  38561. * Gets the scale applied to the radius
  38562. */
  38563. radiusScale: number;
  38564. /**
  38565. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38566. */
  38567. /**
  38568. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38569. */
  38570. positionScale: number;
  38571. /**
  38572. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38573. * behaviour is triggered, in radians.
  38574. */
  38575. /**
  38576. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38577. * behaviour is triggered, in radians.
  38578. */
  38579. defaultElevation: number;
  38580. /**
  38581. * Sets the time (in milliseconds) taken to return to the default beta position.
  38582. * Negative value indicates camera should not return to default.
  38583. */
  38584. /**
  38585. * Gets the time (in milliseconds) taken to return to the default beta position.
  38586. * Negative value indicates camera should not return to default.
  38587. */
  38588. elevationReturnTime: number;
  38589. /**
  38590. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38591. */
  38592. /**
  38593. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38594. */
  38595. elevationReturnWaitTime: number;
  38596. /**
  38597. * Sets the flag that indicates if user zooming should stop animation.
  38598. */
  38599. /**
  38600. * Gets the flag that indicates if user zooming should stop animation.
  38601. */
  38602. zoomStopsAnimation: boolean;
  38603. /**
  38604. * Sets the transition time when framing the mesh, in milliseconds
  38605. */
  38606. /**
  38607. * Gets the transition time when framing the mesh, in milliseconds
  38608. */
  38609. framingTime: number;
  38610. /**
  38611. * Define if the behavior should automatically change the configured
  38612. * camera limits and sensibilities.
  38613. */
  38614. autoCorrectCameraLimitsAndSensibility: boolean;
  38615. private _onPrePointerObservableObserver;
  38616. private _onAfterCheckInputsObserver;
  38617. private _onMeshTargetChangedObserver;
  38618. private _attachedCamera;
  38619. private _isPointerDown;
  38620. private _lastInteractionTime;
  38621. /**
  38622. * Initializes the behavior.
  38623. */
  38624. init(): void;
  38625. /**
  38626. * Attaches the behavior to its arc rotate camera.
  38627. * @param camera Defines the camera to attach the behavior to
  38628. */
  38629. attach(camera: ArcRotateCamera): void;
  38630. /**
  38631. * Detaches the behavior from its current arc rotate camera.
  38632. */
  38633. detach(): void;
  38634. private _animatables;
  38635. private _betaIsAnimating;
  38636. private _betaTransition;
  38637. private _radiusTransition;
  38638. private _vectorTransition;
  38639. /**
  38640. * Targets the given mesh and updates zoom level accordingly.
  38641. * @param mesh The mesh to target.
  38642. * @param radius Optional. If a cached radius position already exists, overrides default.
  38643. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38644. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38645. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38646. */
  38647. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38648. /**
  38649. * Targets the given mesh with its children and updates zoom level accordingly.
  38650. * @param mesh The mesh to target.
  38651. * @param radius Optional. If a cached radius position already exists, overrides default.
  38652. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38655. */
  38656. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38657. /**
  38658. * Targets the given meshes with their children and updates zoom level accordingly.
  38659. * @param meshes The mesh to target.
  38660. * @param radius Optional. If a cached radius position already exists, overrides default.
  38661. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38664. */
  38665. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38666. /**
  38667. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38668. * @param minimumWorld Determines the smaller position of the bounding box extend
  38669. * @param maximumWorld Determines the bigger position of the bounding box extend
  38670. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38671. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38672. */
  38673. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38674. /**
  38675. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38676. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38677. * frustum width.
  38678. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38679. * to fully enclose the mesh in the viewing frustum.
  38680. */
  38681. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38682. /**
  38683. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38684. * is automatically returned to its default position (expected to be above ground plane).
  38685. */
  38686. private _maintainCameraAboveGround;
  38687. /**
  38688. * Returns the frustum slope based on the canvas ratio and camera FOV
  38689. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38690. */
  38691. private _getFrustumSlope;
  38692. /**
  38693. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38694. */
  38695. private _clearAnimationLocks;
  38696. /**
  38697. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38698. */
  38699. private _applyUserInteraction;
  38700. /**
  38701. * Stops and removes all animations that have been applied to the camera
  38702. */
  38703. stopAllAnimations(): void;
  38704. /**
  38705. * Gets a value indicating if the user is moving the camera
  38706. */
  38707. readonly isUserIsMoving: boolean;
  38708. /**
  38709. * The camera can move all the way towards the mesh.
  38710. */
  38711. static IgnoreBoundsSizeMode: number;
  38712. /**
  38713. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38714. */
  38715. static FitFrustumSidesMode: number;
  38716. }
  38717. }
  38718. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38719. import { Nullable } from "babylonjs/types";
  38720. import { Camera } from "babylonjs/Cameras/camera";
  38721. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38722. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38723. /**
  38724. * Base class for Camera Pointer Inputs.
  38725. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38726. * for example usage.
  38727. */
  38728. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38729. /**
  38730. * Defines the camera the input is attached to.
  38731. */
  38732. abstract camera: Camera;
  38733. /**
  38734. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38735. */
  38736. protected _altKey: boolean;
  38737. protected _ctrlKey: boolean;
  38738. protected _metaKey: boolean;
  38739. protected _shiftKey: boolean;
  38740. /**
  38741. * Which mouse buttons were pressed at time of last mouse event.
  38742. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38743. */
  38744. protected _buttonsPressed: number;
  38745. /**
  38746. * Defines the buttons associated with the input to handle camera move.
  38747. */
  38748. buttons: number[];
  38749. /**
  38750. * Attach the input controls to a specific dom element to get the input from.
  38751. * @param element Defines the element the controls should be listened from
  38752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38753. */
  38754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38755. /**
  38756. * Detach the current controls from the specified dom element.
  38757. * @param element Defines the element to stop listening the inputs from
  38758. */
  38759. detachControl(element: Nullable<HTMLElement>): void;
  38760. /**
  38761. * Gets the class name of the current input.
  38762. * @returns the class name
  38763. */
  38764. getClassName(): string;
  38765. /**
  38766. * Get the friendly name associated with the input class.
  38767. * @returns the input friendly name
  38768. */
  38769. getSimpleName(): string;
  38770. /**
  38771. * Called on pointer POINTERDOUBLETAP event.
  38772. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38773. */
  38774. protected onDoubleTap(type: string): void;
  38775. /**
  38776. * Called on pointer POINTERMOVE event if only a single touch is active.
  38777. * Override this method to provide functionality.
  38778. */
  38779. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38780. /**
  38781. * Called on pointer POINTERMOVE event if multiple touches are active.
  38782. * Override this method to provide functionality.
  38783. */
  38784. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38785. /**
  38786. * Called on JS contextmenu event.
  38787. * Override this method to provide functionality.
  38788. */
  38789. protected onContextMenu(evt: PointerEvent): void;
  38790. /**
  38791. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38792. * press.
  38793. * Override this method to provide functionality.
  38794. */
  38795. protected onButtonDown(evt: PointerEvent): void;
  38796. /**
  38797. * Called each time a new POINTERUP event occurs. Ie, for each button
  38798. * release.
  38799. * Override this method to provide functionality.
  38800. */
  38801. protected onButtonUp(evt: PointerEvent): void;
  38802. /**
  38803. * Called when window becomes inactive.
  38804. * Override this method to provide functionality.
  38805. */
  38806. protected onLostFocus(): void;
  38807. private _pointerInput;
  38808. private _observer;
  38809. private _onLostFocus;
  38810. private pointA;
  38811. private pointB;
  38812. }
  38813. }
  38814. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38815. import { Nullable } from "babylonjs/types";
  38816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38817. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38818. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38819. /**
  38820. * Manage the pointers inputs to control an arc rotate camera.
  38821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38822. */
  38823. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38824. /**
  38825. * Defines the camera the input is attached to.
  38826. */
  38827. camera: ArcRotateCamera;
  38828. /**
  38829. * Gets the class name of the current input.
  38830. * @returns the class name
  38831. */
  38832. getClassName(): string;
  38833. /**
  38834. * Defines the buttons associated with the input to handle camera move.
  38835. */
  38836. buttons: number[];
  38837. /**
  38838. * Defines the pointer angular sensibility along the X axis or how fast is
  38839. * the camera rotating.
  38840. */
  38841. angularSensibilityX: number;
  38842. /**
  38843. * Defines the pointer angular sensibility along the Y axis or how fast is
  38844. * the camera rotating.
  38845. */
  38846. angularSensibilityY: number;
  38847. /**
  38848. * Defines the pointer pinch precision or how fast is the camera zooming.
  38849. */
  38850. pinchPrecision: number;
  38851. /**
  38852. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38853. * from 0.
  38854. * It defines the percentage of current camera.radius to use as delta when
  38855. * pinch zoom is used.
  38856. */
  38857. pinchDeltaPercentage: number;
  38858. /**
  38859. * Defines the pointer panning sensibility or how fast is the camera moving.
  38860. */
  38861. panningSensibility: number;
  38862. /**
  38863. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38864. */
  38865. multiTouchPanning: boolean;
  38866. /**
  38867. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38868. * zoom (pinch) through multitouch.
  38869. */
  38870. multiTouchPanAndZoom: boolean;
  38871. /**
  38872. * Revers pinch action direction.
  38873. */
  38874. pinchInwards: boolean;
  38875. private _isPanClick;
  38876. private _twoFingerActivityCount;
  38877. private _isPinching;
  38878. /**
  38879. * Called on pointer POINTERMOVE event if only a single touch is active.
  38880. */
  38881. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38882. /**
  38883. * Called on pointer POINTERDOUBLETAP event.
  38884. */
  38885. protected onDoubleTap(type: string): void;
  38886. /**
  38887. * Called on pointer POINTERMOVE event if multiple touches are active.
  38888. */
  38889. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38890. /**
  38891. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38892. * press.
  38893. */
  38894. protected onButtonDown(evt: PointerEvent): void;
  38895. /**
  38896. * Called each time a new POINTERUP event occurs. Ie, for each button
  38897. * release.
  38898. */
  38899. protected onButtonUp(evt: PointerEvent): void;
  38900. /**
  38901. * Called when window becomes inactive.
  38902. */
  38903. protected onLostFocus(): void;
  38904. }
  38905. }
  38906. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38907. import { Nullable } from "babylonjs/types";
  38908. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38909. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38910. /**
  38911. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38913. */
  38914. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38915. /**
  38916. * Defines the camera the input is attached to.
  38917. */
  38918. camera: ArcRotateCamera;
  38919. /**
  38920. * Defines the list of key codes associated with the up action (increase alpha)
  38921. */
  38922. keysUp: number[];
  38923. /**
  38924. * Defines the list of key codes associated with the down action (decrease alpha)
  38925. */
  38926. keysDown: number[];
  38927. /**
  38928. * Defines the list of key codes associated with the left action (increase beta)
  38929. */
  38930. keysLeft: number[];
  38931. /**
  38932. * Defines the list of key codes associated with the right action (decrease beta)
  38933. */
  38934. keysRight: number[];
  38935. /**
  38936. * Defines the list of key codes associated with the reset action.
  38937. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38938. */
  38939. keysReset: number[];
  38940. /**
  38941. * Defines the panning sensibility of the inputs.
  38942. * (How fast is the camera paning)
  38943. */
  38944. panningSensibility: number;
  38945. /**
  38946. * Defines the zooming sensibility of the inputs.
  38947. * (How fast is the camera zooming)
  38948. */
  38949. zoomingSensibility: number;
  38950. /**
  38951. * Defines wether maintaining the alt key down switch the movement mode from
  38952. * orientation to zoom.
  38953. */
  38954. useAltToZoom: boolean;
  38955. /**
  38956. * Rotation speed of the camera
  38957. */
  38958. angularSpeed: number;
  38959. private _keys;
  38960. private _ctrlPressed;
  38961. private _altPressed;
  38962. private _onCanvasBlurObserver;
  38963. private _onKeyboardObserver;
  38964. private _engine;
  38965. private _scene;
  38966. /**
  38967. * Attach the input controls to a specific dom element to get the input from.
  38968. * @param element Defines the element the controls should be listened from
  38969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38970. */
  38971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38972. /**
  38973. * Detach the current controls from the specified dom element.
  38974. * @param element Defines the element to stop listening the inputs from
  38975. */
  38976. detachControl(element: Nullable<HTMLElement>): void;
  38977. /**
  38978. * Update the current camera state depending on the inputs that have been used this frame.
  38979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38980. */
  38981. checkInputs(): void;
  38982. /**
  38983. * Gets the class name of the current intput.
  38984. * @returns the class name
  38985. */
  38986. getClassName(): string;
  38987. /**
  38988. * Get the friendly name associated with the input class.
  38989. * @returns the input friendly name
  38990. */
  38991. getSimpleName(): string;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38997. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38998. /**
  38999. * Manage the mouse wheel inputs to control an arc rotate camera.
  39000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39001. */
  39002. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39003. /**
  39004. * Defines the camera the input is attached to.
  39005. */
  39006. camera: ArcRotateCamera;
  39007. /**
  39008. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39009. */
  39010. wheelPrecision: number;
  39011. /**
  39012. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39013. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39014. */
  39015. wheelDeltaPercentage: number;
  39016. private _wheel;
  39017. private _observer;
  39018. private computeDeltaFromMouseWheelLegacyEvent;
  39019. /**
  39020. * Attach the input controls to a specific dom element to get the input from.
  39021. * @param element Defines the element the controls should be listened from
  39022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39023. */
  39024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39025. /**
  39026. * Detach the current controls from the specified dom element.
  39027. * @param element Defines the element to stop listening the inputs from
  39028. */
  39029. detachControl(element: Nullable<HTMLElement>): void;
  39030. /**
  39031. * Gets the class name of the current intput.
  39032. * @returns the class name
  39033. */
  39034. getClassName(): string;
  39035. /**
  39036. * Get the friendly name associated with the input class.
  39037. * @returns the input friendly name
  39038. */
  39039. getSimpleName(): string;
  39040. }
  39041. }
  39042. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39043. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39044. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39045. /**
  39046. * Default Inputs manager for the ArcRotateCamera.
  39047. * It groups all the default supported inputs for ease of use.
  39048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39049. */
  39050. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39051. /**
  39052. * Instantiates a new ArcRotateCameraInputsManager.
  39053. * @param camera Defines the camera the inputs belong to
  39054. */
  39055. constructor(camera: ArcRotateCamera);
  39056. /**
  39057. * Add mouse wheel input support to the input manager.
  39058. * @returns the current input manager
  39059. */
  39060. addMouseWheel(): ArcRotateCameraInputsManager;
  39061. /**
  39062. * Add pointers input support to the input manager.
  39063. * @returns the current input manager
  39064. */
  39065. addPointers(): ArcRotateCameraInputsManager;
  39066. /**
  39067. * Add keyboard input support to the input manager.
  39068. * @returns the current input manager
  39069. */
  39070. addKeyboard(): ArcRotateCameraInputsManager;
  39071. }
  39072. }
  39073. declare module "babylonjs/Cameras/arcRotateCamera" {
  39074. import { Observable } from "babylonjs/Misc/observable";
  39075. import { Nullable } from "babylonjs/types";
  39076. import { Scene } from "babylonjs/scene";
  39077. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39079. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39080. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39081. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39082. import { Camera } from "babylonjs/Cameras/camera";
  39083. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39084. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39085. import { Collider } from "babylonjs/Collisions/collider";
  39086. /**
  39087. * This represents an orbital type of camera.
  39088. *
  39089. * 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.
  39090. * 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.
  39091. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39092. */
  39093. export class ArcRotateCamera extends TargetCamera {
  39094. /**
  39095. * Defines the rotation angle of the camera along the longitudinal axis.
  39096. */
  39097. alpha: number;
  39098. /**
  39099. * Defines the rotation angle of the camera along the latitudinal axis.
  39100. */
  39101. beta: number;
  39102. /**
  39103. * Defines the radius of the camera from it s target point.
  39104. */
  39105. radius: number;
  39106. protected _target: Vector3;
  39107. protected _targetHost: Nullable<AbstractMesh>;
  39108. /**
  39109. * Defines the target point of the camera.
  39110. * The camera looks towards it form the radius distance.
  39111. */
  39112. target: Vector3;
  39113. /**
  39114. * Define the current local position of the camera in the scene
  39115. */
  39116. position: Vector3;
  39117. protected _upVector: Vector3;
  39118. protected _upToYMatrix: Matrix;
  39119. protected _YToUpMatrix: Matrix;
  39120. /**
  39121. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39122. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39123. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39124. */
  39125. upVector: Vector3;
  39126. /**
  39127. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39128. */
  39129. setMatUp(): void;
  39130. /**
  39131. * Current inertia value on the longitudinal axis.
  39132. * The bigger this number the longer it will take for the camera to stop.
  39133. */
  39134. inertialAlphaOffset: number;
  39135. /**
  39136. * Current inertia value on the latitudinal axis.
  39137. * The bigger this number the longer it will take for the camera to stop.
  39138. */
  39139. inertialBetaOffset: number;
  39140. /**
  39141. * Current inertia value on the radius axis.
  39142. * The bigger this number the longer it will take for the camera to stop.
  39143. */
  39144. inertialRadiusOffset: number;
  39145. /**
  39146. * Minimum allowed angle on the longitudinal axis.
  39147. * This can help limiting how the Camera is able to move in the scene.
  39148. */
  39149. lowerAlphaLimit: Nullable<number>;
  39150. /**
  39151. * Maximum allowed angle on the longitudinal axis.
  39152. * This can help limiting how the Camera is able to move in the scene.
  39153. */
  39154. upperAlphaLimit: Nullable<number>;
  39155. /**
  39156. * Minimum allowed angle on the latitudinal axis.
  39157. * This can help limiting how the Camera is able to move in the scene.
  39158. */
  39159. lowerBetaLimit: number;
  39160. /**
  39161. * Maximum allowed angle on the latitudinal axis.
  39162. * This can help limiting how the Camera is able to move in the scene.
  39163. */
  39164. upperBetaLimit: number;
  39165. /**
  39166. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39167. * This can help limiting how the Camera is able to move in the scene.
  39168. */
  39169. lowerRadiusLimit: Nullable<number>;
  39170. /**
  39171. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39172. * This can help limiting how the Camera is able to move in the scene.
  39173. */
  39174. upperRadiusLimit: Nullable<number>;
  39175. /**
  39176. * Defines the current inertia value used during panning of the camera along the X axis.
  39177. */
  39178. inertialPanningX: number;
  39179. /**
  39180. * Defines the current inertia value used during panning of the camera along the Y axis.
  39181. */
  39182. inertialPanningY: number;
  39183. /**
  39184. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39185. * Basically if your fingers moves away from more than this distance you will be considered
  39186. * in pinch mode.
  39187. */
  39188. pinchToPanMaxDistance: number;
  39189. /**
  39190. * Defines the maximum distance the camera can pan.
  39191. * This could help keeping the cammera always in your scene.
  39192. */
  39193. panningDistanceLimit: Nullable<number>;
  39194. /**
  39195. * Defines the target of the camera before paning.
  39196. */
  39197. panningOriginTarget: Vector3;
  39198. /**
  39199. * Defines the value of the inertia used during panning.
  39200. * 0 would mean stop inertia and one would mean no decelleration at all.
  39201. */
  39202. panningInertia: number;
  39203. /**
  39204. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39205. */
  39206. angularSensibilityX: number;
  39207. /**
  39208. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39209. */
  39210. angularSensibilityY: number;
  39211. /**
  39212. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39213. */
  39214. pinchPrecision: number;
  39215. /**
  39216. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39217. * It will be used instead of pinchDeltaPrecision if different from 0.
  39218. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39219. */
  39220. pinchDeltaPercentage: number;
  39221. /**
  39222. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39223. */
  39224. panningSensibility: number;
  39225. /**
  39226. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39227. */
  39228. keysUp: number[];
  39229. /**
  39230. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39231. */
  39232. keysDown: number[];
  39233. /**
  39234. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39235. */
  39236. keysLeft: number[];
  39237. /**
  39238. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39239. */
  39240. keysRight: number[];
  39241. /**
  39242. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39243. */
  39244. wheelPrecision: number;
  39245. /**
  39246. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39247. * It will be used instead of pinchDeltaPrecision if different from 0.
  39248. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39249. */
  39250. wheelDeltaPercentage: number;
  39251. /**
  39252. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39253. */
  39254. zoomOnFactor: number;
  39255. /**
  39256. * Defines a screen offset for the camera position.
  39257. */
  39258. targetScreenOffset: Vector2;
  39259. /**
  39260. * Allows the camera to be completely reversed.
  39261. * If false the camera can not arrive upside down.
  39262. */
  39263. allowUpsideDown: boolean;
  39264. /**
  39265. * Define if double tap/click is used to restore the previously saved state of the camera.
  39266. */
  39267. useInputToRestoreState: boolean;
  39268. /** @hidden */
  39269. _viewMatrix: Matrix;
  39270. /** @hidden */
  39271. _useCtrlForPanning: boolean;
  39272. /** @hidden */
  39273. _panningMouseButton: number;
  39274. /**
  39275. * Defines the input associated to the camera.
  39276. */
  39277. inputs: ArcRotateCameraInputsManager;
  39278. /** @hidden */
  39279. _reset: () => void;
  39280. /**
  39281. * Defines the allowed panning axis.
  39282. */
  39283. panningAxis: Vector3;
  39284. protected _localDirection: Vector3;
  39285. protected _transformedDirection: Vector3;
  39286. private _bouncingBehavior;
  39287. /**
  39288. * Gets the bouncing behavior of the camera if it has been enabled.
  39289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39290. */
  39291. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39292. /**
  39293. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39295. */
  39296. useBouncingBehavior: boolean;
  39297. private _framingBehavior;
  39298. /**
  39299. * Gets the framing behavior of the camera if it has been enabled.
  39300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39301. */
  39302. readonly framingBehavior: Nullable<FramingBehavior>;
  39303. /**
  39304. * Defines if the framing behavior of the camera is enabled on the camera.
  39305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39306. */
  39307. useFramingBehavior: boolean;
  39308. private _autoRotationBehavior;
  39309. /**
  39310. * Gets the auto rotation behavior of the camera if it has been enabled.
  39311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39312. */
  39313. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39314. /**
  39315. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39316. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39317. */
  39318. useAutoRotationBehavior: boolean;
  39319. /**
  39320. * Observable triggered when the mesh target has been changed on the camera.
  39321. */
  39322. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39323. /**
  39324. * Event raised when the camera is colliding with a mesh.
  39325. */
  39326. onCollide: (collidedMesh: AbstractMesh) => void;
  39327. /**
  39328. * Defines whether the camera should check collision with the objects oh the scene.
  39329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39330. */
  39331. checkCollisions: boolean;
  39332. /**
  39333. * Defines the collision radius of the camera.
  39334. * This simulates a sphere around the camera.
  39335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39336. */
  39337. collisionRadius: Vector3;
  39338. protected _collider: Collider;
  39339. protected _previousPosition: Vector3;
  39340. protected _collisionVelocity: Vector3;
  39341. protected _newPosition: Vector3;
  39342. protected _previousAlpha: number;
  39343. protected _previousBeta: number;
  39344. protected _previousRadius: number;
  39345. protected _collisionTriggered: boolean;
  39346. protected _targetBoundingCenter: Nullable<Vector3>;
  39347. private _computationVector;
  39348. /**
  39349. * Instantiates a new ArcRotateCamera in a given scene
  39350. * @param name Defines the name of the camera
  39351. * @param alpha Defines the camera rotation along the logitudinal axis
  39352. * @param beta Defines the camera rotation along the latitudinal axis
  39353. * @param radius Defines the camera distance from its target
  39354. * @param target Defines the camera target
  39355. * @param scene Defines the scene the camera belongs to
  39356. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39357. */
  39358. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39359. /** @hidden */
  39360. _initCache(): void;
  39361. /** @hidden */
  39362. _updateCache(ignoreParentClass?: boolean): void;
  39363. protected _getTargetPosition(): Vector3;
  39364. private _storedAlpha;
  39365. private _storedBeta;
  39366. private _storedRadius;
  39367. private _storedTarget;
  39368. private _storedTargetScreenOffset;
  39369. /**
  39370. * Stores the current state of the camera (alpha, beta, radius and target)
  39371. * @returns the camera itself
  39372. */
  39373. storeState(): Camera;
  39374. /**
  39375. * @hidden
  39376. * Restored camera state. You must call storeState() first
  39377. */
  39378. _restoreStateValues(): boolean;
  39379. /** @hidden */
  39380. _isSynchronizedViewMatrix(): boolean;
  39381. /**
  39382. * Attached controls to the current camera.
  39383. * @param element Defines the element the controls should be listened from
  39384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39385. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39386. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39387. */
  39388. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39389. /**
  39390. * Detach the current controls from the camera.
  39391. * The camera will stop reacting to inputs.
  39392. * @param element Defines the element to stop listening the inputs from
  39393. */
  39394. detachControl(element: HTMLElement): void;
  39395. /** @hidden */
  39396. _checkInputs(): void;
  39397. protected _checkLimits(): void;
  39398. /**
  39399. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39400. */
  39401. rebuildAnglesAndRadius(): void;
  39402. /**
  39403. * Use a position to define the current camera related information like alpha, beta and radius
  39404. * @param position Defines the position to set the camera at
  39405. */
  39406. setPosition(position: Vector3): void;
  39407. /**
  39408. * Defines the target the camera should look at.
  39409. * This will automatically adapt alpha beta and radius to fit within the new target.
  39410. * @param target Defines the new target as a Vector or a mesh
  39411. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39412. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39413. */
  39414. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39415. /** @hidden */
  39416. _getViewMatrix(): Matrix;
  39417. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39418. /**
  39419. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39420. * @param meshes Defines the mesh to zoom on
  39421. * @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)
  39422. */
  39423. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39424. /**
  39425. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39426. * The target will be changed but the radius
  39427. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39428. * @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)
  39429. */
  39430. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39431. min: Vector3;
  39432. max: Vector3;
  39433. distance: number;
  39434. }, doNotUpdateMaxZ?: boolean): void;
  39435. /**
  39436. * @override
  39437. * Override Camera.createRigCamera
  39438. */
  39439. createRigCamera(name: string, cameraIndex: number): Camera;
  39440. /**
  39441. * @hidden
  39442. * @override
  39443. * Override Camera._updateRigCameras
  39444. */
  39445. _updateRigCameras(): void;
  39446. /**
  39447. * Destroy the camera and release the current resources hold by it.
  39448. */
  39449. dispose(): void;
  39450. /**
  39451. * Gets the current object class name.
  39452. * @return the class name
  39453. */
  39454. getClassName(): string;
  39455. }
  39456. }
  39457. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39458. import { Behavior } from "babylonjs/Behaviors/behavior";
  39459. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39460. /**
  39461. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39463. */
  39464. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39465. /**
  39466. * Gets the name of the behavior.
  39467. */
  39468. readonly name: string;
  39469. private _zoomStopsAnimation;
  39470. private _idleRotationSpeed;
  39471. private _idleRotationWaitTime;
  39472. private _idleRotationSpinupTime;
  39473. /**
  39474. * Sets the flag that indicates if user zooming should stop animation.
  39475. */
  39476. /**
  39477. * Gets the flag that indicates if user zooming should stop animation.
  39478. */
  39479. zoomStopsAnimation: boolean;
  39480. /**
  39481. * Sets the default speed at which the camera rotates around the model.
  39482. */
  39483. /**
  39484. * Gets the default speed at which the camera rotates around the model.
  39485. */
  39486. idleRotationSpeed: number;
  39487. /**
  39488. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39489. */
  39490. /**
  39491. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39492. */
  39493. idleRotationWaitTime: number;
  39494. /**
  39495. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39496. */
  39497. /**
  39498. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39499. */
  39500. idleRotationSpinupTime: number;
  39501. /**
  39502. * Gets a value indicating if the camera is currently rotating because of this behavior
  39503. */
  39504. readonly rotationInProgress: boolean;
  39505. private _onPrePointerObservableObserver;
  39506. private _onAfterCheckInputsObserver;
  39507. private _attachedCamera;
  39508. private _isPointerDown;
  39509. private _lastFrameTime;
  39510. private _lastInteractionTime;
  39511. private _cameraRotationSpeed;
  39512. /**
  39513. * Initializes the behavior.
  39514. */
  39515. init(): void;
  39516. /**
  39517. * Attaches the behavior to its arc rotate camera.
  39518. * @param camera Defines the camera to attach the behavior to
  39519. */
  39520. attach(camera: ArcRotateCamera): void;
  39521. /**
  39522. * Detaches the behavior from its current arc rotate camera.
  39523. */
  39524. detach(): void;
  39525. /**
  39526. * Returns true if user is scrolling.
  39527. * @return true if user is scrolling.
  39528. */
  39529. private _userIsZooming;
  39530. private _lastFrameRadius;
  39531. private _shouldAnimationStopForInteraction;
  39532. /**
  39533. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39534. */
  39535. private _applyUserInteraction;
  39536. private _userIsMoving;
  39537. }
  39538. }
  39539. declare module "babylonjs/Behaviors/Cameras/index" {
  39540. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39541. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39542. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39543. }
  39544. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39545. import { Mesh } from "babylonjs/Meshes/mesh";
  39546. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39547. import { Behavior } from "babylonjs/Behaviors/behavior";
  39548. /**
  39549. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39550. */
  39551. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39552. private ui;
  39553. /**
  39554. * The name of the behavior
  39555. */
  39556. name: string;
  39557. /**
  39558. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39559. */
  39560. distanceAwayFromFace: number;
  39561. /**
  39562. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39563. */
  39564. distanceAwayFromBottomOfFace: number;
  39565. private _faceVectors;
  39566. private _target;
  39567. private _scene;
  39568. private _onRenderObserver;
  39569. private _tmpMatrix;
  39570. private _tmpVector;
  39571. /**
  39572. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39573. * @param ui The transform node that should be attched to the mesh
  39574. */
  39575. constructor(ui: TransformNode);
  39576. /**
  39577. * Initializes the behavior
  39578. */
  39579. init(): void;
  39580. private _closestFace;
  39581. private _zeroVector;
  39582. private _lookAtTmpMatrix;
  39583. private _lookAtToRef;
  39584. /**
  39585. * Attaches the AttachToBoxBehavior to the passed in mesh
  39586. * @param target The mesh that the specified node will be attached to
  39587. */
  39588. attach(target: Mesh): void;
  39589. /**
  39590. * Detaches the behavior from the mesh
  39591. */
  39592. detach(): void;
  39593. }
  39594. }
  39595. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39596. import { Behavior } from "babylonjs/Behaviors/behavior";
  39597. import { Mesh } from "babylonjs/Meshes/mesh";
  39598. /**
  39599. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39600. */
  39601. export class FadeInOutBehavior implements Behavior<Mesh> {
  39602. /**
  39603. * Time in milliseconds to delay before fading in (Default: 0)
  39604. */
  39605. delay: number;
  39606. /**
  39607. * Time in milliseconds for the mesh to fade in (Default: 300)
  39608. */
  39609. fadeInTime: number;
  39610. private _millisecondsPerFrame;
  39611. private _hovered;
  39612. private _hoverValue;
  39613. private _ownerNode;
  39614. /**
  39615. * Instatiates the FadeInOutBehavior
  39616. */
  39617. constructor();
  39618. /**
  39619. * The name of the behavior
  39620. */
  39621. readonly name: string;
  39622. /**
  39623. * Initializes the behavior
  39624. */
  39625. init(): void;
  39626. /**
  39627. * Attaches the fade behavior on the passed in mesh
  39628. * @param ownerNode The mesh that will be faded in/out once attached
  39629. */
  39630. attach(ownerNode: Mesh): void;
  39631. /**
  39632. * Detaches the behavior from the mesh
  39633. */
  39634. detach(): void;
  39635. /**
  39636. * Triggers the mesh to begin fading in or out
  39637. * @param value if the object should fade in or out (true to fade in)
  39638. */
  39639. fadeIn(value: boolean): void;
  39640. private _update;
  39641. private _setAllVisibility;
  39642. }
  39643. }
  39644. declare module "babylonjs/Misc/pivotTools" {
  39645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39646. /**
  39647. * Class containing a set of static utilities functions for managing Pivots
  39648. * @hidden
  39649. */
  39650. export class PivotTools {
  39651. private static _PivotCached;
  39652. private static _OldPivotPoint;
  39653. private static _PivotTranslation;
  39654. private static _PivotTmpVector;
  39655. /** @hidden */
  39656. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39657. /** @hidden */
  39658. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39659. }
  39660. }
  39661. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39662. import { Scene } from "babylonjs/scene";
  39663. import { Vector4 } from "babylonjs/Maths/math.vector";
  39664. import { Mesh } from "babylonjs/Meshes/mesh";
  39665. import { Nullable } from "babylonjs/types";
  39666. import { Plane } from "babylonjs/Maths/math.plane";
  39667. /**
  39668. * Class containing static functions to help procedurally build meshes
  39669. */
  39670. export class PlaneBuilder {
  39671. /**
  39672. * Creates a plane mesh
  39673. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39674. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39675. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39679. * @param name defines the name of the mesh
  39680. * @param options defines the options used to create the mesh
  39681. * @param scene defines the hosting scene
  39682. * @returns the plane mesh
  39683. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39684. */
  39685. static CreatePlane(name: string, options: {
  39686. size?: number;
  39687. width?: number;
  39688. height?: number;
  39689. sideOrientation?: number;
  39690. frontUVs?: Vector4;
  39691. backUVs?: Vector4;
  39692. updatable?: boolean;
  39693. sourcePlane?: Plane;
  39694. }, scene?: Nullable<Scene>): Mesh;
  39695. }
  39696. }
  39697. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39698. import { Behavior } from "babylonjs/Behaviors/behavior";
  39699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39700. import { Observable } from "babylonjs/Misc/observable";
  39701. import { Vector3 } from "babylonjs/Maths/math.vector";
  39702. import { Ray } from "babylonjs/Culling/ray";
  39703. import "babylonjs/Meshes/Builders/planeBuilder";
  39704. /**
  39705. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39706. */
  39707. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39708. private static _AnyMouseID;
  39709. /**
  39710. * Abstract mesh the behavior is set on
  39711. */
  39712. attachedNode: AbstractMesh;
  39713. private _dragPlane;
  39714. private _scene;
  39715. private _pointerObserver;
  39716. private _beforeRenderObserver;
  39717. private static _planeScene;
  39718. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39719. /**
  39720. * 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)
  39721. */
  39722. maxDragAngle: number;
  39723. /**
  39724. * @hidden
  39725. */
  39726. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39727. /**
  39728. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39729. */
  39730. currentDraggingPointerID: number;
  39731. /**
  39732. * The last position where the pointer hit the drag plane in world space
  39733. */
  39734. lastDragPosition: Vector3;
  39735. /**
  39736. * If the behavior is currently in a dragging state
  39737. */
  39738. dragging: boolean;
  39739. /**
  39740. * 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)
  39741. */
  39742. dragDeltaRatio: number;
  39743. /**
  39744. * If the drag plane orientation should be updated during the dragging (Default: true)
  39745. */
  39746. updateDragPlane: boolean;
  39747. private _debugMode;
  39748. private _moving;
  39749. /**
  39750. * Fires each time the attached mesh is dragged with the pointer
  39751. * * delta between last drag position and current drag position in world space
  39752. * * dragDistance along the drag axis
  39753. * * dragPlaneNormal normal of the current drag plane used during the drag
  39754. * * dragPlanePoint in world space where the drag intersects the drag plane
  39755. */
  39756. onDragObservable: Observable<{
  39757. delta: Vector3;
  39758. dragPlanePoint: Vector3;
  39759. dragPlaneNormal: Vector3;
  39760. dragDistance: number;
  39761. pointerId: number;
  39762. }>;
  39763. /**
  39764. * Fires each time a drag begins (eg. mouse down on mesh)
  39765. */
  39766. onDragStartObservable: Observable<{
  39767. dragPlanePoint: Vector3;
  39768. pointerId: number;
  39769. }>;
  39770. /**
  39771. * Fires each time a drag ends (eg. mouse release after drag)
  39772. */
  39773. onDragEndObservable: Observable<{
  39774. dragPlanePoint: Vector3;
  39775. pointerId: number;
  39776. }>;
  39777. /**
  39778. * If the attached mesh should be moved when dragged
  39779. */
  39780. moveAttached: boolean;
  39781. /**
  39782. * If the drag behavior will react to drag events (Default: true)
  39783. */
  39784. enabled: boolean;
  39785. /**
  39786. * If pointer events should start and release the drag (Default: true)
  39787. */
  39788. startAndReleaseDragOnPointerEvents: boolean;
  39789. /**
  39790. * If camera controls should be detached during the drag
  39791. */
  39792. detachCameraControls: boolean;
  39793. /**
  39794. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39795. */
  39796. useObjectOrienationForDragging: boolean;
  39797. private _options;
  39798. /**
  39799. * Gets the options used by the behavior
  39800. */
  39801. /**
  39802. * Sets the options used by the behavior
  39803. */
  39804. options: {
  39805. dragAxis?: Vector3;
  39806. dragPlaneNormal?: Vector3;
  39807. };
  39808. /**
  39809. * Creates a pointer drag behavior that can be attached to a mesh
  39810. * @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)
  39811. */
  39812. constructor(options?: {
  39813. dragAxis?: Vector3;
  39814. dragPlaneNormal?: Vector3;
  39815. });
  39816. /**
  39817. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39818. */
  39819. validateDrag: (targetPosition: Vector3) => boolean;
  39820. /**
  39821. * The name of the behavior
  39822. */
  39823. readonly name: string;
  39824. /**
  39825. * Initializes the behavior
  39826. */
  39827. init(): void;
  39828. private _tmpVector;
  39829. private _alternatePickedPoint;
  39830. private _worldDragAxis;
  39831. private _targetPosition;
  39832. private _attachedElement;
  39833. /**
  39834. * Attaches the drag behavior the passed in mesh
  39835. * @param ownerNode The mesh that will be dragged around once attached
  39836. * @param predicate Predicate to use for pick filtering
  39837. */
  39838. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39839. /**
  39840. * Force relase the drag action by code.
  39841. */
  39842. releaseDrag(): void;
  39843. private _startDragRay;
  39844. private _lastPointerRay;
  39845. /**
  39846. * Simulates the start of a pointer drag event on the behavior
  39847. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39848. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39849. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39850. */
  39851. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39852. private _startDrag;
  39853. private _dragDelta;
  39854. private _moveDrag;
  39855. private _pickWithRayOnDragPlane;
  39856. private _pointA;
  39857. private _pointB;
  39858. private _pointC;
  39859. private _lineA;
  39860. private _lineB;
  39861. private _localAxis;
  39862. private _lookAt;
  39863. private _updateDragPlanePosition;
  39864. /**
  39865. * Detaches the behavior from the mesh
  39866. */
  39867. detach(): void;
  39868. }
  39869. }
  39870. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39871. import { Mesh } from "babylonjs/Meshes/mesh";
  39872. import { Behavior } from "babylonjs/Behaviors/behavior";
  39873. /**
  39874. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39875. */
  39876. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39877. private _dragBehaviorA;
  39878. private _dragBehaviorB;
  39879. private _startDistance;
  39880. private _initialScale;
  39881. private _targetScale;
  39882. private _ownerNode;
  39883. private _sceneRenderObserver;
  39884. /**
  39885. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39886. */
  39887. constructor();
  39888. /**
  39889. * The name of the behavior
  39890. */
  39891. readonly name: string;
  39892. /**
  39893. * Initializes the behavior
  39894. */
  39895. init(): void;
  39896. private _getCurrentDistance;
  39897. /**
  39898. * Attaches the scale behavior the passed in mesh
  39899. * @param ownerNode The mesh that will be scaled around once attached
  39900. */
  39901. attach(ownerNode: Mesh): void;
  39902. /**
  39903. * Detaches the behavior from the mesh
  39904. */
  39905. detach(): void;
  39906. }
  39907. }
  39908. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39909. import { Behavior } from "babylonjs/Behaviors/behavior";
  39910. import { Mesh } from "babylonjs/Meshes/mesh";
  39911. import { Observable } from "babylonjs/Misc/observable";
  39912. /**
  39913. * 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
  39914. */
  39915. export class SixDofDragBehavior implements Behavior<Mesh> {
  39916. private static _virtualScene;
  39917. private _ownerNode;
  39918. private _sceneRenderObserver;
  39919. private _scene;
  39920. private _targetPosition;
  39921. private _virtualOriginMesh;
  39922. private _virtualDragMesh;
  39923. private _pointerObserver;
  39924. private _moving;
  39925. private _startingOrientation;
  39926. /**
  39927. * 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)
  39928. */
  39929. private zDragFactor;
  39930. /**
  39931. * If the object should rotate to face the drag origin
  39932. */
  39933. rotateDraggedObject: boolean;
  39934. /**
  39935. * If the behavior is currently in a dragging state
  39936. */
  39937. dragging: boolean;
  39938. /**
  39939. * 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)
  39940. */
  39941. dragDeltaRatio: number;
  39942. /**
  39943. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39944. */
  39945. currentDraggingPointerID: number;
  39946. /**
  39947. * If camera controls should be detached during the drag
  39948. */
  39949. detachCameraControls: boolean;
  39950. /**
  39951. * Fires each time a drag starts
  39952. */
  39953. onDragStartObservable: Observable<{}>;
  39954. /**
  39955. * Fires each time a drag ends (eg. mouse release after drag)
  39956. */
  39957. onDragEndObservable: Observable<{}>;
  39958. /**
  39959. * 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
  39960. */
  39961. constructor();
  39962. /**
  39963. * The name of the behavior
  39964. */
  39965. readonly name: string;
  39966. /**
  39967. * Initializes the behavior
  39968. */
  39969. init(): void;
  39970. /**
  39971. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39972. */
  39973. private readonly _pointerCamera;
  39974. /**
  39975. * Attaches the scale behavior the passed in mesh
  39976. * @param ownerNode The mesh that will be scaled around once attached
  39977. */
  39978. attach(ownerNode: Mesh): void;
  39979. /**
  39980. * Detaches the behavior from the mesh
  39981. */
  39982. detach(): void;
  39983. }
  39984. }
  39985. declare module "babylonjs/Behaviors/Meshes/index" {
  39986. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39987. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39988. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39989. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39990. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39991. }
  39992. declare module "babylonjs/Behaviors/index" {
  39993. export * from "babylonjs/Behaviors/behavior";
  39994. export * from "babylonjs/Behaviors/Cameras/index";
  39995. export * from "babylonjs/Behaviors/Meshes/index";
  39996. }
  39997. declare module "babylonjs/Bones/boneIKController" {
  39998. import { Bone } from "babylonjs/Bones/bone";
  39999. import { Vector3 } from "babylonjs/Maths/math.vector";
  40000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40001. import { Nullable } from "babylonjs/types";
  40002. /**
  40003. * Class used to apply inverse kinematics to bones
  40004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40005. */
  40006. export class BoneIKController {
  40007. private static _tmpVecs;
  40008. private static _tmpQuat;
  40009. private static _tmpMats;
  40010. /**
  40011. * Gets or sets the target mesh
  40012. */
  40013. targetMesh: AbstractMesh;
  40014. /** Gets or sets the mesh used as pole */
  40015. poleTargetMesh: AbstractMesh;
  40016. /**
  40017. * Gets or sets the bone used as pole
  40018. */
  40019. poleTargetBone: Nullable<Bone>;
  40020. /**
  40021. * Gets or sets the target position
  40022. */
  40023. targetPosition: Vector3;
  40024. /**
  40025. * Gets or sets the pole target position
  40026. */
  40027. poleTargetPosition: Vector3;
  40028. /**
  40029. * Gets or sets the pole target local offset
  40030. */
  40031. poleTargetLocalOffset: Vector3;
  40032. /**
  40033. * Gets or sets the pole angle
  40034. */
  40035. poleAngle: number;
  40036. /**
  40037. * Gets or sets the mesh associated with the controller
  40038. */
  40039. mesh: AbstractMesh;
  40040. /**
  40041. * 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)
  40042. */
  40043. slerpAmount: number;
  40044. private _bone1Quat;
  40045. private _bone1Mat;
  40046. private _bone2Ang;
  40047. private _bone1;
  40048. private _bone2;
  40049. private _bone1Length;
  40050. private _bone2Length;
  40051. private _maxAngle;
  40052. private _maxReach;
  40053. private _rightHandedSystem;
  40054. private _bendAxis;
  40055. private _slerping;
  40056. private _adjustRoll;
  40057. /**
  40058. * Gets or sets maximum allowed angle
  40059. */
  40060. maxAngle: number;
  40061. /**
  40062. * Creates a new BoneIKController
  40063. * @param mesh defines the mesh to control
  40064. * @param bone defines the bone to control
  40065. * @param options defines options to set up the controller
  40066. */
  40067. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40068. targetMesh?: AbstractMesh;
  40069. poleTargetMesh?: AbstractMesh;
  40070. poleTargetBone?: Bone;
  40071. poleTargetLocalOffset?: Vector3;
  40072. poleAngle?: number;
  40073. bendAxis?: Vector3;
  40074. maxAngle?: number;
  40075. slerpAmount?: number;
  40076. });
  40077. private _setMaxAngle;
  40078. /**
  40079. * Force the controller to update the bones
  40080. */
  40081. update(): void;
  40082. }
  40083. }
  40084. declare module "babylonjs/Bones/boneLookController" {
  40085. import { Vector3 } from "babylonjs/Maths/math.vector";
  40086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40087. import { Bone } from "babylonjs/Bones/bone";
  40088. import { Space } from "babylonjs/Maths/math.axis";
  40089. /**
  40090. * Class used to make a bone look toward a point in space
  40091. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40092. */
  40093. export class BoneLookController {
  40094. private static _tmpVecs;
  40095. private static _tmpQuat;
  40096. private static _tmpMats;
  40097. /**
  40098. * The target Vector3 that the bone will look at
  40099. */
  40100. target: Vector3;
  40101. /**
  40102. * The mesh that the bone is attached to
  40103. */
  40104. mesh: AbstractMesh;
  40105. /**
  40106. * The bone that will be looking to the target
  40107. */
  40108. bone: Bone;
  40109. /**
  40110. * The up axis of the coordinate system that is used when the bone is rotated
  40111. */
  40112. upAxis: Vector3;
  40113. /**
  40114. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40115. */
  40116. upAxisSpace: Space;
  40117. /**
  40118. * Used to make an adjustment to the yaw of the bone
  40119. */
  40120. adjustYaw: number;
  40121. /**
  40122. * Used to make an adjustment to the pitch of the bone
  40123. */
  40124. adjustPitch: number;
  40125. /**
  40126. * Used to make an adjustment to the roll of the bone
  40127. */
  40128. adjustRoll: number;
  40129. /**
  40130. * 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)
  40131. */
  40132. slerpAmount: number;
  40133. private _minYaw;
  40134. private _maxYaw;
  40135. private _minPitch;
  40136. private _maxPitch;
  40137. private _minYawSin;
  40138. private _minYawCos;
  40139. private _maxYawSin;
  40140. private _maxYawCos;
  40141. private _midYawConstraint;
  40142. private _minPitchTan;
  40143. private _maxPitchTan;
  40144. private _boneQuat;
  40145. private _slerping;
  40146. private _transformYawPitch;
  40147. private _transformYawPitchInv;
  40148. private _firstFrameSkipped;
  40149. private _yawRange;
  40150. private _fowardAxis;
  40151. /**
  40152. * Gets or sets the minimum yaw angle that the bone can look to
  40153. */
  40154. minYaw: number;
  40155. /**
  40156. * Gets or sets the maximum yaw angle that the bone can look to
  40157. */
  40158. maxYaw: number;
  40159. /**
  40160. * Gets or sets the minimum pitch angle that the bone can look to
  40161. */
  40162. minPitch: number;
  40163. /**
  40164. * Gets or sets the maximum pitch angle that the bone can look to
  40165. */
  40166. maxPitch: number;
  40167. /**
  40168. * Create a BoneLookController
  40169. * @param mesh the mesh that the bone belongs to
  40170. * @param bone the bone that will be looking to the target
  40171. * @param target the target Vector3 to look at
  40172. * @param options optional settings:
  40173. * * maxYaw: the maximum angle the bone will yaw to
  40174. * * minYaw: the minimum angle the bone will yaw to
  40175. * * maxPitch: the maximum angle the bone will pitch to
  40176. * * minPitch: the minimum angle the bone will yaw to
  40177. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40178. * * upAxis: the up axis of the coordinate system
  40179. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40180. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40181. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40182. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40183. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40184. * * adjustRoll: used to make an adjustment to the roll of the bone
  40185. **/
  40186. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40187. maxYaw?: number;
  40188. minYaw?: number;
  40189. maxPitch?: number;
  40190. minPitch?: number;
  40191. slerpAmount?: number;
  40192. upAxis?: Vector3;
  40193. upAxisSpace?: Space;
  40194. yawAxis?: Vector3;
  40195. pitchAxis?: Vector3;
  40196. adjustYaw?: number;
  40197. adjustPitch?: number;
  40198. adjustRoll?: number;
  40199. });
  40200. /**
  40201. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40202. */
  40203. update(): void;
  40204. private _getAngleDiff;
  40205. private _getAngleBetween;
  40206. private _isAngleBetween;
  40207. }
  40208. }
  40209. declare module "babylonjs/Bones/index" {
  40210. export * from "babylonjs/Bones/bone";
  40211. export * from "babylonjs/Bones/boneIKController";
  40212. export * from "babylonjs/Bones/boneLookController";
  40213. export * from "babylonjs/Bones/skeleton";
  40214. }
  40215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40216. import { Nullable } from "babylonjs/types";
  40217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40219. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40220. /**
  40221. * Manage the gamepad inputs to control an arc rotate camera.
  40222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40223. */
  40224. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40225. /**
  40226. * Defines the camera the input is attached to.
  40227. */
  40228. camera: ArcRotateCamera;
  40229. /**
  40230. * Defines the gamepad the input is gathering event from.
  40231. */
  40232. gamepad: Nullable<Gamepad>;
  40233. /**
  40234. * Defines the gamepad rotation sensiblity.
  40235. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40236. */
  40237. gamepadRotationSensibility: number;
  40238. /**
  40239. * Defines the gamepad move sensiblity.
  40240. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40241. */
  40242. gamepadMoveSensibility: number;
  40243. private _yAxisScale;
  40244. /**
  40245. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40246. */
  40247. invertYAxis: boolean;
  40248. private _onGamepadConnectedObserver;
  40249. private _onGamepadDisconnectedObserver;
  40250. /**
  40251. * Attach the input controls to a specific dom element to get the input from.
  40252. * @param element Defines the element the controls should be listened from
  40253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40254. */
  40255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40256. /**
  40257. * Detach the current controls from the specified dom element.
  40258. * @param element Defines the element to stop listening the inputs from
  40259. */
  40260. detachControl(element: Nullable<HTMLElement>): void;
  40261. /**
  40262. * Update the current camera state depending on the inputs that have been used this frame.
  40263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40264. */
  40265. checkInputs(): void;
  40266. /**
  40267. * Gets the class name of the current intput.
  40268. * @returns the class name
  40269. */
  40270. getClassName(): string;
  40271. /**
  40272. * Get the friendly name associated with the input class.
  40273. * @returns the input friendly name
  40274. */
  40275. getSimpleName(): string;
  40276. }
  40277. }
  40278. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40279. import { Nullable } from "babylonjs/types";
  40280. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40282. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40283. interface ArcRotateCameraInputsManager {
  40284. /**
  40285. * Add orientation input support to the input manager.
  40286. * @returns the current input manager
  40287. */
  40288. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40289. }
  40290. }
  40291. /**
  40292. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40294. */
  40295. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40296. /**
  40297. * Defines the camera the input is attached to.
  40298. */
  40299. camera: ArcRotateCamera;
  40300. /**
  40301. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40302. */
  40303. alphaCorrection: number;
  40304. /**
  40305. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40306. */
  40307. gammaCorrection: number;
  40308. private _alpha;
  40309. private _gamma;
  40310. private _dirty;
  40311. private _deviceOrientationHandler;
  40312. /**
  40313. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40314. */
  40315. constructor();
  40316. /**
  40317. * Attach the input controls to a specific dom element to get the input from.
  40318. * @param element Defines the element the controls should be listened from
  40319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40320. */
  40321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40322. /** @hidden */
  40323. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40324. /**
  40325. * Update the current camera state depending on the inputs that have been used this frame.
  40326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40327. */
  40328. checkInputs(): void;
  40329. /**
  40330. * Detach the current controls from the specified dom element.
  40331. * @param element Defines the element to stop listening the inputs from
  40332. */
  40333. detachControl(element: Nullable<HTMLElement>): void;
  40334. /**
  40335. * Gets the class name of the current intput.
  40336. * @returns the class name
  40337. */
  40338. getClassName(): string;
  40339. /**
  40340. * Get the friendly name associated with the input class.
  40341. * @returns the input friendly name
  40342. */
  40343. getSimpleName(): string;
  40344. }
  40345. }
  40346. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40347. import { Nullable } from "babylonjs/types";
  40348. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40349. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40350. /**
  40351. * Listen to mouse events to control the camera.
  40352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40353. */
  40354. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40355. /**
  40356. * Defines the camera the input is attached to.
  40357. */
  40358. camera: FlyCamera;
  40359. /**
  40360. * Defines if touch is enabled. (Default is true.)
  40361. */
  40362. touchEnabled: boolean;
  40363. /**
  40364. * Defines the buttons associated with the input to handle camera rotation.
  40365. */
  40366. buttons: number[];
  40367. /**
  40368. * Assign buttons for Yaw control.
  40369. */
  40370. buttonsYaw: number[];
  40371. /**
  40372. * Assign buttons for Pitch control.
  40373. */
  40374. buttonsPitch: number[];
  40375. /**
  40376. * Assign buttons for Roll control.
  40377. */
  40378. buttonsRoll: number[];
  40379. /**
  40380. * Detect if any button is being pressed while mouse is moved.
  40381. * -1 = Mouse locked.
  40382. * 0 = Left button.
  40383. * 1 = Middle Button.
  40384. * 2 = Right Button.
  40385. */
  40386. activeButton: number;
  40387. /**
  40388. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40389. * Higher values reduce its sensitivity.
  40390. */
  40391. angularSensibility: number;
  40392. private _mousemoveCallback;
  40393. private _observer;
  40394. private _rollObserver;
  40395. private previousPosition;
  40396. private noPreventDefault;
  40397. private element;
  40398. /**
  40399. * Listen to mouse events to control the camera.
  40400. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40402. */
  40403. constructor(touchEnabled?: boolean);
  40404. /**
  40405. * Attach the mouse control to the HTML DOM element.
  40406. * @param element Defines the element that listens to the input events.
  40407. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40408. */
  40409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40410. /**
  40411. * Detach the current controls from the specified dom element.
  40412. * @param element Defines the element to stop listening the inputs from
  40413. */
  40414. detachControl(element: Nullable<HTMLElement>): void;
  40415. /**
  40416. * Gets the class name of the current input.
  40417. * @returns the class name.
  40418. */
  40419. getClassName(): string;
  40420. /**
  40421. * Get the friendly name associated with the input class.
  40422. * @returns the input's friendly name.
  40423. */
  40424. getSimpleName(): string;
  40425. private _pointerInput;
  40426. private _onMouseMove;
  40427. /**
  40428. * Rotate camera by mouse offset.
  40429. */
  40430. private rotateCamera;
  40431. }
  40432. }
  40433. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40434. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40435. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40436. /**
  40437. * Default Inputs manager for the FlyCamera.
  40438. * It groups all the default supported inputs for ease of use.
  40439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40440. */
  40441. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40442. /**
  40443. * Instantiates a new FlyCameraInputsManager.
  40444. * @param camera Defines the camera the inputs belong to.
  40445. */
  40446. constructor(camera: FlyCamera);
  40447. /**
  40448. * Add keyboard input support to the input manager.
  40449. * @returns the new FlyCameraKeyboardMoveInput().
  40450. */
  40451. addKeyboard(): FlyCameraInputsManager;
  40452. /**
  40453. * Add mouse input support to the input manager.
  40454. * @param touchEnabled Enable touch screen support.
  40455. * @returns the new FlyCameraMouseInput().
  40456. */
  40457. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40458. }
  40459. }
  40460. declare module "babylonjs/Cameras/flyCamera" {
  40461. import { Scene } from "babylonjs/scene";
  40462. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40464. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40465. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40466. /**
  40467. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40468. * such as in a 3D Space Shooter or a Flight Simulator.
  40469. */
  40470. export class FlyCamera extends TargetCamera {
  40471. /**
  40472. * Define the collision ellipsoid of the camera.
  40473. * This is helpful for simulating a camera body, like a player's body.
  40474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40475. */
  40476. ellipsoid: Vector3;
  40477. /**
  40478. * Define an offset for the position of the ellipsoid around the camera.
  40479. * This can be helpful if the camera is attached away from the player's body center,
  40480. * such as at its head.
  40481. */
  40482. ellipsoidOffset: Vector3;
  40483. /**
  40484. * Enable or disable collisions of the camera with the rest of the scene objects.
  40485. */
  40486. checkCollisions: boolean;
  40487. /**
  40488. * Enable or disable gravity on the camera.
  40489. */
  40490. applyGravity: boolean;
  40491. /**
  40492. * Define the current direction the camera is moving to.
  40493. */
  40494. cameraDirection: Vector3;
  40495. /**
  40496. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40497. * This overrides and empties cameraRotation.
  40498. */
  40499. rotationQuaternion: Quaternion;
  40500. /**
  40501. * Track Roll to maintain the wanted Rolling when looking around.
  40502. */
  40503. _trackRoll: number;
  40504. /**
  40505. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40506. */
  40507. rollCorrect: number;
  40508. /**
  40509. * Mimic a banked turn, Rolling the camera when Yawing.
  40510. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40511. */
  40512. bankedTurn: boolean;
  40513. /**
  40514. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40515. */
  40516. bankedTurnLimit: number;
  40517. /**
  40518. * Value of 0 disables the banked Roll.
  40519. * Value of 1 is equal to the Yaw angle in radians.
  40520. */
  40521. bankedTurnMultiplier: number;
  40522. /**
  40523. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40524. */
  40525. inputs: FlyCameraInputsManager;
  40526. /**
  40527. * Gets the input sensibility for mouse input.
  40528. * Higher values reduce sensitivity.
  40529. */
  40530. /**
  40531. * Sets the input sensibility for a mouse input.
  40532. * Higher values reduce sensitivity.
  40533. */
  40534. angularSensibility: number;
  40535. /**
  40536. * Get the keys for camera movement forward.
  40537. */
  40538. /**
  40539. * Set the keys for camera movement forward.
  40540. */
  40541. keysForward: number[];
  40542. /**
  40543. * Get the keys for camera movement backward.
  40544. */
  40545. keysBackward: number[];
  40546. /**
  40547. * Get the keys for camera movement up.
  40548. */
  40549. /**
  40550. * Set the keys for camera movement up.
  40551. */
  40552. keysUp: number[];
  40553. /**
  40554. * Get the keys for camera movement down.
  40555. */
  40556. /**
  40557. * Set the keys for camera movement down.
  40558. */
  40559. keysDown: number[];
  40560. /**
  40561. * Get the keys for camera movement left.
  40562. */
  40563. /**
  40564. * Set the keys for camera movement left.
  40565. */
  40566. keysLeft: number[];
  40567. /**
  40568. * Set the keys for camera movement right.
  40569. */
  40570. /**
  40571. * Set the keys for camera movement right.
  40572. */
  40573. keysRight: number[];
  40574. /**
  40575. * Event raised when the camera collides with a mesh in the scene.
  40576. */
  40577. onCollide: (collidedMesh: AbstractMesh) => void;
  40578. private _collider;
  40579. private _needMoveForGravity;
  40580. private _oldPosition;
  40581. private _diffPosition;
  40582. private _newPosition;
  40583. /** @hidden */
  40584. _localDirection: Vector3;
  40585. /** @hidden */
  40586. _transformedDirection: Vector3;
  40587. /**
  40588. * Instantiates a FlyCamera.
  40589. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40590. * such as in a 3D Space Shooter or a Flight Simulator.
  40591. * @param name Define the name of the camera in the scene.
  40592. * @param position Define the starting position of the camera in the scene.
  40593. * @param scene Define the scene the camera belongs to.
  40594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40595. */
  40596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40597. /**
  40598. * Attach a control to the HTML DOM element.
  40599. * @param element Defines the element that listens to the input events.
  40600. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40601. */
  40602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40603. /**
  40604. * Detach a control from the HTML DOM element.
  40605. * The camera will stop reacting to that input.
  40606. * @param element Defines the element that listens to the input events.
  40607. */
  40608. detachControl(element: HTMLElement): void;
  40609. private _collisionMask;
  40610. /**
  40611. * Get the mask that the camera ignores in collision events.
  40612. */
  40613. /**
  40614. * Set the mask that the camera ignores in collision events.
  40615. */
  40616. collisionMask: number;
  40617. /** @hidden */
  40618. _collideWithWorld(displacement: Vector3): void;
  40619. /** @hidden */
  40620. private _onCollisionPositionChange;
  40621. /** @hidden */
  40622. _checkInputs(): void;
  40623. /** @hidden */
  40624. _decideIfNeedsToMove(): boolean;
  40625. /** @hidden */
  40626. _updatePosition(): void;
  40627. /**
  40628. * Restore the Roll to its target value at the rate specified.
  40629. * @param rate - Higher means slower restoring.
  40630. * @hidden
  40631. */
  40632. restoreRoll(rate: number): void;
  40633. /**
  40634. * Destroy the camera and release the current resources held by it.
  40635. */
  40636. dispose(): void;
  40637. /**
  40638. * Get the current object class name.
  40639. * @returns the class name.
  40640. */
  40641. getClassName(): string;
  40642. }
  40643. }
  40644. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40645. import { Nullable } from "babylonjs/types";
  40646. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40647. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40648. /**
  40649. * Listen to keyboard events to control the camera.
  40650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40651. */
  40652. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40653. /**
  40654. * Defines the camera the input is attached to.
  40655. */
  40656. camera: FlyCamera;
  40657. /**
  40658. * The list of keyboard keys used to control the forward move of the camera.
  40659. */
  40660. keysForward: number[];
  40661. /**
  40662. * The list of keyboard keys used to control the backward move of the camera.
  40663. */
  40664. keysBackward: number[];
  40665. /**
  40666. * The list of keyboard keys used to control the forward move of the camera.
  40667. */
  40668. keysUp: number[];
  40669. /**
  40670. * The list of keyboard keys used to control the backward move of the camera.
  40671. */
  40672. keysDown: number[];
  40673. /**
  40674. * The list of keyboard keys used to control the right strafe move of the camera.
  40675. */
  40676. keysRight: number[];
  40677. /**
  40678. * The list of keyboard keys used to control the left strafe move of the camera.
  40679. */
  40680. keysLeft: number[];
  40681. private _keys;
  40682. private _onCanvasBlurObserver;
  40683. private _onKeyboardObserver;
  40684. private _engine;
  40685. private _scene;
  40686. /**
  40687. * Attach the input controls to a specific dom element to get the input from.
  40688. * @param element Defines the element the controls should be listened from
  40689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40690. */
  40691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40692. /**
  40693. * Detach the current controls from the specified dom element.
  40694. * @param element Defines the element to stop listening the inputs from
  40695. */
  40696. detachControl(element: Nullable<HTMLElement>): void;
  40697. /**
  40698. * Gets the class name of the current intput.
  40699. * @returns the class name
  40700. */
  40701. getClassName(): string;
  40702. /** @hidden */
  40703. _onLostFocus(e: FocusEvent): void;
  40704. /**
  40705. * Get the friendly name associated with the input class.
  40706. * @returns the input friendly name
  40707. */
  40708. getSimpleName(): string;
  40709. /**
  40710. * Update the current camera state depending on the inputs that have been used this frame.
  40711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40712. */
  40713. checkInputs(): void;
  40714. }
  40715. }
  40716. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40717. import { Nullable } from "babylonjs/types";
  40718. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40719. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40720. /**
  40721. * Manage the mouse wheel inputs to control a follow camera.
  40722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40723. */
  40724. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40725. /**
  40726. * Defines the camera the input is attached to.
  40727. */
  40728. camera: FollowCamera;
  40729. /**
  40730. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40731. */
  40732. axisControlRadius: boolean;
  40733. /**
  40734. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40735. */
  40736. axisControlHeight: boolean;
  40737. /**
  40738. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40739. */
  40740. axisControlRotation: boolean;
  40741. /**
  40742. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40743. * relation to mouseWheel events.
  40744. */
  40745. wheelPrecision: number;
  40746. /**
  40747. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40748. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40749. */
  40750. wheelDeltaPercentage: number;
  40751. private _wheel;
  40752. private _observer;
  40753. /**
  40754. * Attach the input controls to a specific dom element to get the input from.
  40755. * @param element Defines the element the controls should be listened from
  40756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40757. */
  40758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40759. /**
  40760. * Detach the current controls from the specified dom element.
  40761. * @param element Defines the element to stop listening the inputs from
  40762. */
  40763. detachControl(element: Nullable<HTMLElement>): void;
  40764. /**
  40765. * Gets the class name of the current intput.
  40766. * @returns the class name
  40767. */
  40768. getClassName(): string;
  40769. /**
  40770. * Get the friendly name associated with the input class.
  40771. * @returns the input friendly name
  40772. */
  40773. getSimpleName(): string;
  40774. }
  40775. }
  40776. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40777. import { Nullable } from "babylonjs/types";
  40778. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40779. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40780. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40781. /**
  40782. * Manage the pointers inputs to control an follow camera.
  40783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40784. */
  40785. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40786. /**
  40787. * Defines the camera the input is attached to.
  40788. */
  40789. camera: FollowCamera;
  40790. /**
  40791. * Gets the class name of the current input.
  40792. * @returns the class name
  40793. */
  40794. getClassName(): string;
  40795. /**
  40796. * Defines the pointer angular sensibility along the X axis or how fast is
  40797. * the camera rotating.
  40798. * A negative number will reverse the axis direction.
  40799. */
  40800. angularSensibilityX: number;
  40801. /**
  40802. * Defines the pointer angular sensibility along the Y axis or how fast is
  40803. * the camera rotating.
  40804. * A negative number will reverse the axis direction.
  40805. */
  40806. angularSensibilityY: number;
  40807. /**
  40808. * Defines the pointer pinch precision or how fast is the camera zooming.
  40809. * A negative number will reverse the axis direction.
  40810. */
  40811. pinchPrecision: number;
  40812. /**
  40813. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40814. * from 0.
  40815. * It defines the percentage of current camera.radius to use as delta when
  40816. * pinch zoom is used.
  40817. */
  40818. pinchDeltaPercentage: number;
  40819. /**
  40820. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40821. */
  40822. axisXControlRadius: boolean;
  40823. /**
  40824. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40825. */
  40826. axisXControlHeight: boolean;
  40827. /**
  40828. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40829. */
  40830. axisXControlRotation: boolean;
  40831. /**
  40832. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40833. */
  40834. axisYControlRadius: boolean;
  40835. /**
  40836. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40837. */
  40838. axisYControlHeight: boolean;
  40839. /**
  40840. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40841. */
  40842. axisYControlRotation: boolean;
  40843. /**
  40844. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40845. */
  40846. axisPinchControlRadius: boolean;
  40847. /**
  40848. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40849. */
  40850. axisPinchControlHeight: boolean;
  40851. /**
  40852. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40853. */
  40854. axisPinchControlRotation: boolean;
  40855. /**
  40856. * Log error messages if basic misconfiguration has occurred.
  40857. */
  40858. warningEnable: boolean;
  40859. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40860. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40861. private _warningCounter;
  40862. private _warning;
  40863. }
  40864. }
  40865. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40866. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40867. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40868. /**
  40869. * Default Inputs manager for the FollowCamera.
  40870. * It groups all the default supported inputs for ease of use.
  40871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40872. */
  40873. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40874. /**
  40875. * Instantiates a new FollowCameraInputsManager.
  40876. * @param camera Defines the camera the inputs belong to
  40877. */
  40878. constructor(camera: FollowCamera);
  40879. /**
  40880. * Add keyboard input support to the input manager.
  40881. * @returns the current input manager
  40882. */
  40883. addKeyboard(): FollowCameraInputsManager;
  40884. /**
  40885. * Add mouse wheel input support to the input manager.
  40886. * @returns the current input manager
  40887. */
  40888. addMouseWheel(): FollowCameraInputsManager;
  40889. /**
  40890. * Add pointers input support to the input manager.
  40891. * @returns the current input manager
  40892. */
  40893. addPointers(): FollowCameraInputsManager;
  40894. /**
  40895. * Add orientation input support to the input manager.
  40896. * @returns the current input manager
  40897. */
  40898. addVRDeviceOrientation(): FollowCameraInputsManager;
  40899. }
  40900. }
  40901. declare module "babylonjs/Cameras/followCamera" {
  40902. import { Nullable } from "babylonjs/types";
  40903. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40904. import { Scene } from "babylonjs/scene";
  40905. import { Vector3 } from "babylonjs/Maths/math.vector";
  40906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40907. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40908. /**
  40909. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40910. * an arc rotate version arcFollowCamera are available.
  40911. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40912. */
  40913. export class FollowCamera extends TargetCamera {
  40914. /**
  40915. * Distance the follow camera should follow an object at
  40916. */
  40917. radius: number;
  40918. /**
  40919. * Minimum allowed distance of the camera to the axis of rotation
  40920. * (The camera can not get closer).
  40921. * This can help limiting how the Camera is able to move in the scene.
  40922. */
  40923. lowerRadiusLimit: Nullable<number>;
  40924. /**
  40925. * Maximum allowed distance of the camera to the axis of rotation
  40926. * (The camera can not get further).
  40927. * This can help limiting how the Camera is able to move in the scene.
  40928. */
  40929. upperRadiusLimit: Nullable<number>;
  40930. /**
  40931. * Define a rotation offset between the camera and the object it follows
  40932. */
  40933. rotationOffset: number;
  40934. /**
  40935. * Minimum allowed angle to camera position relative to target object.
  40936. * This can help limiting how the Camera is able to move in the scene.
  40937. */
  40938. lowerRotationOffsetLimit: Nullable<number>;
  40939. /**
  40940. * Maximum allowed angle to camera position relative to target object.
  40941. * This can help limiting how the Camera is able to move in the scene.
  40942. */
  40943. upperRotationOffsetLimit: Nullable<number>;
  40944. /**
  40945. * Define a height offset between the camera and the object it follows.
  40946. * It can help following an object from the top (like a car chaing a plane)
  40947. */
  40948. heightOffset: number;
  40949. /**
  40950. * Minimum allowed height of camera position relative to target object.
  40951. * This can help limiting how the Camera is able to move in the scene.
  40952. */
  40953. lowerHeightOffsetLimit: Nullable<number>;
  40954. /**
  40955. * Maximum allowed height of camera position relative to target object.
  40956. * This can help limiting how the Camera is able to move in the scene.
  40957. */
  40958. upperHeightOffsetLimit: Nullable<number>;
  40959. /**
  40960. * Define how fast the camera can accelerate to follow it s target.
  40961. */
  40962. cameraAcceleration: number;
  40963. /**
  40964. * Define the speed limit of the camera following an object.
  40965. */
  40966. maxCameraSpeed: number;
  40967. /**
  40968. * Define the target of the camera.
  40969. */
  40970. lockedTarget: Nullable<AbstractMesh>;
  40971. /**
  40972. * Defines the input associated with the camera.
  40973. */
  40974. inputs: FollowCameraInputsManager;
  40975. /**
  40976. * Instantiates the follow camera.
  40977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40978. * @param name Define the name of the camera in the scene
  40979. * @param position Define the position of the camera
  40980. * @param scene Define the scene the camera belong to
  40981. * @param lockedTarget Define the target of the camera
  40982. */
  40983. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40984. private _follow;
  40985. /**
  40986. * Attached controls to the current camera.
  40987. * @param element Defines the element the controls should be listened from
  40988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40989. */
  40990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40991. /**
  40992. * Detach the current controls from the camera.
  40993. * The camera will stop reacting to inputs.
  40994. * @param element Defines the element to stop listening the inputs from
  40995. */
  40996. detachControl(element: HTMLElement): void;
  40997. /** @hidden */
  40998. _checkInputs(): void;
  40999. private _checkLimits;
  41000. /**
  41001. * Gets the camera class name.
  41002. * @returns the class name
  41003. */
  41004. getClassName(): string;
  41005. }
  41006. /**
  41007. * Arc Rotate version of the follow camera.
  41008. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41009. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41010. */
  41011. export class ArcFollowCamera extends TargetCamera {
  41012. /** The longitudinal angle of the camera */
  41013. alpha: number;
  41014. /** The latitudinal angle of the camera */
  41015. beta: number;
  41016. /** The radius of the camera from its target */
  41017. radius: number;
  41018. /** Define the camera target (the messh it should follow) */
  41019. target: Nullable<AbstractMesh>;
  41020. private _cartesianCoordinates;
  41021. /**
  41022. * Instantiates a new ArcFollowCamera
  41023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41024. * @param name Define the name of the camera
  41025. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41026. * @param beta Define the rotation angle of the camera around the elevation axis
  41027. * @param radius Define the radius of the camera from its target point
  41028. * @param target Define the target of the camera
  41029. * @param scene Define the scene the camera belongs to
  41030. */
  41031. constructor(name: string,
  41032. /** The longitudinal angle of the camera */
  41033. alpha: number,
  41034. /** The latitudinal angle of the camera */
  41035. beta: number,
  41036. /** The radius of the camera from its target */
  41037. radius: number,
  41038. /** Define the camera target (the messh it should follow) */
  41039. target: Nullable<AbstractMesh>, scene: Scene);
  41040. private _follow;
  41041. /** @hidden */
  41042. _checkInputs(): void;
  41043. /**
  41044. * Returns the class name of the object.
  41045. * It is mostly used internally for serialization purposes.
  41046. */
  41047. getClassName(): string;
  41048. }
  41049. }
  41050. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41051. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41052. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41053. import { Nullable } from "babylonjs/types";
  41054. /**
  41055. * Manage the keyboard inputs to control the movement of a follow camera.
  41056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41057. */
  41058. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41059. /**
  41060. * Defines the camera the input is attached to.
  41061. */
  41062. camera: FollowCamera;
  41063. /**
  41064. * Defines the list of key codes associated with the up action (increase heightOffset)
  41065. */
  41066. keysHeightOffsetIncr: number[];
  41067. /**
  41068. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41069. */
  41070. keysHeightOffsetDecr: number[];
  41071. /**
  41072. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41073. */
  41074. keysHeightOffsetModifierAlt: boolean;
  41075. /**
  41076. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41077. */
  41078. keysHeightOffsetModifierCtrl: boolean;
  41079. /**
  41080. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41081. */
  41082. keysHeightOffsetModifierShift: boolean;
  41083. /**
  41084. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41085. */
  41086. keysRotationOffsetIncr: number[];
  41087. /**
  41088. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41089. */
  41090. keysRotationOffsetDecr: number[];
  41091. /**
  41092. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41093. */
  41094. keysRotationOffsetModifierAlt: boolean;
  41095. /**
  41096. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41097. */
  41098. keysRotationOffsetModifierCtrl: boolean;
  41099. /**
  41100. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41101. */
  41102. keysRotationOffsetModifierShift: boolean;
  41103. /**
  41104. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41105. */
  41106. keysRadiusIncr: number[];
  41107. /**
  41108. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41109. */
  41110. keysRadiusDecr: number[];
  41111. /**
  41112. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41113. */
  41114. keysRadiusModifierAlt: boolean;
  41115. /**
  41116. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41117. */
  41118. keysRadiusModifierCtrl: boolean;
  41119. /**
  41120. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41121. */
  41122. keysRadiusModifierShift: boolean;
  41123. /**
  41124. * Defines the rate of change of heightOffset.
  41125. */
  41126. heightSensibility: number;
  41127. /**
  41128. * Defines the rate of change of rotationOffset.
  41129. */
  41130. rotationSensibility: number;
  41131. /**
  41132. * Defines the rate of change of radius.
  41133. */
  41134. radiusSensibility: number;
  41135. private _keys;
  41136. private _ctrlPressed;
  41137. private _altPressed;
  41138. private _shiftPressed;
  41139. private _onCanvasBlurObserver;
  41140. private _onKeyboardObserver;
  41141. private _engine;
  41142. private _scene;
  41143. /**
  41144. * Attach the input controls to a specific dom element to get the input from.
  41145. * @param element Defines the element the controls should be listened from
  41146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41147. */
  41148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41149. /**
  41150. * Detach the current controls from the specified dom element.
  41151. * @param element Defines the element to stop listening the inputs from
  41152. */
  41153. detachControl(element: Nullable<HTMLElement>): void;
  41154. /**
  41155. * Update the current camera state depending on the inputs that have been used this frame.
  41156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41157. */
  41158. checkInputs(): void;
  41159. /**
  41160. * Gets the class name of the current input.
  41161. * @returns the class name
  41162. */
  41163. getClassName(): string;
  41164. /**
  41165. * Get the friendly name associated with the input class.
  41166. * @returns the input friendly name
  41167. */
  41168. getSimpleName(): string;
  41169. /**
  41170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41171. * allow modification of the heightOffset value.
  41172. */
  41173. private _modifierHeightOffset;
  41174. /**
  41175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41176. * allow modification of the rotationOffset value.
  41177. */
  41178. private _modifierRotationOffset;
  41179. /**
  41180. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41181. * allow modification of the radius value.
  41182. */
  41183. private _modifierRadius;
  41184. }
  41185. }
  41186. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41187. import { Nullable } from "babylonjs/types";
  41188. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41189. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41190. import { Observable } from "babylonjs/Misc/observable";
  41191. module "babylonjs/Cameras/freeCameraInputsManager" {
  41192. interface FreeCameraInputsManager {
  41193. /**
  41194. * @hidden
  41195. */
  41196. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41197. /**
  41198. * Add orientation input support to the input manager.
  41199. * @returns the current input manager
  41200. */
  41201. addDeviceOrientation(): FreeCameraInputsManager;
  41202. }
  41203. }
  41204. /**
  41205. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41206. * Screen rotation is taken into account.
  41207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41208. */
  41209. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41210. private _camera;
  41211. private _screenOrientationAngle;
  41212. private _constantTranform;
  41213. private _screenQuaternion;
  41214. private _alpha;
  41215. private _beta;
  41216. private _gamma;
  41217. /**
  41218. * Can be used to detect if a device orientation sensor is available on a device
  41219. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41220. * @returns a promise that will resolve on orientation change
  41221. */
  41222. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41223. /**
  41224. * @hidden
  41225. */
  41226. _onDeviceOrientationChangedObservable: Observable<void>;
  41227. /**
  41228. * Instantiates a new input
  41229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41230. */
  41231. constructor();
  41232. /**
  41233. * Define the camera controlled by the input.
  41234. */
  41235. camera: FreeCamera;
  41236. /**
  41237. * Attach the input controls to a specific dom element to get the input from.
  41238. * @param element Defines the element the controls should be listened from
  41239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41240. */
  41241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41242. private _orientationChanged;
  41243. private _deviceOrientation;
  41244. /**
  41245. * Detach the current controls from the specified dom element.
  41246. * @param element Defines the element to stop listening the inputs from
  41247. */
  41248. detachControl(element: Nullable<HTMLElement>): void;
  41249. /**
  41250. * Update the current camera state depending on the inputs that have been used this frame.
  41251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41252. */
  41253. checkInputs(): void;
  41254. /**
  41255. * Gets the class name of the current intput.
  41256. * @returns the class name
  41257. */
  41258. getClassName(): string;
  41259. /**
  41260. * Get the friendly name associated with the input class.
  41261. * @returns the input friendly name
  41262. */
  41263. getSimpleName(): string;
  41264. }
  41265. }
  41266. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41267. import { Nullable } from "babylonjs/types";
  41268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41270. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41271. /**
  41272. * Manage the gamepad inputs to control a free camera.
  41273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41274. */
  41275. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41276. /**
  41277. * Define the camera the input is attached to.
  41278. */
  41279. camera: FreeCamera;
  41280. /**
  41281. * Define the Gamepad controlling the input
  41282. */
  41283. gamepad: Nullable<Gamepad>;
  41284. /**
  41285. * Defines the gamepad rotation sensiblity.
  41286. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41287. */
  41288. gamepadAngularSensibility: number;
  41289. /**
  41290. * Defines the gamepad move sensiblity.
  41291. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41292. */
  41293. gamepadMoveSensibility: number;
  41294. private _yAxisScale;
  41295. /**
  41296. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41297. */
  41298. invertYAxis: boolean;
  41299. private _onGamepadConnectedObserver;
  41300. private _onGamepadDisconnectedObserver;
  41301. private _cameraTransform;
  41302. private _deltaTransform;
  41303. private _vector3;
  41304. private _vector2;
  41305. /**
  41306. * Attach the input controls to a specific dom element to get the input from.
  41307. * @param element Defines the element the controls should be listened from
  41308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41309. */
  41310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41311. /**
  41312. * Detach the current controls from the specified dom element.
  41313. * @param element Defines the element to stop listening the inputs from
  41314. */
  41315. detachControl(element: Nullable<HTMLElement>): void;
  41316. /**
  41317. * Update the current camera state depending on the inputs that have been used this frame.
  41318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41319. */
  41320. checkInputs(): void;
  41321. /**
  41322. * Gets the class name of the current intput.
  41323. * @returns the class name
  41324. */
  41325. getClassName(): string;
  41326. /**
  41327. * Get the friendly name associated with the input class.
  41328. * @returns the input friendly name
  41329. */
  41330. getSimpleName(): string;
  41331. }
  41332. }
  41333. declare module "babylonjs/Misc/virtualJoystick" {
  41334. import { Nullable } from "babylonjs/types";
  41335. import { Vector3 } from "babylonjs/Maths/math.vector";
  41336. /**
  41337. * Defines the potential axis of a Joystick
  41338. */
  41339. export enum JoystickAxis {
  41340. /** X axis */
  41341. X = 0,
  41342. /** Y axis */
  41343. Y = 1,
  41344. /** Z axis */
  41345. Z = 2
  41346. }
  41347. /**
  41348. * Class used to define virtual joystick (used in touch mode)
  41349. */
  41350. export class VirtualJoystick {
  41351. /**
  41352. * Gets or sets a boolean indicating that left and right values must be inverted
  41353. */
  41354. reverseLeftRight: boolean;
  41355. /**
  41356. * Gets or sets a boolean indicating that up and down values must be inverted
  41357. */
  41358. reverseUpDown: boolean;
  41359. /**
  41360. * Gets the offset value for the position (ie. the change of the position value)
  41361. */
  41362. deltaPosition: Vector3;
  41363. /**
  41364. * Gets a boolean indicating if the virtual joystick was pressed
  41365. */
  41366. pressed: boolean;
  41367. /**
  41368. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41369. */
  41370. static Canvas: Nullable<HTMLCanvasElement>;
  41371. private static _globalJoystickIndex;
  41372. private static vjCanvasContext;
  41373. private static vjCanvasWidth;
  41374. private static vjCanvasHeight;
  41375. private static halfWidth;
  41376. private _action;
  41377. private _axisTargetedByLeftAndRight;
  41378. private _axisTargetedByUpAndDown;
  41379. private _joystickSensibility;
  41380. private _inversedSensibility;
  41381. private _joystickPointerID;
  41382. private _joystickColor;
  41383. private _joystickPointerPos;
  41384. private _joystickPreviousPointerPos;
  41385. private _joystickPointerStartPos;
  41386. private _deltaJoystickVector;
  41387. private _leftJoystick;
  41388. private _touches;
  41389. private _onPointerDownHandlerRef;
  41390. private _onPointerMoveHandlerRef;
  41391. private _onPointerUpHandlerRef;
  41392. private _onResize;
  41393. /**
  41394. * Creates a new virtual joystick
  41395. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41396. */
  41397. constructor(leftJoystick?: boolean);
  41398. /**
  41399. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41400. * @param newJoystickSensibility defines the new sensibility
  41401. */
  41402. setJoystickSensibility(newJoystickSensibility: number): void;
  41403. private _onPointerDown;
  41404. private _onPointerMove;
  41405. private _onPointerUp;
  41406. /**
  41407. * Change the color of the virtual joystick
  41408. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41409. */
  41410. setJoystickColor(newColor: string): void;
  41411. /**
  41412. * Defines a callback to call when the joystick is touched
  41413. * @param action defines the callback
  41414. */
  41415. setActionOnTouch(action: () => any): void;
  41416. /**
  41417. * Defines which axis you'd like to control for left & right
  41418. * @param axis defines the axis to use
  41419. */
  41420. setAxisForLeftRight(axis: JoystickAxis): void;
  41421. /**
  41422. * Defines which axis you'd like to control for up & down
  41423. * @param axis defines the axis to use
  41424. */
  41425. setAxisForUpDown(axis: JoystickAxis): void;
  41426. private _drawVirtualJoystick;
  41427. /**
  41428. * Release internal HTML canvas
  41429. */
  41430. releaseCanvas(): void;
  41431. }
  41432. }
  41433. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41434. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41435. import { Nullable } from "babylonjs/types";
  41436. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41438. module "babylonjs/Cameras/freeCameraInputsManager" {
  41439. interface FreeCameraInputsManager {
  41440. /**
  41441. * Add virtual joystick input support to the input manager.
  41442. * @returns the current input manager
  41443. */
  41444. addVirtualJoystick(): FreeCameraInputsManager;
  41445. }
  41446. }
  41447. /**
  41448. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41450. */
  41451. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41452. /**
  41453. * Defines the camera the input is attached to.
  41454. */
  41455. camera: FreeCamera;
  41456. private _leftjoystick;
  41457. private _rightjoystick;
  41458. /**
  41459. * Gets the left stick of the virtual joystick.
  41460. * @returns The virtual Joystick
  41461. */
  41462. getLeftJoystick(): VirtualJoystick;
  41463. /**
  41464. * Gets the right stick of the virtual joystick.
  41465. * @returns The virtual Joystick
  41466. */
  41467. getRightJoystick(): VirtualJoystick;
  41468. /**
  41469. * Update the current camera state depending on the inputs that have been used this frame.
  41470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41471. */
  41472. checkInputs(): void;
  41473. /**
  41474. * Attach the input controls to a specific dom element to get the input from.
  41475. * @param element Defines the element the controls should be listened from
  41476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41477. */
  41478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41479. /**
  41480. * Detach the current controls from the specified dom element.
  41481. * @param element Defines the element to stop listening the inputs from
  41482. */
  41483. detachControl(element: Nullable<HTMLElement>): void;
  41484. /**
  41485. * Gets the class name of the current intput.
  41486. * @returns the class name
  41487. */
  41488. getClassName(): string;
  41489. /**
  41490. * Get the friendly name associated with the input class.
  41491. * @returns the input friendly name
  41492. */
  41493. getSimpleName(): string;
  41494. }
  41495. }
  41496. declare module "babylonjs/Cameras/Inputs/index" {
  41497. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41498. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41499. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41500. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41501. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41502. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41503. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41504. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41505. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41506. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41507. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41508. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41509. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41510. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41511. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41512. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41513. }
  41514. declare module "babylonjs/Cameras/touchCamera" {
  41515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41516. import { Scene } from "babylonjs/scene";
  41517. import { Vector3 } from "babylonjs/Maths/math.vector";
  41518. /**
  41519. * This represents a FPS type of camera controlled by touch.
  41520. * This is like a universal camera minus the Gamepad controls.
  41521. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41522. */
  41523. export class TouchCamera extends FreeCamera {
  41524. /**
  41525. * Defines the touch sensibility for rotation.
  41526. * The higher the faster.
  41527. */
  41528. touchAngularSensibility: number;
  41529. /**
  41530. * Defines the touch sensibility for move.
  41531. * The higher the faster.
  41532. */
  41533. touchMoveSensibility: number;
  41534. /**
  41535. * Instantiates a new touch camera.
  41536. * This represents a FPS type of camera controlled by touch.
  41537. * This is like a universal camera minus the Gamepad controls.
  41538. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41539. * @param name Define the name of the camera in the scene
  41540. * @param position Define the start position of the camera in the scene
  41541. * @param scene Define the scene the camera belongs to
  41542. */
  41543. constructor(name: string, position: Vector3, scene: Scene);
  41544. /**
  41545. * Gets the current object class name.
  41546. * @return the class name
  41547. */
  41548. getClassName(): string;
  41549. /** @hidden */
  41550. _setupInputs(): void;
  41551. }
  41552. }
  41553. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41554. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41555. import { Scene } from "babylonjs/scene";
  41556. import { Vector3 } from "babylonjs/Maths/math.vector";
  41557. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41558. import { Axis } from "babylonjs/Maths/math.axis";
  41559. /**
  41560. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41561. * being tilted forward or back and left or right.
  41562. */
  41563. export class DeviceOrientationCamera extends FreeCamera {
  41564. private _initialQuaternion;
  41565. private _quaternionCache;
  41566. private _tmpDragQuaternion;
  41567. private _disablePointerInputWhenUsingDeviceOrientation;
  41568. /**
  41569. * Creates a new device orientation camera
  41570. * @param name The name of the camera
  41571. * @param position The start position camera
  41572. * @param scene The scene the camera belongs to
  41573. */
  41574. constructor(name: string, position: Vector3, scene: Scene);
  41575. /**
  41576. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41577. */
  41578. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41579. private _dragFactor;
  41580. /**
  41581. * Enabled turning on the y axis when the orientation sensor is active
  41582. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41583. */
  41584. enableHorizontalDragging(dragFactor?: number): void;
  41585. /**
  41586. * Gets the current instance class name ("DeviceOrientationCamera").
  41587. * This helps avoiding instanceof at run time.
  41588. * @returns the class name
  41589. */
  41590. getClassName(): string;
  41591. /**
  41592. * @hidden
  41593. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41594. */
  41595. _checkInputs(): void;
  41596. /**
  41597. * Reset the camera to its default orientation on the specified axis only.
  41598. * @param axis The axis to reset
  41599. */
  41600. resetToCurrentRotation(axis?: Axis): void;
  41601. }
  41602. }
  41603. declare module "babylonjs/Gamepads/xboxGamepad" {
  41604. import { Observable } from "babylonjs/Misc/observable";
  41605. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41606. /**
  41607. * Defines supported buttons for XBox360 compatible gamepads
  41608. */
  41609. export enum Xbox360Button {
  41610. /** A */
  41611. A = 0,
  41612. /** B */
  41613. B = 1,
  41614. /** X */
  41615. X = 2,
  41616. /** Y */
  41617. Y = 3,
  41618. /** Start */
  41619. Start = 4,
  41620. /** Back */
  41621. Back = 5,
  41622. /** Left button */
  41623. LB = 6,
  41624. /** Right button */
  41625. RB = 7,
  41626. /** Left stick */
  41627. LeftStick = 8,
  41628. /** Right stick */
  41629. RightStick = 9
  41630. }
  41631. /** Defines values for XBox360 DPad */
  41632. export enum Xbox360Dpad {
  41633. /** Up */
  41634. Up = 0,
  41635. /** Down */
  41636. Down = 1,
  41637. /** Left */
  41638. Left = 2,
  41639. /** Right */
  41640. Right = 3
  41641. }
  41642. /**
  41643. * Defines a XBox360 gamepad
  41644. */
  41645. export class Xbox360Pad extends Gamepad {
  41646. private _leftTrigger;
  41647. private _rightTrigger;
  41648. private _onlefttriggerchanged;
  41649. private _onrighttriggerchanged;
  41650. private _onbuttondown;
  41651. private _onbuttonup;
  41652. private _ondpaddown;
  41653. private _ondpadup;
  41654. /** Observable raised when a button is pressed */
  41655. onButtonDownObservable: Observable<Xbox360Button>;
  41656. /** Observable raised when a button is released */
  41657. onButtonUpObservable: Observable<Xbox360Button>;
  41658. /** Observable raised when a pad is pressed */
  41659. onPadDownObservable: Observable<Xbox360Dpad>;
  41660. /** Observable raised when a pad is released */
  41661. onPadUpObservable: Observable<Xbox360Dpad>;
  41662. private _buttonA;
  41663. private _buttonB;
  41664. private _buttonX;
  41665. private _buttonY;
  41666. private _buttonBack;
  41667. private _buttonStart;
  41668. private _buttonLB;
  41669. private _buttonRB;
  41670. private _buttonLeftStick;
  41671. private _buttonRightStick;
  41672. private _dPadUp;
  41673. private _dPadDown;
  41674. private _dPadLeft;
  41675. private _dPadRight;
  41676. private _isXboxOnePad;
  41677. /**
  41678. * Creates a new XBox360 gamepad object
  41679. * @param id defines the id of this gamepad
  41680. * @param index defines its index
  41681. * @param gamepad defines the internal HTML gamepad object
  41682. * @param xboxOne defines if it is a XBox One gamepad
  41683. */
  41684. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41685. /**
  41686. * Defines the callback to call when left trigger is pressed
  41687. * @param callback defines the callback to use
  41688. */
  41689. onlefttriggerchanged(callback: (value: number) => void): void;
  41690. /**
  41691. * Defines the callback to call when right trigger is pressed
  41692. * @param callback defines the callback to use
  41693. */
  41694. onrighttriggerchanged(callback: (value: number) => void): void;
  41695. /**
  41696. * Gets the left trigger value
  41697. */
  41698. /**
  41699. * Sets the left trigger value
  41700. */
  41701. leftTrigger: number;
  41702. /**
  41703. * Gets the right trigger value
  41704. */
  41705. /**
  41706. * Sets the right trigger value
  41707. */
  41708. rightTrigger: number;
  41709. /**
  41710. * Defines the callback to call when a button is pressed
  41711. * @param callback defines the callback to use
  41712. */
  41713. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41714. /**
  41715. * Defines the callback to call when a button is released
  41716. * @param callback defines the callback to use
  41717. */
  41718. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41719. /**
  41720. * Defines the callback to call when a pad is pressed
  41721. * @param callback defines the callback to use
  41722. */
  41723. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41724. /**
  41725. * Defines the callback to call when a pad is released
  41726. * @param callback defines the callback to use
  41727. */
  41728. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41729. private _setButtonValue;
  41730. private _setDPadValue;
  41731. /**
  41732. * Gets the value of the `A` button
  41733. */
  41734. /**
  41735. * Sets the value of the `A` button
  41736. */
  41737. buttonA: number;
  41738. /**
  41739. * Gets the value of the `B` button
  41740. */
  41741. /**
  41742. * Sets the value of the `B` button
  41743. */
  41744. buttonB: number;
  41745. /**
  41746. * Gets the value of the `X` button
  41747. */
  41748. /**
  41749. * Sets the value of the `X` button
  41750. */
  41751. buttonX: number;
  41752. /**
  41753. * Gets the value of the `Y` button
  41754. */
  41755. /**
  41756. * Sets the value of the `Y` button
  41757. */
  41758. buttonY: number;
  41759. /**
  41760. * Gets the value of the `Start` button
  41761. */
  41762. /**
  41763. * Sets the value of the `Start` button
  41764. */
  41765. buttonStart: number;
  41766. /**
  41767. * Gets the value of the `Back` button
  41768. */
  41769. /**
  41770. * Sets the value of the `Back` button
  41771. */
  41772. buttonBack: number;
  41773. /**
  41774. * Gets the value of the `Left` button
  41775. */
  41776. /**
  41777. * Sets the value of the `Left` button
  41778. */
  41779. buttonLB: number;
  41780. /**
  41781. * Gets the value of the `Right` button
  41782. */
  41783. /**
  41784. * Sets the value of the `Right` button
  41785. */
  41786. buttonRB: number;
  41787. /**
  41788. * Gets the value of the Left joystick
  41789. */
  41790. /**
  41791. * Sets the value of the Left joystick
  41792. */
  41793. buttonLeftStick: number;
  41794. /**
  41795. * Gets the value of the Right joystick
  41796. */
  41797. /**
  41798. * Sets the value of the Right joystick
  41799. */
  41800. buttonRightStick: number;
  41801. /**
  41802. * Gets the value of D-pad up
  41803. */
  41804. /**
  41805. * Sets the value of D-pad up
  41806. */
  41807. dPadUp: number;
  41808. /**
  41809. * Gets the value of D-pad down
  41810. */
  41811. /**
  41812. * Sets the value of D-pad down
  41813. */
  41814. dPadDown: number;
  41815. /**
  41816. * Gets the value of D-pad left
  41817. */
  41818. /**
  41819. * Sets the value of D-pad left
  41820. */
  41821. dPadLeft: number;
  41822. /**
  41823. * Gets the value of D-pad right
  41824. */
  41825. /**
  41826. * Sets the value of D-pad right
  41827. */
  41828. dPadRight: number;
  41829. /**
  41830. * Force the gamepad to synchronize with device values
  41831. */
  41832. update(): void;
  41833. /**
  41834. * Disposes the gamepad
  41835. */
  41836. dispose(): void;
  41837. }
  41838. }
  41839. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41840. import { Observable } from "babylonjs/Misc/observable";
  41841. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41842. /**
  41843. * Defines supported buttons for DualShock compatible gamepads
  41844. */
  41845. export enum DualShockButton {
  41846. /** Cross */
  41847. Cross = 0,
  41848. /** Circle */
  41849. Circle = 1,
  41850. /** Square */
  41851. Square = 2,
  41852. /** Triangle */
  41853. Triangle = 3,
  41854. /** Options */
  41855. Options = 4,
  41856. /** Share */
  41857. Share = 5,
  41858. /** L1 */
  41859. L1 = 6,
  41860. /** R1 */
  41861. R1 = 7,
  41862. /** Left stick */
  41863. LeftStick = 8,
  41864. /** Right stick */
  41865. RightStick = 9
  41866. }
  41867. /** Defines values for DualShock DPad */
  41868. export enum DualShockDpad {
  41869. /** Up */
  41870. Up = 0,
  41871. /** Down */
  41872. Down = 1,
  41873. /** Left */
  41874. Left = 2,
  41875. /** Right */
  41876. Right = 3
  41877. }
  41878. /**
  41879. * Defines a DualShock gamepad
  41880. */
  41881. export class DualShockPad extends Gamepad {
  41882. private _leftTrigger;
  41883. private _rightTrigger;
  41884. private _onlefttriggerchanged;
  41885. private _onrighttriggerchanged;
  41886. private _onbuttondown;
  41887. private _onbuttonup;
  41888. private _ondpaddown;
  41889. private _ondpadup;
  41890. /** Observable raised when a button is pressed */
  41891. onButtonDownObservable: Observable<DualShockButton>;
  41892. /** Observable raised when a button is released */
  41893. onButtonUpObservable: Observable<DualShockButton>;
  41894. /** Observable raised when a pad is pressed */
  41895. onPadDownObservable: Observable<DualShockDpad>;
  41896. /** Observable raised when a pad is released */
  41897. onPadUpObservable: Observable<DualShockDpad>;
  41898. private _buttonCross;
  41899. private _buttonCircle;
  41900. private _buttonSquare;
  41901. private _buttonTriangle;
  41902. private _buttonShare;
  41903. private _buttonOptions;
  41904. private _buttonL1;
  41905. private _buttonR1;
  41906. private _buttonLeftStick;
  41907. private _buttonRightStick;
  41908. private _dPadUp;
  41909. private _dPadDown;
  41910. private _dPadLeft;
  41911. private _dPadRight;
  41912. /**
  41913. * Creates a new DualShock gamepad object
  41914. * @param id defines the id of this gamepad
  41915. * @param index defines its index
  41916. * @param gamepad defines the internal HTML gamepad object
  41917. */
  41918. constructor(id: string, index: number, gamepad: any);
  41919. /**
  41920. * Defines the callback to call when left trigger is pressed
  41921. * @param callback defines the callback to use
  41922. */
  41923. onlefttriggerchanged(callback: (value: number) => void): void;
  41924. /**
  41925. * Defines the callback to call when right trigger is pressed
  41926. * @param callback defines the callback to use
  41927. */
  41928. onrighttriggerchanged(callback: (value: number) => void): void;
  41929. /**
  41930. * Gets the left trigger value
  41931. */
  41932. /**
  41933. * Sets the left trigger value
  41934. */
  41935. leftTrigger: number;
  41936. /**
  41937. * Gets the right trigger value
  41938. */
  41939. /**
  41940. * Sets the right trigger value
  41941. */
  41942. rightTrigger: number;
  41943. /**
  41944. * Defines the callback to call when a button is pressed
  41945. * @param callback defines the callback to use
  41946. */
  41947. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41948. /**
  41949. * Defines the callback to call when a button is released
  41950. * @param callback defines the callback to use
  41951. */
  41952. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41953. /**
  41954. * Defines the callback to call when a pad is pressed
  41955. * @param callback defines the callback to use
  41956. */
  41957. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41958. /**
  41959. * Defines the callback to call when a pad is released
  41960. * @param callback defines the callback to use
  41961. */
  41962. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41963. private _setButtonValue;
  41964. private _setDPadValue;
  41965. /**
  41966. * Gets the value of the `Cross` button
  41967. */
  41968. /**
  41969. * Sets the value of the `Cross` button
  41970. */
  41971. buttonCross: number;
  41972. /**
  41973. * Gets the value of the `Circle` button
  41974. */
  41975. /**
  41976. * Sets the value of the `Circle` button
  41977. */
  41978. buttonCircle: number;
  41979. /**
  41980. * Gets the value of the `Square` button
  41981. */
  41982. /**
  41983. * Sets the value of the `Square` button
  41984. */
  41985. buttonSquare: number;
  41986. /**
  41987. * Gets the value of the `Triangle` button
  41988. */
  41989. /**
  41990. * Sets the value of the `Triangle` button
  41991. */
  41992. buttonTriangle: number;
  41993. /**
  41994. * Gets the value of the `Options` button
  41995. */
  41996. /**
  41997. * Sets the value of the `Options` button
  41998. */
  41999. buttonOptions: number;
  42000. /**
  42001. * Gets the value of the `Share` button
  42002. */
  42003. /**
  42004. * Sets the value of the `Share` button
  42005. */
  42006. buttonShare: number;
  42007. /**
  42008. * Gets the value of the `L1` button
  42009. */
  42010. /**
  42011. * Sets the value of the `L1` button
  42012. */
  42013. buttonL1: number;
  42014. /**
  42015. * Gets the value of the `R1` button
  42016. */
  42017. /**
  42018. * Sets the value of the `R1` button
  42019. */
  42020. buttonR1: number;
  42021. /**
  42022. * Gets the value of the Left joystick
  42023. */
  42024. /**
  42025. * Sets the value of the Left joystick
  42026. */
  42027. buttonLeftStick: number;
  42028. /**
  42029. * Gets the value of the Right joystick
  42030. */
  42031. /**
  42032. * Sets the value of the Right joystick
  42033. */
  42034. buttonRightStick: number;
  42035. /**
  42036. * Gets the value of D-pad up
  42037. */
  42038. /**
  42039. * Sets the value of D-pad up
  42040. */
  42041. dPadUp: number;
  42042. /**
  42043. * Gets the value of D-pad down
  42044. */
  42045. /**
  42046. * Sets the value of D-pad down
  42047. */
  42048. dPadDown: number;
  42049. /**
  42050. * Gets the value of D-pad left
  42051. */
  42052. /**
  42053. * Sets the value of D-pad left
  42054. */
  42055. dPadLeft: number;
  42056. /**
  42057. * Gets the value of D-pad right
  42058. */
  42059. /**
  42060. * Sets the value of D-pad right
  42061. */
  42062. dPadRight: number;
  42063. /**
  42064. * Force the gamepad to synchronize with device values
  42065. */
  42066. update(): void;
  42067. /**
  42068. * Disposes the gamepad
  42069. */
  42070. dispose(): void;
  42071. }
  42072. }
  42073. declare module "babylonjs/Gamepads/gamepadManager" {
  42074. import { Observable } from "babylonjs/Misc/observable";
  42075. import { Nullable } from "babylonjs/types";
  42076. import { Scene } from "babylonjs/scene";
  42077. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42078. /**
  42079. * Manager for handling gamepads
  42080. */
  42081. export class GamepadManager {
  42082. private _scene?;
  42083. private _babylonGamepads;
  42084. private _oneGamepadConnected;
  42085. /** @hidden */
  42086. _isMonitoring: boolean;
  42087. private _gamepadEventSupported;
  42088. private _gamepadSupport;
  42089. /**
  42090. * observable to be triggered when the gamepad controller has been connected
  42091. */
  42092. onGamepadConnectedObservable: Observable<Gamepad>;
  42093. /**
  42094. * observable to be triggered when the gamepad controller has been disconnected
  42095. */
  42096. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42097. private _onGamepadConnectedEvent;
  42098. private _onGamepadDisconnectedEvent;
  42099. /**
  42100. * Initializes the gamepad manager
  42101. * @param _scene BabylonJS scene
  42102. */
  42103. constructor(_scene?: Scene | undefined);
  42104. /**
  42105. * The gamepads in the game pad manager
  42106. */
  42107. readonly gamepads: Gamepad[];
  42108. /**
  42109. * Get the gamepad controllers based on type
  42110. * @param type The type of gamepad controller
  42111. * @returns Nullable gamepad
  42112. */
  42113. getGamepadByType(type?: number): Nullable<Gamepad>;
  42114. /**
  42115. * Disposes the gamepad manager
  42116. */
  42117. dispose(): void;
  42118. private _addNewGamepad;
  42119. private _startMonitoringGamepads;
  42120. private _stopMonitoringGamepads;
  42121. /** @hidden */
  42122. _checkGamepadsStatus(): void;
  42123. private _updateGamepadObjects;
  42124. }
  42125. }
  42126. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42127. import { Nullable } from "babylonjs/types";
  42128. import { Scene } from "babylonjs/scene";
  42129. import { ISceneComponent } from "babylonjs/sceneComponent";
  42130. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42131. module "babylonjs/scene" {
  42132. interface Scene {
  42133. /** @hidden */
  42134. _gamepadManager: Nullable<GamepadManager>;
  42135. /**
  42136. * Gets the gamepad manager associated with the scene
  42137. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42138. */
  42139. gamepadManager: GamepadManager;
  42140. }
  42141. }
  42142. module "babylonjs/Cameras/freeCameraInputsManager" {
  42143. /**
  42144. * Interface representing a free camera inputs manager
  42145. */
  42146. interface FreeCameraInputsManager {
  42147. /**
  42148. * Adds gamepad input support to the FreeCameraInputsManager.
  42149. * @returns the FreeCameraInputsManager
  42150. */
  42151. addGamepad(): FreeCameraInputsManager;
  42152. }
  42153. }
  42154. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42155. /**
  42156. * Interface representing an arc rotate camera inputs manager
  42157. */
  42158. interface ArcRotateCameraInputsManager {
  42159. /**
  42160. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42161. * @returns the camera inputs manager
  42162. */
  42163. addGamepad(): ArcRotateCameraInputsManager;
  42164. }
  42165. }
  42166. /**
  42167. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42168. */
  42169. export class GamepadSystemSceneComponent implements ISceneComponent {
  42170. /**
  42171. * The component name helpfull to identify the component in the list of scene components.
  42172. */
  42173. readonly name: string;
  42174. /**
  42175. * The scene the component belongs to.
  42176. */
  42177. scene: Scene;
  42178. /**
  42179. * Creates a new instance of the component for the given scene
  42180. * @param scene Defines the scene to register the component in
  42181. */
  42182. constructor(scene: Scene);
  42183. /**
  42184. * Registers the component in a given scene
  42185. */
  42186. register(): void;
  42187. /**
  42188. * Rebuilds the elements related to this component in case of
  42189. * context lost for instance.
  42190. */
  42191. rebuild(): void;
  42192. /**
  42193. * Disposes the component and the associated ressources
  42194. */
  42195. dispose(): void;
  42196. private _beforeCameraUpdate;
  42197. }
  42198. }
  42199. declare module "babylonjs/Cameras/universalCamera" {
  42200. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42201. import { Scene } from "babylonjs/scene";
  42202. import { Vector3 } from "babylonjs/Maths/math.vector";
  42203. import "babylonjs/Gamepads/gamepadSceneComponent";
  42204. /**
  42205. * 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,
  42206. * which still works and will still be found in many Playgrounds.
  42207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42208. */
  42209. export class UniversalCamera extends TouchCamera {
  42210. /**
  42211. * Defines the gamepad rotation sensiblity.
  42212. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42213. */
  42214. gamepadAngularSensibility: number;
  42215. /**
  42216. * Defines the gamepad move sensiblity.
  42217. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42218. */
  42219. gamepadMoveSensibility: number;
  42220. /**
  42221. * 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,
  42222. * which still works and will still be found in many Playgrounds.
  42223. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42224. * @param name Define the name of the camera in the scene
  42225. * @param position Define the start position of the camera in the scene
  42226. * @param scene Define the scene the camera belongs to
  42227. */
  42228. constructor(name: string, position: Vector3, scene: Scene);
  42229. /**
  42230. * Gets the current object class name.
  42231. * @return the class name
  42232. */
  42233. getClassName(): string;
  42234. }
  42235. }
  42236. declare module "babylonjs/Cameras/gamepadCamera" {
  42237. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42238. import { Scene } from "babylonjs/scene";
  42239. import { Vector3 } from "babylonjs/Maths/math.vector";
  42240. /**
  42241. * This represents a FPS type of camera. This is only here for back compat purpose.
  42242. * Please use the UniversalCamera instead as both are identical.
  42243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42244. */
  42245. export class GamepadCamera extends UniversalCamera {
  42246. /**
  42247. * Instantiates a new Gamepad Camera
  42248. * This represents a FPS type of camera. This is only here for back compat purpose.
  42249. * Please use the UniversalCamera instead as both are identical.
  42250. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42251. * @param name Define the name of the camera in the scene
  42252. * @param position Define the start position of the camera in the scene
  42253. * @param scene Define the scene the camera belongs to
  42254. */
  42255. constructor(name: string, position: Vector3, scene: Scene);
  42256. /**
  42257. * Gets the current object class name.
  42258. * @return the class name
  42259. */
  42260. getClassName(): string;
  42261. }
  42262. }
  42263. declare module "babylonjs/Shaders/pass.fragment" {
  42264. /** @hidden */
  42265. export var passPixelShader: {
  42266. name: string;
  42267. shader: string;
  42268. };
  42269. }
  42270. declare module "babylonjs/Shaders/passCube.fragment" {
  42271. /** @hidden */
  42272. export var passCubePixelShader: {
  42273. name: string;
  42274. shader: string;
  42275. };
  42276. }
  42277. declare module "babylonjs/PostProcesses/passPostProcess" {
  42278. import { Nullable } from "babylonjs/types";
  42279. import { Camera } from "babylonjs/Cameras/camera";
  42280. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42281. import { Engine } from "babylonjs/Engines/engine";
  42282. import "babylonjs/Shaders/pass.fragment";
  42283. import "babylonjs/Shaders/passCube.fragment";
  42284. /**
  42285. * PassPostProcess which produces an output the same as it's input
  42286. */
  42287. export class PassPostProcess extends PostProcess {
  42288. /**
  42289. * Creates the PassPostProcess
  42290. * @param name The name of the effect.
  42291. * @param options The required width/height ratio to downsize to before computing the render pass.
  42292. * @param camera The camera to apply the render pass to.
  42293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42294. * @param engine The engine which the post process will be applied. (default: current engine)
  42295. * @param reusable If the post process can be reused on the same frame. (default: false)
  42296. * @param textureType The type of texture to be used when performing the post processing.
  42297. * @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)
  42298. */
  42299. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42300. }
  42301. /**
  42302. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42303. */
  42304. export class PassCubePostProcess extends PostProcess {
  42305. private _face;
  42306. /**
  42307. * Gets or sets the cube face to display.
  42308. * * 0 is +X
  42309. * * 1 is -X
  42310. * * 2 is +Y
  42311. * * 3 is -Y
  42312. * * 4 is +Z
  42313. * * 5 is -Z
  42314. */
  42315. face: number;
  42316. /**
  42317. * Creates the PassCubePostProcess
  42318. * @param name The name of the effect.
  42319. * @param options The required width/height ratio to downsize to before computing the render pass.
  42320. * @param camera The camera to apply the render pass to.
  42321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42322. * @param engine The engine which the post process will be applied. (default: current engine)
  42323. * @param reusable If the post process can be reused on the same frame. (default: false)
  42324. * @param textureType The type of texture to be used when performing the post processing.
  42325. * @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)
  42326. */
  42327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42328. }
  42329. }
  42330. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42331. /** @hidden */
  42332. export var anaglyphPixelShader: {
  42333. name: string;
  42334. shader: string;
  42335. };
  42336. }
  42337. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42338. import { Engine } from "babylonjs/Engines/engine";
  42339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42340. import { Camera } from "babylonjs/Cameras/camera";
  42341. import "babylonjs/Shaders/anaglyph.fragment";
  42342. /**
  42343. * Postprocess used to generate anaglyphic rendering
  42344. */
  42345. export class AnaglyphPostProcess extends PostProcess {
  42346. private _passedProcess;
  42347. /**
  42348. * Creates a new AnaglyphPostProcess
  42349. * @param name defines postprocess name
  42350. * @param options defines creation options or target ratio scale
  42351. * @param rigCameras defines cameras using this postprocess
  42352. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42353. * @param engine defines hosting engine
  42354. * @param reusable defines if the postprocess will be reused multiple times per frame
  42355. */
  42356. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42357. }
  42358. }
  42359. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42360. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42361. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42362. import { Scene } from "babylonjs/scene";
  42363. import { Vector3 } from "babylonjs/Maths/math.vector";
  42364. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42365. /**
  42366. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42367. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42368. */
  42369. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42370. /**
  42371. * Creates a new AnaglyphArcRotateCamera
  42372. * @param name defines camera name
  42373. * @param alpha defines alpha angle (in radians)
  42374. * @param beta defines beta angle (in radians)
  42375. * @param radius defines radius
  42376. * @param target defines camera target
  42377. * @param interaxialDistance defines distance between each color axis
  42378. * @param scene defines the hosting scene
  42379. */
  42380. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42381. /**
  42382. * Gets camera class name
  42383. * @returns AnaglyphArcRotateCamera
  42384. */
  42385. getClassName(): string;
  42386. }
  42387. }
  42388. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42389. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42390. import { Scene } from "babylonjs/scene";
  42391. import { Vector3 } from "babylonjs/Maths/math.vector";
  42392. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42393. /**
  42394. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42395. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42396. */
  42397. export class AnaglyphFreeCamera extends FreeCamera {
  42398. /**
  42399. * Creates a new AnaglyphFreeCamera
  42400. * @param name defines camera name
  42401. * @param position defines initial position
  42402. * @param interaxialDistance defines distance between each color axis
  42403. * @param scene defines the hosting scene
  42404. */
  42405. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42406. /**
  42407. * Gets camera class name
  42408. * @returns AnaglyphFreeCamera
  42409. */
  42410. getClassName(): string;
  42411. }
  42412. }
  42413. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42414. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42415. import { Scene } from "babylonjs/scene";
  42416. import { Vector3 } from "babylonjs/Maths/math.vector";
  42417. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42418. /**
  42419. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42420. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42421. */
  42422. export class AnaglyphGamepadCamera extends GamepadCamera {
  42423. /**
  42424. * Creates a new AnaglyphGamepadCamera
  42425. * @param name defines camera name
  42426. * @param position defines initial position
  42427. * @param interaxialDistance defines distance between each color axis
  42428. * @param scene defines the hosting scene
  42429. */
  42430. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42431. /**
  42432. * Gets camera class name
  42433. * @returns AnaglyphGamepadCamera
  42434. */
  42435. getClassName(): string;
  42436. }
  42437. }
  42438. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42439. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42440. import { Scene } from "babylonjs/scene";
  42441. import { Vector3 } from "babylonjs/Maths/math.vector";
  42442. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42443. /**
  42444. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42445. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42446. */
  42447. export class AnaglyphUniversalCamera extends UniversalCamera {
  42448. /**
  42449. * Creates a new AnaglyphUniversalCamera
  42450. * @param name defines camera name
  42451. * @param position defines initial position
  42452. * @param interaxialDistance defines distance between each color axis
  42453. * @param scene defines the hosting scene
  42454. */
  42455. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42456. /**
  42457. * Gets camera class name
  42458. * @returns AnaglyphUniversalCamera
  42459. */
  42460. getClassName(): string;
  42461. }
  42462. }
  42463. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42464. /** @hidden */
  42465. export var stereoscopicInterlacePixelShader: {
  42466. name: string;
  42467. shader: string;
  42468. };
  42469. }
  42470. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42471. import { Camera } from "babylonjs/Cameras/camera";
  42472. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42473. import { Engine } from "babylonjs/Engines/engine";
  42474. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42475. /**
  42476. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42477. */
  42478. export class StereoscopicInterlacePostProcess extends PostProcess {
  42479. private _stepSize;
  42480. private _passedProcess;
  42481. /**
  42482. * Initializes a StereoscopicInterlacePostProcess
  42483. * @param name The name of the effect.
  42484. * @param rigCameras The rig cameras to be appled to the post process
  42485. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42487. * @param engine The engine which the post process will be applied. (default: current engine)
  42488. * @param reusable If the post process can be reused on the same frame. (default: false)
  42489. */
  42490. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42491. }
  42492. }
  42493. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42494. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42496. import { Scene } from "babylonjs/scene";
  42497. import { Vector3 } from "babylonjs/Maths/math.vector";
  42498. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42499. /**
  42500. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42501. * @see http://doc.babylonjs.com/features/cameras
  42502. */
  42503. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42504. /**
  42505. * Creates a new StereoscopicArcRotateCamera
  42506. * @param name defines camera name
  42507. * @param alpha defines alpha angle (in radians)
  42508. * @param beta defines beta angle (in radians)
  42509. * @param radius defines radius
  42510. * @param target defines camera target
  42511. * @param interaxialDistance defines distance between each color axis
  42512. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42513. * @param scene defines the hosting scene
  42514. */
  42515. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42516. /**
  42517. * Gets camera class name
  42518. * @returns StereoscopicArcRotateCamera
  42519. */
  42520. getClassName(): string;
  42521. }
  42522. }
  42523. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42524. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42525. import { Scene } from "babylonjs/scene";
  42526. import { Vector3 } from "babylonjs/Maths/math.vector";
  42527. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42528. /**
  42529. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42530. * @see http://doc.babylonjs.com/features/cameras
  42531. */
  42532. export class StereoscopicFreeCamera extends FreeCamera {
  42533. /**
  42534. * Creates a new StereoscopicFreeCamera
  42535. * @param name defines camera name
  42536. * @param position defines initial position
  42537. * @param interaxialDistance defines distance between each color axis
  42538. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42539. * @param scene defines the hosting scene
  42540. */
  42541. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42542. /**
  42543. * Gets camera class name
  42544. * @returns StereoscopicFreeCamera
  42545. */
  42546. getClassName(): string;
  42547. }
  42548. }
  42549. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42550. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42551. import { Scene } from "babylonjs/scene";
  42552. import { Vector3 } from "babylonjs/Maths/math.vector";
  42553. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42554. /**
  42555. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42556. * @see http://doc.babylonjs.com/features/cameras
  42557. */
  42558. export class StereoscopicGamepadCamera extends GamepadCamera {
  42559. /**
  42560. * Creates a new StereoscopicGamepadCamera
  42561. * @param name defines camera name
  42562. * @param position defines initial position
  42563. * @param interaxialDistance defines distance between each color axis
  42564. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42565. * @param scene defines the hosting scene
  42566. */
  42567. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42568. /**
  42569. * Gets camera class name
  42570. * @returns StereoscopicGamepadCamera
  42571. */
  42572. getClassName(): string;
  42573. }
  42574. }
  42575. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42576. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42577. import { Scene } from "babylonjs/scene";
  42578. import { Vector3 } from "babylonjs/Maths/math.vector";
  42579. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42580. /**
  42581. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42582. * @see http://doc.babylonjs.com/features/cameras
  42583. */
  42584. export class StereoscopicUniversalCamera extends UniversalCamera {
  42585. /**
  42586. * Creates a new StereoscopicUniversalCamera
  42587. * @param name defines camera name
  42588. * @param position defines initial position
  42589. * @param interaxialDistance defines distance between each color axis
  42590. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42591. * @param scene defines the hosting scene
  42592. */
  42593. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42594. /**
  42595. * Gets camera class name
  42596. * @returns StereoscopicUniversalCamera
  42597. */
  42598. getClassName(): string;
  42599. }
  42600. }
  42601. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42602. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42603. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42604. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42605. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42606. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42607. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42608. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42609. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42610. }
  42611. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42613. import { Scene } from "babylonjs/scene";
  42614. import { Vector3 } from "babylonjs/Maths/math.vector";
  42615. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42616. /**
  42617. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42618. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42619. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42620. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42621. */
  42622. export class VirtualJoysticksCamera extends FreeCamera {
  42623. /**
  42624. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42625. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42626. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42627. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42628. * @param name Define the name of the camera in the scene
  42629. * @param position Define the start position of the camera in the scene
  42630. * @param scene Define the scene the camera belongs to
  42631. */
  42632. constructor(name: string, position: Vector3, scene: Scene);
  42633. /**
  42634. * Gets the current object class name.
  42635. * @return the class name
  42636. */
  42637. getClassName(): string;
  42638. }
  42639. }
  42640. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42641. import { Matrix } from "babylonjs/Maths/math.vector";
  42642. /**
  42643. * This represents all the required metrics to create a VR camera.
  42644. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42645. */
  42646. export class VRCameraMetrics {
  42647. /**
  42648. * Define the horizontal resolution off the screen.
  42649. */
  42650. hResolution: number;
  42651. /**
  42652. * Define the vertical resolution off the screen.
  42653. */
  42654. vResolution: number;
  42655. /**
  42656. * Define the horizontal screen size.
  42657. */
  42658. hScreenSize: number;
  42659. /**
  42660. * Define the vertical screen size.
  42661. */
  42662. vScreenSize: number;
  42663. /**
  42664. * Define the vertical screen center position.
  42665. */
  42666. vScreenCenter: number;
  42667. /**
  42668. * Define the distance of the eyes to the screen.
  42669. */
  42670. eyeToScreenDistance: number;
  42671. /**
  42672. * Define the distance between both lenses
  42673. */
  42674. lensSeparationDistance: number;
  42675. /**
  42676. * Define the distance between both viewer's eyes.
  42677. */
  42678. interpupillaryDistance: number;
  42679. /**
  42680. * Define the distortion factor of the VR postprocess.
  42681. * Please, touch with care.
  42682. */
  42683. distortionK: number[];
  42684. /**
  42685. * Define the chromatic aberration correction factors for the VR post process.
  42686. */
  42687. chromaAbCorrection: number[];
  42688. /**
  42689. * Define the scale factor of the post process.
  42690. * The smaller the better but the slower.
  42691. */
  42692. postProcessScaleFactor: number;
  42693. /**
  42694. * Define an offset for the lens center.
  42695. */
  42696. lensCenterOffset: number;
  42697. /**
  42698. * Define if the current vr camera should compensate the distortion of the lense or not.
  42699. */
  42700. compensateDistortion: boolean;
  42701. /**
  42702. * Defines if multiview should be enabled when rendering (Default: false)
  42703. */
  42704. multiviewEnabled: boolean;
  42705. /**
  42706. * Gets the rendering aspect ratio based on the provided resolutions.
  42707. */
  42708. readonly aspectRatio: number;
  42709. /**
  42710. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42711. */
  42712. readonly aspectRatioFov: number;
  42713. /**
  42714. * @hidden
  42715. */
  42716. readonly leftHMatrix: Matrix;
  42717. /**
  42718. * @hidden
  42719. */
  42720. readonly rightHMatrix: Matrix;
  42721. /**
  42722. * @hidden
  42723. */
  42724. readonly leftPreViewMatrix: Matrix;
  42725. /**
  42726. * @hidden
  42727. */
  42728. readonly rightPreViewMatrix: Matrix;
  42729. /**
  42730. * Get the default VRMetrics based on the most generic setup.
  42731. * @returns the default vr metrics
  42732. */
  42733. static GetDefault(): VRCameraMetrics;
  42734. }
  42735. }
  42736. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42737. /** @hidden */
  42738. export var vrDistortionCorrectionPixelShader: {
  42739. name: string;
  42740. shader: string;
  42741. };
  42742. }
  42743. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42744. import { Camera } from "babylonjs/Cameras/camera";
  42745. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42746. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42747. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42748. /**
  42749. * VRDistortionCorrectionPostProcess used for mobile VR
  42750. */
  42751. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42752. private _isRightEye;
  42753. private _distortionFactors;
  42754. private _postProcessScaleFactor;
  42755. private _lensCenterOffset;
  42756. private _scaleIn;
  42757. private _scaleFactor;
  42758. private _lensCenter;
  42759. /**
  42760. * Initializes the VRDistortionCorrectionPostProcess
  42761. * @param name The name of the effect.
  42762. * @param camera The camera to apply the render pass to.
  42763. * @param isRightEye If this is for the right eye distortion
  42764. * @param vrMetrics All the required metrics for the VR camera
  42765. */
  42766. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42767. }
  42768. }
  42769. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42770. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42771. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42772. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42773. import { Scene } from "babylonjs/scene";
  42774. import { Vector3 } from "babylonjs/Maths/math.vector";
  42775. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42776. import "babylonjs/Cameras/RigModes/vrRigMode";
  42777. /**
  42778. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42779. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42780. */
  42781. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42782. /**
  42783. * Creates a new VRDeviceOrientationArcRotateCamera
  42784. * @param name defines camera name
  42785. * @param alpha defines the camera rotation along the logitudinal axis
  42786. * @param beta defines the camera rotation along the latitudinal axis
  42787. * @param radius defines the camera distance from its target
  42788. * @param target defines the camera target
  42789. * @param scene defines the scene the camera belongs to
  42790. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42791. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42792. */
  42793. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42794. /**
  42795. * Gets camera class name
  42796. * @returns VRDeviceOrientationArcRotateCamera
  42797. */
  42798. getClassName(): string;
  42799. }
  42800. }
  42801. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42802. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42803. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42804. import { Scene } from "babylonjs/scene";
  42805. import { Vector3 } from "babylonjs/Maths/math.vector";
  42806. import "babylonjs/Cameras/RigModes/vrRigMode";
  42807. /**
  42808. * Camera used to simulate VR rendering (based on FreeCamera)
  42809. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42810. */
  42811. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42812. /**
  42813. * Creates a new VRDeviceOrientationFreeCamera
  42814. * @param name defines camera name
  42815. * @param position defines the start position of the camera
  42816. * @param scene defines the scene the camera belongs to
  42817. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42818. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42819. */
  42820. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42821. /**
  42822. * Gets camera class name
  42823. * @returns VRDeviceOrientationFreeCamera
  42824. */
  42825. getClassName(): string;
  42826. }
  42827. }
  42828. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42829. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42830. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42831. import { Scene } from "babylonjs/scene";
  42832. import { Vector3 } from "babylonjs/Maths/math.vector";
  42833. import "babylonjs/Gamepads/gamepadSceneComponent";
  42834. /**
  42835. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42836. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42837. */
  42838. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42839. /**
  42840. * Creates a new VRDeviceOrientationGamepadCamera
  42841. * @param name defines camera name
  42842. * @param position defines the start position of the camera
  42843. * @param scene defines the scene the camera belongs to
  42844. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42845. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42846. */
  42847. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42848. /**
  42849. * Gets camera class name
  42850. * @returns VRDeviceOrientationGamepadCamera
  42851. */
  42852. getClassName(): string;
  42853. }
  42854. }
  42855. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42856. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42858. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42859. /** @hidden */
  42860. export var imageProcessingPixelShader: {
  42861. name: string;
  42862. shader: string;
  42863. };
  42864. }
  42865. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42866. import { Nullable } from "babylonjs/types";
  42867. import { Color4 } from "babylonjs/Maths/math.color";
  42868. import { Camera } from "babylonjs/Cameras/camera";
  42869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42870. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42871. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42872. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42873. import { Engine } from "babylonjs/Engines/engine";
  42874. import "babylonjs/Shaders/imageProcessing.fragment";
  42875. import "babylonjs/Shaders/postprocess.vertex";
  42876. /**
  42877. * ImageProcessingPostProcess
  42878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42879. */
  42880. export class ImageProcessingPostProcess extends PostProcess {
  42881. /**
  42882. * Default configuration related to image processing available in the PBR Material.
  42883. */
  42884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42885. /**
  42886. * Gets the image processing configuration used either in this material.
  42887. */
  42888. /**
  42889. * Sets the Default image processing configuration used either in the this material.
  42890. *
  42891. * If sets to null, the scene one is in use.
  42892. */
  42893. imageProcessingConfiguration: ImageProcessingConfiguration;
  42894. /**
  42895. * Keep track of the image processing observer to allow dispose and replace.
  42896. */
  42897. private _imageProcessingObserver;
  42898. /**
  42899. * Attaches a new image processing configuration to the PBR Material.
  42900. * @param configuration
  42901. */
  42902. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42903. /**
  42904. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42905. */
  42906. /**
  42907. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42908. */
  42909. colorCurves: Nullable<ColorCurves>;
  42910. /**
  42911. * Gets wether the color curves effect is enabled.
  42912. */
  42913. /**
  42914. * Sets wether the color curves effect is enabled.
  42915. */
  42916. colorCurvesEnabled: boolean;
  42917. /**
  42918. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42919. */
  42920. /**
  42921. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42922. */
  42923. colorGradingTexture: Nullable<BaseTexture>;
  42924. /**
  42925. * Gets wether the color grading effect is enabled.
  42926. */
  42927. /**
  42928. * Gets wether the color grading effect is enabled.
  42929. */
  42930. colorGradingEnabled: boolean;
  42931. /**
  42932. * Gets exposure used in the effect.
  42933. */
  42934. /**
  42935. * Sets exposure used in the effect.
  42936. */
  42937. exposure: number;
  42938. /**
  42939. * Gets wether tonemapping is enabled or not.
  42940. */
  42941. /**
  42942. * Sets wether tonemapping is enabled or not
  42943. */
  42944. toneMappingEnabled: boolean;
  42945. /**
  42946. * Gets the type of tone mapping effect.
  42947. */
  42948. /**
  42949. * Sets the type of tone mapping effect.
  42950. */
  42951. toneMappingType: number;
  42952. /**
  42953. * Gets contrast used in the effect.
  42954. */
  42955. /**
  42956. * Sets contrast used in the effect.
  42957. */
  42958. contrast: number;
  42959. /**
  42960. * Gets Vignette stretch size.
  42961. */
  42962. /**
  42963. * Sets Vignette stretch size.
  42964. */
  42965. vignetteStretch: number;
  42966. /**
  42967. * Gets Vignette centre X Offset.
  42968. */
  42969. /**
  42970. * Sets Vignette centre X Offset.
  42971. */
  42972. vignetteCentreX: number;
  42973. /**
  42974. * Gets Vignette centre Y Offset.
  42975. */
  42976. /**
  42977. * Sets Vignette centre Y Offset.
  42978. */
  42979. vignetteCentreY: number;
  42980. /**
  42981. * Gets Vignette weight or intensity of the vignette effect.
  42982. */
  42983. /**
  42984. * Sets Vignette weight or intensity of the vignette effect.
  42985. */
  42986. vignetteWeight: number;
  42987. /**
  42988. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42989. * if vignetteEnabled is set to true.
  42990. */
  42991. /**
  42992. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42993. * if vignetteEnabled is set to true.
  42994. */
  42995. vignetteColor: Color4;
  42996. /**
  42997. * Gets Camera field of view used by the Vignette effect.
  42998. */
  42999. /**
  43000. * Sets Camera field of view used by the Vignette effect.
  43001. */
  43002. vignetteCameraFov: number;
  43003. /**
  43004. * Gets the vignette blend mode allowing different kind of effect.
  43005. */
  43006. /**
  43007. * Sets the vignette blend mode allowing different kind of effect.
  43008. */
  43009. vignetteBlendMode: number;
  43010. /**
  43011. * Gets wether the vignette effect is enabled.
  43012. */
  43013. /**
  43014. * Sets wether the vignette effect is enabled.
  43015. */
  43016. vignetteEnabled: boolean;
  43017. private _fromLinearSpace;
  43018. /**
  43019. * Gets wether the input of the processing is in Gamma or Linear Space.
  43020. */
  43021. /**
  43022. * Sets wether the input of the processing is in Gamma or Linear Space.
  43023. */
  43024. fromLinearSpace: boolean;
  43025. /**
  43026. * Defines cache preventing GC.
  43027. */
  43028. private _defines;
  43029. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43030. /**
  43031. * "ImageProcessingPostProcess"
  43032. * @returns "ImageProcessingPostProcess"
  43033. */
  43034. getClassName(): string;
  43035. protected _updateParameters(): void;
  43036. dispose(camera?: Camera): void;
  43037. }
  43038. }
  43039. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43040. import { Scene } from "babylonjs/scene";
  43041. import { Color3 } from "babylonjs/Maths/math.color";
  43042. import { Mesh } from "babylonjs/Meshes/mesh";
  43043. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43044. import { Nullable } from "babylonjs/types";
  43045. /**
  43046. * Class containing static functions to help procedurally build meshes
  43047. */
  43048. export class GroundBuilder {
  43049. /**
  43050. * Creates a ground mesh
  43051. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43052. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43054. * @param name defines the name of the mesh
  43055. * @param options defines the options used to create the mesh
  43056. * @param scene defines the hosting scene
  43057. * @returns the ground mesh
  43058. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43059. */
  43060. static CreateGround(name: string, options: {
  43061. width?: number;
  43062. height?: number;
  43063. subdivisions?: number;
  43064. subdivisionsX?: number;
  43065. subdivisionsY?: number;
  43066. updatable?: boolean;
  43067. }, scene: any): Mesh;
  43068. /**
  43069. * Creates a tiled ground mesh
  43070. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43071. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43072. * * 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
  43073. * * 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
  43074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43075. * @param name defines the name of the mesh
  43076. * @param options defines the options used to create the mesh
  43077. * @param scene defines the hosting scene
  43078. * @returns the tiled ground mesh
  43079. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43080. */
  43081. static CreateTiledGround(name: string, options: {
  43082. xmin: number;
  43083. zmin: number;
  43084. xmax: number;
  43085. zmax: number;
  43086. subdivisions?: {
  43087. w: number;
  43088. h: number;
  43089. };
  43090. precision?: {
  43091. w: number;
  43092. h: number;
  43093. };
  43094. updatable?: boolean;
  43095. }, scene?: Nullable<Scene>): Mesh;
  43096. /**
  43097. * Creates a ground mesh from a height map
  43098. * * The parameter `url` sets the URL of the height map image resource.
  43099. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43100. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43101. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43102. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43103. * * 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.
  43104. * * 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).
  43105. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43107. * @param name defines the name of the mesh
  43108. * @param url defines the url to the height map
  43109. * @param options defines the options used to create the mesh
  43110. * @param scene defines the hosting scene
  43111. * @returns the ground mesh
  43112. * @see https://doc.babylonjs.com/babylon101/height_map
  43113. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43114. */
  43115. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43116. width?: number;
  43117. height?: number;
  43118. subdivisions?: number;
  43119. minHeight?: number;
  43120. maxHeight?: number;
  43121. colorFilter?: Color3;
  43122. alphaFilter?: number;
  43123. updatable?: boolean;
  43124. onReady?: (mesh: GroundMesh) => void;
  43125. }, scene?: Nullable<Scene>): GroundMesh;
  43126. }
  43127. }
  43128. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43129. import { Vector4 } from "babylonjs/Maths/math.vector";
  43130. import { Mesh } from "babylonjs/Meshes/mesh";
  43131. /**
  43132. * Class containing static functions to help procedurally build meshes
  43133. */
  43134. export class TorusBuilder {
  43135. /**
  43136. * Creates a torus mesh
  43137. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43138. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43139. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43143. * @param name defines the name of the mesh
  43144. * @param options defines the options used to create the mesh
  43145. * @param scene defines the hosting scene
  43146. * @returns the torus mesh
  43147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43148. */
  43149. static CreateTorus(name: string, options: {
  43150. diameter?: number;
  43151. thickness?: number;
  43152. tessellation?: number;
  43153. updatable?: boolean;
  43154. sideOrientation?: number;
  43155. frontUVs?: Vector4;
  43156. backUVs?: Vector4;
  43157. }, scene: any): Mesh;
  43158. }
  43159. }
  43160. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43161. import { Vector4 } from "babylonjs/Maths/math.vector";
  43162. import { Color4 } from "babylonjs/Maths/math.color";
  43163. import { Mesh } from "babylonjs/Meshes/mesh";
  43164. /**
  43165. * Class containing static functions to help procedurally build meshes
  43166. */
  43167. export class CylinderBuilder {
  43168. /**
  43169. * Creates a cylinder or a cone mesh
  43170. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43171. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43172. * * 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.
  43173. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43174. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43175. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43176. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43177. * * 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).
  43178. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43179. * * 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).
  43180. * * 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
  43181. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43182. * * 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
  43183. * * 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.
  43184. * * If `enclose` is false, a ring surface is one element.
  43185. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43186. * * 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
  43187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43190. * @param name defines the name of the mesh
  43191. * @param options defines the options used to create the mesh
  43192. * @param scene defines the hosting scene
  43193. * @returns the cylinder mesh
  43194. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43195. */
  43196. static CreateCylinder(name: string, options: {
  43197. height?: number;
  43198. diameterTop?: number;
  43199. diameterBottom?: number;
  43200. diameter?: number;
  43201. tessellation?: number;
  43202. subdivisions?: number;
  43203. arc?: number;
  43204. faceColors?: Color4[];
  43205. faceUV?: Vector4[];
  43206. updatable?: boolean;
  43207. hasRings?: boolean;
  43208. enclose?: boolean;
  43209. cap?: number;
  43210. sideOrientation?: number;
  43211. frontUVs?: Vector4;
  43212. backUVs?: Vector4;
  43213. }, scene: any): Mesh;
  43214. }
  43215. }
  43216. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43217. import { Nullable } from "babylonjs/types";
  43218. import { IDisposable } from "babylonjs/scene";
  43219. /**
  43220. * States of the webXR experience
  43221. */
  43222. export enum WebXRState {
  43223. /**
  43224. * Transitioning to being in XR mode
  43225. */
  43226. ENTERING_XR = 0,
  43227. /**
  43228. * Transitioning to non XR mode
  43229. */
  43230. EXITING_XR = 1,
  43231. /**
  43232. * In XR mode and presenting
  43233. */
  43234. IN_XR = 2,
  43235. /**
  43236. * Not entered XR mode
  43237. */
  43238. NOT_IN_XR = 3
  43239. }
  43240. /**
  43241. * Abstraction of the XR render target
  43242. */
  43243. export interface WebXRRenderTarget extends IDisposable {
  43244. /**
  43245. * xrpresent context of the canvas which can be used to display/mirror xr content
  43246. */
  43247. canvasContext: WebGLRenderingContext;
  43248. /**
  43249. * xr layer for the canvas
  43250. */
  43251. xrLayer: Nullable<XRWebGLLayer>;
  43252. /**
  43253. * Initializes the xr layer for the session
  43254. * @param xrSession xr session
  43255. * @returns a promise that will resolve once the XR Layer has been created
  43256. */
  43257. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43258. }
  43259. }
  43260. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43261. import { Nullable } from "babylonjs/types";
  43262. import { Observable } from "babylonjs/Misc/observable";
  43263. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43264. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43265. /**
  43266. * COnfiguration object for WebXR output canvas
  43267. */
  43268. export class WebXRManagedOutputCanvasOptions {
  43269. /**
  43270. * Options for this XR Layer output
  43271. */
  43272. canvasOptions: XRWebGLLayerOptions;
  43273. /**
  43274. * CSS styling for a newly created canvas (if not provided)
  43275. */
  43276. newCanvasCssStyle?: string;
  43277. /**
  43278. * Get the default values of the configuration object
  43279. * @returns default values of this configuration object
  43280. */
  43281. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43282. }
  43283. /**
  43284. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43285. */
  43286. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43287. private configuration;
  43288. private _engine;
  43289. private _canvas;
  43290. /**
  43291. * xrpresent context of the canvas which can be used to display/mirror xr content
  43292. */
  43293. canvasContext: WebGLRenderingContext;
  43294. /**
  43295. * xr layer for the canvas
  43296. */
  43297. xrLayer: Nullable<XRWebGLLayer>;
  43298. /**
  43299. * Initializes the xr layer for the session
  43300. * @param xrSession xr session
  43301. * @returns a promise that will resolve once the XR Layer has been created
  43302. */
  43303. initializeXRLayerAsync(xrSession: any): any;
  43304. /**
  43305. * Initializes the canvas to be added/removed upon entering/exiting xr
  43306. * @param engine the Babylon engine
  43307. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43308. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43309. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43310. */
  43311. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43312. /**
  43313. * Disposes of the object
  43314. */
  43315. dispose(): void;
  43316. private _setManagedOutputCanvas;
  43317. private _addCanvas;
  43318. private _removeCanvas;
  43319. }
  43320. }
  43321. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43322. import { Observable } from "babylonjs/Misc/observable";
  43323. import { Nullable } from "babylonjs/types";
  43324. import { IDisposable, Scene } from "babylonjs/scene";
  43325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43326. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43327. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43328. /**
  43329. * Manages an XRSession to work with Babylon's engine
  43330. * @see https://doc.babylonjs.com/how_to/webxr
  43331. */
  43332. export class WebXRSessionManager implements IDisposable {
  43333. /** The scene which the session should be created for */
  43334. scene: Scene;
  43335. /**
  43336. * Fires every time a new xrFrame arrives which can be used to update the camera
  43337. */
  43338. onXRFrameObservable: Observable<XRFrame>;
  43339. /**
  43340. * Fires when the xr session is ended either by the device or manually done
  43341. */
  43342. onXRSessionEnded: Observable<any>;
  43343. /**
  43344. * Fires when the xr session is ended either by the device or manually done
  43345. */
  43346. onXRSessionInit: Observable<XRSession>;
  43347. /**
  43348. * Underlying xr session
  43349. */
  43350. session: XRSession;
  43351. /**
  43352. * Type of reference space used when creating the session
  43353. */
  43354. referenceSpace: XRReferenceSpace;
  43355. /**
  43356. * Current XR frame
  43357. */
  43358. currentFrame: Nullable<XRFrame>;
  43359. /** WebXR timestamp updated every frame */
  43360. currentTimestamp: number;
  43361. private _xrNavigator;
  43362. private baseLayer;
  43363. private _rttProvider;
  43364. private _sessionEnded;
  43365. /**
  43366. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43367. * @param scene The scene which the session should be created for
  43368. */
  43369. constructor(
  43370. /** The scene which the session should be created for */
  43371. scene: Scene);
  43372. /**
  43373. * Initializes the manager
  43374. * After initialization enterXR can be called to start an XR session
  43375. * @returns Promise which resolves after it is initialized
  43376. */
  43377. initializeAsync(): Promise<void>;
  43378. /**
  43379. * Initializes an xr session
  43380. * @param xrSessionMode mode to initialize
  43381. * @param optionalFeatures defines optional values to pass to the session builder
  43382. * @returns a promise which will resolve once the session has been initialized
  43383. */
  43384. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43385. /**
  43386. * Sets the reference space on the xr session
  43387. * @param referenceSpace space to set
  43388. * @returns a promise that will resolve once the reference space has been set
  43389. */
  43390. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43391. /**
  43392. * Updates the render state of the session
  43393. * @param state state to set
  43394. * @returns a promise that resolves once the render state has been updated
  43395. */
  43396. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43397. /**
  43398. * Starts rendering to the xr layer
  43399. * @returns a promise that will resolve once rendering has started
  43400. */
  43401. startRenderingToXRAsync(): Promise<void>;
  43402. /**
  43403. * Gets the correct render target texture to be rendered this frame for this eye
  43404. * @param eye the eye for which to get the render target
  43405. * @returns the render target for the specified eye
  43406. */
  43407. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43408. /**
  43409. * Stops the xrSession and restores the renderloop
  43410. * @returns Promise which resolves after it exits XR
  43411. */
  43412. exitXRAsync(): Promise<void>;
  43413. /**
  43414. * Checks if a session would be supported for the creation options specified
  43415. * @param sessionMode session mode to check if supported eg. immersive-vr
  43416. * @returns true if supported
  43417. */
  43418. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43419. /**
  43420. * Creates a WebXRRenderTarget object for the XR session
  43421. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43422. * @param options optional options to provide when creating a new render target
  43423. * @returns a WebXR render target to which the session can render
  43424. */
  43425. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43426. /**
  43427. * @hidden
  43428. * Converts the render layer of xrSession to a render target
  43429. * @param session session to create render target for
  43430. * @param scene scene the new render target should be created for
  43431. * @param baseLayer the webgl layer to create the render target for
  43432. */
  43433. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43434. /**
  43435. * Disposes of the session manager
  43436. */
  43437. dispose(): void;
  43438. /**
  43439. * Gets a promise returning true when fullfiled if the given session mode is supported
  43440. * @param sessionMode defines the session to test
  43441. * @returns a promise
  43442. */
  43443. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43444. }
  43445. }
  43446. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43447. import { Scene } from "babylonjs/scene";
  43448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43449. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43450. /**
  43451. * WebXR Camera which holds the views for the xrSession
  43452. * @see https://doc.babylonjs.com/how_to/webxr
  43453. */
  43454. export class WebXRCamera extends FreeCamera {
  43455. /**
  43456. * Is the camera in debug mode. Used when using an emulator
  43457. */
  43458. debugMode: boolean;
  43459. /**
  43460. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43461. * @param name the name of the camera
  43462. * @param scene the scene to add the camera to
  43463. */
  43464. constructor(name: string, scene: Scene);
  43465. private _updateNumberOfRigCameras;
  43466. /** @hidden */
  43467. _updateForDualEyeDebugging(): void;
  43468. /**
  43469. * Updates the cameras position from the current pose information of the XR session
  43470. * @param xrSessionManager the session containing pose information
  43471. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43472. */
  43473. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43474. }
  43475. }
  43476. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43477. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43478. import { IDisposable } from "babylonjs/scene";
  43479. /**
  43480. * Defining the interface required for a (webxr) feature
  43481. */
  43482. export interface IWebXRFeature extends IDisposable {
  43483. /**
  43484. * Attach the feature to the session
  43485. * Will usually be called by the features manager
  43486. *
  43487. * @returns true if successful.
  43488. */
  43489. attach(): boolean;
  43490. /**
  43491. * Detach the feature from the session
  43492. * Will usually be called by the features manager
  43493. *
  43494. * @returns true if successful.
  43495. */
  43496. detach(): boolean;
  43497. }
  43498. /**
  43499. * Defining the constructor of a feature. Used to register the modules.
  43500. */
  43501. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43502. /**
  43503. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43504. * It is mainly used in AR sessions.
  43505. *
  43506. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43507. */
  43508. export class WebXRFeaturesManager implements IDisposable {
  43509. private _xrSessionManager;
  43510. private static readonly _AvailableFeatures;
  43511. /**
  43512. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43513. * Mainly used internally.
  43514. *
  43515. * @param featureName the name of the feature to register
  43516. * @param constructorFunction the function used to construct the module
  43517. * @param version the (babylon) version of the module
  43518. * @param stable is that a stable version of this module
  43519. */
  43520. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43521. /**
  43522. * Returns a constructor of a specific feature.
  43523. *
  43524. * @param featureName the name of the feature to construct
  43525. * @param version the version of the feature to load
  43526. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43527. * @param options optional options provided to the module.
  43528. * @returns a function that, when called, will return a new instance of this feature
  43529. */
  43530. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43531. /**
  43532. * Return the latest unstable version of this feature
  43533. * @param featureName the name of the feature to search
  43534. * @returns the version number. if not found will return -1
  43535. */
  43536. static GetLatestVersionOfFeature(featureName: string): number;
  43537. /**
  43538. * Return the latest stable version of this feature
  43539. * @param featureName the name of the feature to search
  43540. * @returns the version number. if not found will return -1
  43541. */
  43542. static GetStableVersionOfFeature(featureName: string): number;
  43543. /**
  43544. * Can be used to return the list of features currently registered
  43545. *
  43546. * @returns an Array of available features
  43547. */
  43548. static GetAvailableFeatures(): string[];
  43549. /**
  43550. * Gets the versions available for a specific feature
  43551. * @param featureName the name of the feature
  43552. * @returns an array with the available versions
  43553. */
  43554. static GetAvailableVersions(featureName: string): string[];
  43555. private _features;
  43556. /**
  43557. * constructs a new features manages.
  43558. *
  43559. * @param _xrSessionManager an instance of WebXRSessionManager
  43560. */
  43561. constructor(_xrSessionManager: WebXRSessionManager);
  43562. /**
  43563. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43564. *
  43565. * @param featureName the name of the feature to load or the class of the feature
  43566. * @param version optional version to load. if not provided the latest version will be enabled
  43567. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43568. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43569. * @returns a new constructed feature or throws an error if feature not found.
  43570. */
  43571. enableFeature(featureName: string | {
  43572. Name: string;
  43573. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43574. /**
  43575. * Used to disable an already-enabled feature
  43576. * @param featureName the feature to disable
  43577. * @returns true if disable was successful
  43578. */
  43579. disableFeature(featureName: string | {
  43580. Name: string;
  43581. }): boolean;
  43582. /**
  43583. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43584. * Can be used during a session to start a feature
  43585. * @param featureName the name of feature to attach
  43586. */
  43587. attachFeature(featureName: string): void;
  43588. /**
  43589. * Can be used inside a session or when the session ends to detach a specific feature
  43590. * @param featureName the name of the feature to detach
  43591. */
  43592. detachFeature(featureName: string): void;
  43593. /**
  43594. * Get the list of enabled features
  43595. * @returns an array of enabled features
  43596. */
  43597. getEnabledFeatures(): string[];
  43598. /**
  43599. * get the implementation of an enabled feature.
  43600. * @param featureName the name of the feature to load
  43601. * @returns the feature class, if found
  43602. */
  43603. getEnabledFeature(featureName: string): IWebXRFeature;
  43604. /**
  43605. * dispose this features manager
  43606. */
  43607. dispose(): void;
  43608. }
  43609. }
  43610. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43611. import { Observable } from "babylonjs/Misc/observable";
  43612. import { IDisposable, Scene } from "babylonjs/scene";
  43613. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43615. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43616. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43617. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43618. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  43619. /**
  43620. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43621. * @see https://doc.babylonjs.com/how_to/webxr
  43622. */
  43623. export class WebXRExperienceHelper implements IDisposable {
  43624. private scene;
  43625. /**
  43626. * 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
  43627. */
  43628. container: AbstractMesh;
  43629. /**
  43630. * Camera used to render xr content
  43631. */
  43632. camera: WebXRCamera;
  43633. /**
  43634. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43635. */
  43636. state: WebXRState;
  43637. private _setState;
  43638. private static _TmpVector;
  43639. /**
  43640. * Fires when the state of the experience helper has changed
  43641. */
  43642. onStateChangedObservable: Observable<WebXRState>;
  43643. /** Session manager used to keep track of xr session */
  43644. sessionManager: WebXRSessionManager;
  43645. /** A features manager for this xr session */
  43646. featuresManager: WebXRFeaturesManager;
  43647. private _nonVRCamera;
  43648. private _originalSceneAutoClear;
  43649. private _supported;
  43650. /**
  43651. * Creates the experience helper
  43652. * @param scene the scene to attach the experience helper to
  43653. * @returns a promise for the experience helper
  43654. */
  43655. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43656. /**
  43657. * Creates a WebXRExperienceHelper
  43658. * @param scene The scene the helper should be created in
  43659. */
  43660. private constructor();
  43661. /**
  43662. * Exits XR mode and returns the scene to its original state
  43663. * @returns promise that resolves after xr mode has exited
  43664. */
  43665. exitXRAsync(): Promise<void>;
  43666. /**
  43667. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43668. * @param sessionMode options for the XR session
  43669. * @param referenceSpaceType frame of reference of the XR session
  43670. * @param renderTarget the output canvas that will be used to enter XR mode
  43671. * @returns promise that resolves after xr mode has entered
  43672. */
  43673. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43674. /**
  43675. * Updates the global position of the camera by moving the camera's container
  43676. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43677. * @param position The desired global position of the camera
  43678. */
  43679. setPositionOfCameraUsingContainer(position: Vector3): void;
  43680. /**
  43681. * Rotates the xr camera by rotating the camera's container around the camera's position
  43682. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43683. * @param rotation the desired quaternion rotation to apply to the camera
  43684. */
  43685. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43686. /**
  43687. * Disposes of the experience helper
  43688. */
  43689. dispose(): void;
  43690. }
  43691. }
  43692. declare module "babylonjs/Cameras/XR/webXRController" {
  43693. import { Nullable } from "babylonjs/types";
  43694. import { Observable } from "babylonjs/Misc/observable";
  43695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43696. import { Ray } from "babylonjs/Culling/ray";
  43697. import { Scene } from "babylonjs/scene";
  43698. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43699. /**
  43700. * Represents an XR input
  43701. */
  43702. export class WebXRController {
  43703. private scene;
  43704. /** The underlying input source for the controller */
  43705. inputSource: XRInputSource;
  43706. private parentContainer;
  43707. /**
  43708. * 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
  43709. */
  43710. grip?: AbstractMesh;
  43711. /**
  43712. * Pointer which can be used to select objects or attach a visible laser to
  43713. */
  43714. pointer: AbstractMesh;
  43715. private _gamepadMode;
  43716. /**
  43717. * If available, this is the gamepad object related to this controller.
  43718. * Using this object it is possible to get click events and trackpad changes of the
  43719. * webxr controller that is currently being used.
  43720. */
  43721. gamepadController?: WebVRController;
  43722. /**
  43723. * Event that fires when the controller is removed/disposed
  43724. */
  43725. onDisposeObservable: Observable<{}>;
  43726. private _tmpQuaternion;
  43727. private _tmpVector;
  43728. /**
  43729. * Creates the controller
  43730. * @see https://doc.babylonjs.com/how_to/webxr
  43731. * @param scene the scene which the controller should be associated to
  43732. * @param inputSource the underlying input source for the controller
  43733. * @param parentContainer parent that the controller meshes should be children of
  43734. */
  43735. constructor(scene: Scene,
  43736. /** The underlying input source for the controller */
  43737. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43738. /**
  43739. * Updates the controller pose based on the given XRFrame
  43740. * @param xrFrame xr frame to update the pose with
  43741. * @param referenceSpace reference space to use
  43742. */
  43743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43744. /**
  43745. * Gets a world space ray coming from the controller
  43746. * @param result the resulting ray
  43747. */
  43748. getWorldPointerRayToRef(result: Ray): void;
  43749. /**
  43750. * Get the scene associated with this controller
  43751. * @returns the scene object
  43752. */
  43753. getScene(): Scene;
  43754. /**
  43755. * Disposes of the object
  43756. */
  43757. dispose(): void;
  43758. }
  43759. }
  43760. declare module "babylonjs/Cameras/XR/webXRInput" {
  43761. import { Observable } from "babylonjs/Misc/observable";
  43762. import { IDisposable } from "babylonjs/scene";
  43763. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43764. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43765. /**
  43766. * XR input used to track XR inputs such as controllers/rays
  43767. */
  43768. export class WebXRInput implements IDisposable {
  43769. /**
  43770. * Base experience the input listens to
  43771. */
  43772. baseExperience: WebXRExperienceHelper;
  43773. /**
  43774. * XR controllers being tracked
  43775. */
  43776. controllers: Array<WebXRController>;
  43777. private _frameObserver;
  43778. private _stateObserver;
  43779. /**
  43780. * Event when a controller has been connected/added
  43781. */
  43782. onControllerAddedObservable: Observable<WebXRController>;
  43783. /**
  43784. * Event when a controller has been removed/disconnected
  43785. */
  43786. onControllerRemovedObservable: Observable<WebXRController>;
  43787. /**
  43788. * Initializes the WebXRInput
  43789. * @param baseExperience experience helper which the input should be created for
  43790. */
  43791. constructor(
  43792. /**
  43793. * Base experience the input listens to
  43794. */
  43795. baseExperience: WebXRExperienceHelper);
  43796. private _onInputSourcesChange;
  43797. private _addAndRemoveControllers;
  43798. /**
  43799. * Disposes of the object
  43800. */
  43801. dispose(): void;
  43802. }
  43803. }
  43804. declare module "babylonjs/Loading/sceneLoader" {
  43805. import { Observable } from "babylonjs/Misc/observable";
  43806. import { Nullable } from "babylonjs/types";
  43807. import { Scene } from "babylonjs/scene";
  43808. import { Engine } from "babylonjs/Engines/engine";
  43809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43810. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43811. import { AssetContainer } from "babylonjs/assetContainer";
  43812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43813. import { Skeleton } from "babylonjs/Bones/skeleton";
  43814. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43815. import { WebRequest } from "babylonjs/Misc/webRequest";
  43816. /**
  43817. * Class used to represent data loading progression
  43818. */
  43819. export class SceneLoaderProgressEvent {
  43820. /** defines if data length to load can be evaluated */
  43821. readonly lengthComputable: boolean;
  43822. /** defines the loaded data length */
  43823. readonly loaded: number;
  43824. /** defines the data length to load */
  43825. readonly total: number;
  43826. /**
  43827. * Create a new progress event
  43828. * @param lengthComputable defines if data length to load can be evaluated
  43829. * @param loaded defines the loaded data length
  43830. * @param total defines the data length to load
  43831. */
  43832. constructor(
  43833. /** defines if data length to load can be evaluated */
  43834. lengthComputable: boolean,
  43835. /** defines the loaded data length */
  43836. loaded: number,
  43837. /** defines the data length to load */
  43838. total: number);
  43839. /**
  43840. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43841. * @param event defines the source event
  43842. * @returns a new SceneLoaderProgressEvent
  43843. */
  43844. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43845. }
  43846. /**
  43847. * Interface used by SceneLoader plugins to define supported file extensions
  43848. */
  43849. export interface ISceneLoaderPluginExtensions {
  43850. /**
  43851. * Defines the list of supported extensions
  43852. */
  43853. [extension: string]: {
  43854. isBinary: boolean;
  43855. };
  43856. }
  43857. /**
  43858. * Interface used by SceneLoader plugin factory
  43859. */
  43860. export interface ISceneLoaderPluginFactory {
  43861. /**
  43862. * Defines the name of the factory
  43863. */
  43864. name: string;
  43865. /**
  43866. * Function called to create a new plugin
  43867. * @return the new plugin
  43868. */
  43869. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43870. /**
  43871. * The callback that returns true if the data can be directly loaded.
  43872. * @param data string containing the file data
  43873. * @returns if the data can be loaded directly
  43874. */
  43875. canDirectLoad?(data: string): boolean;
  43876. }
  43877. /**
  43878. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43879. */
  43880. export interface ISceneLoaderPluginBase {
  43881. /**
  43882. * The friendly name of this plugin.
  43883. */
  43884. name: string;
  43885. /**
  43886. * The file extensions supported by this plugin.
  43887. */
  43888. extensions: string | ISceneLoaderPluginExtensions;
  43889. /**
  43890. * The callback called when loading from a url.
  43891. * @param scene scene loading this url
  43892. * @param url url to load
  43893. * @param onSuccess callback called when the file successfully loads
  43894. * @param onProgress callback called while file is loading (if the server supports this mode)
  43895. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43896. * @param onError callback called when the file fails to load
  43897. * @returns a file request object
  43898. */
  43899. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43900. /**
  43901. * The callback called when loading from a file object.
  43902. * @param scene scene loading this file
  43903. * @param file defines the file to load
  43904. * @param onSuccess defines the callback to call when data is loaded
  43905. * @param onProgress defines the callback to call during loading process
  43906. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43907. * @param onError defines the callback to call when an error occurs
  43908. * @returns a file request object
  43909. */
  43910. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43911. /**
  43912. * The callback that returns true if the data can be directly loaded.
  43913. * @param data string containing the file data
  43914. * @returns if the data can be loaded directly
  43915. */
  43916. canDirectLoad?(data: string): boolean;
  43917. /**
  43918. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43919. * @param scene scene loading this data
  43920. * @param data string containing the data
  43921. * @returns data to pass to the plugin
  43922. */
  43923. directLoad?(scene: Scene, data: string): any;
  43924. /**
  43925. * The callback that allows custom handling of the root url based on the response url.
  43926. * @param rootUrl the original root url
  43927. * @param responseURL the response url if available
  43928. * @returns the new root url
  43929. */
  43930. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43931. }
  43932. /**
  43933. * Interface used to define a SceneLoader plugin
  43934. */
  43935. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43936. /**
  43937. * Import meshes into a scene.
  43938. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43939. * @param scene The scene to import into
  43940. * @param data The data to import
  43941. * @param rootUrl The root url for scene and resources
  43942. * @param meshes The meshes array to import into
  43943. * @param particleSystems The particle systems array to import into
  43944. * @param skeletons The skeletons array to import into
  43945. * @param onError The callback when import fails
  43946. * @returns True if successful or false otherwise
  43947. */
  43948. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43949. /**
  43950. * Load into a scene.
  43951. * @param scene The scene to load into
  43952. * @param data The data to import
  43953. * @param rootUrl The root url for scene and resources
  43954. * @param onError The callback when import fails
  43955. * @returns True if successful or false otherwise
  43956. */
  43957. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43958. /**
  43959. * Load into an asset container.
  43960. * @param scene The scene to load into
  43961. * @param data The data to import
  43962. * @param rootUrl The root url for scene and resources
  43963. * @param onError The callback when import fails
  43964. * @returns The loaded asset container
  43965. */
  43966. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43967. }
  43968. /**
  43969. * Interface used to define an async SceneLoader plugin
  43970. */
  43971. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43972. /**
  43973. * Import meshes into a scene.
  43974. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43975. * @param scene The scene to import into
  43976. * @param data The data to import
  43977. * @param rootUrl The root url for scene and resources
  43978. * @param onProgress The callback when the load progresses
  43979. * @param fileName Defines the name of the file to load
  43980. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43981. */
  43982. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43983. meshes: AbstractMesh[];
  43984. particleSystems: IParticleSystem[];
  43985. skeletons: Skeleton[];
  43986. animationGroups: AnimationGroup[];
  43987. }>;
  43988. /**
  43989. * Load into a scene.
  43990. * @param scene The scene to load into
  43991. * @param data The data to import
  43992. * @param rootUrl The root url for scene and resources
  43993. * @param onProgress The callback when the load progresses
  43994. * @param fileName Defines the name of the file to load
  43995. * @returns Nothing
  43996. */
  43997. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43998. /**
  43999. * Load into an asset container.
  44000. * @param scene The scene to load into
  44001. * @param data The data to import
  44002. * @param rootUrl The root url for scene and resources
  44003. * @param onProgress The callback when the load progresses
  44004. * @param fileName Defines the name of the file to load
  44005. * @returns The loaded asset container
  44006. */
  44007. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44008. }
  44009. /**
  44010. * Mode that determines how to handle old animation groups before loading new ones.
  44011. */
  44012. export enum SceneLoaderAnimationGroupLoadingMode {
  44013. /**
  44014. * Reset all old animations to initial state then dispose them.
  44015. */
  44016. Clean = 0,
  44017. /**
  44018. * Stop all old animations.
  44019. */
  44020. Stop = 1,
  44021. /**
  44022. * Restart old animations from first frame.
  44023. */
  44024. Sync = 2,
  44025. /**
  44026. * Old animations remains untouched.
  44027. */
  44028. NoSync = 3
  44029. }
  44030. /**
  44031. * Class used to load scene from various file formats using registered plugins
  44032. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44033. */
  44034. export class SceneLoader {
  44035. /**
  44036. * No logging while loading
  44037. */
  44038. static readonly NO_LOGGING: number;
  44039. /**
  44040. * Minimal logging while loading
  44041. */
  44042. static readonly MINIMAL_LOGGING: number;
  44043. /**
  44044. * Summary logging while loading
  44045. */
  44046. static readonly SUMMARY_LOGGING: number;
  44047. /**
  44048. * Detailled logging while loading
  44049. */
  44050. static readonly DETAILED_LOGGING: number;
  44051. /**
  44052. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44053. */
  44054. static ForceFullSceneLoadingForIncremental: boolean;
  44055. /**
  44056. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44057. */
  44058. static ShowLoadingScreen: boolean;
  44059. /**
  44060. * Defines the current logging level (while loading the scene)
  44061. * @ignorenaming
  44062. */
  44063. static loggingLevel: number;
  44064. /**
  44065. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44066. */
  44067. static CleanBoneMatrixWeights: boolean;
  44068. /**
  44069. * Event raised when a plugin is used to load a scene
  44070. */
  44071. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44072. private static _registeredPlugins;
  44073. private static _getDefaultPlugin;
  44074. private static _getPluginForExtension;
  44075. private static _getPluginForDirectLoad;
  44076. private static _getPluginForFilename;
  44077. private static _getDirectLoad;
  44078. private static _loadData;
  44079. private static _getFileInfo;
  44080. /**
  44081. * Gets a plugin that can load the given extension
  44082. * @param extension defines the extension to load
  44083. * @returns a plugin or null if none works
  44084. */
  44085. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44086. /**
  44087. * Gets a boolean indicating that the given extension can be loaded
  44088. * @param extension defines the extension to load
  44089. * @returns true if the extension is supported
  44090. */
  44091. static IsPluginForExtensionAvailable(extension: string): boolean;
  44092. /**
  44093. * Adds a new plugin to the list of registered plugins
  44094. * @param plugin defines the plugin to add
  44095. */
  44096. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44097. /**
  44098. * Import meshes into a scene
  44099. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44100. * @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)
  44101. * @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)
  44102. * @param scene the instance of BABYLON.Scene to append to
  44103. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44104. * @param onProgress a callback with a progress event for each file being loaded
  44105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44106. * @param pluginExtension the extension used to determine the plugin
  44107. * @returns The loaded plugin
  44108. */
  44109. 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>;
  44110. /**
  44111. * Import meshes into a scene
  44112. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44113. * @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)
  44114. * @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)
  44115. * @param scene the instance of BABYLON.Scene to append to
  44116. * @param onProgress a callback with a progress event for each file being loaded
  44117. * @param pluginExtension the extension used to determine the plugin
  44118. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44119. */
  44120. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44121. meshes: AbstractMesh[];
  44122. particleSystems: IParticleSystem[];
  44123. skeletons: Skeleton[];
  44124. animationGroups: AnimationGroup[];
  44125. }>;
  44126. /**
  44127. * Load a scene
  44128. * @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)
  44129. * @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)
  44130. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44131. * @param onSuccess a callback with the scene when import succeeds
  44132. * @param onProgress a callback with a progress event for each file being loaded
  44133. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44134. * @param pluginExtension the extension used to determine the plugin
  44135. * @returns The loaded plugin
  44136. */
  44137. 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>;
  44138. /**
  44139. * Load a scene
  44140. * @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)
  44141. * @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)
  44142. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44143. * @param onProgress a callback with a progress event for each file being loaded
  44144. * @param pluginExtension the extension used to determine the plugin
  44145. * @returns The loaded scene
  44146. */
  44147. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44148. /**
  44149. * Append a scene
  44150. * @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)
  44151. * @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)
  44152. * @param scene is the instance of BABYLON.Scene to append to
  44153. * @param onSuccess a callback with the scene when import succeeds
  44154. * @param onProgress a callback with a progress event for each file being loaded
  44155. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44156. * @param pluginExtension the extension used to determine the plugin
  44157. * @returns The loaded plugin
  44158. */
  44159. 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>;
  44160. /**
  44161. * Append a scene
  44162. * @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)
  44163. * @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)
  44164. * @param scene is the instance of BABYLON.Scene to append to
  44165. * @param onProgress a callback with a progress event for each file being loaded
  44166. * @param pluginExtension the extension used to determine the plugin
  44167. * @returns The given scene
  44168. */
  44169. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44170. /**
  44171. * Load a scene into an asset container
  44172. * @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)
  44173. * @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)
  44174. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44175. * @param onSuccess a callback with the scene when import succeeds
  44176. * @param onProgress a callback with a progress event for each file being loaded
  44177. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44178. * @param pluginExtension the extension used to determine the plugin
  44179. * @returns The loaded plugin
  44180. */
  44181. 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>;
  44182. /**
  44183. * Load a scene into an asset container
  44184. * @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)
  44185. * @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)
  44186. * @param scene is the instance of Scene to append to
  44187. * @param onProgress a callback with a progress event for each file being loaded
  44188. * @param pluginExtension the extension used to determine the plugin
  44189. * @returns The loaded asset container
  44190. */
  44191. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44192. /**
  44193. * Import animations from a file into a scene
  44194. * @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)
  44195. * @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)
  44196. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44197. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44198. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44199. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44200. * @param onSuccess a callback with the scene when import succeeds
  44201. * @param onProgress a callback with a progress event for each file being loaded
  44202. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44203. */
  44204. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44205. /**
  44206. * Import animations from a file into a scene
  44207. * @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)
  44208. * @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)
  44209. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44210. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44211. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44212. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44213. * @param onSuccess a callback with the scene when import succeeds
  44214. * @param onProgress a callback with a progress event for each file being loaded
  44215. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44216. * @returns the updated scene with imported animations
  44217. */
  44218. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44219. }
  44220. }
  44221. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44222. import { Scene } from "babylonjs/scene";
  44223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44224. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44225. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44226. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44227. /**
  44228. * Generic Controller
  44229. */
  44230. export class GenericController extends WebVRController {
  44231. /**
  44232. * Base Url for the controller model.
  44233. */
  44234. static readonly MODEL_BASE_URL: string;
  44235. /**
  44236. * File name for the controller model.
  44237. */
  44238. static readonly MODEL_FILENAME: string;
  44239. /**
  44240. * Creates a new GenericController from a gamepad
  44241. * @param vrGamepad the gamepad that the controller should be created from
  44242. */
  44243. constructor(vrGamepad: any);
  44244. /**
  44245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44246. * @param scene scene in which to add meshes
  44247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44248. */
  44249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44250. /**
  44251. * Called once for each button that changed state since the last frame
  44252. * @param buttonIdx Which button index changed
  44253. * @param state New state of the button
  44254. * @param changes Which properties on the state changed since last frame
  44255. */
  44256. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44257. }
  44258. }
  44259. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44260. import { Observable } from "babylonjs/Misc/observable";
  44261. import { Scene } from "babylonjs/scene";
  44262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44263. import { Ray } from "babylonjs/Culling/ray";
  44264. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44265. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44266. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44267. /**
  44268. * Defines the WindowsMotionController object that the state of the windows motion controller
  44269. */
  44270. export class WindowsMotionController extends WebVRController {
  44271. /**
  44272. * The base url used to load the left and right controller models
  44273. */
  44274. static MODEL_BASE_URL: string;
  44275. /**
  44276. * The name of the left controller model file
  44277. */
  44278. static MODEL_LEFT_FILENAME: string;
  44279. /**
  44280. * The name of the right controller model file
  44281. */
  44282. static MODEL_RIGHT_FILENAME: string;
  44283. /**
  44284. * The controller name prefix for this controller type
  44285. */
  44286. static readonly GAMEPAD_ID_PREFIX: string;
  44287. /**
  44288. * The controller id pattern for this controller type
  44289. */
  44290. private static readonly GAMEPAD_ID_PATTERN;
  44291. private _loadedMeshInfo;
  44292. protected readonly _mapping: {
  44293. buttons: string[];
  44294. buttonMeshNames: {
  44295. 'trigger': string;
  44296. 'menu': string;
  44297. 'grip': string;
  44298. 'thumbstick': string;
  44299. 'trackpad': string;
  44300. };
  44301. buttonObservableNames: {
  44302. 'trigger': string;
  44303. 'menu': string;
  44304. 'grip': string;
  44305. 'thumbstick': string;
  44306. 'trackpad': string;
  44307. };
  44308. axisMeshNames: string[];
  44309. pointingPoseMeshName: string;
  44310. };
  44311. /**
  44312. * Fired when the trackpad on this controller is clicked
  44313. */
  44314. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the trackpad on this controller is modified
  44317. */
  44318. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44319. /**
  44320. * The current x and y values of this controller's trackpad
  44321. */
  44322. trackpad: StickValues;
  44323. /**
  44324. * Creates a new WindowsMotionController from a gamepad
  44325. * @param vrGamepad the gamepad that the controller should be created from
  44326. */
  44327. constructor(vrGamepad: any);
  44328. /**
  44329. * Fired when the trigger on this controller is modified
  44330. */
  44331. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44332. /**
  44333. * Fired when the menu button on this controller is modified
  44334. */
  44335. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44336. /**
  44337. * Fired when the grip button on this controller is modified
  44338. */
  44339. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44340. /**
  44341. * Fired when the thumbstick button on this controller is modified
  44342. */
  44343. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44344. /**
  44345. * Fired when the touchpad button on this controller is modified
  44346. */
  44347. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44348. /**
  44349. * Fired when the touchpad values on this controller are modified
  44350. */
  44351. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44352. protected _updateTrackpad(): void;
  44353. /**
  44354. * Called once per frame by the engine.
  44355. */
  44356. update(): void;
  44357. /**
  44358. * Called once for each button that changed state since the last frame
  44359. * @param buttonIdx Which button index changed
  44360. * @param state New state of the button
  44361. * @param changes Which properties on the state changed since last frame
  44362. */
  44363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44364. /**
  44365. * Moves the buttons on the controller mesh based on their current state
  44366. * @param buttonName the name of the button to move
  44367. * @param buttonValue the value of the button which determines the buttons new position
  44368. */
  44369. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44370. /**
  44371. * Moves the axis on the controller mesh based on its current state
  44372. * @param axis the index of the axis
  44373. * @param axisValue the value of the axis which determines the meshes new position
  44374. * @hidden
  44375. */
  44376. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  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, forceDefault?: boolean): void;
  44383. /**
  44384. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44385. * can be transformed by button presses and axes values, based on this._mapping.
  44386. *
  44387. * @param scene scene in which the meshes exist
  44388. * @param meshes list of meshes that make up the controller model to process
  44389. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44390. */
  44391. private processModel;
  44392. private createMeshInfo;
  44393. /**
  44394. * Gets the ray of the controller in the direction the controller is pointing
  44395. * @param length the length the resulting ray should be
  44396. * @returns a ray in the direction the controller is pointing
  44397. */
  44398. getForwardRay(length?: number): Ray;
  44399. /**
  44400. * Disposes of the controller
  44401. */
  44402. dispose(): void;
  44403. }
  44404. /**
  44405. * This class represents a new windows motion controller in XR.
  44406. */
  44407. export class XRWindowsMotionController extends WindowsMotionController {
  44408. /**
  44409. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44410. */
  44411. protected readonly _mapping: {
  44412. buttons: string[];
  44413. buttonMeshNames: {
  44414. 'trigger': string;
  44415. 'menu': string;
  44416. 'grip': string;
  44417. 'thumbstick': string;
  44418. 'trackpad': string;
  44419. };
  44420. buttonObservableNames: {
  44421. 'trigger': string;
  44422. 'menu': string;
  44423. 'grip': string;
  44424. 'thumbstick': string;
  44425. 'trackpad': string;
  44426. };
  44427. axisMeshNames: string[];
  44428. pointingPoseMeshName: string;
  44429. };
  44430. /**
  44431. * Construct a new XR-Based windows motion controller
  44432. *
  44433. * @param gamepadInfo the gamepad object from the browser
  44434. */
  44435. constructor(gamepadInfo: any);
  44436. /**
  44437. * holds the thumbstick values (X,Y)
  44438. */
  44439. thumbstickValues: StickValues;
  44440. /**
  44441. * Fired when the thumbstick on this controller is clicked
  44442. */
  44443. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44444. /**
  44445. * Fired when the thumbstick on this controller is modified
  44446. */
  44447. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44448. /**
  44449. * Fired when the touchpad button on this controller is modified
  44450. */
  44451. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44452. /**
  44453. * Fired when the touchpad values on this controller are modified
  44454. */
  44455. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44456. /**
  44457. * Fired when the thumbstick button on this controller is modified
  44458. * here to prevent breaking changes
  44459. */
  44460. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44461. /**
  44462. * updating the thumbstick(!) and not the trackpad.
  44463. * This is named this way due to the difference between WebVR and XR and to avoid
  44464. * changing the parent class.
  44465. */
  44466. protected _updateTrackpad(): void;
  44467. /**
  44468. * Disposes the class with joy
  44469. */
  44470. dispose(): void;
  44471. }
  44472. }
  44473. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44474. import { Observable } from "babylonjs/Misc/observable";
  44475. import { Scene } from "babylonjs/scene";
  44476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44477. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44478. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44479. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44480. /**
  44481. * Oculus Touch Controller
  44482. */
  44483. export class OculusTouchController extends WebVRController {
  44484. /**
  44485. * Base Url for the controller model.
  44486. */
  44487. static MODEL_BASE_URL: string;
  44488. /**
  44489. * File name for the left controller model.
  44490. */
  44491. static MODEL_LEFT_FILENAME: string;
  44492. /**
  44493. * File name for the right controller model.
  44494. */
  44495. static MODEL_RIGHT_FILENAME: string;
  44496. /**
  44497. * Base Url for the Quest controller model.
  44498. */
  44499. static QUEST_MODEL_BASE_URL: string;
  44500. /**
  44501. * @hidden
  44502. * If the controllers are running on a device that needs the updated Quest controller models
  44503. */
  44504. static _IsQuest: boolean;
  44505. /**
  44506. * Fired when the secondary trigger on this controller is modified
  44507. */
  44508. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44509. /**
  44510. * Fired when the thumb rest on this controller is modified
  44511. */
  44512. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44513. /**
  44514. * Creates a new OculusTouchController from a gamepad
  44515. * @param vrGamepad the gamepad that the controller should be created from
  44516. */
  44517. constructor(vrGamepad: any);
  44518. /**
  44519. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44520. * @param scene scene in which to add meshes
  44521. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44522. */
  44523. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44524. /**
  44525. * Fired when the A button on this controller is modified
  44526. */
  44527. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44528. /**
  44529. * Fired when the B button on this controller is modified
  44530. */
  44531. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44532. /**
  44533. * Fired when the X button on this controller is modified
  44534. */
  44535. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44536. /**
  44537. * Fired when the Y button on this controller is modified
  44538. */
  44539. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44540. /**
  44541. * Called once for each button that changed state since the last frame
  44542. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44543. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44544. * 2) secondary trigger (same)
  44545. * 3) A (right) X (left), touch, pressed = value
  44546. * 4) B / Y
  44547. * 5) thumb rest
  44548. * @param buttonIdx Which button index changed
  44549. * @param state New state of the button
  44550. * @param changes Which properties on the state changed since last frame
  44551. */
  44552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44553. }
  44554. }
  44555. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44556. import { Scene } from "babylonjs/scene";
  44557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44558. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44559. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44560. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44561. import { Observable } from "babylonjs/Misc/observable";
  44562. /**
  44563. * Vive Controller
  44564. */
  44565. export class ViveController extends WebVRController {
  44566. /**
  44567. * Base Url for the controller model.
  44568. */
  44569. static MODEL_BASE_URL: string;
  44570. /**
  44571. * File name for the controller model.
  44572. */
  44573. static MODEL_FILENAME: string;
  44574. /**
  44575. * Creates a new ViveController from a gamepad
  44576. * @param vrGamepad the gamepad that the controller should be created from
  44577. */
  44578. constructor(vrGamepad: any);
  44579. /**
  44580. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44581. * @param scene scene in which to add meshes
  44582. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44583. */
  44584. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44585. /**
  44586. * Fired when the left button on this controller is modified
  44587. */
  44588. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44589. /**
  44590. * Fired when the right button on this controller is modified
  44591. */
  44592. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44593. /**
  44594. * Fired when the menu button on this controller is modified
  44595. */
  44596. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44597. /**
  44598. * Called once for each button that changed state since the last frame
  44599. * Vive mapping:
  44600. * 0: touchpad
  44601. * 1: trigger
  44602. * 2: left AND right buttons
  44603. * 3: menu button
  44604. * @param buttonIdx Which button index changed
  44605. * @param state New state of the button
  44606. * @param changes Which properties on the state changed since last frame
  44607. */
  44608. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44609. }
  44610. }
  44611. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44612. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44613. import { Observable } from "babylonjs/Misc/observable";
  44614. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44615. /**
  44616. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44617. */
  44618. export class WebXRControllerModelLoader {
  44619. /**
  44620. * an observable that triggers when a new model (the mesh itself) was initialized.
  44621. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44622. */
  44623. onControllerModelLoaded: Observable<WebXRController>;
  44624. /**
  44625. * Creates the WebXRControllerModelLoader
  44626. * @param input xr input that creates the controllers
  44627. */
  44628. constructor(input: WebXRInput);
  44629. }
  44630. }
  44631. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44632. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44633. /**
  44634. * Handles pointer input automatically for the pointer of XR controllers
  44635. */
  44636. export class WebXRControllerPointerSelection {
  44637. private static _idCounter;
  44638. private _tmpRay;
  44639. /**
  44640. * Creates a WebXRControllerPointerSelection
  44641. * @param input input manager to setup pointer selection
  44642. */
  44643. constructor(input: WebXRInput);
  44644. private _convertNormalToDirectionOfRay;
  44645. private _updatePointerDistance;
  44646. }
  44647. }
  44648. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44650. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44651. /**
  44652. * Enables teleportation
  44653. */
  44654. export class WebXRControllerTeleportation {
  44655. private _teleportationFillColor;
  44656. private _teleportationBorderColor;
  44657. private _tmpRay;
  44658. private _tmpVector;
  44659. /**
  44660. * when set to true (default) teleportation will wait for thumbstick changes.
  44661. * When set to false teleportation will be disabled.
  44662. *
  44663. * If set to false while teleporting results can be unexpected.
  44664. */
  44665. enabled: boolean;
  44666. /**
  44667. * Creates a WebXRControllerTeleportation
  44668. * @param input input manager to add teleportation to
  44669. * @param floorMeshes floormeshes which can be teleported to
  44670. */
  44671. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44672. }
  44673. }
  44674. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44675. import { Nullable } from "babylonjs/types";
  44676. import { Observable } from "babylonjs/Misc/observable";
  44677. import { IDisposable, Scene } from "babylonjs/scene";
  44678. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44679. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44680. /**
  44681. * Button which can be used to enter a different mode of XR
  44682. */
  44683. export class WebXREnterExitUIButton {
  44684. /** button element */
  44685. element: HTMLElement;
  44686. /** XR initialization options for the button */
  44687. sessionMode: XRSessionMode;
  44688. /** Reference space type */
  44689. referenceSpaceType: XRReferenceSpaceType;
  44690. /**
  44691. * Creates a WebXREnterExitUIButton
  44692. * @param element button element
  44693. * @param sessionMode XR initialization session mode
  44694. * @param referenceSpaceType the type of reference space to be used
  44695. */
  44696. constructor(
  44697. /** button element */
  44698. element: HTMLElement,
  44699. /** XR initialization options for the button */
  44700. sessionMode: XRSessionMode,
  44701. /** Reference space type */
  44702. referenceSpaceType: XRReferenceSpaceType);
  44703. /**
  44704. * Overwritable function which can be used to update the button's visuals when the state changes
  44705. * @param activeButton the current active button in the UI
  44706. */
  44707. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44708. }
  44709. /**
  44710. * Options to create the webXR UI
  44711. */
  44712. export class WebXREnterExitUIOptions {
  44713. /**
  44714. * Context to enter xr with
  44715. */
  44716. renderTarget?: Nullable<WebXRRenderTarget>;
  44717. /**
  44718. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44719. */
  44720. customButtons?: Array<WebXREnterExitUIButton>;
  44721. /**
  44722. * A session mode to use when creating the default button.
  44723. * Default is immersive-vr
  44724. */
  44725. sessionMode?: XRSessionMode;
  44726. /**
  44727. * A reference space type to use when creating the default button.
  44728. * Default is local-floor
  44729. */
  44730. referenceSpaceType?: XRReferenceSpaceType;
  44731. }
  44732. /**
  44733. * UI to allow the user to enter/exit XR mode
  44734. */
  44735. export class WebXREnterExitUI implements IDisposable {
  44736. private scene;
  44737. /** version of the options passed to this UI */
  44738. options: WebXREnterExitUIOptions;
  44739. private _overlay;
  44740. private _buttons;
  44741. private _activeButton;
  44742. /**
  44743. * Fired every time the active button is changed.
  44744. *
  44745. * When xr is entered via a button that launches xr that button will be the callback parameter
  44746. *
  44747. * When exiting xr the callback parameter will be null)
  44748. */
  44749. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44750. /**
  44751. * Creates UI to allow the user to enter/exit XR mode
  44752. * @param scene the scene to add the ui to
  44753. * @param helper the xr experience helper to enter/exit xr with
  44754. * @param options options to configure the UI
  44755. * @returns the created ui
  44756. */
  44757. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44758. /**
  44759. *
  44760. * @param scene babylon scene object to use
  44761. * @param options (read-only) version of the options passed to this UI
  44762. */
  44763. private constructor();
  44764. private _updateButtons;
  44765. /**
  44766. * Disposes of the object
  44767. */
  44768. dispose(): void;
  44769. }
  44770. }
  44771. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44772. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44773. import { Scene } from "babylonjs/scene";
  44774. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44775. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44776. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44777. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44778. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44779. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44781. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44782. /**
  44783. * Options for the default xr helper
  44784. */
  44785. export class WebXRDefaultExperienceOptions {
  44786. /**
  44787. * Floor meshes that should be used for teleporting
  44788. */
  44789. floorMeshes: Array<AbstractMesh>;
  44790. /**
  44791. * Enable or disable default UI to enter XR
  44792. */
  44793. disableDefaultUI?: boolean;
  44794. /**
  44795. * optional configuration for the output canvas
  44796. */
  44797. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44798. /**
  44799. * optional UI options. This can be used among other to change session mode and reference space type
  44800. */
  44801. uiOptions?: WebXREnterExitUIOptions;
  44802. }
  44803. /**
  44804. * Default experience which provides a similar setup to the previous webVRExperience
  44805. */
  44806. export class WebXRDefaultExperience {
  44807. /**
  44808. * Base experience
  44809. */
  44810. baseExperience: WebXRExperienceHelper;
  44811. /**
  44812. * Input experience extension
  44813. */
  44814. input: WebXRInput;
  44815. /**
  44816. * Loads the controller models
  44817. */
  44818. controllerModelLoader: WebXRControllerModelLoader;
  44819. /**
  44820. * Enables laser pointer and selection
  44821. */
  44822. pointerSelection: WebXRControllerPointerSelection;
  44823. /**
  44824. * Enables teleportation
  44825. */
  44826. teleportation: WebXRControllerTeleportation;
  44827. /**
  44828. * Enables ui for entering/exiting xr
  44829. */
  44830. enterExitUI: WebXREnterExitUI;
  44831. /**
  44832. * Default target xr should render to
  44833. */
  44834. renderTarget: WebXRRenderTarget;
  44835. /**
  44836. * Creates the default xr experience
  44837. * @param scene scene
  44838. * @param options options for basic configuration
  44839. * @returns resulting WebXRDefaultExperience
  44840. */
  44841. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44842. private constructor();
  44843. /**
  44844. * DIsposes of the experience helper
  44845. */
  44846. dispose(): void;
  44847. }
  44848. }
  44849. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44850. import { Observable } from "babylonjs/Misc/observable";
  44851. import { Nullable } from "babylonjs/types";
  44852. import { Camera } from "babylonjs/Cameras/camera";
  44853. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44854. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44855. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44856. import { Scene } from "babylonjs/scene";
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color3 } from "babylonjs/Maths/math.color";
  44859. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44861. import { Mesh } from "babylonjs/Meshes/mesh";
  44862. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44863. import { EasingFunction } from "babylonjs/Animations/easing";
  44864. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44865. import "babylonjs/Meshes/Builders/groundBuilder";
  44866. import "babylonjs/Meshes/Builders/torusBuilder";
  44867. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44868. import "babylonjs/Gamepads/gamepadSceneComponent";
  44869. import "babylonjs/Animations/animatable";
  44870. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44871. /**
  44872. * Options to modify the vr teleportation behavior.
  44873. */
  44874. export interface VRTeleportationOptions {
  44875. /**
  44876. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44877. */
  44878. floorMeshName?: string;
  44879. /**
  44880. * A list of meshes to be used as the teleportation floor. (default: empty)
  44881. */
  44882. floorMeshes?: Mesh[];
  44883. /**
  44884. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44885. */
  44886. teleportationMode?: number;
  44887. /**
  44888. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44889. */
  44890. teleportationTime?: number;
  44891. /**
  44892. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44893. */
  44894. teleportationSpeed?: number;
  44895. /**
  44896. * The easing function used in the animation or null for Linear. (default CircleEase)
  44897. */
  44898. easingFunction?: EasingFunction;
  44899. }
  44900. /**
  44901. * Options to modify the vr experience helper's behavior.
  44902. */
  44903. export interface VRExperienceHelperOptions extends WebVROptions {
  44904. /**
  44905. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44906. */
  44907. createDeviceOrientationCamera?: boolean;
  44908. /**
  44909. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44910. */
  44911. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44912. /**
  44913. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44914. */
  44915. laserToggle?: boolean;
  44916. /**
  44917. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44918. */
  44919. floorMeshes?: Mesh[];
  44920. /**
  44921. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44922. */
  44923. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44924. /**
  44925. * Defines if WebXR should be used instead of WebVR (if available)
  44926. */
  44927. useXR?: boolean;
  44928. }
  44929. /**
  44930. * Event containing information after VR has been entered
  44931. */
  44932. export class OnAfterEnteringVRObservableEvent {
  44933. /**
  44934. * If entering vr was successful
  44935. */
  44936. success: boolean;
  44937. }
  44938. /**
  44939. * Helps to quickly add VR support to an existing scene.
  44940. * See http://doc.babylonjs.com/how_to/webvr_helper
  44941. */
  44942. export class VRExperienceHelper {
  44943. /** Options to modify the vr experience helper's behavior. */
  44944. webVROptions: VRExperienceHelperOptions;
  44945. private _scene;
  44946. private _position;
  44947. private _btnVR;
  44948. private _btnVRDisplayed;
  44949. private _webVRsupported;
  44950. private _webVRready;
  44951. private _webVRrequesting;
  44952. private _webVRpresenting;
  44953. private _hasEnteredVR;
  44954. private _fullscreenVRpresenting;
  44955. private _inputElement;
  44956. private _webVRCamera;
  44957. private _vrDeviceOrientationCamera;
  44958. private _deviceOrientationCamera;
  44959. private _existingCamera;
  44960. private _onKeyDown;
  44961. private _onVrDisplayPresentChange;
  44962. private _onVRDisplayChanged;
  44963. private _onVRRequestPresentStart;
  44964. private _onVRRequestPresentComplete;
  44965. /**
  44966. * 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)
  44967. */
  44968. enableGazeEvenWhenNoPointerLock: boolean;
  44969. /**
  44970. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44971. */
  44972. exitVROnDoubleTap: boolean;
  44973. /**
  44974. * Observable raised right before entering VR.
  44975. */
  44976. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44977. /**
  44978. * Observable raised when entering VR has completed.
  44979. */
  44980. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44981. /**
  44982. * Observable raised when exiting VR.
  44983. */
  44984. onExitingVRObservable: Observable<VRExperienceHelper>;
  44985. /**
  44986. * Observable raised when controller mesh is loaded.
  44987. */
  44988. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44989. /** Return this.onEnteringVRObservable
  44990. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44991. */
  44992. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44993. /** Return this.onExitingVRObservable
  44994. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44995. */
  44996. readonly onExitingVR: Observable<VRExperienceHelper>;
  44997. /** Return this.onControllerMeshLoadedObservable
  44998. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44999. */
  45000. readonly onControllerMeshLoaded: Observable<WebVRController>;
  45001. private _rayLength;
  45002. private _useCustomVRButton;
  45003. private _teleportationRequested;
  45004. private _teleportActive;
  45005. private _floorMeshName;
  45006. private _floorMeshesCollection;
  45007. private _teleportationMode;
  45008. private _teleportationTime;
  45009. private _teleportationSpeed;
  45010. private _teleportationEasing;
  45011. private _rotationAllowed;
  45012. private _teleportBackwardsVector;
  45013. private _teleportationTarget;
  45014. private _isDefaultTeleportationTarget;
  45015. private _postProcessMove;
  45016. private _teleportationFillColor;
  45017. private _teleportationBorderColor;
  45018. private _rotationAngle;
  45019. private _haloCenter;
  45020. private _cameraGazer;
  45021. private _padSensibilityUp;
  45022. private _padSensibilityDown;
  45023. private _leftController;
  45024. private _rightController;
  45025. /**
  45026. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45027. */
  45028. onNewMeshSelected: Observable<AbstractMesh>;
  45029. /**
  45030. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45031. * This observable will provide the mesh and the controller used to select the mesh
  45032. */
  45033. onMeshSelectedWithController: Observable<{
  45034. mesh: AbstractMesh;
  45035. controller: WebVRController;
  45036. }>;
  45037. /**
  45038. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45039. */
  45040. onNewMeshPicked: Observable<PickingInfo>;
  45041. private _circleEase;
  45042. /**
  45043. * Observable raised before camera teleportation
  45044. */
  45045. onBeforeCameraTeleport: Observable<Vector3>;
  45046. /**
  45047. * Observable raised after camera teleportation
  45048. */
  45049. onAfterCameraTeleport: Observable<Vector3>;
  45050. /**
  45051. * Observable raised when current selected mesh gets unselected
  45052. */
  45053. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45054. private _raySelectionPredicate;
  45055. /**
  45056. * To be optionaly changed by user to define custom ray selection
  45057. */
  45058. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45059. /**
  45060. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45061. */
  45062. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45063. /**
  45064. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45065. */
  45066. teleportationEnabled: boolean;
  45067. private _defaultHeight;
  45068. private _teleportationInitialized;
  45069. private _interactionsEnabled;
  45070. private _interactionsRequested;
  45071. private _displayGaze;
  45072. private _displayLaserPointer;
  45073. /**
  45074. * The mesh used to display where the user is going to teleport.
  45075. */
  45076. /**
  45077. * Sets the mesh to be used to display where the user is going to teleport.
  45078. */
  45079. teleportationTarget: Mesh;
  45080. /**
  45081. * 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
  45082. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45083. * See http://doc.babylonjs.com/resources/baking_transformations
  45084. */
  45085. gazeTrackerMesh: Mesh;
  45086. /**
  45087. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45088. */
  45089. updateGazeTrackerScale: boolean;
  45090. /**
  45091. * If the gaze trackers color should be updated when selecting meshes
  45092. */
  45093. updateGazeTrackerColor: boolean;
  45094. /**
  45095. * If the controller laser color should be updated when selecting meshes
  45096. */
  45097. updateControllerLaserColor: boolean;
  45098. /**
  45099. * The gaze tracking mesh corresponding to the left controller
  45100. */
  45101. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  45102. /**
  45103. * The gaze tracking mesh corresponding to the right controller
  45104. */
  45105. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  45106. /**
  45107. * If the ray of the gaze should be displayed.
  45108. */
  45109. /**
  45110. * Sets if the ray of the gaze should be displayed.
  45111. */
  45112. displayGaze: boolean;
  45113. /**
  45114. * If the ray of the LaserPointer should be displayed.
  45115. */
  45116. /**
  45117. * Sets if the ray of the LaserPointer should be displayed.
  45118. */
  45119. displayLaserPointer: boolean;
  45120. /**
  45121. * The deviceOrientationCamera used as the camera when not in VR.
  45122. */
  45123. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  45124. /**
  45125. * Based on the current WebVR support, returns the current VR camera used.
  45126. */
  45127. readonly currentVRCamera: Nullable<Camera>;
  45128. /**
  45129. * The webVRCamera which is used when in VR.
  45130. */
  45131. readonly webVRCamera: WebVRFreeCamera;
  45132. /**
  45133. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45134. */
  45135. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  45136. /**
  45137. * The html button that is used to trigger entering into VR.
  45138. */
  45139. readonly vrButton: Nullable<HTMLButtonElement>;
  45140. private readonly _teleportationRequestInitiated;
  45141. /**
  45142. * Defines wether or not Pointer lock should be requested when switching to
  45143. * full screen.
  45144. */
  45145. requestPointerLockOnFullScreen: boolean;
  45146. /**
  45147. * If asking to force XR, this will be populated with the default xr experience
  45148. */
  45149. xr: WebXRDefaultExperience;
  45150. /**
  45151. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45152. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45153. */
  45154. xrTestDone: boolean;
  45155. /**
  45156. * Instantiates a VRExperienceHelper.
  45157. * Helps to quickly add VR support to an existing scene.
  45158. * @param scene The scene the VRExperienceHelper belongs to.
  45159. * @param webVROptions Options to modify the vr experience helper's behavior.
  45160. */
  45161. constructor(scene: Scene,
  45162. /** Options to modify the vr experience helper's behavior. */
  45163. webVROptions?: VRExperienceHelperOptions);
  45164. private completeVRInit;
  45165. private _onDefaultMeshLoaded;
  45166. private _onResize;
  45167. private _onFullscreenChange;
  45168. /**
  45169. * Gets a value indicating if we are currently in VR mode.
  45170. */
  45171. readonly isInVRMode: boolean;
  45172. private onVrDisplayPresentChange;
  45173. private onVRDisplayChanged;
  45174. private moveButtonToBottomRight;
  45175. private displayVRButton;
  45176. private updateButtonVisibility;
  45177. private _cachedAngularSensibility;
  45178. /**
  45179. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45180. * Otherwise, will use the fullscreen API.
  45181. */
  45182. enterVR(): void;
  45183. /**
  45184. * Attempt to exit VR, or fullscreen.
  45185. */
  45186. exitVR(): void;
  45187. /**
  45188. * The position of the vr experience helper.
  45189. */
  45190. /**
  45191. * Sets the position of the vr experience helper.
  45192. */
  45193. position: Vector3;
  45194. /**
  45195. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45196. */
  45197. enableInteractions(): void;
  45198. private readonly _noControllerIsActive;
  45199. private beforeRender;
  45200. private _isTeleportationFloor;
  45201. /**
  45202. * Adds a floor mesh to be used for teleportation.
  45203. * @param floorMesh the mesh to be used for teleportation.
  45204. */
  45205. addFloorMesh(floorMesh: Mesh): void;
  45206. /**
  45207. * Removes a floor mesh from being used for teleportation.
  45208. * @param floorMesh the mesh to be removed.
  45209. */
  45210. removeFloorMesh(floorMesh: Mesh): void;
  45211. /**
  45212. * Enables interactions and teleportation using the VR controllers and gaze.
  45213. * @param vrTeleportationOptions options to modify teleportation behavior.
  45214. */
  45215. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45216. private _onNewGamepadConnected;
  45217. private _tryEnableInteractionOnController;
  45218. private _onNewGamepadDisconnected;
  45219. private _enableInteractionOnController;
  45220. private _checkTeleportWithRay;
  45221. private _checkRotate;
  45222. private _checkTeleportBackwards;
  45223. private _enableTeleportationOnController;
  45224. private _createTeleportationCircles;
  45225. private _displayTeleportationTarget;
  45226. private _hideTeleportationTarget;
  45227. private _rotateCamera;
  45228. private _moveTeleportationSelectorTo;
  45229. private _workingVector;
  45230. private _workingQuaternion;
  45231. private _workingMatrix;
  45232. /**
  45233. * Time Constant Teleportation Mode
  45234. */
  45235. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45236. /**
  45237. * Speed Constant Teleportation Mode
  45238. */
  45239. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45240. /**
  45241. * Teleports the users feet to the desired location
  45242. * @param location The location where the user's feet should be placed
  45243. */
  45244. teleportCamera(location: Vector3): void;
  45245. private _convertNormalToDirectionOfRay;
  45246. private _castRayAndSelectObject;
  45247. private _notifySelectedMeshUnselected;
  45248. /**
  45249. * Sets the color of the laser ray from the vr controllers.
  45250. * @param color new color for the ray.
  45251. */
  45252. changeLaserColor(color: Color3): void;
  45253. /**
  45254. * Sets the color of the ray from the vr headsets gaze.
  45255. * @param color new color for the ray.
  45256. */
  45257. changeGazeColor(color: Color3): void;
  45258. /**
  45259. * Exits VR and disposes of the vr experience helper
  45260. */
  45261. dispose(): void;
  45262. /**
  45263. * Gets the name of the VRExperienceHelper class
  45264. * @returns "VRExperienceHelper"
  45265. */
  45266. getClassName(): string;
  45267. }
  45268. }
  45269. declare module "babylonjs/Cameras/VR/index" {
  45270. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45271. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45272. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45273. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45274. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45275. export * from "babylonjs/Cameras/VR/webVRCamera";
  45276. }
  45277. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45278. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45279. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45280. import { Observable } from "babylonjs/Misc/observable";
  45281. import { Matrix } from "babylonjs/Maths/math.vector";
  45282. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45283. /**
  45284. * Options used for hit testing
  45285. */
  45286. export interface IWebXRHitTestOptions {
  45287. /**
  45288. * Only test when user interacted with the scene. Default - hit test every frame
  45289. */
  45290. testOnPointerDownOnly?: boolean;
  45291. /**
  45292. * The node to use to transform the local results to world coordinates
  45293. */
  45294. worldParentNode?: TransformNode;
  45295. }
  45296. /**
  45297. * Interface defining the babylon result of raycasting/hit-test
  45298. */
  45299. export interface IWebXRHitResult {
  45300. /**
  45301. * The native hit test result
  45302. */
  45303. xrHitResult: XRHitResult;
  45304. /**
  45305. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45306. */
  45307. transformationMatrix: Matrix;
  45308. }
  45309. /**
  45310. * The currently-working hit-test module.
  45311. * Hit test (or raycasting) is used to interact with the real world.
  45312. * For further information read here - https://github.com/immersive-web/hit-test
  45313. */
  45314. export class WebXRHitTestLegacy implements IWebXRFeature {
  45315. private _xrSessionManager;
  45316. /**
  45317. * options to use when constructing this feature
  45318. */
  45319. readonly options: IWebXRHitTestOptions;
  45320. /**
  45321. * The module's name
  45322. */
  45323. static readonly Name: string;
  45324. /**
  45325. * The (Babylon) version of this module.
  45326. * This is an integer representing the implementation version.
  45327. * This number does not correspond to the webxr specs version
  45328. */
  45329. static readonly Version: number;
  45330. /**
  45331. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45332. * @param event the (select) event to use to select with
  45333. * @param referenceSpace the reference space to use for this hit test
  45334. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45335. */
  45336. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45337. /**
  45338. * execute a hit test with an XR Ray
  45339. *
  45340. * @param xrSession a native xrSession that will execute this hit test
  45341. * @param xrRay the ray (position and direction) to use for raycasting
  45342. * @param referenceSpace native XR reference space to use for the hit-test
  45343. * @param filter filter function that will filter the results
  45344. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45345. */
  45346. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45347. /**
  45348. * Triggered when new babylon (transformed) hit test results are available
  45349. */
  45350. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45351. /**
  45352. * Creates a new instance of the (legacy version) hit test feature
  45353. * @param _xrSessionManager an instance of WebXRSessionManager
  45354. * @param options options to use when constructing this feature
  45355. */
  45356. constructor(_xrSessionManager: WebXRSessionManager,
  45357. /**
  45358. * options to use when constructing this feature
  45359. */
  45360. options?: IWebXRHitTestOptions);
  45361. private _onSelectEnabled;
  45362. private _xrFrameObserver;
  45363. private _attached;
  45364. /**
  45365. * Populated with the last native XR Hit Results
  45366. */
  45367. lastNativeXRHitResults: XRHitResult[];
  45368. /**
  45369. * attach this feature
  45370. * Will usually be called by the features manager
  45371. *
  45372. * @returns true if successful.
  45373. */
  45374. attach(): boolean;
  45375. /**
  45376. * detach this feature.
  45377. * Will usually be called by the features manager
  45378. *
  45379. * @returns true if successful.
  45380. */
  45381. detach(): boolean;
  45382. private _onHitTestResults;
  45383. private _onSelect;
  45384. /**
  45385. * Dispose this feature and all of the resources attached
  45386. */
  45387. dispose(): void;
  45388. }
  45389. }
  45390. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45391. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45392. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45393. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45394. import { Observable } from "babylonjs/Misc/observable";
  45395. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45396. /**
  45397. * Options used in the plane detector module
  45398. */
  45399. export interface IWebXRPlaneDetectorOptions {
  45400. /**
  45401. * The node to use to transform the local results to world coordinates
  45402. */
  45403. worldParentNode?: TransformNode;
  45404. }
  45405. /**
  45406. * A babylon interface for a webxr plane.
  45407. * A Plane is actually a polygon, built from N points in space
  45408. */
  45409. export interface IWebXRPlane {
  45410. /**
  45411. * a babylon-assigned ID for this polygon
  45412. */
  45413. id: number;
  45414. /**
  45415. * the native xr-plane object
  45416. */
  45417. xrPlane: XRPlane;
  45418. /**
  45419. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45420. */
  45421. polygonDefinition: Array<Vector3>;
  45422. /**
  45423. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45424. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45425. */
  45426. transformationMatrix: Matrix;
  45427. }
  45428. /**
  45429. * The plane detector is used to detect planes in the real world when in AR
  45430. * For more information see https://github.com/immersive-web/real-world-geometry/
  45431. */
  45432. export class WebXRPlaneDetector implements IWebXRFeature {
  45433. private _xrSessionManager;
  45434. private _options;
  45435. /**
  45436. * The module's name
  45437. */
  45438. static readonly Name: string;
  45439. /**
  45440. * The (Babylon) version of this module.
  45441. * This is an integer representing the implementation version.
  45442. * This number does not correspond to the webxr specs version
  45443. */
  45444. static readonly Version: number;
  45445. /**
  45446. * Observers registered here will be executed when a new plane was added to the session
  45447. */
  45448. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45449. /**
  45450. * Observers registered here will be executed when a plane is no longer detected in the session
  45451. */
  45452. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45453. /**
  45454. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45455. * This can execute N times every frame
  45456. */
  45457. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45458. private _enabled;
  45459. private _attached;
  45460. private _detectedPlanes;
  45461. private _lastFrameDetected;
  45462. private _observerTracked;
  45463. /**
  45464. * construct a new Plane Detector
  45465. * @param _xrSessionManager an instance of xr Session manager
  45466. * @param _options configuration to use when constructing this feature
  45467. */
  45468. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45469. /**
  45470. * attach this feature
  45471. * Will usually be called by the features manager
  45472. *
  45473. * @returns true if successful.
  45474. */
  45475. attach(): boolean;
  45476. /**
  45477. * detach this feature.
  45478. * Will usually be called by the features manager
  45479. *
  45480. * @returns true if successful.
  45481. */
  45482. detach(): boolean;
  45483. /**
  45484. * Dispose this feature and all of the resources attached
  45485. */
  45486. dispose(): void;
  45487. private _updatePlaneWithXRPlane;
  45488. /**
  45489. * avoiding using Array.find for global support.
  45490. * @param xrPlane the plane to find in the array
  45491. */
  45492. private findIndexInPlaneArray;
  45493. }
  45494. }
  45495. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45496. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45497. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45498. import { Observable } from "babylonjs/Misc/observable";
  45499. import { Matrix } from "babylonjs/Maths/math.vector";
  45500. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45501. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45502. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45503. /**
  45504. * Configuration options of the anchor system
  45505. */
  45506. export interface IWebXRAnchorSystemOptions {
  45507. /**
  45508. * a node that will be used to convert local to world coordinates
  45509. */
  45510. worldParentNode?: TransformNode;
  45511. /**
  45512. * should the anchor system use plane detection.
  45513. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45514. */
  45515. usePlaneDetection?: boolean;
  45516. /**
  45517. * Should a new anchor be added every time a select event is triggered
  45518. */
  45519. addAnchorOnSelect?: boolean;
  45520. }
  45521. /**
  45522. * A babylon container for an XR Anchor
  45523. */
  45524. export interface IWebXRAnchor {
  45525. /**
  45526. * A babylon-assigned ID for this anchor
  45527. */
  45528. id: number;
  45529. /**
  45530. * The native anchor object
  45531. */
  45532. xrAnchor: XRAnchor;
  45533. /**
  45534. * Transformation matrix to apply to an object attached to this anchor
  45535. */
  45536. transformationMatrix: Matrix;
  45537. }
  45538. /**
  45539. * An implementation of the anchor system of WebXR.
  45540. * Note that the current documented implementation is not available in any browser. Future implementations
  45541. * will use the frame to create an anchor and not the session or a detected plane
  45542. * For further information see https://github.com/immersive-web/anchors/
  45543. */
  45544. export class WebXRAnchorSystem implements IWebXRFeature {
  45545. private _xrSessionManager;
  45546. private _options;
  45547. /**
  45548. * The module's name
  45549. */
  45550. static readonly Name: string;
  45551. /**
  45552. * The (Babylon) version of this module.
  45553. * This is an integer representing the implementation version.
  45554. * This number does not correspond to the webxr specs version
  45555. */
  45556. static readonly Version: number;
  45557. /**
  45558. * Observers registered here will be executed when a new anchor was added to the session
  45559. */
  45560. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45561. /**
  45562. * Observers registered here will be executed when an existing anchor updates
  45563. * This can execute N times every frame
  45564. */
  45565. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45566. /**
  45567. * Observers registered here will be executed when an anchor was removed from the session
  45568. */
  45569. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45570. private _planeDetector;
  45571. private _hitTestModule;
  45572. private _enabled;
  45573. private _attached;
  45574. private _trackedAnchors;
  45575. private _lastFrameDetected;
  45576. private _observerTracked;
  45577. /**
  45578. * constructs a new anchor system
  45579. * @param _xrSessionManager an instance of WebXRSessionManager
  45580. * @param _options configuration object for this feature
  45581. */
  45582. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45583. /**
  45584. * set the plane detector to use in order to create anchors from frames
  45585. * @param planeDetector the plane-detector module to use
  45586. * @param enable enable plane-anchors. default is true
  45587. */
  45588. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45589. /**
  45590. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45591. * @param hitTestModule the hit-test module to use.
  45592. */
  45593. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45594. /**
  45595. * attach this feature
  45596. * Will usually be called by the features manager
  45597. *
  45598. * @returns true if successful.
  45599. */
  45600. attach(): boolean;
  45601. /**
  45602. * detach this feature.
  45603. * Will usually be called by the features manager
  45604. *
  45605. * @returns true if successful.
  45606. */
  45607. detach(): boolean;
  45608. /**
  45609. * Dispose this feature and all of the resources attached
  45610. */
  45611. dispose(): void;
  45612. private _onSelect;
  45613. /**
  45614. * Add anchor at a specific XR point.
  45615. *
  45616. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45617. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45618. * @returns a promise the fulfills when the anchor was created
  45619. */
  45620. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45621. private _updateAnchorWithXRFrame;
  45622. /**
  45623. * avoiding using Array.find for global support.
  45624. * @param xrAnchor the plane to find in the array
  45625. */
  45626. private _findIndexInAnchorArray;
  45627. }
  45628. }
  45629. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  45630. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45631. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45633. import { Observable } from "babylonjs/Misc/observable";
  45634. /**
  45635. * Options interface for the background remover plugin
  45636. */
  45637. export interface IWebXRBackgroundRemoverOptions {
  45638. /**
  45639. * don't disable the environment helper
  45640. */
  45641. ignoreEnvironmentHelper?: boolean;
  45642. /**
  45643. * flags to configure the removal of the environment helper.
  45644. * If not set, the entire background will be removed. If set, flags should be set as well.
  45645. */
  45646. environmentHelperRemovalFlags?: {
  45647. /**
  45648. * Should the skybox be removed (default false)
  45649. */
  45650. skyBox?: boolean;
  45651. /**
  45652. * Should the ground be removed (default false)
  45653. */
  45654. ground?: boolean;
  45655. };
  45656. /**
  45657. * Further background meshes to disable when entering AR
  45658. */
  45659. backgroundMeshes?: AbstractMesh[];
  45660. }
  45661. /**
  45662. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45663. */
  45664. export class WebXRBackgroundRemover implements IWebXRFeature {
  45665. private _xrSessionManager;
  45666. /**
  45667. * read-only options to be used in this module
  45668. */
  45669. readonly options: IWebXRBackgroundRemoverOptions;
  45670. /**
  45671. * The module's name
  45672. */
  45673. static readonly Name: string;
  45674. /**
  45675. * The (Babylon) version of this module.
  45676. * This is an integer representing the implementation version.
  45677. * This number does not correspond to the webxr specs version
  45678. */
  45679. static readonly Version: number;
  45680. /**
  45681. * registered observers will be triggered when the background state changes
  45682. */
  45683. onBackgroundStateChangedObservable: Observable<boolean>;
  45684. /**
  45685. * constructs a new background remover module
  45686. * @param _xrSessionManager the session manager for this module
  45687. * @param options read-only options to be used in this module
  45688. */
  45689. constructor(_xrSessionManager: WebXRSessionManager,
  45690. /**
  45691. * read-only options to be used in this module
  45692. */
  45693. options?: IWebXRBackgroundRemoverOptions);
  45694. /**
  45695. * attach this feature
  45696. * Will usually be called by the features manager
  45697. *
  45698. * @returns true if successful.
  45699. */
  45700. attach(): boolean;
  45701. /**
  45702. * detach this feature.
  45703. * Will usually be called by the features manager
  45704. *
  45705. * @returns true if successful.
  45706. */
  45707. detach(): boolean;
  45708. private _setBackgroundState;
  45709. /**
  45710. * Dispose this feature and all of the resources attached
  45711. */
  45712. dispose(): void;
  45713. }
  45714. }
  45715. declare module "babylonjs/Cameras/XR/features/index" {
  45716. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45717. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  45718. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45719. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  45720. }
  45721. declare module "babylonjs/Cameras/XR/index" {
  45722. export * from "babylonjs/Cameras/XR/webXRCamera";
  45723. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  45724. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45725. export * from "babylonjs/Cameras/XR/webXRInput";
  45726. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45727. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45728. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45729. export * from "babylonjs/Cameras/XR/webXRController";
  45730. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45731. export * from "babylonjs/Cameras/XR/webXRTypes";
  45732. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  45733. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45734. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45735. export * from "babylonjs/Cameras/XR/features/index";
  45736. }
  45737. declare module "babylonjs/Cameras/RigModes/index" {
  45738. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45739. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45740. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45741. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45742. }
  45743. declare module "babylonjs/Cameras/index" {
  45744. export * from "babylonjs/Cameras/Inputs/index";
  45745. export * from "babylonjs/Cameras/cameraInputsManager";
  45746. export * from "babylonjs/Cameras/camera";
  45747. export * from "babylonjs/Cameras/targetCamera";
  45748. export * from "babylonjs/Cameras/freeCamera";
  45749. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45750. export * from "babylonjs/Cameras/touchCamera";
  45751. export * from "babylonjs/Cameras/arcRotateCamera";
  45752. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45753. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45754. export * from "babylonjs/Cameras/flyCamera";
  45755. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45756. export * from "babylonjs/Cameras/followCamera";
  45757. export * from "babylonjs/Cameras/followCameraInputsManager";
  45758. export * from "babylonjs/Cameras/gamepadCamera";
  45759. export * from "babylonjs/Cameras/Stereoscopic/index";
  45760. export * from "babylonjs/Cameras/universalCamera";
  45761. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45762. export * from "babylonjs/Cameras/VR/index";
  45763. export * from "babylonjs/Cameras/XR/index";
  45764. export * from "babylonjs/Cameras/RigModes/index";
  45765. }
  45766. declare module "babylonjs/Collisions/index" {
  45767. export * from "babylonjs/Collisions/collider";
  45768. export * from "babylonjs/Collisions/collisionCoordinator";
  45769. export * from "babylonjs/Collisions/pickingInfo";
  45770. export * from "babylonjs/Collisions/intersectionInfo";
  45771. export * from "babylonjs/Collisions/meshCollisionData";
  45772. }
  45773. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45774. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45775. import { Vector3 } from "babylonjs/Maths/math.vector";
  45776. import { Ray } from "babylonjs/Culling/ray";
  45777. import { Plane } from "babylonjs/Maths/math.plane";
  45778. /**
  45779. * Contains an array of blocks representing the octree
  45780. */
  45781. export interface IOctreeContainer<T> {
  45782. /**
  45783. * Blocks within the octree
  45784. */
  45785. blocks: Array<OctreeBlock<T>>;
  45786. }
  45787. /**
  45788. * Class used to store a cell in an octree
  45789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45790. */
  45791. export class OctreeBlock<T> {
  45792. /**
  45793. * Gets the content of the current block
  45794. */
  45795. entries: T[];
  45796. /**
  45797. * Gets the list of block children
  45798. */
  45799. blocks: Array<OctreeBlock<T>>;
  45800. private _depth;
  45801. private _maxDepth;
  45802. private _capacity;
  45803. private _minPoint;
  45804. private _maxPoint;
  45805. private _boundingVectors;
  45806. private _creationFunc;
  45807. /**
  45808. * Creates a new block
  45809. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45810. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45811. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45812. * @param depth defines the current depth of this block in the octree
  45813. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45814. * @param creationFunc defines a callback to call when an element is added to the block
  45815. */
  45816. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45817. /**
  45818. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45819. */
  45820. readonly capacity: number;
  45821. /**
  45822. * Gets the minimum vector (in world space) of the block's bounding box
  45823. */
  45824. readonly minPoint: Vector3;
  45825. /**
  45826. * Gets the maximum vector (in world space) of the block's bounding box
  45827. */
  45828. readonly maxPoint: Vector3;
  45829. /**
  45830. * Add a new element to this block
  45831. * @param entry defines the element to add
  45832. */
  45833. addEntry(entry: T): void;
  45834. /**
  45835. * Remove an element from this block
  45836. * @param entry defines the element to remove
  45837. */
  45838. removeEntry(entry: T): void;
  45839. /**
  45840. * Add an array of elements to this block
  45841. * @param entries defines the array of elements to add
  45842. */
  45843. addEntries(entries: T[]): void;
  45844. /**
  45845. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45846. * @param frustumPlanes defines the frustum planes to test
  45847. * @param selection defines the array to store current content if selection is positive
  45848. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45849. */
  45850. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45851. /**
  45852. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45853. * @param sphereCenter defines the bounding sphere center
  45854. * @param sphereRadius defines the bounding sphere radius
  45855. * @param selection defines the array to store current content if selection is positive
  45856. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45857. */
  45858. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45859. /**
  45860. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45861. * @param ray defines the ray to test with
  45862. * @param selection defines the array to store current content if selection is positive
  45863. */
  45864. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45865. /**
  45866. * Subdivide the content into child blocks (this block will then be empty)
  45867. */
  45868. createInnerBlocks(): void;
  45869. /**
  45870. * @hidden
  45871. */
  45872. 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;
  45873. }
  45874. }
  45875. declare module "babylonjs/Culling/Octrees/octree" {
  45876. import { SmartArray } from "babylonjs/Misc/smartArray";
  45877. import { Vector3 } from "babylonjs/Maths/math.vector";
  45878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45880. import { Ray } from "babylonjs/Culling/ray";
  45881. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45882. import { Plane } from "babylonjs/Maths/math.plane";
  45883. /**
  45884. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45886. */
  45887. export class Octree<T> {
  45888. /** 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.) */
  45889. maxDepth: number;
  45890. /**
  45891. * Blocks within the octree containing objects
  45892. */
  45893. blocks: Array<OctreeBlock<T>>;
  45894. /**
  45895. * Content stored in the octree
  45896. */
  45897. dynamicContent: T[];
  45898. private _maxBlockCapacity;
  45899. private _selectionContent;
  45900. private _creationFunc;
  45901. /**
  45902. * Creates a octree
  45903. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45904. * @param creationFunc function to be used to instatiate the octree
  45905. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45906. * @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.)
  45907. */
  45908. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45909. /** 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.) */
  45910. maxDepth?: number);
  45911. /**
  45912. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45913. * @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);
  45914. * @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);
  45915. * @param entries meshes to be added to the octree blocks
  45916. */
  45917. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45918. /**
  45919. * Adds a mesh to the octree
  45920. * @param entry Mesh to add to the octree
  45921. */
  45922. addMesh(entry: T): void;
  45923. /**
  45924. * Remove an element from the octree
  45925. * @param entry defines the element to remove
  45926. */
  45927. removeMesh(entry: T): void;
  45928. /**
  45929. * Selects an array of meshes within the frustum
  45930. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45931. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45932. * @returns array of meshes within the frustum
  45933. */
  45934. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45935. /**
  45936. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45937. * @param sphereCenter defines the bounding sphere center
  45938. * @param sphereRadius defines the bounding sphere radius
  45939. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45940. * @returns an array of objects that intersect the sphere
  45941. */
  45942. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45943. /**
  45944. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45945. * @param ray defines the ray to test with
  45946. * @returns array of intersected objects
  45947. */
  45948. intersectsRay(ray: Ray): SmartArray<T>;
  45949. /**
  45950. * Adds a mesh into the octree block if it intersects the block
  45951. */
  45952. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45953. /**
  45954. * Adds a submesh into the octree block if it intersects the block
  45955. */
  45956. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45957. }
  45958. }
  45959. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45960. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45961. import { Scene } from "babylonjs/scene";
  45962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45964. import { Ray } from "babylonjs/Culling/ray";
  45965. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45966. import { Collider } from "babylonjs/Collisions/collider";
  45967. module "babylonjs/scene" {
  45968. interface Scene {
  45969. /**
  45970. * @hidden
  45971. * Backing Filed
  45972. */
  45973. _selectionOctree: Octree<AbstractMesh>;
  45974. /**
  45975. * Gets the octree used to boost mesh selection (picking)
  45976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45977. */
  45978. selectionOctree: Octree<AbstractMesh>;
  45979. /**
  45980. * Creates or updates the octree used to boost selection (picking)
  45981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45982. * @param maxCapacity defines the maximum capacity per leaf
  45983. * @param maxDepth defines the maximum depth of the octree
  45984. * @returns an octree of AbstractMesh
  45985. */
  45986. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45987. }
  45988. }
  45989. module "babylonjs/Meshes/abstractMesh" {
  45990. interface AbstractMesh {
  45991. /**
  45992. * @hidden
  45993. * Backing Field
  45994. */
  45995. _submeshesOctree: Octree<SubMesh>;
  45996. /**
  45997. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45998. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45999. * @param maxCapacity defines the maximum size of each block (64 by default)
  46000. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46001. * @returns the new octree
  46002. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46004. */
  46005. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46006. }
  46007. }
  46008. /**
  46009. * Defines the octree scene component responsible to manage any octrees
  46010. * in a given scene.
  46011. */
  46012. export class OctreeSceneComponent {
  46013. /**
  46014. * The component name help to identify the component in the list of scene components.
  46015. */
  46016. readonly name: string;
  46017. /**
  46018. * The scene the component belongs to.
  46019. */
  46020. scene: Scene;
  46021. /**
  46022. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46023. */
  46024. readonly checksIsEnabled: boolean;
  46025. /**
  46026. * Creates a new instance of the component for the given scene
  46027. * @param scene Defines the scene to register the component in
  46028. */
  46029. constructor(scene: Scene);
  46030. /**
  46031. * Registers the component in a given scene
  46032. */
  46033. register(): void;
  46034. /**
  46035. * Return the list of active meshes
  46036. * @returns the list of active meshes
  46037. */
  46038. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46039. /**
  46040. * Return the list of active sub meshes
  46041. * @param mesh The mesh to get the candidates sub meshes from
  46042. * @returns the list of active sub meshes
  46043. */
  46044. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46045. private _tempRay;
  46046. /**
  46047. * Return the list of sub meshes intersecting with a given local ray
  46048. * @param mesh defines the mesh to find the submesh for
  46049. * @param localRay defines the ray in local space
  46050. * @returns the list of intersecting sub meshes
  46051. */
  46052. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46053. /**
  46054. * Return the list of sub meshes colliding with a collider
  46055. * @param mesh defines the mesh to find the submesh for
  46056. * @param collider defines the collider to evaluate the collision against
  46057. * @returns the list of colliding sub meshes
  46058. */
  46059. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46060. /**
  46061. * Rebuilds the elements related to this component in case of
  46062. * context lost for instance.
  46063. */
  46064. rebuild(): void;
  46065. /**
  46066. * Disposes the component and the associated ressources.
  46067. */
  46068. dispose(): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Culling/Octrees/index" {
  46072. export * from "babylonjs/Culling/Octrees/octree";
  46073. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46074. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46075. }
  46076. declare module "babylonjs/Culling/index" {
  46077. export * from "babylonjs/Culling/boundingBox";
  46078. export * from "babylonjs/Culling/boundingInfo";
  46079. export * from "babylonjs/Culling/boundingSphere";
  46080. export * from "babylonjs/Culling/Octrees/index";
  46081. export * from "babylonjs/Culling/ray";
  46082. }
  46083. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46084. import { IDisposable, Scene } from "babylonjs/scene";
  46085. import { Nullable } from "babylonjs/types";
  46086. import { Observable } from "babylonjs/Misc/observable";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46089. import { Camera } from "babylonjs/Cameras/camera";
  46090. /**
  46091. * Renders a layer on top of an existing scene
  46092. */
  46093. export class UtilityLayerRenderer implements IDisposable {
  46094. /** the original scene that will be rendered on top of */
  46095. originalScene: Scene;
  46096. private _pointerCaptures;
  46097. private _lastPointerEvents;
  46098. private static _DefaultUtilityLayer;
  46099. private static _DefaultKeepDepthUtilityLayer;
  46100. private _sharedGizmoLight;
  46101. private _renderCamera;
  46102. /**
  46103. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46104. * @returns the camera that is used when rendering the utility layer
  46105. */
  46106. getRenderCamera(): Nullable<Camera>;
  46107. /**
  46108. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46109. * @param cam the camera that should be used when rendering the utility layer
  46110. */
  46111. setRenderCamera(cam: Nullable<Camera>): void;
  46112. /**
  46113. * @hidden
  46114. * Light which used by gizmos to get light shading
  46115. */
  46116. _getSharedGizmoLight(): HemisphericLight;
  46117. /**
  46118. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46119. */
  46120. pickUtilitySceneFirst: boolean;
  46121. /**
  46122. * 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)
  46123. */
  46124. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  46125. /**
  46126. * 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)
  46127. */
  46128. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  46129. /**
  46130. * The scene that is rendered on top of the original scene
  46131. */
  46132. utilityLayerScene: Scene;
  46133. /**
  46134. * If the utility layer should automatically be rendered on top of existing scene
  46135. */
  46136. shouldRender: boolean;
  46137. /**
  46138. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46139. */
  46140. onlyCheckPointerDownEvents: boolean;
  46141. /**
  46142. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46143. */
  46144. processAllEvents: boolean;
  46145. /**
  46146. * Observable raised when the pointer move from the utility layer scene to the main scene
  46147. */
  46148. onPointerOutObservable: Observable<number>;
  46149. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46150. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46151. private _afterRenderObserver;
  46152. private _sceneDisposeObserver;
  46153. private _originalPointerObserver;
  46154. /**
  46155. * Instantiates a UtilityLayerRenderer
  46156. * @param originalScene the original scene that will be rendered on top of
  46157. * @param handleEvents boolean indicating if the utility layer should handle events
  46158. */
  46159. constructor(
  46160. /** the original scene that will be rendered on top of */
  46161. originalScene: Scene, handleEvents?: boolean);
  46162. private _notifyObservers;
  46163. /**
  46164. * Renders the utility layers scene on top of the original scene
  46165. */
  46166. render(): void;
  46167. /**
  46168. * Disposes of the renderer
  46169. */
  46170. dispose(): void;
  46171. private _updateCamera;
  46172. }
  46173. }
  46174. declare module "babylonjs/Gizmos/gizmo" {
  46175. import { Nullable } from "babylonjs/types";
  46176. import { IDisposable } from "babylonjs/scene";
  46177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46178. import { Mesh } from "babylonjs/Meshes/mesh";
  46179. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46180. /**
  46181. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46182. */
  46183. export class Gizmo implements IDisposable {
  46184. /** The utility layer the gizmo will be added to */
  46185. gizmoLayer: UtilityLayerRenderer;
  46186. /**
  46187. * The root mesh of the gizmo
  46188. */
  46189. _rootMesh: Mesh;
  46190. private _attachedMesh;
  46191. /**
  46192. * Ratio for the scale of the gizmo (Default: 1)
  46193. */
  46194. scaleRatio: number;
  46195. /**
  46196. * If a custom mesh has been set (Default: false)
  46197. */
  46198. protected _customMeshSet: boolean;
  46199. /**
  46200. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46201. * * When set, interactions will be enabled
  46202. */
  46203. attachedMesh: Nullable<AbstractMesh>;
  46204. /**
  46205. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46206. * @param mesh The mesh to replace the default mesh of the gizmo
  46207. */
  46208. setCustomMesh(mesh: Mesh): void;
  46209. /**
  46210. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46211. */
  46212. updateGizmoRotationToMatchAttachedMesh: boolean;
  46213. /**
  46214. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46215. */
  46216. updateGizmoPositionToMatchAttachedMesh: boolean;
  46217. /**
  46218. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46219. */
  46220. updateScale: boolean;
  46221. protected _interactionsEnabled: boolean;
  46222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46223. private _beforeRenderObserver;
  46224. private _tempVector;
  46225. /**
  46226. * Creates a gizmo
  46227. * @param gizmoLayer The utility layer the gizmo will be added to
  46228. */
  46229. constructor(
  46230. /** The utility layer the gizmo will be added to */
  46231. gizmoLayer?: UtilityLayerRenderer);
  46232. /**
  46233. * Updates the gizmo to match the attached mesh's position/rotation
  46234. */
  46235. protected _update(): void;
  46236. /**
  46237. * Disposes of the gizmo
  46238. */
  46239. dispose(): void;
  46240. }
  46241. }
  46242. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46243. import { Observable } from "babylonjs/Misc/observable";
  46244. import { Nullable } from "babylonjs/types";
  46245. import { Vector3 } from "babylonjs/Maths/math.vector";
  46246. import { Color3 } from "babylonjs/Maths/math.color";
  46247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46249. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46250. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46252. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46253. import { Scene } from "babylonjs/scene";
  46254. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46255. /**
  46256. * Single plane drag gizmo
  46257. */
  46258. export class PlaneDragGizmo extends Gizmo {
  46259. /**
  46260. * Drag behavior responsible for the gizmos dragging interactions
  46261. */
  46262. dragBehavior: PointerDragBehavior;
  46263. private _pointerObserver;
  46264. /**
  46265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46266. */
  46267. snapDistance: number;
  46268. /**
  46269. * Event that fires each time the gizmo snaps to a new location.
  46270. * * snapDistance is the the change in distance
  46271. */
  46272. onSnapObservable: Observable<{
  46273. snapDistance: number;
  46274. }>;
  46275. private _plane;
  46276. private _coloredMaterial;
  46277. private _hoverMaterial;
  46278. private _isEnabled;
  46279. private _parent;
  46280. /** @hidden */
  46281. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46282. /** @hidden */
  46283. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46284. /**
  46285. * Creates a PlaneDragGizmo
  46286. * @param gizmoLayer The utility layer the gizmo will be added to
  46287. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46288. * @param color The color of the gizmo
  46289. */
  46290. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46292. /**
  46293. * If the gizmo is enabled
  46294. */
  46295. isEnabled: boolean;
  46296. /**
  46297. * Disposes of the gizmo
  46298. */
  46299. dispose(): void;
  46300. }
  46301. }
  46302. declare module "babylonjs/Gizmos/positionGizmo" {
  46303. import { Observable } from "babylonjs/Misc/observable";
  46304. import { Nullable } from "babylonjs/types";
  46305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46306. import { Mesh } from "babylonjs/Meshes/mesh";
  46307. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46308. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46309. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46310. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46311. /**
  46312. * Gizmo that enables dragging a mesh along 3 axis
  46313. */
  46314. export class PositionGizmo extends Gizmo {
  46315. /**
  46316. * Internal gizmo used for interactions on the x axis
  46317. */
  46318. xGizmo: AxisDragGizmo;
  46319. /**
  46320. * Internal gizmo used for interactions on the y axis
  46321. */
  46322. yGizmo: AxisDragGizmo;
  46323. /**
  46324. * Internal gizmo used for interactions on the z axis
  46325. */
  46326. zGizmo: AxisDragGizmo;
  46327. /**
  46328. * Internal gizmo used for interactions on the yz plane
  46329. */
  46330. xPlaneGizmo: PlaneDragGizmo;
  46331. /**
  46332. * Internal gizmo used for interactions on the xz plane
  46333. */
  46334. yPlaneGizmo: PlaneDragGizmo;
  46335. /**
  46336. * Internal gizmo used for interactions on the xy plane
  46337. */
  46338. zPlaneGizmo: PlaneDragGizmo;
  46339. /**
  46340. * private variables
  46341. */
  46342. private _meshAttached;
  46343. private _updateGizmoRotationToMatchAttachedMesh;
  46344. private _snapDistance;
  46345. private _scaleRatio;
  46346. /** Fires an event when any of it's sub gizmos are dragged */
  46347. onDragStartObservable: Observable<unknown>;
  46348. /** Fires an event when any of it's sub gizmos are released from dragging */
  46349. onDragEndObservable: Observable<unknown>;
  46350. /**
  46351. * If set to true, planar drag is enabled
  46352. */
  46353. private _planarGizmoEnabled;
  46354. attachedMesh: Nullable<AbstractMesh>;
  46355. /**
  46356. * Creates a PositionGizmo
  46357. * @param gizmoLayer The utility layer the gizmo will be added to
  46358. */
  46359. constructor(gizmoLayer?: UtilityLayerRenderer);
  46360. /**
  46361. * If the planar drag gizmo is enabled
  46362. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46363. */
  46364. planarGizmoEnabled: boolean;
  46365. updateGizmoRotationToMatchAttachedMesh: boolean;
  46366. /**
  46367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46368. */
  46369. snapDistance: number;
  46370. /**
  46371. * Ratio for the scale of the gizmo (Default: 1)
  46372. */
  46373. scaleRatio: number;
  46374. /**
  46375. * Disposes of the gizmo
  46376. */
  46377. dispose(): void;
  46378. /**
  46379. * CustomMeshes are not supported by this gizmo
  46380. * @param mesh The mesh to replace the default mesh of the gizmo
  46381. */
  46382. setCustomMesh(mesh: Mesh): void;
  46383. }
  46384. }
  46385. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46386. import { Observable } from "babylonjs/Misc/observable";
  46387. import { Nullable } from "babylonjs/types";
  46388. import { Vector3 } from "babylonjs/Maths/math.vector";
  46389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46391. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46392. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46393. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46394. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46395. import { Scene } from "babylonjs/scene";
  46396. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46397. import { Color3 } from "babylonjs/Maths/math.color";
  46398. /**
  46399. * Single axis drag gizmo
  46400. */
  46401. export class AxisDragGizmo extends Gizmo {
  46402. /**
  46403. * Drag behavior responsible for the gizmos dragging interactions
  46404. */
  46405. dragBehavior: PointerDragBehavior;
  46406. private _pointerObserver;
  46407. /**
  46408. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46409. */
  46410. snapDistance: number;
  46411. /**
  46412. * Event that fires each time the gizmo snaps to a new location.
  46413. * * snapDistance is the the change in distance
  46414. */
  46415. onSnapObservable: Observable<{
  46416. snapDistance: number;
  46417. }>;
  46418. private _isEnabled;
  46419. private _parent;
  46420. private _arrow;
  46421. private _coloredMaterial;
  46422. private _hoverMaterial;
  46423. /** @hidden */
  46424. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46425. /** @hidden */
  46426. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46427. /**
  46428. * Creates an AxisDragGizmo
  46429. * @param gizmoLayer The utility layer the gizmo will be added to
  46430. * @param dragAxis The axis which the gizmo will be able to drag on
  46431. * @param color The color of the gizmo
  46432. */
  46433. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46434. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46435. /**
  46436. * If the gizmo is enabled
  46437. */
  46438. isEnabled: boolean;
  46439. /**
  46440. * Disposes of the gizmo
  46441. */
  46442. dispose(): void;
  46443. }
  46444. }
  46445. declare module "babylonjs/Debug/axesViewer" {
  46446. import { Vector3 } from "babylonjs/Maths/math.vector";
  46447. import { Nullable } from "babylonjs/types";
  46448. import { Scene } from "babylonjs/scene";
  46449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46450. /**
  46451. * The Axes viewer will show 3 axes in a specific point in space
  46452. */
  46453. export class AxesViewer {
  46454. private _xAxis;
  46455. private _yAxis;
  46456. private _zAxis;
  46457. private _scaleLinesFactor;
  46458. private _instanced;
  46459. /**
  46460. * Gets the hosting scene
  46461. */
  46462. scene: Scene;
  46463. /**
  46464. * Gets or sets a number used to scale line length
  46465. */
  46466. scaleLines: number;
  46467. /** Gets the node hierarchy used to render x-axis */
  46468. readonly xAxis: TransformNode;
  46469. /** Gets the node hierarchy used to render y-axis */
  46470. readonly yAxis: TransformNode;
  46471. /** Gets the node hierarchy used to render z-axis */
  46472. readonly zAxis: TransformNode;
  46473. /**
  46474. * Creates a new AxesViewer
  46475. * @param scene defines the hosting scene
  46476. * @param scaleLines defines a number used to scale line length (1 by default)
  46477. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46478. * @param xAxis defines the node hierarchy used to render the x-axis
  46479. * @param yAxis defines the node hierarchy used to render the y-axis
  46480. * @param zAxis defines the node hierarchy used to render the z-axis
  46481. */
  46482. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46483. /**
  46484. * Force the viewer to update
  46485. * @param position defines the position of the viewer
  46486. * @param xaxis defines the x axis of the viewer
  46487. * @param yaxis defines the y axis of the viewer
  46488. * @param zaxis defines the z axis of the viewer
  46489. */
  46490. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46491. /**
  46492. * Creates an instance of this axes viewer.
  46493. * @returns a new axes viewer with instanced meshes
  46494. */
  46495. createInstance(): AxesViewer;
  46496. /** Releases resources */
  46497. dispose(): void;
  46498. private static _SetRenderingGroupId;
  46499. }
  46500. }
  46501. declare module "babylonjs/Debug/boneAxesViewer" {
  46502. import { Nullable } from "babylonjs/types";
  46503. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46504. import { Vector3 } from "babylonjs/Maths/math.vector";
  46505. import { Mesh } from "babylonjs/Meshes/mesh";
  46506. import { Bone } from "babylonjs/Bones/bone";
  46507. import { Scene } from "babylonjs/scene";
  46508. /**
  46509. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46510. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46511. */
  46512. export class BoneAxesViewer extends AxesViewer {
  46513. /**
  46514. * Gets or sets the target mesh where to display the axes viewer
  46515. */
  46516. mesh: Nullable<Mesh>;
  46517. /**
  46518. * Gets or sets the target bone where to display the axes viewer
  46519. */
  46520. bone: Nullable<Bone>;
  46521. /** Gets current position */
  46522. pos: Vector3;
  46523. /** Gets direction of X axis */
  46524. xaxis: Vector3;
  46525. /** Gets direction of Y axis */
  46526. yaxis: Vector3;
  46527. /** Gets direction of Z axis */
  46528. zaxis: Vector3;
  46529. /**
  46530. * Creates a new BoneAxesViewer
  46531. * @param scene defines the hosting scene
  46532. * @param bone defines the target bone
  46533. * @param mesh defines the target mesh
  46534. * @param scaleLines defines a scaling factor for line length (1 by default)
  46535. */
  46536. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46537. /**
  46538. * Force the viewer to update
  46539. */
  46540. update(): void;
  46541. /** Releases resources */
  46542. dispose(): void;
  46543. }
  46544. }
  46545. declare module "babylonjs/Debug/debugLayer" {
  46546. import { Scene } from "babylonjs/scene";
  46547. /**
  46548. * Interface used to define scene explorer extensibility option
  46549. */
  46550. export interface IExplorerExtensibilityOption {
  46551. /**
  46552. * Define the option label
  46553. */
  46554. label: string;
  46555. /**
  46556. * Defines the action to execute on click
  46557. */
  46558. action: (entity: any) => void;
  46559. }
  46560. /**
  46561. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46562. */
  46563. export interface IExplorerExtensibilityGroup {
  46564. /**
  46565. * Defines a predicate to test if a given type mut be extended
  46566. */
  46567. predicate: (entity: any) => boolean;
  46568. /**
  46569. * Gets the list of options added to a type
  46570. */
  46571. entries: IExplorerExtensibilityOption[];
  46572. }
  46573. /**
  46574. * Interface used to define the options to use to create the Inspector
  46575. */
  46576. export interface IInspectorOptions {
  46577. /**
  46578. * Display in overlay mode (default: false)
  46579. */
  46580. overlay?: boolean;
  46581. /**
  46582. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46583. */
  46584. globalRoot?: HTMLElement;
  46585. /**
  46586. * Display the Scene explorer
  46587. */
  46588. showExplorer?: boolean;
  46589. /**
  46590. * Display the property inspector
  46591. */
  46592. showInspector?: boolean;
  46593. /**
  46594. * Display in embed mode (both panes on the right)
  46595. */
  46596. embedMode?: boolean;
  46597. /**
  46598. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46599. */
  46600. handleResize?: boolean;
  46601. /**
  46602. * Allow the panes to popup (default: true)
  46603. */
  46604. enablePopup?: boolean;
  46605. /**
  46606. * Allow the panes to be closed by users (default: true)
  46607. */
  46608. enableClose?: boolean;
  46609. /**
  46610. * Optional list of extensibility entries
  46611. */
  46612. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46613. /**
  46614. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46615. */
  46616. inspectorURL?: string;
  46617. /**
  46618. * Optional initial tab (default to DebugLayerTab.Properties)
  46619. */
  46620. initialTab?: DebugLayerTab;
  46621. }
  46622. module "babylonjs/scene" {
  46623. interface Scene {
  46624. /**
  46625. * @hidden
  46626. * Backing field
  46627. */
  46628. _debugLayer: DebugLayer;
  46629. /**
  46630. * Gets the debug layer (aka Inspector) associated with the scene
  46631. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46632. */
  46633. debugLayer: DebugLayer;
  46634. }
  46635. }
  46636. /**
  46637. * Enum of inspector action tab
  46638. */
  46639. export enum DebugLayerTab {
  46640. /**
  46641. * Properties tag (default)
  46642. */
  46643. Properties = 0,
  46644. /**
  46645. * Debug tab
  46646. */
  46647. Debug = 1,
  46648. /**
  46649. * Statistics tab
  46650. */
  46651. Statistics = 2,
  46652. /**
  46653. * Tools tab
  46654. */
  46655. Tools = 3,
  46656. /**
  46657. * Settings tab
  46658. */
  46659. Settings = 4
  46660. }
  46661. /**
  46662. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46663. * what is happening in your scene
  46664. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46665. */
  46666. export class DebugLayer {
  46667. /**
  46668. * Define the url to get the inspector script from.
  46669. * By default it uses the babylonjs CDN.
  46670. * @ignoreNaming
  46671. */
  46672. static InspectorURL: string;
  46673. private _scene;
  46674. private BJSINSPECTOR;
  46675. private _onPropertyChangedObservable?;
  46676. /**
  46677. * Observable triggered when a property is changed through the inspector.
  46678. */
  46679. readonly onPropertyChangedObservable: any;
  46680. /**
  46681. * Instantiates a new debug layer.
  46682. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46683. * what is happening in your scene
  46684. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46685. * @param scene Defines the scene to inspect
  46686. */
  46687. constructor(scene: Scene);
  46688. /** Creates the inspector window. */
  46689. private _createInspector;
  46690. /**
  46691. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46692. * @param entity defines the entity to select
  46693. * @param lineContainerTitle defines the specific block to highlight
  46694. */
  46695. select(entity: any, lineContainerTitle?: string): void;
  46696. /** Get the inspector from bundle or global */
  46697. private _getGlobalInspector;
  46698. /**
  46699. * Get if the inspector is visible or not.
  46700. * @returns true if visible otherwise, false
  46701. */
  46702. isVisible(): boolean;
  46703. /**
  46704. * Hide the inspector and close its window.
  46705. */
  46706. hide(): void;
  46707. /**
  46708. * Launch the debugLayer.
  46709. * @param config Define the configuration of the inspector
  46710. * @return a promise fulfilled when the debug layer is visible
  46711. */
  46712. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46713. }
  46714. }
  46715. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  46716. import { Nullable } from "babylonjs/types";
  46717. import { Scene } from "babylonjs/scene";
  46718. import { Vector4 } from "babylonjs/Maths/math.vector";
  46719. import { Color4 } from "babylonjs/Maths/math.color";
  46720. import { Mesh } from "babylonjs/Meshes/mesh";
  46721. /**
  46722. * Class containing static functions to help procedurally build meshes
  46723. */
  46724. export class BoxBuilder {
  46725. /**
  46726. * Creates a box mesh
  46727. * * The parameter `size` sets the size (float) of each box side (default 1)
  46728. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46729. * * 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)
  46730. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46734. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46735. * @param name defines the name of the mesh
  46736. * @param options defines the options used to create the mesh
  46737. * @param scene defines the hosting scene
  46738. * @returns the box mesh
  46739. */
  46740. static CreateBox(name: string, options: {
  46741. size?: number;
  46742. width?: number;
  46743. height?: number;
  46744. depth?: number;
  46745. faceUV?: Vector4[];
  46746. faceColors?: Color4[];
  46747. sideOrientation?: number;
  46748. frontUVs?: Vector4;
  46749. backUVs?: Vector4;
  46750. wrap?: boolean;
  46751. topBaseAt?: number;
  46752. bottomBaseAt?: number;
  46753. updatable?: boolean;
  46754. }, scene?: Nullable<Scene>): Mesh;
  46755. }
  46756. }
  46757. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46758. import { Vector4 } from "babylonjs/Maths/math.vector";
  46759. import { Mesh } from "babylonjs/Meshes/mesh";
  46760. import { Scene } from "babylonjs/scene";
  46761. import { Nullable } from "babylonjs/types";
  46762. /**
  46763. * Class containing static functions to help procedurally build meshes
  46764. */
  46765. export class SphereBuilder {
  46766. /**
  46767. * Creates a sphere mesh
  46768. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46769. * * 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`)
  46770. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46771. * * 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
  46772. * * 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)
  46773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46776. * @param name defines the name of the mesh
  46777. * @param options defines the options used to create the mesh
  46778. * @param scene defines the hosting scene
  46779. * @returns the sphere mesh
  46780. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46781. */
  46782. static CreateSphere(name: string, options: {
  46783. segments?: number;
  46784. diameter?: number;
  46785. diameterX?: number;
  46786. diameterY?: number;
  46787. diameterZ?: number;
  46788. arc?: number;
  46789. slice?: number;
  46790. sideOrientation?: number;
  46791. frontUVs?: Vector4;
  46792. backUVs?: Vector4;
  46793. updatable?: boolean;
  46794. }, scene?: Nullable<Scene>): Mesh;
  46795. }
  46796. }
  46797. declare module "babylonjs/Debug/physicsViewer" {
  46798. import { Nullable } from "babylonjs/types";
  46799. import { Scene } from "babylonjs/scene";
  46800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46801. import { Mesh } from "babylonjs/Meshes/mesh";
  46802. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46803. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46804. /**
  46805. * Used to show the physics impostor around the specific mesh
  46806. */
  46807. export class PhysicsViewer {
  46808. /** @hidden */
  46809. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46810. /** @hidden */
  46811. protected _meshes: Array<Nullable<AbstractMesh>>;
  46812. /** @hidden */
  46813. protected _scene: Nullable<Scene>;
  46814. /** @hidden */
  46815. protected _numMeshes: number;
  46816. /** @hidden */
  46817. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46818. private _renderFunction;
  46819. private _utilityLayer;
  46820. private _debugBoxMesh;
  46821. private _debugSphereMesh;
  46822. private _debugCylinderMesh;
  46823. private _debugMaterial;
  46824. private _debugMeshMeshes;
  46825. /**
  46826. * Creates a new PhysicsViewer
  46827. * @param scene defines the hosting scene
  46828. */
  46829. constructor(scene: Scene);
  46830. /** @hidden */
  46831. protected _updateDebugMeshes(): void;
  46832. /**
  46833. * Renders a specified physic impostor
  46834. * @param impostor defines the impostor to render
  46835. * @param targetMesh defines the mesh represented by the impostor
  46836. * @returns the new debug mesh used to render the impostor
  46837. */
  46838. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46839. /**
  46840. * Hides a specified physic impostor
  46841. * @param impostor defines the impostor to hide
  46842. */
  46843. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46844. private _getDebugMaterial;
  46845. private _getDebugBoxMesh;
  46846. private _getDebugSphereMesh;
  46847. private _getDebugCylinderMesh;
  46848. private _getDebugMeshMesh;
  46849. private _getDebugMesh;
  46850. /** Releases all resources */
  46851. dispose(): void;
  46852. }
  46853. }
  46854. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46855. import { Vector3 } from "babylonjs/Maths/math.vector";
  46856. import { Color4 } from "babylonjs/Maths/math.color";
  46857. import { Nullable } from "babylonjs/types";
  46858. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46859. import { Scene } from "babylonjs/scene";
  46860. /**
  46861. * Class containing static functions to help procedurally build meshes
  46862. */
  46863. export class LinesBuilder {
  46864. /**
  46865. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46866. * * 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
  46867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46868. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46869. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46870. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46871. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46872. * * 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
  46873. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46876. * @param name defines the name of the new line system
  46877. * @param options defines the options used to create the line system
  46878. * @param scene defines the hosting scene
  46879. * @returns a new line system mesh
  46880. */
  46881. static CreateLineSystem(name: string, options: {
  46882. lines: Vector3[][];
  46883. updatable?: boolean;
  46884. instance?: Nullable<LinesMesh>;
  46885. colors?: Nullable<Color4[][]>;
  46886. useVertexAlpha?: boolean;
  46887. }, scene: Nullable<Scene>): LinesMesh;
  46888. /**
  46889. * Creates a line mesh
  46890. * 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
  46891. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46892. * * The parameter `points` is an array successive Vector3
  46893. * * 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
  46894. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46895. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46896. * * When updating an instance, remember that only point positions can change, not the number of points
  46897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46899. * @param name defines the name of the new line system
  46900. * @param options defines the options used to create the line system
  46901. * @param scene defines the hosting scene
  46902. * @returns a new line mesh
  46903. */
  46904. static CreateLines(name: string, options: {
  46905. points: Vector3[];
  46906. updatable?: boolean;
  46907. instance?: Nullable<LinesMesh>;
  46908. colors?: Color4[];
  46909. useVertexAlpha?: boolean;
  46910. }, scene?: Nullable<Scene>): LinesMesh;
  46911. /**
  46912. * Creates a dashed line mesh
  46913. * * 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
  46914. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46915. * * The parameter `points` is an array successive Vector3
  46916. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46917. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46918. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46919. * * 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
  46920. * * When updating an instance, remember that only point positions can change, not the number of points
  46921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46922. * @param name defines the name of the mesh
  46923. * @param options defines the options used to create the mesh
  46924. * @param scene defines the hosting scene
  46925. * @returns the dashed line mesh
  46926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46927. */
  46928. static CreateDashedLines(name: string, options: {
  46929. points: Vector3[];
  46930. dashSize?: number;
  46931. gapSize?: number;
  46932. dashNb?: number;
  46933. updatable?: boolean;
  46934. instance?: LinesMesh;
  46935. }, scene?: Nullable<Scene>): LinesMesh;
  46936. }
  46937. }
  46938. declare module "babylonjs/Debug/rayHelper" {
  46939. import { Nullable } from "babylonjs/types";
  46940. import { Ray } from "babylonjs/Culling/ray";
  46941. import { Vector3 } from "babylonjs/Maths/math.vector";
  46942. import { Color3 } from "babylonjs/Maths/math.color";
  46943. import { Scene } from "babylonjs/scene";
  46944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46945. import "babylonjs/Meshes/Builders/linesBuilder";
  46946. /**
  46947. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46948. * in order to better appreciate the issue one might have.
  46949. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46950. */
  46951. export class RayHelper {
  46952. /**
  46953. * Defines the ray we are currently tryin to visualize.
  46954. */
  46955. ray: Nullable<Ray>;
  46956. private _renderPoints;
  46957. private _renderLine;
  46958. private _renderFunction;
  46959. private _scene;
  46960. private _updateToMeshFunction;
  46961. private _attachedToMesh;
  46962. private _meshSpaceDirection;
  46963. private _meshSpaceOrigin;
  46964. /**
  46965. * Helper function to create a colored helper in a scene in one line.
  46966. * @param ray Defines the ray we are currently tryin to visualize
  46967. * @param scene Defines the scene the ray is used in
  46968. * @param color Defines the color we want to see the ray in
  46969. * @returns The newly created ray helper.
  46970. */
  46971. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46972. /**
  46973. * Instantiate a new ray helper.
  46974. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46975. * in order to better appreciate the issue one might have.
  46976. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46977. * @param ray Defines the ray we are currently tryin to visualize
  46978. */
  46979. constructor(ray: Ray);
  46980. /**
  46981. * Shows the ray we are willing to debug.
  46982. * @param scene Defines the scene the ray needs to be rendered in
  46983. * @param color Defines the color the ray needs to be rendered in
  46984. */
  46985. show(scene: Scene, color?: Color3): void;
  46986. /**
  46987. * Hides the ray we are debugging.
  46988. */
  46989. hide(): void;
  46990. private _render;
  46991. /**
  46992. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46993. * @param mesh Defines the mesh we want the helper attached to
  46994. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46995. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46996. * @param length Defines the length of the ray
  46997. */
  46998. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46999. /**
  47000. * Detach the ray helper from the mesh it has previously been attached to.
  47001. */
  47002. detachFromMesh(): void;
  47003. private _updateToMesh;
  47004. /**
  47005. * Dispose the helper and release its associated resources.
  47006. */
  47007. dispose(): void;
  47008. }
  47009. }
  47010. declare module "babylonjs/Debug/skeletonViewer" {
  47011. import { Color3 } from "babylonjs/Maths/math.color";
  47012. import { Scene } from "babylonjs/scene";
  47013. import { Nullable } from "babylonjs/types";
  47014. import { Skeleton } from "babylonjs/Bones/skeleton";
  47015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47016. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47017. /**
  47018. * Class used to render a debug view of a given skeleton
  47019. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47020. */
  47021. export class SkeletonViewer {
  47022. /** defines the skeleton to render */
  47023. skeleton: Skeleton;
  47024. /** defines the mesh attached to the skeleton */
  47025. mesh: AbstractMesh;
  47026. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47027. autoUpdateBonesMatrices: boolean;
  47028. /** defines the rendering group id to use with the viewer */
  47029. renderingGroupId: number;
  47030. /** Gets or sets the color used to render the skeleton */
  47031. color: Color3;
  47032. private _scene;
  47033. private _debugLines;
  47034. private _debugMesh;
  47035. private _isEnabled;
  47036. private _renderFunction;
  47037. private _utilityLayer;
  47038. /**
  47039. * Returns the mesh used to render the bones
  47040. */
  47041. readonly debugMesh: Nullable<LinesMesh>;
  47042. /**
  47043. * Creates a new SkeletonViewer
  47044. * @param skeleton defines the skeleton to render
  47045. * @param mesh defines the mesh attached to the skeleton
  47046. * @param scene defines the hosting scene
  47047. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47048. * @param renderingGroupId defines the rendering group id to use with the viewer
  47049. */
  47050. constructor(
  47051. /** defines the skeleton to render */
  47052. skeleton: Skeleton,
  47053. /** defines the mesh attached to the skeleton */
  47054. mesh: AbstractMesh, scene: Scene,
  47055. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47056. autoUpdateBonesMatrices?: boolean,
  47057. /** defines the rendering group id to use with the viewer */
  47058. renderingGroupId?: number);
  47059. /** Gets or sets a boolean indicating if the viewer is enabled */
  47060. isEnabled: boolean;
  47061. private _getBonePosition;
  47062. private _getLinesForBonesWithLength;
  47063. private _getLinesForBonesNoLength;
  47064. /** Update the viewer to sync with current skeleton state */
  47065. update(): void;
  47066. /** Release associated resources */
  47067. dispose(): void;
  47068. }
  47069. }
  47070. declare module "babylonjs/Debug/index" {
  47071. export * from "babylonjs/Debug/axesViewer";
  47072. export * from "babylonjs/Debug/boneAxesViewer";
  47073. export * from "babylonjs/Debug/debugLayer";
  47074. export * from "babylonjs/Debug/physicsViewer";
  47075. export * from "babylonjs/Debug/rayHelper";
  47076. export * from "babylonjs/Debug/skeletonViewer";
  47077. }
  47078. declare module "babylonjs/Engines/nullEngine" {
  47079. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47080. import { Scene } from "babylonjs/scene";
  47081. import { Engine } from "babylonjs/Engines/engine";
  47082. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47085. import { Effect } from "babylonjs/Materials/effect";
  47086. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47087. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47088. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47089. /**
  47090. * Options to create the null engine
  47091. */
  47092. export class NullEngineOptions {
  47093. /**
  47094. * Render width (Default: 512)
  47095. */
  47096. renderWidth: number;
  47097. /**
  47098. * Render height (Default: 256)
  47099. */
  47100. renderHeight: number;
  47101. /**
  47102. * Texture size (Default: 512)
  47103. */
  47104. textureSize: number;
  47105. /**
  47106. * If delta time between frames should be constant
  47107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47108. */
  47109. deterministicLockstep: boolean;
  47110. /**
  47111. * Maximum about of steps between frames (Default: 4)
  47112. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47113. */
  47114. lockstepMaxSteps: number;
  47115. }
  47116. /**
  47117. * The null engine class provides support for headless version of babylon.js.
  47118. * This can be used in server side scenario or for testing purposes
  47119. */
  47120. export class NullEngine extends Engine {
  47121. private _options;
  47122. /**
  47123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47125. * @returns true if engine is in deterministic lock step mode
  47126. */
  47127. isDeterministicLockStep(): boolean;
  47128. /**
  47129. * Gets the max steps when engine is running in deterministic lock step
  47130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47131. * @returns the max steps
  47132. */
  47133. getLockstepMaxSteps(): number;
  47134. /**
  47135. * Gets the current hardware scaling level.
  47136. * By default the hardware scaling level is computed from the window device ratio.
  47137. * 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.
  47138. * @returns a number indicating the current hardware scaling level
  47139. */
  47140. getHardwareScalingLevel(): number;
  47141. constructor(options?: NullEngineOptions);
  47142. /**
  47143. * Creates a vertex buffer
  47144. * @param vertices the data for the vertex buffer
  47145. * @returns the new WebGL static buffer
  47146. */
  47147. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47148. /**
  47149. * Creates a new index buffer
  47150. * @param indices defines the content of the index buffer
  47151. * @param updatable defines if the index buffer must be updatable
  47152. * @returns a new webGL buffer
  47153. */
  47154. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47155. /**
  47156. * Clear the current render buffer or the current render target (if any is set up)
  47157. * @param color defines the color to use
  47158. * @param backBuffer defines if the back buffer must be cleared
  47159. * @param depth defines if the depth buffer must be cleared
  47160. * @param stencil defines if the stencil buffer must be cleared
  47161. */
  47162. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47163. /**
  47164. * Gets the current render width
  47165. * @param useScreen defines if screen size must be used (or the current render target if any)
  47166. * @returns a number defining the current render width
  47167. */
  47168. getRenderWidth(useScreen?: boolean): number;
  47169. /**
  47170. * Gets the current render height
  47171. * @param useScreen defines if screen size must be used (or the current render target if any)
  47172. * @returns a number defining the current render height
  47173. */
  47174. getRenderHeight(useScreen?: boolean): number;
  47175. /**
  47176. * Set the WebGL's viewport
  47177. * @param viewport defines the viewport element to be used
  47178. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47179. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47180. */
  47181. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47183. /**
  47184. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47185. * @param pipelineContext defines the pipeline context to use
  47186. * @param uniformsNames defines the list of uniform names
  47187. * @returns an array of webGL uniform locations
  47188. */
  47189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47190. /**
  47191. * Gets the lsit of active attributes for a given webGL program
  47192. * @param pipelineContext defines the pipeline context to use
  47193. * @param attributesNames defines the list of attribute names to get
  47194. * @returns an array of indices indicating the offset of each attribute
  47195. */
  47196. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47197. /**
  47198. * Binds an effect to the webGL context
  47199. * @param effect defines the effect to bind
  47200. */
  47201. bindSamplers(effect: Effect): void;
  47202. /**
  47203. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47204. * @param effect defines the effect to activate
  47205. */
  47206. enableEffect(effect: Effect): void;
  47207. /**
  47208. * Set various states to the webGL context
  47209. * @param culling defines backface culling state
  47210. * @param zOffset defines the value to apply to zOffset (0 by default)
  47211. * @param force defines if states must be applied even if cache is up to date
  47212. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47213. */
  47214. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47215. /**
  47216. * Set the value of an uniform to an array of int32
  47217. * @param uniform defines the webGL uniform location where to store the value
  47218. * @param array defines the array of int32 to store
  47219. */
  47220. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47221. /**
  47222. * Set the value of an uniform to an array of int32 (stored as vec2)
  47223. * @param uniform defines the webGL uniform location where to store the value
  47224. * @param array defines the array of int32 to store
  47225. */
  47226. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47227. /**
  47228. * Set the value of an uniform to an array of int32 (stored as vec3)
  47229. * @param uniform defines the webGL uniform location where to store the value
  47230. * @param array defines the array of int32 to store
  47231. */
  47232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47233. /**
  47234. * Set the value of an uniform to an array of int32 (stored as vec4)
  47235. * @param uniform defines the webGL uniform location where to store the value
  47236. * @param array defines the array of int32 to store
  47237. */
  47238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47239. /**
  47240. * Set the value of an uniform to an array of float32
  47241. * @param uniform defines the webGL uniform location where to store the value
  47242. * @param array defines the array of float32 to store
  47243. */
  47244. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47245. /**
  47246. * Set the value of an uniform to an array of float32 (stored as vec2)
  47247. * @param uniform defines the webGL uniform location where to store the value
  47248. * @param array defines the array of float32 to store
  47249. */
  47250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47251. /**
  47252. * Set the value of an uniform to an array of float32 (stored as vec3)
  47253. * @param uniform defines the webGL uniform location where to store the value
  47254. * @param array defines the array of float32 to store
  47255. */
  47256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47257. /**
  47258. * Set the value of an uniform to an array of float32 (stored as vec4)
  47259. * @param uniform defines the webGL uniform location where to store the value
  47260. * @param array defines the array of float32 to store
  47261. */
  47262. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47263. /**
  47264. * Set the value of an uniform to an array of number
  47265. * @param uniform defines the webGL uniform location where to store the value
  47266. * @param array defines the array of number to store
  47267. */
  47268. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47269. /**
  47270. * Set the value of an uniform to an array of number (stored as vec2)
  47271. * @param uniform defines the webGL uniform location where to store the value
  47272. * @param array defines the array of number to store
  47273. */
  47274. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47275. /**
  47276. * Set the value of an uniform to an array of number (stored as vec3)
  47277. * @param uniform defines the webGL uniform location where to store the value
  47278. * @param array defines the array of number to store
  47279. */
  47280. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47281. /**
  47282. * Set the value of an uniform to an array of number (stored as vec4)
  47283. * @param uniform defines the webGL uniform location where to store the value
  47284. * @param array defines the array of number to store
  47285. */
  47286. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47287. /**
  47288. * Set the value of an uniform to an array of float32 (stored as matrices)
  47289. * @param uniform defines the webGL uniform location where to store the value
  47290. * @param matrices defines the array of float32 to store
  47291. */
  47292. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47293. /**
  47294. * Set the value of an uniform to a matrix (3x3)
  47295. * @param uniform defines the webGL uniform location where to store the value
  47296. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47297. */
  47298. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47299. /**
  47300. * Set the value of an uniform to a matrix (2x2)
  47301. * @param uniform defines the webGL uniform location where to store the value
  47302. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47303. */
  47304. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47305. /**
  47306. * Set the value of an uniform to a number (float)
  47307. * @param uniform defines the webGL uniform location where to store the value
  47308. * @param value defines the float number to store
  47309. */
  47310. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47311. /**
  47312. * Set the value of an uniform to a vec2
  47313. * @param uniform defines the webGL uniform location where to store the value
  47314. * @param x defines the 1st component of the value
  47315. * @param y defines the 2nd component of the value
  47316. */
  47317. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47318. /**
  47319. * Set the value of an uniform to a vec3
  47320. * @param uniform defines the webGL uniform location where to store the value
  47321. * @param x defines the 1st component of the value
  47322. * @param y defines the 2nd component of the value
  47323. * @param z defines the 3rd component of the value
  47324. */
  47325. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47326. /**
  47327. * Set the value of an uniform to a boolean
  47328. * @param uniform defines the webGL uniform location where to store the value
  47329. * @param bool defines the boolean to store
  47330. */
  47331. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47332. /**
  47333. * Set the value of an uniform to a vec4
  47334. * @param uniform defines the webGL uniform location where to store the value
  47335. * @param x defines the 1st component of the value
  47336. * @param y defines the 2nd component of the value
  47337. * @param z defines the 3rd component of the value
  47338. * @param w defines the 4th component of the value
  47339. */
  47340. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47341. /**
  47342. * Sets the current alpha mode
  47343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47346. */
  47347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47348. /**
  47349. * Bind webGl buffers directly to the webGL context
  47350. * @param vertexBuffers defines the vertex buffer to bind
  47351. * @param indexBuffer defines the index buffer to bind
  47352. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47353. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47354. * @param effect defines the effect associated with the vertex buffer
  47355. */
  47356. bindBuffers(vertexBuffers: {
  47357. [key: string]: VertexBuffer;
  47358. }, indexBuffer: DataBuffer, effect: Effect): void;
  47359. /**
  47360. * Force the entire cache to be cleared
  47361. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47362. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47363. */
  47364. wipeCaches(bruteForce?: boolean): void;
  47365. /**
  47366. * Send a draw order
  47367. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47368. * @param indexStart defines the starting index
  47369. * @param indexCount defines the number of index to draw
  47370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47371. */
  47372. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47373. /**
  47374. * Draw a list of indexed primitives
  47375. * @param fillMode defines the primitive to use
  47376. * @param indexStart defines the starting index
  47377. * @param indexCount defines the number of index to draw
  47378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47379. */
  47380. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47381. /**
  47382. * Draw a list of unindexed primitives
  47383. * @param fillMode defines the primitive to use
  47384. * @param verticesStart defines the index of first vertex to draw
  47385. * @param verticesCount defines the count of vertices to draw
  47386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47387. */
  47388. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47389. /** @hidden */
  47390. _createTexture(): WebGLTexture;
  47391. /** @hidden */
  47392. _releaseTexture(texture: InternalTexture): void;
  47393. /**
  47394. * Usually called from Texture.ts.
  47395. * Passed information to create a WebGLTexture
  47396. * @param urlArg defines a value which contains one of the following:
  47397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47401. * @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)
  47402. * @param scene needed for loading to the correct scene
  47403. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47404. * @param onLoad optional callback to be called upon successful completion
  47405. * @param onError optional callback to be called upon failure
  47406. * @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
  47407. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47409. * @param forcedExtension defines the extension to use to pick the right loader
  47410. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47411. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47412. */
  47413. 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;
  47414. /**
  47415. * Creates a new render target texture
  47416. * @param size defines the size of the texture
  47417. * @param options defines the options used to create the texture
  47418. * @returns a new render target texture stored in an InternalTexture
  47419. */
  47420. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47421. /**
  47422. * Update the sampling mode of a given texture
  47423. * @param samplingMode defines the required sampling mode
  47424. * @param texture defines the texture to update
  47425. */
  47426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47427. /**
  47428. * Binds the frame buffer to the specified texture.
  47429. * @param texture The texture to render to or null for the default canvas
  47430. * @param faceIndex The face of the texture to render to in case of cube texture
  47431. * @param requiredWidth The width of the target to render to
  47432. * @param requiredHeight The height of the target to render to
  47433. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47434. * @param depthStencilTexture The depth stencil texture to use to render
  47435. * @param lodLevel defines le lod level to bind to the frame buffer
  47436. */
  47437. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47438. /**
  47439. * Unbind the current render target texture from the webGL context
  47440. * @param texture defines the render target texture to unbind
  47441. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47442. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47443. */
  47444. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47445. /**
  47446. * Creates a dynamic vertex buffer
  47447. * @param vertices the data for the dynamic vertex buffer
  47448. * @returns the new WebGL dynamic buffer
  47449. */
  47450. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47451. /**
  47452. * Update the content of a dynamic texture
  47453. * @param texture defines the texture to update
  47454. * @param canvas defines the canvas containing the source
  47455. * @param invertY defines if data must be stored with Y axis inverted
  47456. * @param premulAlpha defines if alpha is stored as premultiplied
  47457. * @param format defines the format of the data
  47458. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47459. */
  47460. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47461. /**
  47462. * Gets a boolean indicating if all created effects are ready
  47463. * @returns true if all effects are ready
  47464. */
  47465. areAllEffectsReady(): boolean;
  47466. /**
  47467. * @hidden
  47468. * Get the current error code of the webGL context
  47469. * @returns the error code
  47470. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47471. */
  47472. getError(): number;
  47473. /** @hidden */
  47474. _getUnpackAlignement(): number;
  47475. /** @hidden */
  47476. _unpackFlipY(value: boolean): void;
  47477. /**
  47478. * Update a dynamic index buffer
  47479. * @param indexBuffer defines the target index buffer
  47480. * @param indices defines the data to update
  47481. * @param offset defines the offset in the target index buffer where update should start
  47482. */
  47483. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47484. /**
  47485. * Updates a dynamic vertex buffer.
  47486. * @param vertexBuffer the vertex buffer to update
  47487. * @param vertices the data used to update the vertex buffer
  47488. * @param byteOffset the byte offset of the data (optional)
  47489. * @param byteLength the byte length of the data (optional)
  47490. */
  47491. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47492. /** @hidden */
  47493. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47494. /** @hidden */
  47495. _bindTexture(channel: number, texture: InternalTexture): void;
  47496. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47497. /**
  47498. * 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
  47499. */
  47500. releaseEffects(): void;
  47501. displayLoadingUI(): void;
  47502. hideLoadingUI(): void;
  47503. /** @hidden */
  47504. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47505. /** @hidden */
  47506. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47507. /** @hidden */
  47508. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47509. /** @hidden */
  47510. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47511. }
  47512. }
  47513. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  47514. import { Nullable, int } from "babylonjs/types";
  47515. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  47516. /** @hidden */
  47517. export class _OcclusionDataStorage {
  47518. /** @hidden */
  47519. occlusionInternalRetryCounter: number;
  47520. /** @hidden */
  47521. isOcclusionQueryInProgress: boolean;
  47522. /** @hidden */
  47523. isOccluded: boolean;
  47524. /** @hidden */
  47525. occlusionRetryCount: number;
  47526. /** @hidden */
  47527. occlusionType: number;
  47528. /** @hidden */
  47529. occlusionQueryAlgorithmType: number;
  47530. }
  47531. module "babylonjs/Engines/engine" {
  47532. interface Engine {
  47533. /**
  47534. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47535. * @return the new query
  47536. */
  47537. createQuery(): WebGLQuery;
  47538. /**
  47539. * Delete and release a webGL query
  47540. * @param query defines the query to delete
  47541. * @return the current engine
  47542. */
  47543. deleteQuery(query: WebGLQuery): Engine;
  47544. /**
  47545. * Check if a given query has resolved and got its value
  47546. * @param query defines the query to check
  47547. * @returns true if the query got its value
  47548. */
  47549. isQueryResultAvailable(query: WebGLQuery): boolean;
  47550. /**
  47551. * Gets the value of a given query
  47552. * @param query defines the query to check
  47553. * @returns the value of the query
  47554. */
  47555. getQueryResult(query: WebGLQuery): number;
  47556. /**
  47557. * Initiates an occlusion query
  47558. * @param algorithmType defines the algorithm to use
  47559. * @param query defines the query to use
  47560. * @returns the current engine
  47561. * @see http://doc.babylonjs.com/features/occlusionquery
  47562. */
  47563. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47564. /**
  47565. * Ends an occlusion query
  47566. * @see http://doc.babylonjs.com/features/occlusionquery
  47567. * @param algorithmType defines the algorithm to use
  47568. * @returns the current engine
  47569. */
  47570. endOcclusionQuery(algorithmType: number): Engine;
  47571. /**
  47572. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47573. * Please note that only one query can be issued at a time
  47574. * @returns a time token used to track the time span
  47575. */
  47576. startTimeQuery(): Nullable<_TimeToken>;
  47577. /**
  47578. * Ends a time query
  47579. * @param token defines the token used to measure the time span
  47580. * @returns the time spent (in ns)
  47581. */
  47582. endTimeQuery(token: _TimeToken): int;
  47583. /** @hidden */
  47584. _currentNonTimestampToken: Nullable<_TimeToken>;
  47585. /** @hidden */
  47586. _createTimeQuery(): WebGLQuery;
  47587. /** @hidden */
  47588. _deleteTimeQuery(query: WebGLQuery): void;
  47589. /** @hidden */
  47590. _getGlAlgorithmType(algorithmType: number): number;
  47591. /** @hidden */
  47592. _getTimeQueryResult(query: WebGLQuery): any;
  47593. /** @hidden */
  47594. _getTimeQueryAvailability(query: WebGLQuery): any;
  47595. }
  47596. }
  47597. module "babylonjs/Meshes/abstractMesh" {
  47598. interface AbstractMesh {
  47599. /**
  47600. * Backing filed
  47601. * @hidden
  47602. */
  47603. __occlusionDataStorage: _OcclusionDataStorage;
  47604. /**
  47605. * Access property
  47606. * @hidden
  47607. */
  47608. _occlusionDataStorage: _OcclusionDataStorage;
  47609. /**
  47610. * 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.
  47611. * The default value is -1 which means don't break the query and wait till the result
  47612. * @see http://doc.babylonjs.com/features/occlusionquery
  47613. */
  47614. occlusionRetryCount: number;
  47615. /**
  47616. * 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:
  47617. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47618. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47619. * * 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.
  47620. * @see http://doc.babylonjs.com/features/occlusionquery
  47621. */
  47622. occlusionType: number;
  47623. /**
  47624. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47625. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47626. * * 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.
  47627. * @see http://doc.babylonjs.com/features/occlusionquery
  47628. */
  47629. occlusionQueryAlgorithmType: number;
  47630. /**
  47631. * 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
  47632. * @see http://doc.babylonjs.com/features/occlusionquery
  47633. */
  47634. isOccluded: boolean;
  47635. /**
  47636. * Flag to check the progress status of the query
  47637. * @see http://doc.babylonjs.com/features/occlusionquery
  47638. */
  47639. isOcclusionQueryInProgress: boolean;
  47640. }
  47641. }
  47642. }
  47643. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  47644. import { Nullable } from "babylonjs/types";
  47645. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47646. /** @hidden */
  47647. export var _forceTransformFeedbackToBundle: boolean;
  47648. module "babylonjs/Engines/engine" {
  47649. interface Engine {
  47650. /**
  47651. * Creates a webGL transform feedback object
  47652. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47653. * @returns the webGL transform feedback object
  47654. */
  47655. createTransformFeedback(): WebGLTransformFeedback;
  47656. /**
  47657. * Delete a webGL transform feedback object
  47658. * @param value defines the webGL transform feedback object to delete
  47659. */
  47660. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47661. /**
  47662. * Bind a webGL transform feedback object to the webgl context
  47663. * @param value defines the webGL transform feedback object to bind
  47664. */
  47665. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47666. /**
  47667. * Begins a transform feedback operation
  47668. * @param usePoints defines if points or triangles must be used
  47669. */
  47670. beginTransformFeedback(usePoints: boolean): void;
  47671. /**
  47672. * Ends a transform feedback operation
  47673. */
  47674. endTransformFeedback(): void;
  47675. /**
  47676. * Specify the varyings to use with transform feedback
  47677. * @param program defines the associated webGL program
  47678. * @param value defines the list of strings representing the varying names
  47679. */
  47680. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47681. /**
  47682. * Bind a webGL buffer for a transform feedback operation
  47683. * @param value defines the webGL buffer to bind
  47684. */
  47685. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47686. }
  47687. }
  47688. }
  47689. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  47690. import { Scene } from "babylonjs/scene";
  47691. import { Engine } from "babylonjs/Engines/engine";
  47692. import { Texture } from "babylonjs/Materials/Textures/texture";
  47693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47694. import "babylonjs/Engines/Extensions/engine.multiRender";
  47695. /**
  47696. * Creation options of the multi render target texture.
  47697. */
  47698. export interface IMultiRenderTargetOptions {
  47699. /**
  47700. * Define if the texture needs to create mip maps after render.
  47701. */
  47702. generateMipMaps?: boolean;
  47703. /**
  47704. * Define the types of all the draw buffers we want to create
  47705. */
  47706. types?: number[];
  47707. /**
  47708. * Define the sampling modes of all the draw buffers we want to create
  47709. */
  47710. samplingModes?: number[];
  47711. /**
  47712. * Define if a depth buffer is required
  47713. */
  47714. generateDepthBuffer?: boolean;
  47715. /**
  47716. * Define if a stencil buffer is required
  47717. */
  47718. generateStencilBuffer?: boolean;
  47719. /**
  47720. * Define if a depth texture is required instead of a depth buffer
  47721. */
  47722. generateDepthTexture?: boolean;
  47723. /**
  47724. * Define the number of desired draw buffers
  47725. */
  47726. textureCount?: number;
  47727. /**
  47728. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47729. */
  47730. doNotChangeAspectRatio?: boolean;
  47731. /**
  47732. * Define the default type of the buffers we are creating
  47733. */
  47734. defaultType?: number;
  47735. }
  47736. /**
  47737. * A multi render target, like a render target provides the ability to render to a texture.
  47738. * Unlike the render target, it can render to several draw buffers in one draw.
  47739. * This is specially interesting in deferred rendering or for any effects requiring more than
  47740. * just one color from a single pass.
  47741. */
  47742. export class MultiRenderTarget extends RenderTargetTexture {
  47743. private _internalTextures;
  47744. private _textures;
  47745. private _multiRenderTargetOptions;
  47746. /**
  47747. * Get if draw buffers are currently supported by the used hardware and browser.
  47748. */
  47749. readonly isSupported: boolean;
  47750. /**
  47751. * Get the list of textures generated by the multi render target.
  47752. */
  47753. readonly textures: Texture[];
  47754. /**
  47755. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47756. */
  47757. readonly depthTexture: Texture;
  47758. /**
  47759. * Set the wrapping mode on U of all the textures we are rendering to.
  47760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47761. */
  47762. wrapU: number;
  47763. /**
  47764. * Set the wrapping mode on V of all the textures we are rendering to.
  47765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47766. */
  47767. wrapV: number;
  47768. /**
  47769. * Instantiate a new multi render target texture.
  47770. * A multi render target, like a render target provides the ability to render to a texture.
  47771. * Unlike the render target, it can render to several draw buffers in one draw.
  47772. * This is specially interesting in deferred rendering or for any effects requiring more than
  47773. * just one color from a single pass.
  47774. * @param name Define the name of the texture
  47775. * @param size Define the size of the buffers to render to
  47776. * @param count Define the number of target we are rendering into
  47777. * @param scene Define the scene the texture belongs to
  47778. * @param options Define the options used to create the multi render target
  47779. */
  47780. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47781. /** @hidden */
  47782. _rebuild(): void;
  47783. private _createInternalTextures;
  47784. private _createTextures;
  47785. /**
  47786. * Define the number of samples used if MSAA is enabled.
  47787. */
  47788. samples: number;
  47789. /**
  47790. * Resize all the textures in the multi render target.
  47791. * Be carrefull as it will recreate all the data in the new texture.
  47792. * @param size Define the new size
  47793. */
  47794. resize(size: any): void;
  47795. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47796. /**
  47797. * Dispose the render targets and their associated resources
  47798. */
  47799. dispose(): void;
  47800. /**
  47801. * Release all the underlying texture used as draw buffers.
  47802. */
  47803. releaseInternalTextures(): void;
  47804. }
  47805. }
  47806. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47808. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47809. import { Nullable } from "babylonjs/types";
  47810. module "babylonjs/Engines/thinEngine" {
  47811. interface ThinEngine {
  47812. /**
  47813. * Unbind a list of render target textures from the webGL context
  47814. * This is used only when drawBuffer extension or webGL2 are active
  47815. * @param textures defines the render target textures to unbind
  47816. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47817. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47818. */
  47819. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47820. /**
  47821. * Create a multi render target texture
  47822. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47823. * @param size defines the size of the texture
  47824. * @param options defines the creation options
  47825. * @returns the cube texture as an InternalTexture
  47826. */
  47827. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47828. /**
  47829. * Update the sample count for a given multiple render target texture
  47830. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47831. * @param textures defines the textures to update
  47832. * @param samples defines the sample count to set
  47833. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47834. */
  47835. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47836. }
  47837. }
  47838. }
  47839. declare module "babylonjs/Engines/Extensions/engine.views" {
  47840. import { Camera } from "babylonjs/Cameras/camera";
  47841. import { Nullable } from "babylonjs/types";
  47842. /**
  47843. * Class used to define an additional view for the engine
  47844. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47845. */
  47846. export class EngineView {
  47847. /** Defines the canvas where to render the view */
  47848. target: HTMLCanvasElement;
  47849. /** Defines an optional camera used to render the view (will use active camera else) */
  47850. camera?: Camera;
  47851. }
  47852. module "babylonjs/Engines/engine" {
  47853. interface Engine {
  47854. /**
  47855. * Gets or sets the HTML element to use for attaching events
  47856. */
  47857. inputElement: Nullable<HTMLElement>;
  47858. /**
  47859. * Gets the current engine view
  47860. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47861. */
  47862. activeView: Nullable<EngineView>;
  47863. /** Gets or sets the list of views */
  47864. views: EngineView[];
  47865. /**
  47866. * Register a new child canvas
  47867. * @param canvas defines the canvas to register
  47868. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47869. * @returns the associated view
  47870. */
  47871. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47872. /**
  47873. * Remove a registered child canvas
  47874. * @param canvas defines the canvas to remove
  47875. * @returns the current engine
  47876. */
  47877. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47878. }
  47879. }
  47880. }
  47881. declare module "babylonjs/Engines/Extensions/index" {
  47882. export * from "babylonjs/Engines/Extensions/engine.alpha";
  47883. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47884. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47885. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47886. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47887. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47888. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47889. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47890. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47891. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47892. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47893. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47894. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47895. export * from "babylonjs/Engines/Extensions/engine.views";
  47896. }
  47897. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47898. import { Nullable } from "babylonjs/types";
  47899. /**
  47900. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47901. */
  47902. export interface CubeMapInfo {
  47903. /**
  47904. * The pixel array for the front face.
  47905. * This is stored in format, left to right, up to down format.
  47906. */
  47907. front: Nullable<ArrayBufferView>;
  47908. /**
  47909. * The pixel array for the back face.
  47910. * This is stored in format, left to right, up to down format.
  47911. */
  47912. back: Nullable<ArrayBufferView>;
  47913. /**
  47914. * The pixel array for the left face.
  47915. * This is stored in format, left to right, up to down format.
  47916. */
  47917. left: Nullable<ArrayBufferView>;
  47918. /**
  47919. * The pixel array for the right face.
  47920. * This is stored in format, left to right, up to down format.
  47921. */
  47922. right: Nullable<ArrayBufferView>;
  47923. /**
  47924. * The pixel array for the up face.
  47925. * This is stored in format, left to right, up to down format.
  47926. */
  47927. up: Nullable<ArrayBufferView>;
  47928. /**
  47929. * The pixel array for the down face.
  47930. * This is stored in format, left to right, up to down format.
  47931. */
  47932. down: Nullable<ArrayBufferView>;
  47933. /**
  47934. * The size of the cubemap stored.
  47935. *
  47936. * Each faces will be size * size pixels.
  47937. */
  47938. size: number;
  47939. /**
  47940. * The format of the texture.
  47941. *
  47942. * RGBA, RGB.
  47943. */
  47944. format: number;
  47945. /**
  47946. * The type of the texture data.
  47947. *
  47948. * UNSIGNED_INT, FLOAT.
  47949. */
  47950. type: number;
  47951. /**
  47952. * Specifies whether the texture is in gamma space.
  47953. */
  47954. gammaSpace: boolean;
  47955. }
  47956. /**
  47957. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47958. */
  47959. export class PanoramaToCubeMapTools {
  47960. private static FACE_FRONT;
  47961. private static FACE_BACK;
  47962. private static FACE_RIGHT;
  47963. private static FACE_LEFT;
  47964. private static FACE_DOWN;
  47965. private static FACE_UP;
  47966. /**
  47967. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47968. *
  47969. * @param float32Array The source data.
  47970. * @param inputWidth The width of the input panorama.
  47971. * @param inputHeight The height of the input panorama.
  47972. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47973. * @return The cubemap data
  47974. */
  47975. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47976. private static CreateCubemapTexture;
  47977. private static CalcProjectionSpherical;
  47978. }
  47979. }
  47980. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47981. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47983. import { Nullable } from "babylonjs/types";
  47984. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47985. /**
  47986. * Helper class dealing with the extraction of spherical polynomial dataArray
  47987. * from a cube map.
  47988. */
  47989. export class CubeMapToSphericalPolynomialTools {
  47990. private static FileFaces;
  47991. /**
  47992. * Converts a texture to the according Spherical Polynomial data.
  47993. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47994. *
  47995. * @param texture The texture to extract the information from.
  47996. * @return The Spherical Polynomial data.
  47997. */
  47998. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47999. /**
  48000. * Converts a cubemap to the according Spherical Polynomial data.
  48001. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48002. *
  48003. * @param cubeInfo The Cube map to extract the information from.
  48004. * @return The Spherical Polynomial data.
  48005. */
  48006. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48007. }
  48008. }
  48009. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48010. import { Nullable } from "babylonjs/types";
  48011. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48012. module "babylonjs/Materials/Textures/baseTexture" {
  48013. interface BaseTexture {
  48014. /**
  48015. * Get the polynomial representation of the texture data.
  48016. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48017. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48018. */
  48019. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48020. }
  48021. }
  48022. }
  48023. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48025. /** @hidden */
  48026. export var rgbdEncodePixelShader: {
  48027. name: string;
  48028. shader: string;
  48029. };
  48030. }
  48031. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48032. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48033. /** @hidden */
  48034. export var rgbdDecodePixelShader: {
  48035. name: string;
  48036. shader: string;
  48037. };
  48038. }
  48039. declare module "babylonjs/Misc/environmentTextureTools" {
  48040. import { Nullable } from "babylonjs/types";
  48041. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48043. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48045. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48046. import "babylonjs/Shaders/rgbdEncode.fragment";
  48047. import "babylonjs/Shaders/rgbdDecode.fragment";
  48048. /**
  48049. * Raw texture data and descriptor sufficient for WebGL texture upload
  48050. */
  48051. export interface EnvironmentTextureInfo {
  48052. /**
  48053. * Version of the environment map
  48054. */
  48055. version: number;
  48056. /**
  48057. * Width of image
  48058. */
  48059. width: number;
  48060. /**
  48061. * Irradiance information stored in the file.
  48062. */
  48063. irradiance: any;
  48064. /**
  48065. * Specular information stored in the file.
  48066. */
  48067. specular: any;
  48068. }
  48069. /**
  48070. * Defines One Image in the file. It requires only the position in the file
  48071. * as well as the length.
  48072. */
  48073. interface BufferImageData {
  48074. /**
  48075. * Length of the image data.
  48076. */
  48077. length: number;
  48078. /**
  48079. * Position of the data from the null terminator delimiting the end of the JSON.
  48080. */
  48081. position: number;
  48082. }
  48083. /**
  48084. * Defines the specular data enclosed in the file.
  48085. * This corresponds to the version 1 of the data.
  48086. */
  48087. export interface EnvironmentTextureSpecularInfoV1 {
  48088. /**
  48089. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48090. */
  48091. specularDataPosition?: number;
  48092. /**
  48093. * This contains all the images data needed to reconstruct the cubemap.
  48094. */
  48095. mipmaps: Array<BufferImageData>;
  48096. /**
  48097. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48098. */
  48099. lodGenerationScale: number;
  48100. }
  48101. /**
  48102. * Sets of helpers addressing the serialization and deserialization of environment texture
  48103. * stored in a BabylonJS env file.
  48104. * Those files are usually stored as .env files.
  48105. */
  48106. export class EnvironmentTextureTools {
  48107. /**
  48108. * Magic number identifying the env file.
  48109. */
  48110. private static _MagicBytes;
  48111. /**
  48112. * Gets the environment info from an env file.
  48113. * @param data The array buffer containing the .env bytes.
  48114. * @returns the environment file info (the json header) if successfully parsed.
  48115. */
  48116. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48117. /**
  48118. * Creates an environment texture from a loaded cube texture.
  48119. * @param texture defines the cube texture to convert in env file
  48120. * @return a promise containing the environment data if succesfull.
  48121. */
  48122. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48123. /**
  48124. * Creates a JSON representation of the spherical data.
  48125. * @param texture defines the texture containing the polynomials
  48126. * @return the JSON representation of the spherical info
  48127. */
  48128. private static _CreateEnvTextureIrradiance;
  48129. /**
  48130. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48131. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48132. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48133. * @return the views described by info providing access to the underlying buffer
  48134. */
  48135. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48136. /**
  48137. * Uploads the texture info contained in the env file to the GPU.
  48138. * @param texture defines the internal texture to upload to
  48139. * @param arrayBuffer defines the buffer cotaining the data to load
  48140. * @param info defines the texture info retrieved through the GetEnvInfo method
  48141. * @returns a promise
  48142. */
  48143. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48144. private static _OnImageReadyAsync;
  48145. /**
  48146. * Uploads the levels of image data to the GPU.
  48147. * @param texture defines the internal texture to upload to
  48148. * @param imageData defines the array buffer views of image data [mipmap][face]
  48149. * @returns a promise
  48150. */
  48151. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48152. /**
  48153. * Uploads spherical polynomials information to the texture.
  48154. * @param texture defines the texture we are trying to upload the information to
  48155. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48156. */
  48157. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48158. /** @hidden */
  48159. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48160. }
  48161. }
  48162. declare module "babylonjs/Maths/math.vertexFormat" {
  48163. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48164. /**
  48165. * Contains position and normal vectors for a vertex
  48166. */
  48167. export class PositionNormalVertex {
  48168. /** the position of the vertex (defaut: 0,0,0) */
  48169. position: Vector3;
  48170. /** the normal of the vertex (defaut: 0,1,0) */
  48171. normal: Vector3;
  48172. /**
  48173. * Creates a PositionNormalVertex
  48174. * @param position the position of the vertex (defaut: 0,0,0)
  48175. * @param normal the normal of the vertex (defaut: 0,1,0)
  48176. */
  48177. constructor(
  48178. /** the position of the vertex (defaut: 0,0,0) */
  48179. position?: Vector3,
  48180. /** the normal of the vertex (defaut: 0,1,0) */
  48181. normal?: Vector3);
  48182. /**
  48183. * Clones the PositionNormalVertex
  48184. * @returns the cloned PositionNormalVertex
  48185. */
  48186. clone(): PositionNormalVertex;
  48187. }
  48188. /**
  48189. * Contains position, normal and uv vectors for a vertex
  48190. */
  48191. export class PositionNormalTextureVertex {
  48192. /** the position of the vertex (defaut: 0,0,0) */
  48193. position: Vector3;
  48194. /** the normal of the vertex (defaut: 0,1,0) */
  48195. normal: Vector3;
  48196. /** the uv of the vertex (default: 0,0) */
  48197. uv: Vector2;
  48198. /**
  48199. * Creates a PositionNormalTextureVertex
  48200. * @param position the position of the vertex (defaut: 0,0,0)
  48201. * @param normal the normal of the vertex (defaut: 0,1,0)
  48202. * @param uv the uv of the vertex (default: 0,0)
  48203. */
  48204. constructor(
  48205. /** the position of the vertex (defaut: 0,0,0) */
  48206. position?: Vector3,
  48207. /** the normal of the vertex (defaut: 0,1,0) */
  48208. normal?: Vector3,
  48209. /** the uv of the vertex (default: 0,0) */
  48210. uv?: Vector2);
  48211. /**
  48212. * Clones the PositionNormalTextureVertex
  48213. * @returns the cloned PositionNormalTextureVertex
  48214. */
  48215. clone(): PositionNormalTextureVertex;
  48216. }
  48217. }
  48218. declare module "babylonjs/Maths/math" {
  48219. export * from "babylonjs/Maths/math.axis";
  48220. export * from "babylonjs/Maths/math.color";
  48221. export * from "babylonjs/Maths/math.constants";
  48222. export * from "babylonjs/Maths/math.frustum";
  48223. export * from "babylonjs/Maths/math.path";
  48224. export * from "babylonjs/Maths/math.plane";
  48225. export * from "babylonjs/Maths/math.size";
  48226. export * from "babylonjs/Maths/math.vector";
  48227. export * from "babylonjs/Maths/math.vertexFormat";
  48228. export * from "babylonjs/Maths/math.viewport";
  48229. }
  48230. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48231. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48232. /** @hidden */
  48233. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48234. private _genericAttributeLocation;
  48235. private _varyingLocationCount;
  48236. private _varyingLocationMap;
  48237. private _replacements;
  48238. private _textureCount;
  48239. private _uniforms;
  48240. lineProcessor(line: string): string;
  48241. attributeProcessor(attribute: string): string;
  48242. varyingProcessor(varying: string, isFragment: boolean): string;
  48243. uniformProcessor(uniform: string): string;
  48244. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48245. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48246. }
  48247. }
  48248. declare module "babylonjs/Engines/nativeEngine" {
  48249. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48250. import { Engine } from "babylonjs/Engines/engine";
  48251. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48254. import { Effect } from "babylonjs/Materials/effect";
  48255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48256. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48257. import { IColor4Like } from "babylonjs/Maths/math.like";
  48258. import { Scene } from "babylonjs/scene";
  48259. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48260. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48261. /**
  48262. * Container for accessors for natively-stored mesh data buffers.
  48263. */
  48264. class NativeDataBuffer extends DataBuffer {
  48265. /**
  48266. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48267. */
  48268. nativeIndexBuffer?: any;
  48269. /**
  48270. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48271. */
  48272. nativeVertexBuffer?: any;
  48273. }
  48274. /** @hidden */
  48275. class NativeTexture extends InternalTexture {
  48276. getInternalTexture(): InternalTexture;
  48277. getViewCount(): number;
  48278. }
  48279. /** @hidden */
  48280. export class NativeEngine extends Engine {
  48281. private readonly _native;
  48282. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48283. private readonly INVALID_HANDLE;
  48284. getHardwareScalingLevel(): number;
  48285. constructor();
  48286. /**
  48287. * Can be used to override the current requestAnimationFrame requester.
  48288. * @hidden
  48289. */
  48290. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48291. /**
  48292. * Override default engine behavior.
  48293. * @param color
  48294. * @param backBuffer
  48295. * @param depth
  48296. * @param stencil
  48297. */
  48298. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48299. /**
  48300. * Gets host document
  48301. * @returns the host document object
  48302. */
  48303. getHostDocument(): Nullable<Document>;
  48304. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48305. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48306. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48307. recordVertexArrayObject(vertexBuffers: {
  48308. [key: string]: VertexBuffer;
  48309. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48310. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48311. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48312. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48313. /**
  48314. * Draw a list of indexed primitives
  48315. * @param fillMode defines the primitive to use
  48316. * @param indexStart defines the starting index
  48317. * @param indexCount defines the number of index to draw
  48318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48319. */
  48320. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48321. /**
  48322. * Draw a list of unindexed primitives
  48323. * @param fillMode defines the primitive to use
  48324. * @param verticesStart defines the index of first vertex to draw
  48325. * @param verticesCount defines the count of vertices to draw
  48326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48327. */
  48328. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48329. createPipelineContext(): IPipelineContext;
  48330. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48331. /** @hidden */
  48332. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48333. /** @hidden */
  48334. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48335. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48336. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48337. protected _setProgram(program: WebGLProgram): void;
  48338. _releaseEffect(effect: Effect): void;
  48339. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48340. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48341. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48342. bindSamplers(effect: Effect): void;
  48343. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48344. getRenderWidth(useScreen?: boolean): number;
  48345. getRenderHeight(useScreen?: boolean): number;
  48346. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48347. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48348. /**
  48349. * Set the z offset to apply to current rendering
  48350. * @param value defines the offset to apply
  48351. */
  48352. setZOffset(value: number): void;
  48353. /**
  48354. * Gets the current value of the zOffset
  48355. * @returns the current zOffset state
  48356. */
  48357. getZOffset(): number;
  48358. /**
  48359. * Enable or disable depth buffering
  48360. * @param enable defines the state to set
  48361. */
  48362. setDepthBuffer(enable: boolean): void;
  48363. /**
  48364. * Gets a boolean indicating if depth writing is enabled
  48365. * @returns the current depth writing state
  48366. */
  48367. getDepthWrite(): boolean;
  48368. /**
  48369. * Enable or disable depth writing
  48370. * @param enable defines the state to set
  48371. */
  48372. setDepthWrite(enable: boolean): void;
  48373. /**
  48374. * Enable or disable color writing
  48375. * @param enable defines the state to set
  48376. */
  48377. setColorWrite(enable: boolean): void;
  48378. /**
  48379. * Gets a boolean indicating if color writing is enabled
  48380. * @returns the current color writing state
  48381. */
  48382. getColorWrite(): boolean;
  48383. /**
  48384. * Sets alpha constants used by some alpha blending modes
  48385. * @param r defines the red component
  48386. * @param g defines the green component
  48387. * @param b defines the blue component
  48388. * @param a defines the alpha component
  48389. */
  48390. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48391. /**
  48392. * Sets the current alpha mode
  48393. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48394. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48395. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48396. */
  48397. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48398. /**
  48399. * Gets the current alpha mode
  48400. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48401. * @returns the current alpha mode
  48402. */
  48403. getAlphaMode(): number;
  48404. setInt(uniform: WebGLUniformLocation, int: number): void;
  48405. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48406. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48407. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48408. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48409. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48410. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48411. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48412. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48413. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48414. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48415. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48416. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48417. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48418. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48419. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48420. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48421. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48422. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48423. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48424. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48425. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48426. wipeCaches(bruteForce?: boolean): void;
  48427. _createTexture(): WebGLTexture;
  48428. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48429. /**
  48430. * Usually called from BABYLON.Texture.ts.
  48431. * Passed information to create a WebGLTexture
  48432. * @param urlArg defines a value which contains one of the following:
  48433. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48434. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48435. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48437. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48438. * @param scene needed for loading to the correct scene
  48439. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48440. * @param onLoad optional callback to be called upon successful completion
  48441. * @param onError optional callback to be called upon failure
  48442. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48443. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48444. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48445. * @param forcedExtension defines the extension to use to pick the right loader
  48446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48447. */
  48448. 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;
  48449. /**
  48450. * Creates a cube texture
  48451. * @param rootUrl defines the url where the files to load is located
  48452. * @param scene defines the current scene
  48453. * @param files defines the list of files to load (1 per face)
  48454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48455. * @param onLoad defines an optional callback raised when the texture is loaded
  48456. * @param onError defines an optional callback raised if there is an issue to load the texture
  48457. * @param format defines the format of the data
  48458. * @param forcedExtension defines the extension to use to pick the right loader
  48459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48462. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48463. * @returns the cube texture as an InternalTexture
  48464. */
  48465. 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;
  48466. private _getSamplingFilter;
  48467. private static _GetNativeTextureFormat;
  48468. createRenderTargetTexture(size: number | {
  48469. width: number;
  48470. height: number;
  48471. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48472. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48473. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48474. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48475. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48476. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48477. /**
  48478. * Updates a dynamic vertex buffer.
  48479. * @param vertexBuffer the vertex buffer to update
  48480. * @param data the data used to update the vertex buffer
  48481. * @param byteOffset the byte offset of the data (optional)
  48482. * @param byteLength the byte length of the data (optional)
  48483. */
  48484. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48485. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48486. private _updateAnisotropicLevel;
  48487. private _getAddressMode;
  48488. /** @hidden */
  48489. _bindTexture(channel: number, texture: InternalTexture): void;
  48490. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48491. releaseEffects(): void;
  48492. /** @hidden */
  48493. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48494. /** @hidden */
  48495. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48496. /** @hidden */
  48497. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48498. /** @hidden */
  48499. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48500. }
  48501. }
  48502. declare module "babylonjs/Engines/index" {
  48503. export * from "babylonjs/Engines/constants";
  48504. export * from "babylonjs/Engines/engineCapabilities";
  48505. export * from "babylonjs/Engines/instancingAttributeInfo";
  48506. export * from "babylonjs/Engines/thinEngine";
  48507. export * from "babylonjs/Engines/engine";
  48508. export * from "babylonjs/Engines/engineStore";
  48509. export * from "babylonjs/Engines/nullEngine";
  48510. export * from "babylonjs/Engines/Extensions/index";
  48511. export * from "babylonjs/Engines/IPipelineContext";
  48512. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  48513. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48514. export * from "babylonjs/Engines/nativeEngine";
  48515. }
  48516. declare module "babylonjs/Events/clipboardEvents" {
  48517. /**
  48518. * Gather the list of clipboard event types as constants.
  48519. */
  48520. export class ClipboardEventTypes {
  48521. /**
  48522. * The clipboard event is fired when a copy command is active (pressed).
  48523. */
  48524. static readonly COPY: number;
  48525. /**
  48526. * The clipboard event is fired when a cut command is active (pressed).
  48527. */
  48528. static readonly CUT: number;
  48529. /**
  48530. * The clipboard event is fired when a paste command is active (pressed).
  48531. */
  48532. static readonly PASTE: number;
  48533. }
  48534. /**
  48535. * This class is used to store clipboard related info for the onClipboardObservable event.
  48536. */
  48537. export class ClipboardInfo {
  48538. /**
  48539. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48540. */
  48541. type: number;
  48542. /**
  48543. * Defines the related dom event
  48544. */
  48545. event: ClipboardEvent;
  48546. /**
  48547. *Creates an instance of ClipboardInfo.
  48548. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48549. * @param event Defines the related dom event
  48550. */
  48551. constructor(
  48552. /**
  48553. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48554. */
  48555. type: number,
  48556. /**
  48557. * Defines the related dom event
  48558. */
  48559. event: ClipboardEvent);
  48560. /**
  48561. * Get the clipboard event's type from the keycode.
  48562. * @param keyCode Defines the keyCode for the current keyboard event.
  48563. * @return {number}
  48564. */
  48565. static GetTypeFromCharacter(keyCode: number): number;
  48566. }
  48567. }
  48568. declare module "babylonjs/Events/index" {
  48569. export * from "babylonjs/Events/keyboardEvents";
  48570. export * from "babylonjs/Events/pointerEvents";
  48571. export * from "babylonjs/Events/clipboardEvents";
  48572. }
  48573. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  48574. import { Scene } from "babylonjs/scene";
  48575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48576. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48578. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48579. /**
  48580. * Google Daydream controller
  48581. */
  48582. export class DaydreamController extends WebVRController {
  48583. /**
  48584. * Base Url for the controller model.
  48585. */
  48586. static MODEL_BASE_URL: string;
  48587. /**
  48588. * File name for the controller model.
  48589. */
  48590. static MODEL_FILENAME: string;
  48591. /**
  48592. * Gamepad Id prefix used to identify Daydream Controller.
  48593. */
  48594. static readonly GAMEPAD_ID_PREFIX: string;
  48595. /**
  48596. * Creates a new DaydreamController from a gamepad
  48597. * @param vrGamepad the gamepad that the controller should be created from
  48598. */
  48599. constructor(vrGamepad: any);
  48600. /**
  48601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48602. * @param scene scene in which to add meshes
  48603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48604. */
  48605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48606. /**
  48607. * Called once for each button that changed state since the last frame
  48608. * @param buttonIdx Which button index changed
  48609. * @param state New state of the button
  48610. * @param changes Which properties on the state changed since last frame
  48611. */
  48612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48613. }
  48614. }
  48615. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  48616. import { Scene } from "babylonjs/scene";
  48617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48618. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48619. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48620. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48621. /**
  48622. * Gear VR Controller
  48623. */
  48624. export class GearVRController extends WebVRController {
  48625. /**
  48626. * Base Url for the controller model.
  48627. */
  48628. static MODEL_BASE_URL: string;
  48629. /**
  48630. * File name for the controller model.
  48631. */
  48632. static MODEL_FILENAME: string;
  48633. /**
  48634. * Gamepad Id prefix used to identify this controller.
  48635. */
  48636. static readonly GAMEPAD_ID_PREFIX: string;
  48637. private readonly _buttonIndexToObservableNameMap;
  48638. /**
  48639. * Creates a new GearVRController from a gamepad
  48640. * @param vrGamepad the gamepad that the controller should be created from
  48641. */
  48642. constructor(vrGamepad: any);
  48643. /**
  48644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48645. * @param scene scene in which to add meshes
  48646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48647. */
  48648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48649. /**
  48650. * Called once for each button that changed state since the last frame
  48651. * @param buttonIdx Which button index changed
  48652. * @param state New state of the button
  48653. * @param changes Which properties on the state changed since last frame
  48654. */
  48655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48656. }
  48657. }
  48658. declare module "babylonjs/Gamepads/Controllers/index" {
  48659. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  48660. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  48661. export * from "babylonjs/Gamepads/Controllers/genericController";
  48662. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  48663. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48664. export * from "babylonjs/Gamepads/Controllers/viveController";
  48665. export * from "babylonjs/Gamepads/Controllers/webVRController";
  48666. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  48667. }
  48668. declare module "babylonjs/Gamepads/index" {
  48669. export * from "babylonjs/Gamepads/Controllers/index";
  48670. export * from "babylonjs/Gamepads/gamepad";
  48671. export * from "babylonjs/Gamepads/gamepadManager";
  48672. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  48673. export * from "babylonjs/Gamepads/xboxGamepad";
  48674. export * from "babylonjs/Gamepads/dualShockGamepad";
  48675. }
  48676. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  48677. import { Scene } from "babylonjs/scene";
  48678. import { Vector4 } from "babylonjs/Maths/math.vector";
  48679. import { Color4 } from "babylonjs/Maths/math.color";
  48680. import { Mesh } from "babylonjs/Meshes/mesh";
  48681. import { Nullable } from "babylonjs/types";
  48682. /**
  48683. * Class containing static functions to help procedurally build meshes
  48684. */
  48685. export class PolyhedronBuilder {
  48686. /**
  48687. * Creates a polyhedron mesh
  48688. * * 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
  48689. * * The parameter `size` (positive float, default 1) sets the polygon size
  48690. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48691. * * 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`
  48692. * * 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
  48693. * * 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)`)
  48694. * * 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
  48695. * * 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
  48696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48699. * @param name defines the name of the mesh
  48700. * @param options defines the options used to create the mesh
  48701. * @param scene defines the hosting scene
  48702. * @returns the polyhedron mesh
  48703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48704. */
  48705. static CreatePolyhedron(name: string, options: {
  48706. type?: number;
  48707. size?: number;
  48708. sizeX?: number;
  48709. sizeY?: number;
  48710. sizeZ?: number;
  48711. custom?: any;
  48712. faceUV?: Vector4[];
  48713. faceColors?: Color4[];
  48714. flat?: boolean;
  48715. updatable?: boolean;
  48716. sideOrientation?: number;
  48717. frontUVs?: Vector4;
  48718. backUVs?: Vector4;
  48719. }, scene?: Nullable<Scene>): Mesh;
  48720. }
  48721. }
  48722. declare module "babylonjs/Gizmos/scaleGizmo" {
  48723. import { Observable } from "babylonjs/Misc/observable";
  48724. import { Nullable } from "babylonjs/types";
  48725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48726. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48727. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  48728. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48729. /**
  48730. * Gizmo that enables scaling a mesh along 3 axis
  48731. */
  48732. export class ScaleGizmo extends Gizmo {
  48733. /**
  48734. * Internal gizmo used for interactions on the x axis
  48735. */
  48736. xGizmo: AxisScaleGizmo;
  48737. /**
  48738. * Internal gizmo used for interactions on the y axis
  48739. */
  48740. yGizmo: AxisScaleGizmo;
  48741. /**
  48742. * Internal gizmo used for interactions on the z axis
  48743. */
  48744. zGizmo: AxisScaleGizmo;
  48745. /**
  48746. * Internal gizmo used to scale all axis equally
  48747. */
  48748. uniformScaleGizmo: AxisScaleGizmo;
  48749. private _meshAttached;
  48750. private _updateGizmoRotationToMatchAttachedMesh;
  48751. private _snapDistance;
  48752. private _scaleRatio;
  48753. private _uniformScalingMesh;
  48754. private _octahedron;
  48755. private _sensitivity;
  48756. /** Fires an event when any of it's sub gizmos are dragged */
  48757. onDragStartObservable: Observable<unknown>;
  48758. /** Fires an event when any of it's sub gizmos are released from dragging */
  48759. onDragEndObservable: Observable<unknown>;
  48760. attachedMesh: Nullable<AbstractMesh>;
  48761. /**
  48762. * Creates a ScaleGizmo
  48763. * @param gizmoLayer The utility layer the gizmo will be added to
  48764. */
  48765. constructor(gizmoLayer?: UtilityLayerRenderer);
  48766. updateGizmoRotationToMatchAttachedMesh: boolean;
  48767. /**
  48768. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48769. */
  48770. snapDistance: number;
  48771. /**
  48772. * Ratio for the scale of the gizmo (Default: 1)
  48773. */
  48774. scaleRatio: number;
  48775. /**
  48776. * Sensitivity factor for dragging (Default: 1)
  48777. */
  48778. sensitivity: number;
  48779. /**
  48780. * Disposes of the gizmo
  48781. */
  48782. dispose(): void;
  48783. }
  48784. }
  48785. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48786. import { Observable } from "babylonjs/Misc/observable";
  48787. import { Nullable } from "babylonjs/types";
  48788. import { Vector3 } from "babylonjs/Maths/math.vector";
  48789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48790. import { Mesh } from "babylonjs/Meshes/mesh";
  48791. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48792. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48793. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48794. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48795. import { Color3 } from "babylonjs/Maths/math.color";
  48796. /**
  48797. * Single axis scale gizmo
  48798. */
  48799. export class AxisScaleGizmo extends Gizmo {
  48800. /**
  48801. * Drag behavior responsible for the gizmos dragging interactions
  48802. */
  48803. dragBehavior: PointerDragBehavior;
  48804. private _pointerObserver;
  48805. /**
  48806. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48807. */
  48808. snapDistance: number;
  48809. /**
  48810. * Event that fires each time the gizmo snaps to a new location.
  48811. * * snapDistance is the the change in distance
  48812. */
  48813. onSnapObservable: Observable<{
  48814. snapDistance: number;
  48815. }>;
  48816. /**
  48817. * If the scaling operation should be done on all axis (default: false)
  48818. */
  48819. uniformScaling: boolean;
  48820. /**
  48821. * Custom sensitivity value for the drag strength
  48822. */
  48823. sensitivity: number;
  48824. private _isEnabled;
  48825. private _parent;
  48826. private _arrow;
  48827. private _coloredMaterial;
  48828. private _hoverMaterial;
  48829. /**
  48830. * Creates an AxisScaleGizmo
  48831. * @param gizmoLayer The utility layer the gizmo will be added to
  48832. * @param dragAxis The axis which the gizmo will be able to scale on
  48833. * @param color The color of the gizmo
  48834. */
  48835. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48836. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48837. /**
  48838. * If the gizmo is enabled
  48839. */
  48840. isEnabled: boolean;
  48841. /**
  48842. * Disposes of the gizmo
  48843. */
  48844. dispose(): void;
  48845. /**
  48846. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48847. * @param mesh The mesh to replace the default mesh of the gizmo
  48848. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48849. */
  48850. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48851. }
  48852. }
  48853. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48854. import { Observable } from "babylonjs/Misc/observable";
  48855. import { Nullable } from "babylonjs/types";
  48856. import { Vector3 } from "babylonjs/Maths/math.vector";
  48857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48858. import { Mesh } from "babylonjs/Meshes/mesh";
  48859. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48860. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48861. import { Color3 } from "babylonjs/Maths/math.color";
  48862. import "babylonjs/Meshes/Builders/boxBuilder";
  48863. /**
  48864. * Bounding box gizmo
  48865. */
  48866. export class BoundingBoxGizmo extends Gizmo {
  48867. private _lineBoundingBox;
  48868. private _rotateSpheresParent;
  48869. private _scaleBoxesParent;
  48870. private _boundingDimensions;
  48871. private _renderObserver;
  48872. private _pointerObserver;
  48873. private _scaleDragSpeed;
  48874. private _tmpQuaternion;
  48875. private _tmpVector;
  48876. private _tmpRotationMatrix;
  48877. /**
  48878. * 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)
  48879. */
  48880. ignoreChildren: boolean;
  48881. /**
  48882. * 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)
  48883. */
  48884. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48885. /**
  48886. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48887. */
  48888. rotationSphereSize: number;
  48889. /**
  48890. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48891. */
  48892. scaleBoxSize: number;
  48893. /**
  48894. * 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)
  48895. */
  48896. fixedDragMeshScreenSize: boolean;
  48897. /**
  48898. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48899. */
  48900. fixedDragMeshScreenSizeDistanceFactor: number;
  48901. /**
  48902. * Fired when a rotation sphere or scale box is dragged
  48903. */
  48904. onDragStartObservable: Observable<{}>;
  48905. /**
  48906. * Fired when a scale box is dragged
  48907. */
  48908. onScaleBoxDragObservable: Observable<{}>;
  48909. /**
  48910. * Fired when a scale box drag is ended
  48911. */
  48912. onScaleBoxDragEndObservable: Observable<{}>;
  48913. /**
  48914. * Fired when a rotation sphere is dragged
  48915. */
  48916. onRotationSphereDragObservable: Observable<{}>;
  48917. /**
  48918. * Fired when a rotation sphere drag is ended
  48919. */
  48920. onRotationSphereDragEndObservable: Observable<{}>;
  48921. /**
  48922. * 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)
  48923. */
  48924. scalePivot: Nullable<Vector3>;
  48925. /**
  48926. * Mesh used as a pivot to rotate the attached mesh
  48927. */
  48928. private _anchorMesh;
  48929. private _existingMeshScale;
  48930. private _dragMesh;
  48931. private pointerDragBehavior;
  48932. private coloredMaterial;
  48933. private hoverColoredMaterial;
  48934. /**
  48935. * Sets the color of the bounding box gizmo
  48936. * @param color the color to set
  48937. */
  48938. setColor(color: Color3): void;
  48939. /**
  48940. * Creates an BoundingBoxGizmo
  48941. * @param gizmoLayer The utility layer the gizmo will be added to
  48942. * @param color The color of the gizmo
  48943. */
  48944. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48945. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48946. private _selectNode;
  48947. /**
  48948. * Updates the bounding box information for the Gizmo
  48949. */
  48950. updateBoundingBox(): void;
  48951. private _updateRotationSpheres;
  48952. private _updateScaleBoxes;
  48953. /**
  48954. * Enables rotation on the specified axis and disables rotation on the others
  48955. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48956. */
  48957. setEnabledRotationAxis(axis: string): void;
  48958. /**
  48959. * Enables/disables scaling
  48960. * @param enable if scaling should be enabled
  48961. */
  48962. setEnabledScaling(enable: boolean): void;
  48963. private _updateDummy;
  48964. /**
  48965. * Enables a pointer drag behavior on the bounding box of the gizmo
  48966. */
  48967. enableDragBehavior(): void;
  48968. /**
  48969. * Disposes of the gizmo
  48970. */
  48971. dispose(): void;
  48972. /**
  48973. * 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)
  48974. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48975. * @returns the bounding box mesh with the passed in mesh as a child
  48976. */
  48977. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48978. /**
  48979. * CustomMeshes are not supported by this gizmo
  48980. * @param mesh The mesh to replace the default mesh of the gizmo
  48981. */
  48982. setCustomMesh(mesh: Mesh): void;
  48983. }
  48984. }
  48985. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48986. import { Observable } from "babylonjs/Misc/observable";
  48987. import { Nullable } from "babylonjs/types";
  48988. import { Vector3 } from "babylonjs/Maths/math.vector";
  48989. import { Color3 } from "babylonjs/Maths/math.color";
  48990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48991. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48992. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48993. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48994. import "babylonjs/Meshes/Builders/linesBuilder";
  48995. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48996. /**
  48997. * Single plane rotation gizmo
  48998. */
  48999. export class PlaneRotationGizmo extends Gizmo {
  49000. /**
  49001. * Drag behavior responsible for the gizmos dragging interactions
  49002. */
  49003. dragBehavior: PointerDragBehavior;
  49004. private _pointerObserver;
  49005. /**
  49006. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49007. */
  49008. snapDistance: number;
  49009. /**
  49010. * Event that fires each time the gizmo snaps to a new location.
  49011. * * snapDistance is the the change in distance
  49012. */
  49013. onSnapObservable: Observable<{
  49014. snapDistance: number;
  49015. }>;
  49016. private _isEnabled;
  49017. private _parent;
  49018. /**
  49019. * Creates a PlaneRotationGizmo
  49020. * @param gizmoLayer The utility layer the gizmo will be added to
  49021. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49022. * @param color The color of the gizmo
  49023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49024. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49025. */
  49026. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49028. /**
  49029. * If the gizmo is enabled
  49030. */
  49031. isEnabled: boolean;
  49032. /**
  49033. * Disposes of the gizmo
  49034. */
  49035. dispose(): void;
  49036. }
  49037. }
  49038. declare module "babylonjs/Gizmos/rotationGizmo" {
  49039. import { Observable } from "babylonjs/Misc/observable";
  49040. import { Nullable } from "babylonjs/types";
  49041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49042. import { Mesh } from "babylonjs/Meshes/mesh";
  49043. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49044. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49045. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49046. /**
  49047. * Gizmo that enables rotating a mesh along 3 axis
  49048. */
  49049. export class RotationGizmo extends Gizmo {
  49050. /**
  49051. * Internal gizmo used for interactions on the x axis
  49052. */
  49053. xGizmo: PlaneRotationGizmo;
  49054. /**
  49055. * Internal gizmo used for interactions on the y axis
  49056. */
  49057. yGizmo: PlaneRotationGizmo;
  49058. /**
  49059. * Internal gizmo used for interactions on the z axis
  49060. */
  49061. zGizmo: PlaneRotationGizmo;
  49062. /** Fires an event when any of it's sub gizmos are dragged */
  49063. onDragStartObservable: Observable<unknown>;
  49064. /** Fires an event when any of it's sub gizmos are released from dragging */
  49065. onDragEndObservable: Observable<unknown>;
  49066. private _meshAttached;
  49067. attachedMesh: Nullable<AbstractMesh>;
  49068. /**
  49069. * Creates a RotationGizmo
  49070. * @param gizmoLayer The utility layer the gizmo will be added to
  49071. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49072. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49073. */
  49074. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49075. updateGizmoRotationToMatchAttachedMesh: boolean;
  49076. /**
  49077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49078. */
  49079. snapDistance: number;
  49080. /**
  49081. * Ratio for the scale of the gizmo (Default: 1)
  49082. */
  49083. scaleRatio: number;
  49084. /**
  49085. * Disposes of the gizmo
  49086. */
  49087. dispose(): void;
  49088. /**
  49089. * CustomMeshes are not supported by this gizmo
  49090. * @param mesh The mesh to replace the default mesh of the gizmo
  49091. */
  49092. setCustomMesh(mesh: Mesh): void;
  49093. }
  49094. }
  49095. declare module "babylonjs/Gizmos/gizmoManager" {
  49096. import { Observable } from "babylonjs/Misc/observable";
  49097. import { Nullable } from "babylonjs/types";
  49098. import { Scene, IDisposable } from "babylonjs/scene";
  49099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49100. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49101. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49102. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49103. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49104. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49105. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49106. /**
  49107. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49108. */
  49109. export class GizmoManager implements IDisposable {
  49110. private scene;
  49111. /**
  49112. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49113. */
  49114. gizmos: {
  49115. positionGizmo: Nullable<PositionGizmo>;
  49116. rotationGizmo: Nullable<RotationGizmo>;
  49117. scaleGizmo: Nullable<ScaleGizmo>;
  49118. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49119. };
  49120. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49121. clearGizmoOnEmptyPointerEvent: boolean;
  49122. /** Fires an event when the manager is attached to a mesh */
  49123. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49124. private _gizmosEnabled;
  49125. private _pointerObserver;
  49126. private _attachedMesh;
  49127. private _boundingBoxColor;
  49128. private _defaultUtilityLayer;
  49129. private _defaultKeepDepthUtilityLayer;
  49130. /**
  49131. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49132. */
  49133. boundingBoxDragBehavior: SixDofDragBehavior;
  49134. /**
  49135. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49136. */
  49137. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49138. /**
  49139. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49140. */
  49141. usePointerToAttachGizmos: boolean;
  49142. /**
  49143. * Utility layer that the bounding box gizmo belongs to
  49144. */
  49145. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  49146. /**
  49147. * Utility layer that all gizmos besides bounding box belong to
  49148. */
  49149. readonly utilityLayer: UtilityLayerRenderer;
  49150. /**
  49151. * Instatiates a gizmo manager
  49152. * @param scene the scene to overlay the gizmos on top of
  49153. */
  49154. constructor(scene: Scene);
  49155. /**
  49156. * Attaches a set of gizmos to the specified mesh
  49157. * @param mesh The mesh the gizmo's should be attached to
  49158. */
  49159. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49160. /**
  49161. * If the position gizmo is enabled
  49162. */
  49163. positionGizmoEnabled: boolean;
  49164. /**
  49165. * If the rotation gizmo is enabled
  49166. */
  49167. rotationGizmoEnabled: boolean;
  49168. /**
  49169. * If the scale gizmo is enabled
  49170. */
  49171. scaleGizmoEnabled: boolean;
  49172. /**
  49173. * If the boundingBox gizmo is enabled
  49174. */
  49175. boundingBoxGizmoEnabled: boolean;
  49176. /**
  49177. * Disposes of the gizmo manager
  49178. */
  49179. dispose(): void;
  49180. }
  49181. }
  49182. declare module "babylonjs/Lights/directionalLight" {
  49183. import { Camera } from "babylonjs/Cameras/camera";
  49184. import { Scene } from "babylonjs/scene";
  49185. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49187. import { Light } from "babylonjs/Lights/light";
  49188. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49189. import { Effect } from "babylonjs/Materials/effect";
  49190. /**
  49191. * A directional light is defined by a direction (what a surprise!).
  49192. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49193. * 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.
  49194. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49195. */
  49196. export class DirectionalLight extends ShadowLight {
  49197. private _shadowFrustumSize;
  49198. /**
  49199. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49200. */
  49201. /**
  49202. * Specifies a fix frustum size for the shadow generation.
  49203. */
  49204. shadowFrustumSize: number;
  49205. private _shadowOrthoScale;
  49206. /**
  49207. * Gets the shadow projection scale against the optimal computed one.
  49208. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49209. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49210. */
  49211. /**
  49212. * Sets the shadow projection scale against the optimal computed one.
  49213. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49214. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49215. */
  49216. shadowOrthoScale: number;
  49217. /**
  49218. * Automatically compute the projection matrix to best fit (including all the casters)
  49219. * on each frame.
  49220. */
  49221. autoUpdateExtends: boolean;
  49222. private _orthoLeft;
  49223. private _orthoRight;
  49224. private _orthoTop;
  49225. private _orthoBottom;
  49226. /**
  49227. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49228. * The directional light is emitted from everywhere in the given direction.
  49229. * It can cast shadows.
  49230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49231. * @param name The friendly name of the light
  49232. * @param direction The direction of the light
  49233. * @param scene The scene the light belongs to
  49234. */
  49235. constructor(name: string, direction: Vector3, scene: Scene);
  49236. /**
  49237. * Returns the string "DirectionalLight".
  49238. * @return The class name
  49239. */
  49240. getClassName(): string;
  49241. /**
  49242. * Returns the integer 1.
  49243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49244. */
  49245. getTypeID(): number;
  49246. /**
  49247. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49248. * Returns the DirectionalLight Shadow projection matrix.
  49249. */
  49250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49251. /**
  49252. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49253. * Returns the DirectionalLight Shadow projection matrix.
  49254. */
  49255. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49256. /**
  49257. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49258. * Returns the DirectionalLight Shadow projection matrix.
  49259. */
  49260. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49261. protected _buildUniformLayout(): void;
  49262. /**
  49263. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49264. * @param effect The effect to update
  49265. * @param lightIndex The index of the light in the effect to update
  49266. * @returns The directional light
  49267. */
  49268. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49269. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49270. /**
  49271. * Gets the minZ used for shadow according to both the scene and the light.
  49272. *
  49273. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49274. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49275. * @param activeCamera The camera we are returning the min for
  49276. * @returns the depth min z
  49277. */
  49278. getDepthMinZ(activeCamera: Camera): number;
  49279. /**
  49280. * Gets the maxZ used for shadow according to both the scene and the light.
  49281. *
  49282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49284. * @param activeCamera The camera we are returning the max for
  49285. * @returns the depth max z
  49286. */
  49287. getDepthMaxZ(activeCamera: Camera): number;
  49288. /**
  49289. * Prepares the list of defines specific to the light type.
  49290. * @param defines the list of defines
  49291. * @param lightIndex defines the index of the light for the effect
  49292. */
  49293. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49294. }
  49295. }
  49296. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49297. import { Mesh } from "babylonjs/Meshes/mesh";
  49298. /**
  49299. * Class containing static functions to help procedurally build meshes
  49300. */
  49301. export class HemisphereBuilder {
  49302. /**
  49303. * Creates a hemisphere mesh
  49304. * @param name defines the name of the mesh
  49305. * @param options defines the options used to create the mesh
  49306. * @param scene defines the hosting scene
  49307. * @returns the hemisphere mesh
  49308. */
  49309. static CreateHemisphere(name: string, options: {
  49310. segments?: number;
  49311. diameter?: number;
  49312. sideOrientation?: number;
  49313. }, scene: any): Mesh;
  49314. }
  49315. }
  49316. declare module "babylonjs/Lights/spotLight" {
  49317. import { Nullable } from "babylonjs/types";
  49318. import { Scene } from "babylonjs/scene";
  49319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49321. import { Effect } from "babylonjs/Materials/effect";
  49322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49323. import { Light } from "babylonjs/Lights/light";
  49324. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49325. /**
  49326. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49327. * These values define a cone of light starting from the position, emitting toward the direction.
  49328. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49329. * and the exponent defines the speed of the decay of the light with distance (reach).
  49330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49331. */
  49332. export class SpotLight extends ShadowLight {
  49333. private _angle;
  49334. private _innerAngle;
  49335. private _cosHalfAngle;
  49336. private _lightAngleScale;
  49337. private _lightAngleOffset;
  49338. /**
  49339. * Gets the cone angle of the spot light in Radians.
  49340. */
  49341. /**
  49342. * Sets the cone angle of the spot light in Radians.
  49343. */
  49344. angle: number;
  49345. /**
  49346. * Only used in gltf falloff mode, this defines the angle where
  49347. * the directional falloff will start before cutting at angle which could be seen
  49348. * as outer angle.
  49349. */
  49350. /**
  49351. * Only used in gltf falloff mode, this defines the angle where
  49352. * the directional falloff will start before cutting at angle which could be seen
  49353. * as outer angle.
  49354. */
  49355. innerAngle: number;
  49356. private _shadowAngleScale;
  49357. /**
  49358. * Allows scaling the angle of the light for shadow generation only.
  49359. */
  49360. /**
  49361. * Allows scaling the angle of the light for shadow generation only.
  49362. */
  49363. shadowAngleScale: number;
  49364. /**
  49365. * The light decay speed with the distance from the emission spot.
  49366. */
  49367. exponent: number;
  49368. private _projectionTextureMatrix;
  49369. /**
  49370. * Allows reading the projecton texture
  49371. */
  49372. readonly projectionTextureMatrix: Matrix;
  49373. protected _projectionTextureLightNear: number;
  49374. /**
  49375. * Gets the near clip of the Spotlight for texture projection.
  49376. */
  49377. /**
  49378. * Sets the near clip of the Spotlight for texture projection.
  49379. */
  49380. projectionTextureLightNear: number;
  49381. protected _projectionTextureLightFar: number;
  49382. /**
  49383. * Gets the far clip of the Spotlight for texture projection.
  49384. */
  49385. /**
  49386. * Sets the far clip of the Spotlight for texture projection.
  49387. */
  49388. projectionTextureLightFar: number;
  49389. protected _projectionTextureUpDirection: Vector3;
  49390. /**
  49391. * Gets the Up vector of the Spotlight for texture projection.
  49392. */
  49393. /**
  49394. * Sets the Up vector of the Spotlight for texture projection.
  49395. */
  49396. projectionTextureUpDirection: Vector3;
  49397. private _projectionTexture;
  49398. /**
  49399. * Gets the projection texture of the light.
  49400. */
  49401. /**
  49402. * Sets the projection texture of the light.
  49403. */
  49404. projectionTexture: Nullable<BaseTexture>;
  49405. private _projectionTextureViewLightDirty;
  49406. private _projectionTextureProjectionLightDirty;
  49407. private _projectionTextureDirty;
  49408. private _projectionTextureViewTargetVector;
  49409. private _projectionTextureViewLightMatrix;
  49410. private _projectionTextureProjectionLightMatrix;
  49411. private _projectionTextureScalingMatrix;
  49412. /**
  49413. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49414. * It can cast shadows.
  49415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49416. * @param name The light friendly name
  49417. * @param position The position of the spot light in the scene
  49418. * @param direction The direction of the light in the scene
  49419. * @param angle The cone angle of the light in Radians
  49420. * @param exponent The light decay speed with the distance from the emission spot
  49421. * @param scene The scene the lights belongs to
  49422. */
  49423. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49424. /**
  49425. * Returns the string "SpotLight".
  49426. * @returns the class name
  49427. */
  49428. getClassName(): string;
  49429. /**
  49430. * Returns the integer 2.
  49431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49432. */
  49433. getTypeID(): number;
  49434. /**
  49435. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49436. */
  49437. protected _setDirection(value: Vector3): void;
  49438. /**
  49439. * Overrides the position setter to recompute the projection texture view light Matrix.
  49440. */
  49441. protected _setPosition(value: Vector3): void;
  49442. /**
  49443. * 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.
  49444. * Returns the SpotLight.
  49445. */
  49446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49447. protected _computeProjectionTextureViewLightMatrix(): void;
  49448. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49449. /**
  49450. * Main function for light texture projection matrix computing.
  49451. */
  49452. protected _computeProjectionTextureMatrix(): void;
  49453. protected _buildUniformLayout(): void;
  49454. private _computeAngleValues;
  49455. /**
  49456. * Sets the passed Effect "effect" with the Light textures.
  49457. * @param effect The effect to update
  49458. * @param lightIndex The index of the light in the effect to update
  49459. * @returns The light
  49460. */
  49461. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49462. /**
  49463. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49464. * @param effect The effect to update
  49465. * @param lightIndex The index of the light in the effect to update
  49466. * @returns The spot light
  49467. */
  49468. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49469. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49470. /**
  49471. * Disposes the light and the associated resources.
  49472. */
  49473. dispose(): void;
  49474. /**
  49475. * Prepares the list of defines specific to the light type.
  49476. * @param defines the list of defines
  49477. * @param lightIndex defines the index of the light for the effect
  49478. */
  49479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49480. }
  49481. }
  49482. declare module "babylonjs/Gizmos/lightGizmo" {
  49483. import { Nullable } from "babylonjs/types";
  49484. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49486. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  49487. import { Light } from "babylonjs/Lights/light";
  49488. /**
  49489. * Gizmo that enables viewing a light
  49490. */
  49491. export class LightGizmo extends Gizmo {
  49492. private _lightMesh;
  49493. private _material;
  49494. private _cachedPosition;
  49495. private _cachedForward;
  49496. private _attachedMeshParent;
  49497. /**
  49498. * Creates a LightGizmo
  49499. * @param gizmoLayer The utility layer the gizmo will be added to
  49500. */
  49501. constructor(gizmoLayer?: UtilityLayerRenderer);
  49502. private _light;
  49503. /**
  49504. * The light that the gizmo is attached to
  49505. */
  49506. light: Nullable<Light>;
  49507. /**
  49508. * Gets the material used to render the light gizmo
  49509. */
  49510. readonly material: StandardMaterial;
  49511. /**
  49512. * @hidden
  49513. * Updates the gizmo to match the attached mesh's position/rotation
  49514. */
  49515. protected _update(): void;
  49516. private static _Scale;
  49517. /**
  49518. * Creates the lines for a light mesh
  49519. */
  49520. private static _CreateLightLines;
  49521. /**
  49522. * Disposes of the light gizmo
  49523. */
  49524. dispose(): void;
  49525. private static _CreateHemisphericLightMesh;
  49526. private static _CreatePointLightMesh;
  49527. private static _CreateSpotLightMesh;
  49528. private static _CreateDirectionalLightMesh;
  49529. }
  49530. }
  49531. declare module "babylonjs/Gizmos/index" {
  49532. export * from "babylonjs/Gizmos/axisDragGizmo";
  49533. export * from "babylonjs/Gizmos/axisScaleGizmo";
  49534. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  49535. export * from "babylonjs/Gizmos/gizmo";
  49536. export * from "babylonjs/Gizmos/gizmoManager";
  49537. export * from "babylonjs/Gizmos/planeRotationGizmo";
  49538. export * from "babylonjs/Gizmos/positionGizmo";
  49539. export * from "babylonjs/Gizmos/rotationGizmo";
  49540. export * from "babylonjs/Gizmos/scaleGizmo";
  49541. export * from "babylonjs/Gizmos/lightGizmo";
  49542. export * from "babylonjs/Gizmos/planeDragGizmo";
  49543. }
  49544. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  49545. /** @hidden */
  49546. export var backgroundFragmentDeclaration: {
  49547. name: string;
  49548. shader: string;
  49549. };
  49550. }
  49551. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  49552. /** @hidden */
  49553. export var backgroundUboDeclaration: {
  49554. name: string;
  49555. shader: string;
  49556. };
  49557. }
  49558. declare module "babylonjs/Shaders/background.fragment" {
  49559. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  49560. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  49561. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49562. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49563. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49564. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49566. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  49567. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49568. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49570. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49572. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49573. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49574. /** @hidden */
  49575. export var backgroundPixelShader: {
  49576. name: string;
  49577. shader: string;
  49578. };
  49579. }
  49580. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  49581. /** @hidden */
  49582. export var backgroundVertexDeclaration: {
  49583. name: string;
  49584. shader: string;
  49585. };
  49586. }
  49587. declare module "babylonjs/Shaders/background.vertex" {
  49588. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  49589. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  49590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49591. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49592. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49593. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49594. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49595. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49596. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49597. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49598. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49599. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49600. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49601. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49602. /** @hidden */
  49603. export var backgroundVertexShader: {
  49604. name: string;
  49605. shader: string;
  49606. };
  49607. }
  49608. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  49609. import { Nullable, int, float } from "babylonjs/types";
  49610. import { Scene } from "babylonjs/scene";
  49611. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49614. import { Mesh } from "babylonjs/Meshes/mesh";
  49615. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49616. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49617. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49619. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  49620. import { Color3 } from "babylonjs/Maths/math.color";
  49621. import "babylonjs/Shaders/background.fragment";
  49622. import "babylonjs/Shaders/background.vertex";
  49623. /**
  49624. * Background material used to create an efficient environement around your scene.
  49625. */
  49626. export class BackgroundMaterial extends PushMaterial {
  49627. /**
  49628. * Standard reflectance value at parallel view angle.
  49629. */
  49630. static StandardReflectance0: number;
  49631. /**
  49632. * Standard reflectance value at grazing angle.
  49633. */
  49634. static StandardReflectance90: number;
  49635. protected _primaryColor: Color3;
  49636. /**
  49637. * Key light Color (multiply against the environement texture)
  49638. */
  49639. primaryColor: Color3;
  49640. protected __perceptualColor: Nullable<Color3>;
  49641. /**
  49642. * Experimental Internal Use Only.
  49643. *
  49644. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49645. * This acts as a helper to set the primary color to a more "human friendly" value.
  49646. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49647. * output color as close as possible from the chosen value.
  49648. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49649. * part of lighting setup.)
  49650. */
  49651. _perceptualColor: Nullable<Color3>;
  49652. protected _primaryColorShadowLevel: float;
  49653. /**
  49654. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49655. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49656. */
  49657. primaryColorShadowLevel: float;
  49658. protected _primaryColorHighlightLevel: float;
  49659. /**
  49660. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49661. * The primary color is used at the level chosen to define what the white area would look.
  49662. */
  49663. primaryColorHighlightLevel: float;
  49664. protected _reflectionTexture: Nullable<BaseTexture>;
  49665. /**
  49666. * Reflection Texture used in the material.
  49667. * Should be author in a specific way for the best result (refer to the documentation).
  49668. */
  49669. reflectionTexture: Nullable<BaseTexture>;
  49670. protected _reflectionBlur: float;
  49671. /**
  49672. * Reflection Texture level of blur.
  49673. *
  49674. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49675. * texture twice.
  49676. */
  49677. reflectionBlur: float;
  49678. protected _diffuseTexture: Nullable<BaseTexture>;
  49679. /**
  49680. * Diffuse Texture used in the material.
  49681. * Should be author in a specific way for the best result (refer to the documentation).
  49682. */
  49683. diffuseTexture: Nullable<BaseTexture>;
  49684. protected _shadowLights: Nullable<IShadowLight[]>;
  49685. /**
  49686. * Specify the list of lights casting shadow on the material.
  49687. * All scene shadow lights will be included if null.
  49688. */
  49689. shadowLights: Nullable<IShadowLight[]>;
  49690. protected _shadowLevel: float;
  49691. /**
  49692. * Helps adjusting the shadow to a softer level if required.
  49693. * 0 means black shadows and 1 means no shadows.
  49694. */
  49695. shadowLevel: float;
  49696. protected _sceneCenter: Vector3;
  49697. /**
  49698. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49699. * It is usually zero but might be interesting to modify according to your setup.
  49700. */
  49701. sceneCenter: Vector3;
  49702. protected _opacityFresnel: boolean;
  49703. /**
  49704. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49705. * This helps ensuring a nice transition when the camera goes under the ground.
  49706. */
  49707. opacityFresnel: boolean;
  49708. protected _reflectionFresnel: boolean;
  49709. /**
  49710. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49711. * This helps adding a mirror texture on the ground.
  49712. */
  49713. reflectionFresnel: boolean;
  49714. protected _reflectionFalloffDistance: number;
  49715. /**
  49716. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49717. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49718. */
  49719. reflectionFalloffDistance: number;
  49720. protected _reflectionAmount: number;
  49721. /**
  49722. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49723. */
  49724. reflectionAmount: number;
  49725. protected _reflectionReflectance0: number;
  49726. /**
  49727. * This specifies the weight of the reflection at grazing angle.
  49728. */
  49729. reflectionReflectance0: number;
  49730. protected _reflectionReflectance90: number;
  49731. /**
  49732. * This specifies the weight of the reflection at a perpendicular point of view.
  49733. */
  49734. reflectionReflectance90: number;
  49735. /**
  49736. * Sets the reflection reflectance fresnel values according to the default standard
  49737. * empirically know to work well :-)
  49738. */
  49739. reflectionStandardFresnelWeight: number;
  49740. protected _useRGBColor: boolean;
  49741. /**
  49742. * Helps to directly use the maps channels instead of their level.
  49743. */
  49744. useRGBColor: boolean;
  49745. protected _enableNoise: boolean;
  49746. /**
  49747. * This helps reducing the banding effect that could occur on the background.
  49748. */
  49749. enableNoise: boolean;
  49750. /**
  49751. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49752. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49753. * Recommended to be keep at 1.0 except for special cases.
  49754. */
  49755. fovMultiplier: number;
  49756. private _fovMultiplier;
  49757. /**
  49758. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49759. */
  49760. useEquirectangularFOV: boolean;
  49761. private _maxSimultaneousLights;
  49762. /**
  49763. * Number of Simultaneous lights allowed on the material.
  49764. */
  49765. maxSimultaneousLights: int;
  49766. /**
  49767. * Default configuration related to image processing available in the Background Material.
  49768. */
  49769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49770. /**
  49771. * Keep track of the image processing observer to allow dispose and replace.
  49772. */
  49773. private _imageProcessingObserver;
  49774. /**
  49775. * Attaches a new image processing configuration to the PBR Material.
  49776. * @param configuration (if null the scene configuration will be use)
  49777. */
  49778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49779. /**
  49780. * Gets the image processing configuration used either in this material.
  49781. */
  49782. /**
  49783. * Sets the Default image processing configuration used either in the this material.
  49784. *
  49785. * If sets to null, the scene one is in use.
  49786. */
  49787. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49788. /**
  49789. * Gets wether the color curves effect is enabled.
  49790. */
  49791. /**
  49792. * Sets wether the color curves effect is enabled.
  49793. */
  49794. cameraColorCurvesEnabled: boolean;
  49795. /**
  49796. * Gets wether the color grading effect is enabled.
  49797. */
  49798. /**
  49799. * Gets wether the color grading effect is enabled.
  49800. */
  49801. cameraColorGradingEnabled: boolean;
  49802. /**
  49803. * Gets wether tonemapping is enabled or not.
  49804. */
  49805. /**
  49806. * Sets wether tonemapping is enabled or not
  49807. */
  49808. cameraToneMappingEnabled: boolean;
  49809. /**
  49810. * The camera exposure used on this material.
  49811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49812. * This corresponds to a photographic exposure.
  49813. */
  49814. /**
  49815. * The camera exposure used on this material.
  49816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49817. * This corresponds to a photographic exposure.
  49818. */
  49819. cameraExposure: float;
  49820. /**
  49821. * Gets The camera contrast used on this material.
  49822. */
  49823. /**
  49824. * Sets The camera contrast used on this material.
  49825. */
  49826. cameraContrast: float;
  49827. /**
  49828. * Gets the Color Grading 2D Lookup Texture.
  49829. */
  49830. /**
  49831. * Sets the Color Grading 2D Lookup Texture.
  49832. */
  49833. cameraColorGradingTexture: Nullable<BaseTexture>;
  49834. /**
  49835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49837. * 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;
  49838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49839. */
  49840. /**
  49841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49843. * 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;
  49844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49845. */
  49846. cameraColorCurves: Nullable<ColorCurves>;
  49847. /**
  49848. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49849. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49850. */
  49851. switchToBGR: boolean;
  49852. private _renderTargets;
  49853. private _reflectionControls;
  49854. private _white;
  49855. private _primaryShadowColor;
  49856. private _primaryHighlightColor;
  49857. /**
  49858. * Instantiates a Background Material in the given scene
  49859. * @param name The friendly name of the material
  49860. * @param scene The scene to add the material to
  49861. */
  49862. constructor(name: string, scene: Scene);
  49863. /**
  49864. * Gets a boolean indicating that current material needs to register RTT
  49865. */
  49866. readonly hasRenderTargetTextures: boolean;
  49867. /**
  49868. * The entire material has been created in order to prevent overdraw.
  49869. * @returns false
  49870. */
  49871. needAlphaTesting(): boolean;
  49872. /**
  49873. * The entire material has been created in order to prevent overdraw.
  49874. * @returns true if blending is enable
  49875. */
  49876. needAlphaBlending(): boolean;
  49877. /**
  49878. * Checks wether the material is ready to be rendered for a given mesh.
  49879. * @param mesh The mesh to render
  49880. * @param subMesh The submesh to check against
  49881. * @param useInstances Specify wether or not the material is used with instances
  49882. * @returns true if all the dependencies are ready (Textures, Effects...)
  49883. */
  49884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49885. /**
  49886. * Compute the primary color according to the chosen perceptual color.
  49887. */
  49888. private _computePrimaryColorFromPerceptualColor;
  49889. /**
  49890. * Compute the highlights and shadow colors according to their chosen levels.
  49891. */
  49892. private _computePrimaryColors;
  49893. /**
  49894. * Build the uniform buffer used in the material.
  49895. */
  49896. buildUniformLayout(): void;
  49897. /**
  49898. * Unbind the material.
  49899. */
  49900. unbind(): void;
  49901. /**
  49902. * Bind only the world matrix to the material.
  49903. * @param world The world matrix to bind.
  49904. */
  49905. bindOnlyWorldMatrix(world: Matrix): void;
  49906. /**
  49907. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49908. * @param world The world matrix to bind.
  49909. * @param subMesh The submesh to bind for.
  49910. */
  49911. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49912. /**
  49913. * Checks to see if a texture is used in the material.
  49914. * @param texture - Base texture to use.
  49915. * @returns - Boolean specifying if a texture is used in the material.
  49916. */
  49917. hasTexture(texture: BaseTexture): boolean;
  49918. /**
  49919. * Dispose the material.
  49920. * @param forceDisposeEffect Force disposal of the associated effect.
  49921. * @param forceDisposeTextures Force disposal of the associated textures.
  49922. */
  49923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49924. /**
  49925. * Clones the material.
  49926. * @param name The cloned name.
  49927. * @returns The cloned material.
  49928. */
  49929. clone(name: string): BackgroundMaterial;
  49930. /**
  49931. * Serializes the current material to its JSON representation.
  49932. * @returns The JSON representation.
  49933. */
  49934. serialize(): any;
  49935. /**
  49936. * Gets the class name of the material
  49937. * @returns "BackgroundMaterial"
  49938. */
  49939. getClassName(): string;
  49940. /**
  49941. * Parse a JSON input to create back a background material.
  49942. * @param source The JSON data to parse
  49943. * @param scene The scene to create the parsed material in
  49944. * @param rootUrl The root url of the assets the material depends upon
  49945. * @returns the instantiated BackgroundMaterial.
  49946. */
  49947. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49948. }
  49949. }
  49950. declare module "babylonjs/Helpers/environmentHelper" {
  49951. import { Observable } from "babylonjs/Misc/observable";
  49952. import { Nullable } from "babylonjs/types";
  49953. import { Scene } from "babylonjs/scene";
  49954. import { Vector3 } from "babylonjs/Maths/math.vector";
  49955. import { Color3 } from "babylonjs/Maths/math.color";
  49956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49957. import { Mesh } from "babylonjs/Meshes/mesh";
  49958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49959. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49960. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49961. import "babylonjs/Meshes/Builders/planeBuilder";
  49962. import "babylonjs/Meshes/Builders/boxBuilder";
  49963. /**
  49964. * Represents the different options available during the creation of
  49965. * a Environment helper.
  49966. *
  49967. * This can control the default ground, skybox and image processing setup of your scene.
  49968. */
  49969. export interface IEnvironmentHelperOptions {
  49970. /**
  49971. * Specifies wether or not to create a ground.
  49972. * True by default.
  49973. */
  49974. createGround: boolean;
  49975. /**
  49976. * Specifies the ground size.
  49977. * 15 by default.
  49978. */
  49979. groundSize: number;
  49980. /**
  49981. * The texture used on the ground for the main color.
  49982. * Comes from the BabylonJS CDN by default.
  49983. *
  49984. * Remarks: Can be either a texture or a url.
  49985. */
  49986. groundTexture: string | BaseTexture;
  49987. /**
  49988. * The color mixed in the ground texture by default.
  49989. * BabylonJS clearColor by default.
  49990. */
  49991. groundColor: Color3;
  49992. /**
  49993. * Specifies the ground opacity.
  49994. * 1 by default.
  49995. */
  49996. groundOpacity: number;
  49997. /**
  49998. * Enables the ground to receive shadows.
  49999. * True by default.
  50000. */
  50001. enableGroundShadow: boolean;
  50002. /**
  50003. * Helps preventing the shadow to be fully black on the ground.
  50004. * 0.5 by default.
  50005. */
  50006. groundShadowLevel: number;
  50007. /**
  50008. * Creates a mirror texture attach to the ground.
  50009. * false by default.
  50010. */
  50011. enableGroundMirror: boolean;
  50012. /**
  50013. * Specifies the ground mirror size ratio.
  50014. * 0.3 by default as the default kernel is 64.
  50015. */
  50016. groundMirrorSizeRatio: number;
  50017. /**
  50018. * Specifies the ground mirror blur kernel size.
  50019. * 64 by default.
  50020. */
  50021. groundMirrorBlurKernel: number;
  50022. /**
  50023. * Specifies the ground mirror visibility amount.
  50024. * 1 by default
  50025. */
  50026. groundMirrorAmount: number;
  50027. /**
  50028. * Specifies the ground mirror reflectance weight.
  50029. * This uses the standard weight of the background material to setup the fresnel effect
  50030. * of the mirror.
  50031. * 1 by default.
  50032. */
  50033. groundMirrorFresnelWeight: number;
  50034. /**
  50035. * Specifies the ground mirror Falloff distance.
  50036. * This can helps reducing the size of the reflection.
  50037. * 0 by Default.
  50038. */
  50039. groundMirrorFallOffDistance: number;
  50040. /**
  50041. * Specifies the ground mirror texture type.
  50042. * Unsigned Int by Default.
  50043. */
  50044. groundMirrorTextureType: number;
  50045. /**
  50046. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50047. * the shown objects.
  50048. */
  50049. groundYBias: number;
  50050. /**
  50051. * Specifies wether or not to create a skybox.
  50052. * True by default.
  50053. */
  50054. createSkybox: boolean;
  50055. /**
  50056. * Specifies the skybox size.
  50057. * 20 by default.
  50058. */
  50059. skyboxSize: number;
  50060. /**
  50061. * The texture used on the skybox for the main color.
  50062. * Comes from the BabylonJS CDN by default.
  50063. *
  50064. * Remarks: Can be either a texture or a url.
  50065. */
  50066. skyboxTexture: string | BaseTexture;
  50067. /**
  50068. * The color mixed in the skybox texture by default.
  50069. * BabylonJS clearColor by default.
  50070. */
  50071. skyboxColor: Color3;
  50072. /**
  50073. * The background rotation around the Y axis of the scene.
  50074. * This helps aligning the key lights of your scene with the background.
  50075. * 0 by default.
  50076. */
  50077. backgroundYRotation: number;
  50078. /**
  50079. * Compute automatically the size of the elements to best fit with the scene.
  50080. */
  50081. sizeAuto: boolean;
  50082. /**
  50083. * Default position of the rootMesh if autoSize is not true.
  50084. */
  50085. rootPosition: Vector3;
  50086. /**
  50087. * Sets up the image processing in the scene.
  50088. * true by default.
  50089. */
  50090. setupImageProcessing: boolean;
  50091. /**
  50092. * The texture used as your environment texture in the scene.
  50093. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50094. *
  50095. * Remarks: Can be either a texture or a url.
  50096. */
  50097. environmentTexture: string | BaseTexture;
  50098. /**
  50099. * The value of the exposure to apply to the scene.
  50100. * 0.6 by default if setupImageProcessing is true.
  50101. */
  50102. cameraExposure: number;
  50103. /**
  50104. * The value of the contrast to apply to the scene.
  50105. * 1.6 by default if setupImageProcessing is true.
  50106. */
  50107. cameraContrast: number;
  50108. /**
  50109. * Specifies wether or not tonemapping should be enabled in the scene.
  50110. * true by default if setupImageProcessing is true.
  50111. */
  50112. toneMappingEnabled: boolean;
  50113. }
  50114. /**
  50115. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50116. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50117. * It also helps with the default setup of your imageProcessing configuration.
  50118. */
  50119. export class EnvironmentHelper {
  50120. /**
  50121. * Default ground texture URL.
  50122. */
  50123. private static _groundTextureCDNUrl;
  50124. /**
  50125. * Default skybox texture URL.
  50126. */
  50127. private static _skyboxTextureCDNUrl;
  50128. /**
  50129. * Default environment texture URL.
  50130. */
  50131. private static _environmentTextureCDNUrl;
  50132. /**
  50133. * Creates the default options for the helper.
  50134. */
  50135. private static _getDefaultOptions;
  50136. private _rootMesh;
  50137. /**
  50138. * Gets the root mesh created by the helper.
  50139. */
  50140. readonly rootMesh: Mesh;
  50141. private _skybox;
  50142. /**
  50143. * Gets the skybox created by the helper.
  50144. */
  50145. readonly skybox: Nullable<Mesh>;
  50146. private _skyboxTexture;
  50147. /**
  50148. * Gets the skybox texture created by the helper.
  50149. */
  50150. readonly skyboxTexture: Nullable<BaseTexture>;
  50151. private _skyboxMaterial;
  50152. /**
  50153. * Gets the skybox material created by the helper.
  50154. */
  50155. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  50156. private _ground;
  50157. /**
  50158. * Gets the ground mesh created by the helper.
  50159. */
  50160. readonly ground: Nullable<Mesh>;
  50161. private _groundTexture;
  50162. /**
  50163. * Gets the ground texture created by the helper.
  50164. */
  50165. readonly groundTexture: Nullable<BaseTexture>;
  50166. private _groundMirror;
  50167. /**
  50168. * Gets the ground mirror created by the helper.
  50169. */
  50170. readonly groundMirror: Nullable<MirrorTexture>;
  50171. /**
  50172. * Gets the ground mirror render list to helps pushing the meshes
  50173. * you wish in the ground reflection.
  50174. */
  50175. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  50176. private _groundMaterial;
  50177. /**
  50178. * Gets the ground material created by the helper.
  50179. */
  50180. readonly groundMaterial: Nullable<BackgroundMaterial>;
  50181. /**
  50182. * Stores the creation options.
  50183. */
  50184. private readonly _scene;
  50185. private _options;
  50186. /**
  50187. * This observable will be notified with any error during the creation of the environment,
  50188. * mainly texture creation errors.
  50189. */
  50190. onErrorObservable: Observable<{
  50191. message?: string;
  50192. exception?: any;
  50193. }>;
  50194. /**
  50195. * constructor
  50196. * @param options Defines the options we want to customize the helper
  50197. * @param scene The scene to add the material to
  50198. */
  50199. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50200. /**
  50201. * Updates the background according to the new options
  50202. * @param options
  50203. */
  50204. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50205. /**
  50206. * Sets the primary color of all the available elements.
  50207. * @param color the main color to affect to the ground and the background
  50208. */
  50209. setMainColor(color: Color3): void;
  50210. /**
  50211. * Setup the image processing according to the specified options.
  50212. */
  50213. private _setupImageProcessing;
  50214. /**
  50215. * Setup the environment texture according to the specified options.
  50216. */
  50217. private _setupEnvironmentTexture;
  50218. /**
  50219. * Setup the background according to the specified options.
  50220. */
  50221. private _setupBackground;
  50222. /**
  50223. * Get the scene sizes according to the setup.
  50224. */
  50225. private _getSceneSize;
  50226. /**
  50227. * Setup the ground according to the specified options.
  50228. */
  50229. private _setupGround;
  50230. /**
  50231. * Setup the ground material according to the specified options.
  50232. */
  50233. private _setupGroundMaterial;
  50234. /**
  50235. * Setup the ground diffuse texture according to the specified options.
  50236. */
  50237. private _setupGroundDiffuseTexture;
  50238. /**
  50239. * Setup the ground mirror texture according to the specified options.
  50240. */
  50241. private _setupGroundMirrorTexture;
  50242. /**
  50243. * Setup the ground to receive the mirror texture.
  50244. */
  50245. private _setupMirrorInGroundMaterial;
  50246. /**
  50247. * Setup the skybox according to the specified options.
  50248. */
  50249. private _setupSkybox;
  50250. /**
  50251. * Setup the skybox material according to the specified options.
  50252. */
  50253. private _setupSkyboxMaterial;
  50254. /**
  50255. * Setup the skybox reflection texture according to the specified options.
  50256. */
  50257. private _setupSkyboxReflectionTexture;
  50258. private _errorHandler;
  50259. /**
  50260. * Dispose all the elements created by the Helper.
  50261. */
  50262. dispose(): void;
  50263. }
  50264. }
  50265. declare module "babylonjs/Helpers/photoDome" {
  50266. import { Observable } from "babylonjs/Misc/observable";
  50267. import { Nullable } from "babylonjs/types";
  50268. import { Scene } from "babylonjs/scene";
  50269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50270. import { Mesh } from "babylonjs/Meshes/mesh";
  50271. import { Texture } from "babylonjs/Materials/Textures/texture";
  50272. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50273. import "babylonjs/Meshes/Builders/sphereBuilder";
  50274. /**
  50275. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50276. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50277. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50278. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50279. */
  50280. export class PhotoDome extends TransformNode {
  50281. /**
  50282. * Define the image as a Monoscopic panoramic 360 image.
  50283. */
  50284. static readonly MODE_MONOSCOPIC: number;
  50285. /**
  50286. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50287. */
  50288. static readonly MODE_TOPBOTTOM: number;
  50289. /**
  50290. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50291. */
  50292. static readonly MODE_SIDEBYSIDE: number;
  50293. private _useDirectMapping;
  50294. /**
  50295. * The texture being displayed on the sphere
  50296. */
  50297. protected _photoTexture: Texture;
  50298. /**
  50299. * Gets or sets the texture being displayed on the sphere
  50300. */
  50301. photoTexture: Texture;
  50302. /**
  50303. * Observable raised when an error occured while loading the 360 image
  50304. */
  50305. onLoadErrorObservable: Observable<string>;
  50306. /**
  50307. * The skybox material
  50308. */
  50309. protected _material: BackgroundMaterial;
  50310. /**
  50311. * The surface used for the skybox
  50312. */
  50313. protected _mesh: Mesh;
  50314. /**
  50315. * Gets the mesh used for the skybox.
  50316. */
  50317. readonly mesh: Mesh;
  50318. /**
  50319. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50320. * Also see the options.resolution property.
  50321. */
  50322. fovMultiplier: number;
  50323. private _imageMode;
  50324. /**
  50325. * Gets or set the current video mode for the video. It can be:
  50326. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50327. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50328. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50329. */
  50330. imageMode: number;
  50331. /**
  50332. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50333. * @param name Element's name, child elements will append suffixes for their own names.
  50334. * @param urlsOfPhoto defines the url of the photo to display
  50335. * @param options defines an object containing optional or exposed sub element properties
  50336. * @param onError defines a callback called when an error occured while loading the texture
  50337. */
  50338. constructor(name: string, urlOfPhoto: string, options: {
  50339. resolution?: number;
  50340. size?: number;
  50341. useDirectMapping?: boolean;
  50342. faceForward?: boolean;
  50343. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50344. private _onBeforeCameraRenderObserver;
  50345. private _changeImageMode;
  50346. /**
  50347. * Releases resources associated with this node.
  50348. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50349. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50350. */
  50351. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50352. }
  50353. }
  50354. declare module "babylonjs/Misc/rgbdTextureTools" {
  50355. import "babylonjs/Shaders/rgbdDecode.fragment";
  50356. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50357. import { Texture } from "babylonjs/Materials/Textures/texture";
  50358. /**
  50359. * Class used to host RGBD texture specific utilities
  50360. */
  50361. export class RGBDTextureTools {
  50362. /**
  50363. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50364. * @param texture the texture to expand.
  50365. */
  50366. static ExpandRGBDTexture(texture: Texture): void;
  50367. }
  50368. }
  50369. declare module "babylonjs/Misc/brdfTextureTools" {
  50370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50371. import { Scene } from "babylonjs/scene";
  50372. /**
  50373. * Class used to host texture specific utilities
  50374. */
  50375. export class BRDFTextureTools {
  50376. /**
  50377. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50378. * @param scene defines the hosting scene
  50379. * @returns the environment BRDF texture
  50380. */
  50381. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50382. private static _environmentBRDFBase64Texture;
  50383. }
  50384. }
  50385. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50386. import { Nullable } from "babylonjs/types";
  50387. import { Color3 } from "babylonjs/Maths/math.color";
  50388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50390. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50391. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50392. import { Engine } from "babylonjs/Engines/engine";
  50393. import { Scene } from "babylonjs/scene";
  50394. /**
  50395. * @hidden
  50396. */
  50397. export interface IMaterialClearCoatDefines {
  50398. CLEARCOAT: boolean;
  50399. CLEARCOAT_DEFAULTIOR: boolean;
  50400. CLEARCOAT_TEXTURE: boolean;
  50401. CLEARCOAT_TEXTUREDIRECTUV: number;
  50402. CLEARCOAT_BUMP: boolean;
  50403. CLEARCOAT_BUMPDIRECTUV: number;
  50404. CLEARCOAT_TINT: boolean;
  50405. CLEARCOAT_TINT_TEXTURE: boolean;
  50406. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50407. /** @hidden */
  50408. _areTexturesDirty: boolean;
  50409. }
  50410. /**
  50411. * Define the code related to the clear coat parameters of the pbr material.
  50412. */
  50413. export class PBRClearCoatConfiguration {
  50414. /**
  50415. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50416. * The default fits with a polyurethane material.
  50417. */
  50418. private static readonly _DefaultIndexOfRefraction;
  50419. private _isEnabled;
  50420. /**
  50421. * Defines if the clear coat is enabled in the material.
  50422. */
  50423. isEnabled: boolean;
  50424. /**
  50425. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50426. */
  50427. intensity: number;
  50428. /**
  50429. * Defines the clear coat layer roughness.
  50430. */
  50431. roughness: number;
  50432. private _indexOfRefraction;
  50433. /**
  50434. * Defines the index of refraction of the clear coat.
  50435. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50436. * The default fits with a polyurethane material.
  50437. * Changing the default value is more performance intensive.
  50438. */
  50439. indexOfRefraction: number;
  50440. private _texture;
  50441. /**
  50442. * Stores the clear coat values in a texture.
  50443. */
  50444. texture: Nullable<BaseTexture>;
  50445. private _bumpTexture;
  50446. /**
  50447. * Define the clear coat specific bump texture.
  50448. */
  50449. bumpTexture: Nullable<BaseTexture>;
  50450. private _isTintEnabled;
  50451. /**
  50452. * Defines if the clear coat tint is enabled in the material.
  50453. */
  50454. isTintEnabled: boolean;
  50455. /**
  50456. * Defines the clear coat tint of the material.
  50457. * This is only use if tint is enabled
  50458. */
  50459. tintColor: Color3;
  50460. /**
  50461. * Defines the distance at which the tint color should be found in the
  50462. * clear coat media.
  50463. * This is only use if tint is enabled
  50464. */
  50465. tintColorAtDistance: number;
  50466. /**
  50467. * Defines the clear coat layer thickness.
  50468. * This is only use if tint is enabled
  50469. */
  50470. tintThickness: number;
  50471. private _tintTexture;
  50472. /**
  50473. * Stores the clear tint values in a texture.
  50474. * rgb is tint
  50475. * a is a thickness factor
  50476. */
  50477. tintTexture: Nullable<BaseTexture>;
  50478. /** @hidden */
  50479. private _internalMarkAllSubMeshesAsTexturesDirty;
  50480. /** @hidden */
  50481. _markAllSubMeshesAsTexturesDirty(): void;
  50482. /**
  50483. * Instantiate a new istance of clear coat configuration.
  50484. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50485. */
  50486. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50487. /**
  50488. * Gets wehter the submesh is ready to be used or not.
  50489. * @param defines the list of "defines" to update.
  50490. * @param scene defines the scene the material belongs to.
  50491. * @param engine defines the engine the material belongs to.
  50492. * @param disableBumpMap defines wether the material disables bump or not.
  50493. * @returns - boolean indicating that the submesh is ready or not.
  50494. */
  50495. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50496. /**
  50497. * Checks to see if a texture is used in the material.
  50498. * @param defines the list of "defines" to update.
  50499. * @param scene defines the scene to the material belongs to.
  50500. */
  50501. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50502. /**
  50503. * Binds the material data.
  50504. * @param uniformBuffer defines the Uniform buffer to fill in.
  50505. * @param scene defines the scene the material belongs to.
  50506. * @param engine defines the engine the material belongs to.
  50507. * @param disableBumpMap defines wether the material disables bump or not.
  50508. * @param isFrozen defines wether the material is frozen or not.
  50509. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50510. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50511. */
  50512. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50513. /**
  50514. * Checks to see if a texture is used in the material.
  50515. * @param texture - Base texture to use.
  50516. * @returns - Boolean specifying if a texture is used in the material.
  50517. */
  50518. hasTexture(texture: BaseTexture): boolean;
  50519. /**
  50520. * Returns an array of the actively used textures.
  50521. * @param activeTextures Array of BaseTextures
  50522. */
  50523. getActiveTextures(activeTextures: BaseTexture[]): void;
  50524. /**
  50525. * Returns the animatable textures.
  50526. * @param animatables Array of animatable textures.
  50527. */
  50528. getAnimatables(animatables: IAnimatable[]): void;
  50529. /**
  50530. * Disposes the resources of the material.
  50531. * @param forceDisposeTextures - Forces the disposal of all textures.
  50532. */
  50533. dispose(forceDisposeTextures?: boolean): void;
  50534. /**
  50535. * Get the current class name of the texture useful for serialization or dynamic coding.
  50536. * @returns "PBRClearCoatConfiguration"
  50537. */
  50538. getClassName(): string;
  50539. /**
  50540. * Add fallbacks to the effect fallbacks list.
  50541. * @param defines defines the Base texture to use.
  50542. * @param fallbacks defines the current fallback list.
  50543. * @param currentRank defines the current fallback rank.
  50544. * @returns the new fallback rank.
  50545. */
  50546. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50547. /**
  50548. * Add the required uniforms to the current list.
  50549. * @param uniforms defines the current uniform list.
  50550. */
  50551. static AddUniforms(uniforms: string[]): void;
  50552. /**
  50553. * Add the required samplers to the current list.
  50554. * @param samplers defines the current sampler list.
  50555. */
  50556. static AddSamplers(samplers: string[]): void;
  50557. /**
  50558. * Add the required uniforms to the current buffer.
  50559. * @param uniformBuffer defines the current uniform buffer.
  50560. */
  50561. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50562. /**
  50563. * Makes a duplicate of the current configuration into another one.
  50564. * @param clearCoatConfiguration define the config where to copy the info
  50565. */
  50566. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50567. /**
  50568. * Serializes this clear coat configuration.
  50569. * @returns - An object with the serialized config.
  50570. */
  50571. serialize(): any;
  50572. /**
  50573. * Parses a anisotropy Configuration from a serialized object.
  50574. * @param source - Serialized object.
  50575. * @param scene Defines the scene we are parsing for
  50576. * @param rootUrl Defines the rootUrl to load from
  50577. */
  50578. parse(source: any, scene: Scene, rootUrl: string): void;
  50579. }
  50580. }
  50581. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  50582. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50584. import { Vector2 } from "babylonjs/Maths/math.vector";
  50585. import { Scene } from "babylonjs/scene";
  50586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50587. import { Nullable } from "babylonjs/types";
  50588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50589. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50590. /**
  50591. * @hidden
  50592. */
  50593. export interface IMaterialAnisotropicDefines {
  50594. ANISOTROPIC: boolean;
  50595. ANISOTROPIC_TEXTURE: boolean;
  50596. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50597. MAINUV1: boolean;
  50598. _areTexturesDirty: boolean;
  50599. _needUVs: boolean;
  50600. }
  50601. /**
  50602. * Define the code related to the anisotropic parameters of the pbr material.
  50603. */
  50604. export class PBRAnisotropicConfiguration {
  50605. private _isEnabled;
  50606. /**
  50607. * Defines if the anisotropy is enabled in the material.
  50608. */
  50609. isEnabled: boolean;
  50610. /**
  50611. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50612. */
  50613. intensity: number;
  50614. /**
  50615. * Defines if the effect is along the tangents, bitangents or in between.
  50616. * By default, the effect is "strectching" the highlights along the tangents.
  50617. */
  50618. direction: Vector2;
  50619. private _texture;
  50620. /**
  50621. * Stores the anisotropy values in a texture.
  50622. * rg is direction (like normal from -1 to 1)
  50623. * b is a intensity
  50624. */
  50625. texture: Nullable<BaseTexture>;
  50626. /** @hidden */
  50627. private _internalMarkAllSubMeshesAsTexturesDirty;
  50628. /** @hidden */
  50629. _markAllSubMeshesAsTexturesDirty(): void;
  50630. /**
  50631. * Instantiate a new istance of anisotropy configuration.
  50632. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50633. */
  50634. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50635. /**
  50636. * Specifies that the submesh is ready to be used.
  50637. * @param defines the list of "defines" to update.
  50638. * @param scene defines the scene the material belongs to.
  50639. * @returns - boolean indicating that the submesh is ready or not.
  50640. */
  50641. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50642. /**
  50643. * Checks to see if a texture is used in the material.
  50644. * @param defines the list of "defines" to update.
  50645. * @param mesh the mesh we are preparing the defines for.
  50646. * @param scene defines the scene the material belongs to.
  50647. */
  50648. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50649. /**
  50650. * Binds the material data.
  50651. * @param uniformBuffer defines the Uniform buffer to fill in.
  50652. * @param scene defines the scene the material belongs to.
  50653. * @param isFrozen defines wether the material is frozen or not.
  50654. */
  50655. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50656. /**
  50657. * Checks to see if a texture is used in the material.
  50658. * @param texture - Base texture to use.
  50659. * @returns - Boolean specifying if a texture is used in the material.
  50660. */
  50661. hasTexture(texture: BaseTexture): boolean;
  50662. /**
  50663. * Returns an array of the actively used textures.
  50664. * @param activeTextures Array of BaseTextures
  50665. */
  50666. getActiveTextures(activeTextures: BaseTexture[]): void;
  50667. /**
  50668. * Returns the animatable textures.
  50669. * @param animatables Array of animatable textures.
  50670. */
  50671. getAnimatables(animatables: IAnimatable[]): void;
  50672. /**
  50673. * Disposes the resources of the material.
  50674. * @param forceDisposeTextures - Forces the disposal of all textures.
  50675. */
  50676. dispose(forceDisposeTextures?: boolean): void;
  50677. /**
  50678. * Get the current class name of the texture useful for serialization or dynamic coding.
  50679. * @returns "PBRAnisotropicConfiguration"
  50680. */
  50681. getClassName(): string;
  50682. /**
  50683. * Add fallbacks to the effect fallbacks list.
  50684. * @param defines defines the Base texture to use.
  50685. * @param fallbacks defines the current fallback list.
  50686. * @param currentRank defines the current fallback rank.
  50687. * @returns the new fallback rank.
  50688. */
  50689. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50690. /**
  50691. * Add the required uniforms to the current list.
  50692. * @param uniforms defines the current uniform list.
  50693. */
  50694. static AddUniforms(uniforms: string[]): void;
  50695. /**
  50696. * Add the required uniforms to the current buffer.
  50697. * @param uniformBuffer defines the current uniform buffer.
  50698. */
  50699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50700. /**
  50701. * Add the required samplers to the current list.
  50702. * @param samplers defines the current sampler list.
  50703. */
  50704. static AddSamplers(samplers: string[]): void;
  50705. /**
  50706. * Makes a duplicate of the current configuration into another one.
  50707. * @param anisotropicConfiguration define the config where to copy the info
  50708. */
  50709. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50710. /**
  50711. * Serializes this anisotropy configuration.
  50712. * @returns - An object with the serialized config.
  50713. */
  50714. serialize(): any;
  50715. /**
  50716. * Parses a anisotropy Configuration from a serialized object.
  50717. * @param source - Serialized object.
  50718. * @param scene Defines the scene we are parsing for
  50719. * @param rootUrl Defines the rootUrl to load from
  50720. */
  50721. parse(source: any, scene: Scene, rootUrl: string): void;
  50722. }
  50723. }
  50724. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  50725. import { Scene } from "babylonjs/scene";
  50726. /**
  50727. * @hidden
  50728. */
  50729. export interface IMaterialBRDFDefines {
  50730. BRDF_V_HEIGHT_CORRELATED: boolean;
  50731. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50732. SPHERICAL_HARMONICS: boolean;
  50733. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50734. /** @hidden */
  50735. _areMiscDirty: boolean;
  50736. }
  50737. /**
  50738. * Define the code related to the BRDF parameters of the pbr material.
  50739. */
  50740. export class PBRBRDFConfiguration {
  50741. /**
  50742. * Default value used for the energy conservation.
  50743. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50744. */
  50745. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50746. /**
  50747. * Default value used for the Smith Visibility Height Correlated mode.
  50748. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50749. */
  50750. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50751. /**
  50752. * Default value used for the IBL diffuse part.
  50753. * This can help switching back to the polynomials mode globally which is a tiny bit
  50754. * less GPU intensive at the drawback of a lower quality.
  50755. */
  50756. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50757. /**
  50758. * Default value used for activating energy conservation for the specular workflow.
  50759. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50760. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50761. */
  50762. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50763. private _useEnergyConservation;
  50764. /**
  50765. * Defines if the material uses energy conservation.
  50766. */
  50767. useEnergyConservation: boolean;
  50768. private _useSmithVisibilityHeightCorrelated;
  50769. /**
  50770. * LEGACY Mode set to false
  50771. * Defines if the material uses height smith correlated visibility term.
  50772. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50773. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50774. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50775. * Not relying on height correlated will also disable energy conservation.
  50776. */
  50777. useSmithVisibilityHeightCorrelated: boolean;
  50778. private _useSphericalHarmonics;
  50779. /**
  50780. * LEGACY Mode set to false
  50781. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50782. * diffuse part of the IBL.
  50783. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50784. * to the ground truth.
  50785. */
  50786. useSphericalHarmonics: boolean;
  50787. private _useSpecularGlossinessInputEnergyConservation;
  50788. /**
  50789. * Defines if the material uses energy conservation, when the specular workflow is active.
  50790. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50791. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50792. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50793. */
  50794. useSpecularGlossinessInputEnergyConservation: boolean;
  50795. /** @hidden */
  50796. private _internalMarkAllSubMeshesAsMiscDirty;
  50797. /** @hidden */
  50798. _markAllSubMeshesAsMiscDirty(): void;
  50799. /**
  50800. * Instantiate a new istance of clear coat configuration.
  50801. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50802. */
  50803. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50804. /**
  50805. * Checks to see if a texture is used in the material.
  50806. * @param defines the list of "defines" to update.
  50807. */
  50808. prepareDefines(defines: IMaterialBRDFDefines): void;
  50809. /**
  50810. * Get the current class name of the texture useful for serialization or dynamic coding.
  50811. * @returns "PBRClearCoatConfiguration"
  50812. */
  50813. getClassName(): string;
  50814. /**
  50815. * Makes a duplicate of the current configuration into another one.
  50816. * @param brdfConfiguration define the config where to copy the info
  50817. */
  50818. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50819. /**
  50820. * Serializes this BRDF configuration.
  50821. * @returns - An object with the serialized config.
  50822. */
  50823. serialize(): any;
  50824. /**
  50825. * Parses a anisotropy Configuration from a serialized object.
  50826. * @param source - Serialized object.
  50827. * @param scene Defines the scene we are parsing for
  50828. * @param rootUrl Defines the rootUrl to load from
  50829. */
  50830. parse(source: any, scene: Scene, rootUrl: string): void;
  50831. }
  50832. }
  50833. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50834. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50835. import { Color3 } from "babylonjs/Maths/math.color";
  50836. import { Scene } from "babylonjs/scene";
  50837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50838. import { Nullable } from "babylonjs/types";
  50839. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50840. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50841. /**
  50842. * @hidden
  50843. */
  50844. export interface IMaterialSheenDefines {
  50845. SHEEN: boolean;
  50846. SHEEN_TEXTURE: boolean;
  50847. SHEEN_TEXTUREDIRECTUV: number;
  50848. SHEEN_LINKWITHALBEDO: boolean;
  50849. /** @hidden */
  50850. _areTexturesDirty: boolean;
  50851. }
  50852. /**
  50853. * Define the code related to the Sheen parameters of the pbr material.
  50854. */
  50855. export class PBRSheenConfiguration {
  50856. private _isEnabled;
  50857. /**
  50858. * Defines if the material uses sheen.
  50859. */
  50860. isEnabled: boolean;
  50861. private _linkSheenWithAlbedo;
  50862. /**
  50863. * Defines if the sheen is linked to the sheen color.
  50864. */
  50865. linkSheenWithAlbedo: boolean;
  50866. /**
  50867. * Defines the sheen intensity.
  50868. */
  50869. intensity: number;
  50870. /**
  50871. * Defines the sheen color.
  50872. */
  50873. color: Color3;
  50874. private _texture;
  50875. /**
  50876. * Stores the sheen tint values in a texture.
  50877. * rgb is tint
  50878. * a is a intensity
  50879. */
  50880. texture: Nullable<BaseTexture>;
  50881. /** @hidden */
  50882. private _internalMarkAllSubMeshesAsTexturesDirty;
  50883. /** @hidden */
  50884. _markAllSubMeshesAsTexturesDirty(): void;
  50885. /**
  50886. * Instantiate a new istance of clear coat configuration.
  50887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50888. */
  50889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50890. /**
  50891. * Specifies that the submesh is ready to be used.
  50892. * @param defines the list of "defines" to update.
  50893. * @param scene defines the scene the material belongs to.
  50894. * @returns - boolean indicating that the submesh is ready or not.
  50895. */
  50896. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50897. /**
  50898. * Checks to see if a texture is used in the material.
  50899. * @param defines the list of "defines" to update.
  50900. * @param scene defines the scene the material belongs to.
  50901. */
  50902. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50903. /**
  50904. * Binds the material data.
  50905. * @param uniformBuffer defines the Uniform buffer to fill in.
  50906. * @param scene defines the scene the material belongs to.
  50907. * @param isFrozen defines wether the material is frozen or not.
  50908. */
  50909. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50910. /**
  50911. * Checks to see if a texture is used in the material.
  50912. * @param texture - Base texture to use.
  50913. * @returns - Boolean specifying if a texture is used in the material.
  50914. */
  50915. hasTexture(texture: BaseTexture): boolean;
  50916. /**
  50917. * Returns an array of the actively used textures.
  50918. * @param activeTextures Array of BaseTextures
  50919. */
  50920. getActiveTextures(activeTextures: BaseTexture[]): void;
  50921. /**
  50922. * Returns the animatable textures.
  50923. * @param animatables Array of animatable textures.
  50924. */
  50925. getAnimatables(animatables: IAnimatable[]): void;
  50926. /**
  50927. * Disposes the resources of the material.
  50928. * @param forceDisposeTextures - Forces the disposal of all textures.
  50929. */
  50930. dispose(forceDisposeTextures?: boolean): void;
  50931. /**
  50932. * Get the current class name of the texture useful for serialization or dynamic coding.
  50933. * @returns "PBRSheenConfiguration"
  50934. */
  50935. getClassName(): string;
  50936. /**
  50937. * Add fallbacks to the effect fallbacks list.
  50938. * @param defines defines the Base texture to use.
  50939. * @param fallbacks defines the current fallback list.
  50940. * @param currentRank defines the current fallback rank.
  50941. * @returns the new fallback rank.
  50942. */
  50943. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50944. /**
  50945. * Add the required uniforms to the current list.
  50946. * @param uniforms defines the current uniform list.
  50947. */
  50948. static AddUniforms(uniforms: string[]): void;
  50949. /**
  50950. * Add the required uniforms to the current buffer.
  50951. * @param uniformBuffer defines the current uniform buffer.
  50952. */
  50953. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50954. /**
  50955. * Add the required samplers to the current list.
  50956. * @param samplers defines the current sampler list.
  50957. */
  50958. static AddSamplers(samplers: string[]): void;
  50959. /**
  50960. * Makes a duplicate of the current configuration into another one.
  50961. * @param sheenConfiguration define the config where to copy the info
  50962. */
  50963. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50964. /**
  50965. * Serializes this BRDF configuration.
  50966. * @returns - An object with the serialized config.
  50967. */
  50968. serialize(): any;
  50969. /**
  50970. * Parses a anisotropy Configuration from a serialized object.
  50971. * @param source - Serialized object.
  50972. * @param scene Defines the scene we are parsing for
  50973. * @param rootUrl Defines the rootUrl to load from
  50974. */
  50975. parse(source: any, scene: Scene, rootUrl: string): void;
  50976. }
  50977. }
  50978. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50979. import { Nullable } from "babylonjs/types";
  50980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50981. import { Color3 } from "babylonjs/Maths/math.color";
  50982. import { SmartArray } from "babylonjs/Misc/smartArray";
  50983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50984. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50985. import { Effect } from "babylonjs/Materials/effect";
  50986. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50987. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50988. import { Engine } from "babylonjs/Engines/engine";
  50989. import { Scene } from "babylonjs/scene";
  50990. /**
  50991. * @hidden
  50992. */
  50993. export interface IMaterialSubSurfaceDefines {
  50994. SUBSURFACE: boolean;
  50995. SS_REFRACTION: boolean;
  50996. SS_TRANSLUCENCY: boolean;
  50997. SS_SCATERRING: boolean;
  50998. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50999. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51000. SS_REFRACTIONMAP_3D: boolean;
  51001. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51002. SS_LODINREFRACTIONALPHA: boolean;
  51003. SS_GAMMAREFRACTION: boolean;
  51004. SS_RGBDREFRACTION: boolean;
  51005. SS_LINEARSPECULARREFRACTION: boolean;
  51006. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51007. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51008. /** @hidden */
  51009. _areTexturesDirty: boolean;
  51010. }
  51011. /**
  51012. * Define the code related to the sub surface parameters of the pbr material.
  51013. */
  51014. export class PBRSubSurfaceConfiguration {
  51015. private _isRefractionEnabled;
  51016. /**
  51017. * Defines if the refraction is enabled in the material.
  51018. */
  51019. isRefractionEnabled: boolean;
  51020. private _isTranslucencyEnabled;
  51021. /**
  51022. * Defines if the translucency is enabled in the material.
  51023. */
  51024. isTranslucencyEnabled: boolean;
  51025. private _isScatteringEnabled;
  51026. /**
  51027. * Defines the refraction intensity of the material.
  51028. * The refraction when enabled replaces the Diffuse part of the material.
  51029. * The intensity helps transitionning between diffuse and refraction.
  51030. */
  51031. refractionIntensity: number;
  51032. /**
  51033. * Defines the translucency intensity of the material.
  51034. * When translucency has been enabled, this defines how much of the "translucency"
  51035. * is addded to the diffuse part of the material.
  51036. */
  51037. translucencyIntensity: number;
  51038. /**
  51039. * Defines the scattering intensity of the material.
  51040. * When scattering has been enabled, this defines how much of the "scattered light"
  51041. * is addded to the diffuse part of the material.
  51042. */
  51043. scatteringIntensity: number;
  51044. private _thicknessTexture;
  51045. /**
  51046. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51047. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51048. * 0 would mean minimumThickness
  51049. * 1 would mean maximumThickness
  51050. * The other channels might be use as a mask to vary the different effects intensity.
  51051. */
  51052. thicknessTexture: Nullable<BaseTexture>;
  51053. private _refractionTexture;
  51054. /**
  51055. * Defines the texture to use for refraction.
  51056. */
  51057. refractionTexture: Nullable<BaseTexture>;
  51058. private _indexOfRefraction;
  51059. /**
  51060. * Defines the index of refraction used in the material.
  51061. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51062. */
  51063. indexOfRefraction: number;
  51064. private _invertRefractionY;
  51065. /**
  51066. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51067. */
  51068. invertRefractionY: boolean;
  51069. private _linkRefractionWithTransparency;
  51070. /**
  51071. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51072. * Materials half opaque for instance using refraction could benefit from this control.
  51073. */
  51074. linkRefractionWithTransparency: boolean;
  51075. /**
  51076. * Defines the minimum thickness stored in the thickness map.
  51077. * If no thickness map is defined, this value will be used to simulate thickness.
  51078. */
  51079. minimumThickness: number;
  51080. /**
  51081. * Defines the maximum thickness stored in the thickness map.
  51082. */
  51083. maximumThickness: number;
  51084. /**
  51085. * Defines the volume tint of the material.
  51086. * This is used for both translucency and scattering.
  51087. */
  51088. tintColor: Color3;
  51089. /**
  51090. * Defines the distance at which the tint color should be found in the media.
  51091. * This is used for refraction only.
  51092. */
  51093. tintColorAtDistance: number;
  51094. /**
  51095. * Defines how far each channel transmit through the media.
  51096. * It is defined as a color to simplify it selection.
  51097. */
  51098. diffusionDistance: Color3;
  51099. private _useMaskFromThicknessTexture;
  51100. /**
  51101. * Stores the intensity of the different subsurface effects in the thickness texture.
  51102. * * the green channel is the translucency intensity.
  51103. * * the blue channel is the scattering intensity.
  51104. * * the alpha channel is the refraction intensity.
  51105. */
  51106. useMaskFromThicknessTexture: boolean;
  51107. /** @hidden */
  51108. private _internalMarkAllSubMeshesAsTexturesDirty;
  51109. /** @hidden */
  51110. _markAllSubMeshesAsTexturesDirty(): void;
  51111. /**
  51112. * Instantiate a new istance of sub surface configuration.
  51113. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51114. */
  51115. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51116. /**
  51117. * Gets wehter the submesh is ready to be used or not.
  51118. * @param defines the list of "defines" to update.
  51119. * @param scene defines the scene the material belongs to.
  51120. * @returns - boolean indicating that the submesh is ready or not.
  51121. */
  51122. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51123. /**
  51124. * Checks to see if a texture is used in the material.
  51125. * @param defines the list of "defines" to update.
  51126. * @param scene defines the scene to the material belongs to.
  51127. */
  51128. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51129. /**
  51130. * Binds the material data.
  51131. * @param uniformBuffer defines the Uniform buffer to fill in.
  51132. * @param scene defines the scene the material belongs to.
  51133. * @param engine defines the engine the material belongs to.
  51134. * @param isFrozen defines wether the material is frozen or not.
  51135. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51136. */
  51137. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51138. /**
  51139. * Unbinds the material from the mesh.
  51140. * @param activeEffect defines the effect that should be unbound from.
  51141. * @returns true if unbound, otherwise false
  51142. */
  51143. unbind(activeEffect: Effect): boolean;
  51144. /**
  51145. * Returns the texture used for refraction or null if none is used.
  51146. * @param scene defines the scene the material belongs to.
  51147. * @returns - Refraction texture if present. If no refraction texture and refraction
  51148. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51149. */
  51150. private _getRefractionTexture;
  51151. /**
  51152. * Returns true if alpha blending should be disabled.
  51153. */
  51154. readonly disableAlphaBlending: boolean;
  51155. /**
  51156. * Fills the list of render target textures.
  51157. * @param renderTargets the list of render targets to update
  51158. */
  51159. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51160. /**
  51161. * Checks to see if a texture is used in the material.
  51162. * @param texture - Base texture to use.
  51163. * @returns - Boolean specifying if a texture is used in the material.
  51164. */
  51165. hasTexture(texture: BaseTexture): boolean;
  51166. /**
  51167. * Gets a boolean indicating that current material needs to register RTT
  51168. * @returns true if this uses a render target otherwise false.
  51169. */
  51170. hasRenderTargetTextures(): boolean;
  51171. /**
  51172. * Returns an array of the actively used textures.
  51173. * @param activeTextures Array of BaseTextures
  51174. */
  51175. getActiveTextures(activeTextures: BaseTexture[]): void;
  51176. /**
  51177. * Returns the animatable textures.
  51178. * @param animatables Array of animatable textures.
  51179. */
  51180. getAnimatables(animatables: IAnimatable[]): void;
  51181. /**
  51182. * Disposes the resources of the material.
  51183. * @param forceDisposeTextures - Forces the disposal of all textures.
  51184. */
  51185. dispose(forceDisposeTextures?: boolean): void;
  51186. /**
  51187. * Get the current class name of the texture useful for serialization or dynamic coding.
  51188. * @returns "PBRSubSurfaceConfiguration"
  51189. */
  51190. getClassName(): string;
  51191. /**
  51192. * Add fallbacks to the effect fallbacks list.
  51193. * @param defines defines the Base texture to use.
  51194. * @param fallbacks defines the current fallback list.
  51195. * @param currentRank defines the current fallback rank.
  51196. * @returns the new fallback rank.
  51197. */
  51198. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51199. /**
  51200. * Add the required uniforms to the current list.
  51201. * @param uniforms defines the current uniform list.
  51202. */
  51203. static AddUniforms(uniforms: string[]): void;
  51204. /**
  51205. * Add the required samplers to the current list.
  51206. * @param samplers defines the current sampler list.
  51207. */
  51208. static AddSamplers(samplers: string[]): void;
  51209. /**
  51210. * Add the required uniforms to the current buffer.
  51211. * @param uniformBuffer defines the current uniform buffer.
  51212. */
  51213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51214. /**
  51215. * Makes a duplicate of the current configuration into another one.
  51216. * @param configuration define the config where to copy the info
  51217. */
  51218. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51219. /**
  51220. * Serializes this Sub Surface configuration.
  51221. * @returns - An object with the serialized config.
  51222. */
  51223. serialize(): any;
  51224. /**
  51225. * Parses a anisotropy Configuration from a serialized object.
  51226. * @param source - Serialized object.
  51227. * @param scene Defines the scene we are parsing for
  51228. * @param rootUrl Defines the rootUrl to load from
  51229. */
  51230. parse(source: any, scene: Scene, rootUrl: string): void;
  51231. }
  51232. }
  51233. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51234. /** @hidden */
  51235. export var pbrFragmentDeclaration: {
  51236. name: string;
  51237. shader: string;
  51238. };
  51239. }
  51240. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51241. /** @hidden */
  51242. export var pbrUboDeclaration: {
  51243. name: string;
  51244. shader: string;
  51245. };
  51246. }
  51247. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51248. /** @hidden */
  51249. export var pbrFragmentExtraDeclaration: {
  51250. name: string;
  51251. shader: string;
  51252. };
  51253. }
  51254. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51255. /** @hidden */
  51256. export var pbrFragmentSamplersDeclaration: {
  51257. name: string;
  51258. shader: string;
  51259. };
  51260. }
  51261. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51262. /** @hidden */
  51263. export var pbrHelperFunctions: {
  51264. name: string;
  51265. shader: string;
  51266. };
  51267. }
  51268. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51269. /** @hidden */
  51270. export var harmonicsFunctions: {
  51271. name: string;
  51272. shader: string;
  51273. };
  51274. }
  51275. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51276. /** @hidden */
  51277. export var pbrDirectLightingSetupFunctions: {
  51278. name: string;
  51279. shader: string;
  51280. };
  51281. }
  51282. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51283. /** @hidden */
  51284. export var pbrDirectLightingFalloffFunctions: {
  51285. name: string;
  51286. shader: string;
  51287. };
  51288. }
  51289. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51290. /** @hidden */
  51291. export var pbrBRDFFunctions: {
  51292. name: string;
  51293. shader: string;
  51294. };
  51295. }
  51296. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51297. /** @hidden */
  51298. export var pbrDirectLightingFunctions: {
  51299. name: string;
  51300. shader: string;
  51301. };
  51302. }
  51303. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51304. /** @hidden */
  51305. export var pbrIBLFunctions: {
  51306. name: string;
  51307. shader: string;
  51308. };
  51309. }
  51310. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51311. /** @hidden */
  51312. export var pbrDebug: {
  51313. name: string;
  51314. shader: string;
  51315. };
  51316. }
  51317. declare module "babylonjs/Shaders/pbr.fragment" {
  51318. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51319. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51320. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51321. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51322. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51323. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51324. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51326. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51327. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51328. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51329. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51330. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51331. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51332. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51333. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51334. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51335. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51336. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51337. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51338. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51339. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51340. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51341. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51342. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51343. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51344. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51345. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51346. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51347. /** @hidden */
  51348. export var pbrPixelShader: {
  51349. name: string;
  51350. shader: string;
  51351. };
  51352. }
  51353. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51354. /** @hidden */
  51355. export var pbrVertexDeclaration: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module "babylonjs/Shaders/pbr.vertex" {
  51361. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51362. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51363. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51364. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51365. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51366. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51367. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51368. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51369. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51370. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51371. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51373. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51374. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51376. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51377. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51378. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51380. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51381. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51382. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51383. /** @hidden */
  51384. export var pbrVertexShader: {
  51385. name: string;
  51386. shader: string;
  51387. };
  51388. }
  51389. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51390. import { Nullable } from "babylonjs/types";
  51391. import { Scene } from "babylonjs/scene";
  51392. import { Matrix } from "babylonjs/Maths/math.vector";
  51393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51395. import { Mesh } from "babylonjs/Meshes/mesh";
  51396. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51397. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51398. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51399. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51400. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51401. import { Color3 } from "babylonjs/Maths/math.color";
  51402. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51403. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51404. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51405. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51407. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51408. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51409. import "babylonjs/Shaders/pbr.fragment";
  51410. import "babylonjs/Shaders/pbr.vertex";
  51411. /**
  51412. * Manages the defines for the PBR Material.
  51413. * @hidden
  51414. */
  51415. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51416. PBR: boolean;
  51417. MAINUV1: boolean;
  51418. MAINUV2: boolean;
  51419. UV1: boolean;
  51420. UV2: boolean;
  51421. ALBEDO: boolean;
  51422. ALBEDODIRECTUV: number;
  51423. VERTEXCOLOR: boolean;
  51424. AMBIENT: boolean;
  51425. AMBIENTDIRECTUV: number;
  51426. AMBIENTINGRAYSCALE: boolean;
  51427. OPACITY: boolean;
  51428. VERTEXALPHA: boolean;
  51429. OPACITYDIRECTUV: number;
  51430. OPACITYRGB: boolean;
  51431. ALPHATEST: boolean;
  51432. DEPTHPREPASS: boolean;
  51433. ALPHABLEND: boolean;
  51434. ALPHAFROMALBEDO: boolean;
  51435. ALPHATESTVALUE: string;
  51436. SPECULAROVERALPHA: boolean;
  51437. RADIANCEOVERALPHA: boolean;
  51438. ALPHAFRESNEL: boolean;
  51439. LINEARALPHAFRESNEL: boolean;
  51440. PREMULTIPLYALPHA: boolean;
  51441. EMISSIVE: boolean;
  51442. EMISSIVEDIRECTUV: number;
  51443. REFLECTIVITY: boolean;
  51444. REFLECTIVITYDIRECTUV: number;
  51445. SPECULARTERM: boolean;
  51446. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51447. MICROSURFACEAUTOMATIC: boolean;
  51448. LODBASEDMICROSFURACE: boolean;
  51449. MICROSURFACEMAP: boolean;
  51450. MICROSURFACEMAPDIRECTUV: number;
  51451. METALLICWORKFLOW: boolean;
  51452. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51453. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51454. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51455. AOSTOREINMETALMAPRED: boolean;
  51456. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51457. ENVIRONMENTBRDF: boolean;
  51458. ENVIRONMENTBRDF_RGBD: boolean;
  51459. NORMAL: boolean;
  51460. TANGENT: boolean;
  51461. BUMP: boolean;
  51462. BUMPDIRECTUV: number;
  51463. OBJECTSPACE_NORMALMAP: boolean;
  51464. PARALLAX: boolean;
  51465. PARALLAXOCCLUSION: boolean;
  51466. NORMALXYSCALE: boolean;
  51467. LIGHTMAP: boolean;
  51468. LIGHTMAPDIRECTUV: number;
  51469. USELIGHTMAPASSHADOWMAP: boolean;
  51470. GAMMALIGHTMAP: boolean;
  51471. RGBDLIGHTMAP: boolean;
  51472. REFLECTION: boolean;
  51473. REFLECTIONMAP_3D: boolean;
  51474. REFLECTIONMAP_SPHERICAL: boolean;
  51475. REFLECTIONMAP_PLANAR: boolean;
  51476. REFLECTIONMAP_CUBIC: boolean;
  51477. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51478. REFLECTIONMAP_PROJECTION: boolean;
  51479. REFLECTIONMAP_SKYBOX: boolean;
  51480. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51481. REFLECTIONMAP_EXPLICIT: boolean;
  51482. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51483. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51484. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51485. INVERTCUBICMAP: boolean;
  51486. USESPHERICALFROMREFLECTIONMAP: boolean;
  51487. USEIRRADIANCEMAP: boolean;
  51488. SPHERICAL_HARMONICS: boolean;
  51489. USESPHERICALINVERTEX: boolean;
  51490. REFLECTIONMAP_OPPOSITEZ: boolean;
  51491. LODINREFLECTIONALPHA: boolean;
  51492. GAMMAREFLECTION: boolean;
  51493. RGBDREFLECTION: boolean;
  51494. LINEARSPECULARREFLECTION: boolean;
  51495. RADIANCEOCCLUSION: boolean;
  51496. HORIZONOCCLUSION: boolean;
  51497. INSTANCES: boolean;
  51498. NUM_BONE_INFLUENCERS: number;
  51499. BonesPerMesh: number;
  51500. BONETEXTURE: boolean;
  51501. NONUNIFORMSCALING: boolean;
  51502. MORPHTARGETS: boolean;
  51503. MORPHTARGETS_NORMAL: boolean;
  51504. MORPHTARGETS_TANGENT: boolean;
  51505. MORPHTARGETS_UV: boolean;
  51506. NUM_MORPH_INFLUENCERS: number;
  51507. IMAGEPROCESSING: boolean;
  51508. VIGNETTE: boolean;
  51509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51510. VIGNETTEBLENDMODEOPAQUE: boolean;
  51511. TONEMAPPING: boolean;
  51512. TONEMAPPING_ACES: boolean;
  51513. CONTRAST: boolean;
  51514. COLORCURVES: boolean;
  51515. COLORGRADING: boolean;
  51516. COLORGRADING3D: boolean;
  51517. SAMPLER3DGREENDEPTH: boolean;
  51518. SAMPLER3DBGRMAP: boolean;
  51519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51520. EXPOSURE: boolean;
  51521. MULTIVIEW: boolean;
  51522. USEPHYSICALLIGHTFALLOFF: boolean;
  51523. USEGLTFLIGHTFALLOFF: boolean;
  51524. TWOSIDEDLIGHTING: boolean;
  51525. SHADOWFLOAT: boolean;
  51526. CLIPPLANE: boolean;
  51527. CLIPPLANE2: boolean;
  51528. CLIPPLANE3: boolean;
  51529. CLIPPLANE4: boolean;
  51530. POINTSIZE: boolean;
  51531. FOG: boolean;
  51532. LOGARITHMICDEPTH: boolean;
  51533. FORCENORMALFORWARD: boolean;
  51534. SPECULARAA: boolean;
  51535. CLEARCOAT: boolean;
  51536. CLEARCOAT_DEFAULTIOR: boolean;
  51537. CLEARCOAT_TEXTURE: boolean;
  51538. CLEARCOAT_TEXTUREDIRECTUV: number;
  51539. CLEARCOAT_BUMP: boolean;
  51540. CLEARCOAT_BUMPDIRECTUV: number;
  51541. CLEARCOAT_TINT: boolean;
  51542. CLEARCOAT_TINT_TEXTURE: boolean;
  51543. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51544. ANISOTROPIC: boolean;
  51545. ANISOTROPIC_TEXTURE: boolean;
  51546. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51547. BRDF_V_HEIGHT_CORRELATED: boolean;
  51548. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51549. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51550. SHEEN: boolean;
  51551. SHEEN_TEXTURE: boolean;
  51552. SHEEN_TEXTUREDIRECTUV: number;
  51553. SHEEN_LINKWITHALBEDO: boolean;
  51554. SUBSURFACE: boolean;
  51555. SS_REFRACTION: boolean;
  51556. SS_TRANSLUCENCY: boolean;
  51557. SS_SCATERRING: boolean;
  51558. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51559. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51560. SS_REFRACTIONMAP_3D: boolean;
  51561. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51562. SS_LODINREFRACTIONALPHA: boolean;
  51563. SS_GAMMAREFRACTION: boolean;
  51564. SS_RGBDREFRACTION: boolean;
  51565. SS_LINEARSPECULARREFRACTION: boolean;
  51566. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51567. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51568. UNLIT: boolean;
  51569. DEBUGMODE: number;
  51570. /**
  51571. * Initializes the PBR Material defines.
  51572. */
  51573. constructor();
  51574. /**
  51575. * Resets the PBR Material defines.
  51576. */
  51577. reset(): void;
  51578. }
  51579. /**
  51580. * The Physically based material base class of BJS.
  51581. *
  51582. * This offers the main features of a standard PBR material.
  51583. * For more information, please refer to the documentation :
  51584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51585. */
  51586. export abstract class PBRBaseMaterial extends PushMaterial {
  51587. /**
  51588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51589. */
  51590. static readonly PBRMATERIAL_OPAQUE: number;
  51591. /**
  51592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51593. */
  51594. static readonly PBRMATERIAL_ALPHATEST: number;
  51595. /**
  51596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51597. */
  51598. static readonly PBRMATERIAL_ALPHABLEND: number;
  51599. /**
  51600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51601. * They are also discarded below the alpha cutoff threshold to improve performances.
  51602. */
  51603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51604. /**
  51605. * Defines the default value of how much AO map is occluding the analytical lights
  51606. * (point spot...).
  51607. */
  51608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51609. /**
  51610. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51611. */
  51612. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51613. /**
  51614. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51615. * to enhance interoperability with other engines.
  51616. */
  51617. static readonly LIGHTFALLOFF_GLTF: number;
  51618. /**
  51619. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51620. * to enhance interoperability with other materials.
  51621. */
  51622. static readonly LIGHTFALLOFF_STANDARD: number;
  51623. /**
  51624. * Intensity of the direct lights e.g. the four lights available in your scene.
  51625. * This impacts both the direct diffuse and specular highlights.
  51626. */
  51627. protected _directIntensity: number;
  51628. /**
  51629. * Intensity of the emissive part of the material.
  51630. * This helps controlling the emissive effect without modifying the emissive color.
  51631. */
  51632. protected _emissiveIntensity: number;
  51633. /**
  51634. * Intensity of the environment e.g. how much the environment will light the object
  51635. * either through harmonics for rough material or through the refelction for shiny ones.
  51636. */
  51637. protected _environmentIntensity: number;
  51638. /**
  51639. * This is a special control allowing the reduction of the specular highlights coming from the
  51640. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51641. */
  51642. protected _specularIntensity: number;
  51643. /**
  51644. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51645. */
  51646. private _lightingInfos;
  51647. /**
  51648. * Debug Control allowing disabling the bump map on this material.
  51649. */
  51650. protected _disableBumpMap: boolean;
  51651. /**
  51652. * AKA Diffuse Texture in standard nomenclature.
  51653. */
  51654. protected _albedoTexture: Nullable<BaseTexture>;
  51655. /**
  51656. * AKA Occlusion Texture in other nomenclature.
  51657. */
  51658. protected _ambientTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * AKA Occlusion Texture Intensity in other nomenclature.
  51661. */
  51662. protected _ambientTextureStrength: number;
  51663. /**
  51664. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51665. * 1 means it completely occludes it
  51666. * 0 mean it has no impact
  51667. */
  51668. protected _ambientTextureImpactOnAnalyticalLights: number;
  51669. /**
  51670. * Stores the alpha values in a texture.
  51671. */
  51672. protected _opacityTexture: Nullable<BaseTexture>;
  51673. /**
  51674. * Stores the reflection values in a texture.
  51675. */
  51676. protected _reflectionTexture: Nullable<BaseTexture>;
  51677. /**
  51678. * Stores the emissive values in a texture.
  51679. */
  51680. protected _emissiveTexture: Nullable<BaseTexture>;
  51681. /**
  51682. * AKA Specular texture in other nomenclature.
  51683. */
  51684. protected _reflectivityTexture: Nullable<BaseTexture>;
  51685. /**
  51686. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51687. */
  51688. protected _metallicTexture: Nullable<BaseTexture>;
  51689. /**
  51690. * Specifies the metallic scalar of the metallic/roughness workflow.
  51691. * Can also be used to scale the metalness values of the metallic texture.
  51692. */
  51693. protected _metallic: Nullable<number>;
  51694. /**
  51695. * Specifies the roughness scalar of the metallic/roughness workflow.
  51696. * Can also be used to scale the roughness values of the metallic texture.
  51697. */
  51698. protected _roughness: Nullable<number>;
  51699. /**
  51700. * Specifies the an F0 factor to help configuring the material F0.
  51701. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51702. * to 0.5 the previously hard coded value stays the same.
  51703. * Can also be used to scale the F0 values of the metallic texture.
  51704. */
  51705. protected _metallicF0Factor: number;
  51706. /**
  51707. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51708. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51709. * your expectation as it multiplies with the texture data.
  51710. */
  51711. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51712. /**
  51713. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51714. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51715. */
  51716. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51717. /**
  51718. * Stores surface normal data used to displace a mesh in a texture.
  51719. */
  51720. protected _bumpTexture: Nullable<BaseTexture>;
  51721. /**
  51722. * Stores the pre-calculated light information of a mesh in a texture.
  51723. */
  51724. protected _lightmapTexture: Nullable<BaseTexture>;
  51725. /**
  51726. * The color of a material in ambient lighting.
  51727. */
  51728. protected _ambientColor: Color3;
  51729. /**
  51730. * AKA Diffuse Color in other nomenclature.
  51731. */
  51732. protected _albedoColor: Color3;
  51733. /**
  51734. * AKA Specular Color in other nomenclature.
  51735. */
  51736. protected _reflectivityColor: Color3;
  51737. /**
  51738. * The color applied when light is reflected from a material.
  51739. */
  51740. protected _reflectionColor: Color3;
  51741. /**
  51742. * The color applied when light is emitted from a material.
  51743. */
  51744. protected _emissiveColor: Color3;
  51745. /**
  51746. * AKA Glossiness in other nomenclature.
  51747. */
  51748. protected _microSurface: number;
  51749. /**
  51750. * Specifies that the material will use the light map as a show map.
  51751. */
  51752. protected _useLightmapAsShadowmap: boolean;
  51753. /**
  51754. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51755. * makes the reflect vector face the model (under horizon).
  51756. */
  51757. protected _useHorizonOcclusion: boolean;
  51758. /**
  51759. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51760. * too much the area relying on ambient texture to define their ambient occlusion.
  51761. */
  51762. protected _useRadianceOcclusion: boolean;
  51763. /**
  51764. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51765. */
  51766. protected _useAlphaFromAlbedoTexture: boolean;
  51767. /**
  51768. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51769. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51770. */
  51771. protected _useSpecularOverAlpha: boolean;
  51772. /**
  51773. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51774. */
  51775. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51776. /**
  51777. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51778. */
  51779. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51780. /**
  51781. * Specifies if the metallic texture contains the roughness information in its green channel.
  51782. */
  51783. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51784. /**
  51785. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51786. */
  51787. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51788. /**
  51789. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51790. */
  51791. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51792. /**
  51793. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51794. */
  51795. protected _useAmbientInGrayScale: boolean;
  51796. /**
  51797. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51798. * The material will try to infer what glossiness each pixel should be.
  51799. */
  51800. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51801. /**
  51802. * Defines the falloff type used in this material.
  51803. * It by default is Physical.
  51804. */
  51805. protected _lightFalloff: number;
  51806. /**
  51807. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51808. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51809. */
  51810. protected _useRadianceOverAlpha: boolean;
  51811. /**
  51812. * Allows using an object space normal map (instead of tangent space).
  51813. */
  51814. protected _useObjectSpaceNormalMap: boolean;
  51815. /**
  51816. * Allows using the bump map in parallax mode.
  51817. */
  51818. protected _useParallax: boolean;
  51819. /**
  51820. * Allows using the bump map in parallax occlusion mode.
  51821. */
  51822. protected _useParallaxOcclusion: boolean;
  51823. /**
  51824. * Controls the scale bias of the parallax mode.
  51825. */
  51826. protected _parallaxScaleBias: number;
  51827. /**
  51828. * If sets to true, disables all the lights affecting the material.
  51829. */
  51830. protected _disableLighting: boolean;
  51831. /**
  51832. * Number of Simultaneous lights allowed on the material.
  51833. */
  51834. protected _maxSimultaneousLights: number;
  51835. /**
  51836. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51837. */
  51838. protected _invertNormalMapX: boolean;
  51839. /**
  51840. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51841. */
  51842. protected _invertNormalMapY: boolean;
  51843. /**
  51844. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51845. */
  51846. protected _twoSidedLighting: boolean;
  51847. /**
  51848. * Defines the alpha limits in alpha test mode.
  51849. */
  51850. protected _alphaCutOff: number;
  51851. /**
  51852. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51853. */
  51854. protected _forceAlphaTest: boolean;
  51855. /**
  51856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51857. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51858. */
  51859. protected _useAlphaFresnel: boolean;
  51860. /**
  51861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51862. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51863. */
  51864. protected _useLinearAlphaFresnel: boolean;
  51865. /**
  51866. * The transparency mode of the material.
  51867. */
  51868. protected _transparencyMode: Nullable<number>;
  51869. /**
  51870. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51871. * from cos thetav and roughness:
  51872. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51873. */
  51874. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51875. /**
  51876. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51877. */
  51878. protected _forceIrradianceInFragment: boolean;
  51879. /**
  51880. * Force normal to face away from face.
  51881. */
  51882. protected _forceNormalForward: boolean;
  51883. /**
  51884. * Enables specular anti aliasing in the PBR shader.
  51885. * It will both interacts on the Geometry for analytical and IBL lighting.
  51886. * It also prefilter the roughness map based on the bump values.
  51887. */
  51888. protected _enableSpecularAntiAliasing: boolean;
  51889. /**
  51890. * Default configuration related to image processing available in the PBR Material.
  51891. */
  51892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51893. /**
  51894. * Keep track of the image processing observer to allow dispose and replace.
  51895. */
  51896. private _imageProcessingObserver;
  51897. /**
  51898. * Attaches a new image processing configuration to the PBR Material.
  51899. * @param configuration
  51900. */
  51901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51902. /**
  51903. * Stores the available render targets.
  51904. */
  51905. private _renderTargets;
  51906. /**
  51907. * Sets the global ambient color for the material used in lighting calculations.
  51908. */
  51909. private _globalAmbientColor;
  51910. /**
  51911. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51912. */
  51913. private _useLogarithmicDepth;
  51914. /**
  51915. * If set to true, no lighting calculations will be applied.
  51916. */
  51917. private _unlit;
  51918. private _debugMode;
  51919. /**
  51920. * @hidden
  51921. * This is reserved for the inspector.
  51922. * Defines the material debug mode.
  51923. * It helps seeing only some components of the material while troubleshooting.
  51924. */
  51925. debugMode: number;
  51926. /**
  51927. * @hidden
  51928. * This is reserved for the inspector.
  51929. * Specify from where on screen the debug mode should start.
  51930. * The value goes from -1 (full screen) to 1 (not visible)
  51931. * It helps with side by side comparison against the final render
  51932. * This defaults to -1
  51933. */
  51934. private debugLimit;
  51935. /**
  51936. * @hidden
  51937. * This is reserved for the inspector.
  51938. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51939. * You can use the factor to better multiply the final value.
  51940. */
  51941. private debugFactor;
  51942. /**
  51943. * Defines the clear coat layer parameters for the material.
  51944. */
  51945. readonly clearCoat: PBRClearCoatConfiguration;
  51946. /**
  51947. * Defines the anisotropic parameters for the material.
  51948. */
  51949. readonly anisotropy: PBRAnisotropicConfiguration;
  51950. /**
  51951. * Defines the BRDF parameters for the material.
  51952. */
  51953. readonly brdf: PBRBRDFConfiguration;
  51954. /**
  51955. * Defines the Sheen parameters for the material.
  51956. */
  51957. readonly sheen: PBRSheenConfiguration;
  51958. /**
  51959. * Defines the SubSurface parameters for the material.
  51960. */
  51961. readonly subSurface: PBRSubSurfaceConfiguration;
  51962. /**
  51963. * Custom callback helping to override the default shader used in the material.
  51964. */
  51965. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51966. protected _rebuildInParallel: boolean;
  51967. /**
  51968. * Instantiates a new PBRMaterial instance.
  51969. *
  51970. * @param name The material name
  51971. * @param scene The scene the material will be use in.
  51972. */
  51973. constructor(name: string, scene: Scene);
  51974. /**
  51975. * Gets a boolean indicating that current material needs to register RTT
  51976. */
  51977. readonly hasRenderTargetTextures: boolean;
  51978. /**
  51979. * Gets the name of the material class.
  51980. */
  51981. getClassName(): string;
  51982. /**
  51983. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51984. */
  51985. /**
  51986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51987. */
  51988. useLogarithmicDepth: boolean;
  51989. /**
  51990. * Gets the current transparency mode.
  51991. */
  51992. /**
  51993. * Sets the transparency mode of the material.
  51994. *
  51995. * | Value | Type | Description |
  51996. * | ----- | ----------------------------------- | ----------- |
  51997. * | 0 | OPAQUE | |
  51998. * | 1 | ALPHATEST | |
  51999. * | 2 | ALPHABLEND | |
  52000. * | 3 | ALPHATESTANDBLEND | |
  52001. *
  52002. */
  52003. transparencyMode: Nullable<number>;
  52004. /**
  52005. * Returns true if alpha blending should be disabled.
  52006. */
  52007. private readonly _disableAlphaBlending;
  52008. /**
  52009. * Specifies whether or not this material should be rendered in alpha blend mode.
  52010. */
  52011. needAlphaBlending(): boolean;
  52012. /**
  52013. * Specifies if the mesh will require alpha blending.
  52014. * @param mesh - BJS mesh.
  52015. */
  52016. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52017. /**
  52018. * Specifies whether or not this material should be rendered in alpha test mode.
  52019. */
  52020. needAlphaTesting(): boolean;
  52021. /**
  52022. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52023. */
  52024. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52025. /**
  52026. * Gets the texture used for the alpha test.
  52027. */
  52028. getAlphaTestTexture(): Nullable<BaseTexture>;
  52029. /**
  52030. * Specifies that the submesh is ready to be used.
  52031. * @param mesh - BJS mesh.
  52032. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52033. * @param useInstances - Specifies that instances should be used.
  52034. * @returns - boolean indicating that the submesh is ready or not.
  52035. */
  52036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52037. /**
  52038. * Specifies if the material uses metallic roughness workflow.
  52039. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52040. */
  52041. isMetallicWorkflow(): boolean;
  52042. private _prepareEffect;
  52043. private _prepareDefines;
  52044. /**
  52045. * Force shader compilation
  52046. */
  52047. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52048. /**
  52049. * Initializes the uniform buffer layout for the shader.
  52050. */
  52051. buildUniformLayout(): void;
  52052. /**
  52053. * Unbinds the material from the mesh
  52054. */
  52055. unbind(): void;
  52056. /**
  52057. * Binds the submesh data.
  52058. * @param world - The world matrix.
  52059. * @param mesh - The BJS mesh.
  52060. * @param subMesh - A submesh of the BJS mesh.
  52061. */
  52062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52063. /**
  52064. * Returns the animatable textures.
  52065. * @returns - Array of animatable textures.
  52066. */
  52067. getAnimatables(): IAnimatable[];
  52068. /**
  52069. * Returns the texture used for reflections.
  52070. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52071. */
  52072. private _getReflectionTexture;
  52073. /**
  52074. * Returns an array of the actively used textures.
  52075. * @returns - Array of BaseTextures
  52076. */
  52077. getActiveTextures(): BaseTexture[];
  52078. /**
  52079. * Checks to see if a texture is used in the material.
  52080. * @param texture - Base texture to use.
  52081. * @returns - Boolean specifying if a texture is used in the material.
  52082. */
  52083. hasTexture(texture: BaseTexture): boolean;
  52084. /**
  52085. * Disposes the resources of the material.
  52086. * @param forceDisposeEffect - Forces the disposal of effects.
  52087. * @param forceDisposeTextures - Forces the disposal of all textures.
  52088. */
  52089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52090. }
  52091. }
  52092. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52093. import { Nullable } from "babylonjs/types";
  52094. import { Scene } from "babylonjs/scene";
  52095. import { Color3 } from "babylonjs/Maths/math.color";
  52096. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52097. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52099. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52100. /**
  52101. * The Physically based material of BJS.
  52102. *
  52103. * This offers the main features of a standard PBR material.
  52104. * For more information, please refer to the documentation :
  52105. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52106. */
  52107. export class PBRMaterial extends PBRBaseMaterial {
  52108. /**
  52109. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52110. */
  52111. static readonly PBRMATERIAL_OPAQUE: number;
  52112. /**
  52113. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52114. */
  52115. static readonly PBRMATERIAL_ALPHATEST: number;
  52116. /**
  52117. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52118. */
  52119. static readonly PBRMATERIAL_ALPHABLEND: number;
  52120. /**
  52121. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52122. * They are also discarded below the alpha cutoff threshold to improve performances.
  52123. */
  52124. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52125. /**
  52126. * Defines the default value of how much AO map is occluding the analytical lights
  52127. * (point spot...).
  52128. */
  52129. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52130. /**
  52131. * Intensity of the direct lights e.g. the four lights available in your scene.
  52132. * This impacts both the direct diffuse and specular highlights.
  52133. */
  52134. directIntensity: number;
  52135. /**
  52136. * Intensity of the emissive part of the material.
  52137. * This helps controlling the emissive effect without modifying the emissive color.
  52138. */
  52139. emissiveIntensity: number;
  52140. /**
  52141. * Intensity of the environment e.g. how much the environment will light the object
  52142. * either through harmonics for rough material or through the refelction for shiny ones.
  52143. */
  52144. environmentIntensity: number;
  52145. /**
  52146. * This is a special control allowing the reduction of the specular highlights coming from the
  52147. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52148. */
  52149. specularIntensity: number;
  52150. /**
  52151. * Debug Control allowing disabling the bump map on this material.
  52152. */
  52153. disableBumpMap: boolean;
  52154. /**
  52155. * AKA Diffuse Texture in standard nomenclature.
  52156. */
  52157. albedoTexture: BaseTexture;
  52158. /**
  52159. * AKA Occlusion Texture in other nomenclature.
  52160. */
  52161. ambientTexture: BaseTexture;
  52162. /**
  52163. * AKA Occlusion Texture Intensity in other nomenclature.
  52164. */
  52165. ambientTextureStrength: number;
  52166. /**
  52167. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52168. * 1 means it completely occludes it
  52169. * 0 mean it has no impact
  52170. */
  52171. ambientTextureImpactOnAnalyticalLights: number;
  52172. /**
  52173. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52174. */
  52175. opacityTexture: BaseTexture;
  52176. /**
  52177. * Stores the reflection values in a texture.
  52178. */
  52179. reflectionTexture: Nullable<BaseTexture>;
  52180. /**
  52181. * Stores the emissive values in a texture.
  52182. */
  52183. emissiveTexture: BaseTexture;
  52184. /**
  52185. * AKA Specular texture in other nomenclature.
  52186. */
  52187. reflectivityTexture: BaseTexture;
  52188. /**
  52189. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52190. */
  52191. metallicTexture: BaseTexture;
  52192. /**
  52193. * Specifies the metallic scalar of the metallic/roughness workflow.
  52194. * Can also be used to scale the metalness values of the metallic texture.
  52195. */
  52196. metallic: Nullable<number>;
  52197. /**
  52198. * Specifies the roughness scalar of the metallic/roughness workflow.
  52199. * Can also be used to scale the roughness values of the metallic texture.
  52200. */
  52201. roughness: Nullable<number>;
  52202. /**
  52203. * Specifies the an F0 factor to help configuring the material F0.
  52204. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52205. * to 0.5 the previously hard coded value stays the same.
  52206. * Can also be used to scale the F0 values of the metallic texture.
  52207. */
  52208. metallicF0Factor: number;
  52209. /**
  52210. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52211. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52212. * your expectation as it multiplies with the texture data.
  52213. */
  52214. useMetallicF0FactorFromMetallicTexture: boolean;
  52215. /**
  52216. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52217. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52218. */
  52219. microSurfaceTexture: BaseTexture;
  52220. /**
  52221. * Stores surface normal data used to displace a mesh in a texture.
  52222. */
  52223. bumpTexture: BaseTexture;
  52224. /**
  52225. * Stores the pre-calculated light information of a mesh in a texture.
  52226. */
  52227. lightmapTexture: BaseTexture;
  52228. /**
  52229. * Stores the refracted light information in a texture.
  52230. */
  52231. refractionTexture: Nullable<BaseTexture>;
  52232. /**
  52233. * The color of a material in ambient lighting.
  52234. */
  52235. ambientColor: Color3;
  52236. /**
  52237. * AKA Diffuse Color in other nomenclature.
  52238. */
  52239. albedoColor: Color3;
  52240. /**
  52241. * AKA Specular Color in other nomenclature.
  52242. */
  52243. reflectivityColor: Color3;
  52244. /**
  52245. * The color reflected from the material.
  52246. */
  52247. reflectionColor: Color3;
  52248. /**
  52249. * The color emitted from the material.
  52250. */
  52251. emissiveColor: Color3;
  52252. /**
  52253. * AKA Glossiness in other nomenclature.
  52254. */
  52255. microSurface: number;
  52256. /**
  52257. * source material index of refraction (IOR)' / 'destination material IOR.
  52258. */
  52259. indexOfRefraction: number;
  52260. /**
  52261. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52262. */
  52263. invertRefractionY: boolean;
  52264. /**
  52265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52266. * Materials half opaque for instance using refraction could benefit from this control.
  52267. */
  52268. linkRefractionWithTransparency: boolean;
  52269. /**
  52270. * If true, the light map contains occlusion information instead of lighting info.
  52271. */
  52272. useLightmapAsShadowmap: boolean;
  52273. /**
  52274. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52275. */
  52276. useAlphaFromAlbedoTexture: boolean;
  52277. /**
  52278. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52279. */
  52280. forceAlphaTest: boolean;
  52281. /**
  52282. * Defines the alpha limits in alpha test mode.
  52283. */
  52284. alphaCutOff: number;
  52285. /**
  52286. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52287. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52288. */
  52289. useSpecularOverAlpha: boolean;
  52290. /**
  52291. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52292. */
  52293. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52294. /**
  52295. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52296. */
  52297. useRoughnessFromMetallicTextureAlpha: boolean;
  52298. /**
  52299. * Specifies if the metallic texture contains the roughness information in its green channel.
  52300. */
  52301. useRoughnessFromMetallicTextureGreen: boolean;
  52302. /**
  52303. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52304. */
  52305. useMetallnessFromMetallicTextureBlue: boolean;
  52306. /**
  52307. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52308. */
  52309. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52310. /**
  52311. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52312. */
  52313. useAmbientInGrayScale: boolean;
  52314. /**
  52315. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52316. * The material will try to infer what glossiness each pixel should be.
  52317. */
  52318. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52319. /**
  52320. * BJS is using an harcoded light falloff based on a manually sets up range.
  52321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52323. */
  52324. /**
  52325. * BJS is using an harcoded light falloff based on a manually sets up range.
  52326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52328. */
  52329. usePhysicalLightFalloff: boolean;
  52330. /**
  52331. * In order to support the falloff compatibility with gltf, a special mode has been added
  52332. * to reproduce the gltf light falloff.
  52333. */
  52334. /**
  52335. * In order to support the falloff compatibility with gltf, a special mode has been added
  52336. * to reproduce the gltf light falloff.
  52337. */
  52338. useGLTFLightFalloff: boolean;
  52339. /**
  52340. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52341. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52342. */
  52343. useRadianceOverAlpha: boolean;
  52344. /**
  52345. * Allows using an object space normal map (instead of tangent space).
  52346. */
  52347. useObjectSpaceNormalMap: boolean;
  52348. /**
  52349. * Allows using the bump map in parallax mode.
  52350. */
  52351. useParallax: boolean;
  52352. /**
  52353. * Allows using the bump map in parallax occlusion mode.
  52354. */
  52355. useParallaxOcclusion: boolean;
  52356. /**
  52357. * Controls the scale bias of the parallax mode.
  52358. */
  52359. parallaxScaleBias: number;
  52360. /**
  52361. * If sets to true, disables all the lights affecting the material.
  52362. */
  52363. disableLighting: boolean;
  52364. /**
  52365. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52366. */
  52367. forceIrradianceInFragment: boolean;
  52368. /**
  52369. * Number of Simultaneous lights allowed on the material.
  52370. */
  52371. maxSimultaneousLights: number;
  52372. /**
  52373. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52374. */
  52375. invertNormalMapX: boolean;
  52376. /**
  52377. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52378. */
  52379. invertNormalMapY: boolean;
  52380. /**
  52381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52382. */
  52383. twoSidedLighting: boolean;
  52384. /**
  52385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52386. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52387. */
  52388. useAlphaFresnel: boolean;
  52389. /**
  52390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52391. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52392. */
  52393. useLinearAlphaFresnel: boolean;
  52394. /**
  52395. * Let user defines the brdf lookup texture used for IBL.
  52396. * A default 8bit version is embedded but you could point at :
  52397. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52398. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52399. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52400. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52401. */
  52402. environmentBRDFTexture: Nullable<BaseTexture>;
  52403. /**
  52404. * Force normal to face away from face.
  52405. */
  52406. forceNormalForward: boolean;
  52407. /**
  52408. * Enables specular anti aliasing in the PBR shader.
  52409. * It will both interacts on the Geometry for analytical and IBL lighting.
  52410. * It also prefilter the roughness map based on the bump values.
  52411. */
  52412. enableSpecularAntiAliasing: boolean;
  52413. /**
  52414. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52415. * makes the reflect vector face the model (under horizon).
  52416. */
  52417. useHorizonOcclusion: boolean;
  52418. /**
  52419. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52420. * too much the area relying on ambient texture to define their ambient occlusion.
  52421. */
  52422. useRadianceOcclusion: boolean;
  52423. /**
  52424. * If set to true, no lighting calculations will be applied.
  52425. */
  52426. unlit: boolean;
  52427. /**
  52428. * Gets the image processing configuration used either in this material.
  52429. */
  52430. /**
  52431. * Sets the Default image processing configuration used either in the this material.
  52432. *
  52433. * If sets to null, the scene one is in use.
  52434. */
  52435. imageProcessingConfiguration: ImageProcessingConfiguration;
  52436. /**
  52437. * Gets wether the color curves effect is enabled.
  52438. */
  52439. /**
  52440. * Sets wether the color curves effect is enabled.
  52441. */
  52442. cameraColorCurvesEnabled: boolean;
  52443. /**
  52444. * Gets wether the color grading effect is enabled.
  52445. */
  52446. /**
  52447. * Gets wether the color grading effect is enabled.
  52448. */
  52449. cameraColorGradingEnabled: boolean;
  52450. /**
  52451. * Gets wether tonemapping is enabled or not.
  52452. */
  52453. /**
  52454. * Sets wether tonemapping is enabled or not
  52455. */
  52456. cameraToneMappingEnabled: boolean;
  52457. /**
  52458. * The camera exposure used on this material.
  52459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52460. * This corresponds to a photographic exposure.
  52461. */
  52462. /**
  52463. * The camera exposure used on this material.
  52464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52465. * This corresponds to a photographic exposure.
  52466. */
  52467. cameraExposure: number;
  52468. /**
  52469. * Gets The camera contrast used on this material.
  52470. */
  52471. /**
  52472. * Sets The camera contrast used on this material.
  52473. */
  52474. cameraContrast: number;
  52475. /**
  52476. * Gets the Color Grading 2D Lookup Texture.
  52477. */
  52478. /**
  52479. * Sets the Color Grading 2D Lookup Texture.
  52480. */
  52481. cameraColorGradingTexture: Nullable<BaseTexture>;
  52482. /**
  52483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52485. * 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;
  52486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52487. */
  52488. /**
  52489. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52490. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52491. * 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;
  52492. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52493. */
  52494. cameraColorCurves: Nullable<ColorCurves>;
  52495. /**
  52496. * Instantiates a new PBRMaterial instance.
  52497. *
  52498. * @param name The material name
  52499. * @param scene The scene the material will be use in.
  52500. */
  52501. constructor(name: string, scene: Scene);
  52502. /**
  52503. * Returns the name of this material class.
  52504. */
  52505. getClassName(): string;
  52506. /**
  52507. * Makes a duplicate of the current material.
  52508. * @param name - name to use for the new material.
  52509. */
  52510. clone(name: string): PBRMaterial;
  52511. /**
  52512. * Serializes this PBR Material.
  52513. * @returns - An object with the serialized material.
  52514. */
  52515. serialize(): any;
  52516. /**
  52517. * Parses a PBR Material from a serialized object.
  52518. * @param source - Serialized object.
  52519. * @param scene - BJS scene instance.
  52520. * @param rootUrl - url for the scene object
  52521. * @returns - PBRMaterial
  52522. */
  52523. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52524. }
  52525. }
  52526. declare module "babylonjs/Misc/dds" {
  52527. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52529. import { Nullable } from "babylonjs/types";
  52530. import { Scene } from "babylonjs/scene";
  52531. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  52532. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52533. /**
  52534. * Direct draw surface info
  52535. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52536. */
  52537. export interface DDSInfo {
  52538. /**
  52539. * Width of the texture
  52540. */
  52541. width: number;
  52542. /**
  52543. * Width of the texture
  52544. */
  52545. height: number;
  52546. /**
  52547. * Number of Mipmaps for the texture
  52548. * @see https://en.wikipedia.org/wiki/Mipmap
  52549. */
  52550. mipmapCount: number;
  52551. /**
  52552. * If the textures format is a known fourCC format
  52553. * @see https://www.fourcc.org/
  52554. */
  52555. isFourCC: boolean;
  52556. /**
  52557. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52558. */
  52559. isRGB: boolean;
  52560. /**
  52561. * If the texture is a lumincance format
  52562. */
  52563. isLuminance: boolean;
  52564. /**
  52565. * If this is a cube texture
  52566. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52567. */
  52568. isCube: boolean;
  52569. /**
  52570. * If the texture is a compressed format eg. FOURCC_DXT1
  52571. */
  52572. isCompressed: boolean;
  52573. /**
  52574. * The dxgiFormat of the texture
  52575. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52576. */
  52577. dxgiFormat: number;
  52578. /**
  52579. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52580. */
  52581. textureType: number;
  52582. /**
  52583. * Sphericle polynomial created for the dds texture
  52584. */
  52585. sphericalPolynomial?: SphericalPolynomial;
  52586. }
  52587. /**
  52588. * Class used to provide DDS decompression tools
  52589. */
  52590. export class DDSTools {
  52591. /**
  52592. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52593. */
  52594. static StoreLODInAlphaChannel: boolean;
  52595. /**
  52596. * Gets DDS information from an array buffer
  52597. * @param arrayBuffer defines the array buffer to read data from
  52598. * @returns the DDS information
  52599. */
  52600. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  52601. private static _FloatView;
  52602. private static _Int32View;
  52603. private static _ToHalfFloat;
  52604. private static _FromHalfFloat;
  52605. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52606. private static _GetHalfFloatRGBAArrayBuffer;
  52607. private static _GetFloatRGBAArrayBuffer;
  52608. private static _GetFloatAsUIntRGBAArrayBuffer;
  52609. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52610. private static _GetRGBAArrayBuffer;
  52611. private static _ExtractLongWordOrder;
  52612. private static _GetRGBArrayBuffer;
  52613. private static _GetLuminanceArrayBuffer;
  52614. /**
  52615. * Uploads DDS Levels to a Babylon Texture
  52616. * @hidden
  52617. */
  52618. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52619. }
  52620. module "babylonjs/Engines/thinEngine" {
  52621. interface ThinEngine {
  52622. /**
  52623. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52624. * @param rootUrl defines the url where the file to load is located
  52625. * @param scene defines the current scene
  52626. * @param lodScale defines scale to apply to the mip map selection
  52627. * @param lodOffset defines offset to apply to the mip map selection
  52628. * @param onLoad defines an optional callback raised when the texture is loaded
  52629. * @param onError defines an optional callback raised if there is an issue to load the texture
  52630. * @param format defines the format of the data
  52631. * @param forcedExtension defines the extension to use to pick the right loader
  52632. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52633. * @returns the cube texture as an InternalTexture
  52634. */
  52635. 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;
  52636. }
  52637. }
  52638. }
  52639. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  52640. import { Nullable } from "babylonjs/types";
  52641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52642. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52643. /**
  52644. * Implementation of the DDS Texture Loader.
  52645. * @hidden
  52646. */
  52647. export class _DDSTextureLoader implements IInternalTextureLoader {
  52648. /**
  52649. * Defines wether the loader supports cascade loading the different faces.
  52650. */
  52651. readonly supportCascades: boolean;
  52652. /**
  52653. * This returns if the loader support the current file information.
  52654. * @param extension defines the file extension of the file being loaded
  52655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52656. * @param fallback defines the fallback internal texture if any
  52657. * @param isBase64 defines whether the texture is encoded as a base64
  52658. * @param isBuffer defines whether the texture data are stored as a buffer
  52659. * @returns true if the loader can load the specified file
  52660. */
  52661. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52662. /**
  52663. * Transform the url before loading if required.
  52664. * @param rootUrl the url of the texture
  52665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52666. * @returns the transformed texture
  52667. */
  52668. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52669. /**
  52670. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52671. * @param rootUrl the url of the texture
  52672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52673. * @returns the fallback texture
  52674. */
  52675. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52676. /**
  52677. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52678. * @param data contains the texture data
  52679. * @param texture defines the BabylonJS internal texture
  52680. * @param createPolynomials will be true if polynomials have been requested
  52681. * @param onLoad defines the callback to trigger once the texture is ready
  52682. * @param onError defines the callback to trigger in case of error
  52683. */
  52684. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52685. /**
  52686. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52687. * @param data contains the texture data
  52688. * @param texture defines the BabylonJS internal texture
  52689. * @param callback defines the method to call once ready to upload
  52690. */
  52691. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52692. }
  52693. }
  52694. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  52695. import { Nullable } from "babylonjs/types";
  52696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52697. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52698. /**
  52699. * Implementation of the ENV Texture Loader.
  52700. * @hidden
  52701. */
  52702. export class _ENVTextureLoader implements IInternalTextureLoader {
  52703. /**
  52704. * Defines wether the loader supports cascade loading the different faces.
  52705. */
  52706. readonly supportCascades: boolean;
  52707. /**
  52708. * This returns if the loader support the current file information.
  52709. * @param extension defines the file extension of the file being loaded
  52710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52711. * @param fallback defines the fallback internal texture if any
  52712. * @param isBase64 defines whether the texture is encoded as a base64
  52713. * @param isBuffer defines whether the texture data are stored as a buffer
  52714. * @returns true if the loader can load the specified file
  52715. */
  52716. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52717. /**
  52718. * Transform the url before loading if required.
  52719. * @param rootUrl the url of the texture
  52720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52721. * @returns the transformed texture
  52722. */
  52723. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52724. /**
  52725. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52726. * @param rootUrl the url of the texture
  52727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52728. * @returns the fallback texture
  52729. */
  52730. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52731. /**
  52732. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52733. * @param data contains the texture data
  52734. * @param texture defines the BabylonJS internal texture
  52735. * @param createPolynomials will be true if polynomials have been requested
  52736. * @param onLoad defines the callback to trigger once the texture is ready
  52737. * @param onError defines the callback to trigger in case of error
  52738. */
  52739. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52740. /**
  52741. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52742. * @param data contains the texture data
  52743. * @param texture defines the BabylonJS internal texture
  52744. * @param callback defines the method to call once ready to upload
  52745. */
  52746. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52747. }
  52748. }
  52749. declare module "babylonjs/Misc/khronosTextureContainer" {
  52750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52751. /**
  52752. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52753. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52754. */
  52755. export class KhronosTextureContainer {
  52756. /** contents of the KTX container file */
  52757. arrayBuffer: any;
  52758. private static HEADER_LEN;
  52759. private static COMPRESSED_2D;
  52760. private static COMPRESSED_3D;
  52761. private static TEX_2D;
  52762. private static TEX_3D;
  52763. /**
  52764. * Gets the openGL type
  52765. */
  52766. glType: number;
  52767. /**
  52768. * Gets the openGL type size
  52769. */
  52770. glTypeSize: number;
  52771. /**
  52772. * Gets the openGL format
  52773. */
  52774. glFormat: number;
  52775. /**
  52776. * Gets the openGL internal format
  52777. */
  52778. glInternalFormat: number;
  52779. /**
  52780. * Gets the base internal format
  52781. */
  52782. glBaseInternalFormat: number;
  52783. /**
  52784. * Gets image width in pixel
  52785. */
  52786. pixelWidth: number;
  52787. /**
  52788. * Gets image height in pixel
  52789. */
  52790. pixelHeight: number;
  52791. /**
  52792. * Gets image depth in pixels
  52793. */
  52794. pixelDepth: number;
  52795. /**
  52796. * Gets the number of array elements
  52797. */
  52798. numberOfArrayElements: number;
  52799. /**
  52800. * Gets the number of faces
  52801. */
  52802. numberOfFaces: number;
  52803. /**
  52804. * Gets the number of mipmap levels
  52805. */
  52806. numberOfMipmapLevels: number;
  52807. /**
  52808. * Gets the bytes of key value data
  52809. */
  52810. bytesOfKeyValueData: number;
  52811. /**
  52812. * Gets the load type
  52813. */
  52814. loadType: number;
  52815. /**
  52816. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52817. */
  52818. isInvalid: boolean;
  52819. /**
  52820. * Creates a new KhronosTextureContainer
  52821. * @param arrayBuffer contents of the KTX container file
  52822. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52823. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52824. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52825. */
  52826. constructor(
  52827. /** contents of the KTX container file */
  52828. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52829. /**
  52830. * Uploads KTX content to a Babylon Texture.
  52831. * It is assumed that the texture has already been created & is currently bound
  52832. * @hidden
  52833. */
  52834. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52835. private _upload2DCompressedLevels;
  52836. }
  52837. }
  52838. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52839. import { Nullable } from "babylonjs/types";
  52840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52841. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52842. /**
  52843. * Implementation of the KTX Texture Loader.
  52844. * @hidden
  52845. */
  52846. export class _KTXTextureLoader implements IInternalTextureLoader {
  52847. /**
  52848. * Defines wether the loader supports cascade loading the different faces.
  52849. */
  52850. readonly supportCascades: boolean;
  52851. /**
  52852. * This returns if the loader support the current file information.
  52853. * @param extension defines the file extension of the file being loaded
  52854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52855. * @param fallback defines the fallback internal texture if any
  52856. * @param isBase64 defines whether the texture is encoded as a base64
  52857. * @param isBuffer defines whether the texture data are stored as a buffer
  52858. * @returns true if the loader can load the specified file
  52859. */
  52860. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52861. /**
  52862. * Transform the url before loading if required.
  52863. * @param rootUrl the url of the texture
  52864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52865. * @returns the transformed texture
  52866. */
  52867. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52868. /**
  52869. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52870. * @param rootUrl the url of the texture
  52871. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52872. * @returns the fallback texture
  52873. */
  52874. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52875. /**
  52876. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52877. * @param data contains the texture data
  52878. * @param texture defines the BabylonJS internal texture
  52879. * @param createPolynomials will be true if polynomials have been requested
  52880. * @param onLoad defines the callback to trigger once the texture is ready
  52881. * @param onError defines the callback to trigger in case of error
  52882. */
  52883. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52884. /**
  52885. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52886. * @param data contains the texture data
  52887. * @param texture defines the BabylonJS internal texture
  52888. * @param callback defines the method to call once ready to upload
  52889. */
  52890. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52891. }
  52892. }
  52893. declare module "babylonjs/Helpers/sceneHelpers" {
  52894. import { Nullable } from "babylonjs/types";
  52895. import { Mesh } from "babylonjs/Meshes/mesh";
  52896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52897. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52898. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52899. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52900. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52901. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52902. import "babylonjs/Meshes/Builders/boxBuilder";
  52903. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52904. /** @hidden */
  52905. export var _forceSceneHelpersToBundle: boolean;
  52906. module "babylonjs/scene" {
  52907. interface Scene {
  52908. /**
  52909. * Creates a default light for the scene.
  52910. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52911. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52912. */
  52913. createDefaultLight(replace?: boolean): void;
  52914. /**
  52915. * Creates a default camera for the scene.
  52916. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52917. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52918. * @param replace has default false, when true replaces the active camera in the scene
  52919. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52920. */
  52921. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52922. /**
  52923. * Creates a default camera and a default light.
  52924. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52925. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52926. * @param replace has the default false, when true replaces the active camera/light in the scene
  52927. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52928. */
  52929. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52930. /**
  52931. * Creates a new sky box
  52932. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52933. * @param environmentTexture defines the texture to use as environment texture
  52934. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52935. * @param scale defines the overall scale of the skybox
  52936. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52937. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52938. * @returns a new mesh holding the sky box
  52939. */
  52940. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52941. /**
  52942. * Creates a new environment
  52943. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52944. * @param options defines the options you can use to configure the environment
  52945. * @returns the new EnvironmentHelper
  52946. */
  52947. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52948. /**
  52949. * Creates a new VREXperienceHelper
  52950. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52951. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52952. * @returns a new VREXperienceHelper
  52953. */
  52954. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52955. /**
  52956. * Creates a new WebXRDefaultExperience
  52957. * @see http://doc.babylonjs.com/how_to/webxr
  52958. * @param options experience options
  52959. * @returns a promise for a new WebXRDefaultExperience
  52960. */
  52961. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52962. }
  52963. }
  52964. }
  52965. declare module "babylonjs/Helpers/videoDome" {
  52966. import { Scene } from "babylonjs/scene";
  52967. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52968. import { Mesh } from "babylonjs/Meshes/mesh";
  52969. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52970. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52971. import "babylonjs/Meshes/Builders/sphereBuilder";
  52972. /**
  52973. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52974. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52975. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52976. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52977. */
  52978. export class VideoDome extends TransformNode {
  52979. /**
  52980. * Define the video source as a Monoscopic panoramic 360 video.
  52981. */
  52982. static readonly MODE_MONOSCOPIC: number;
  52983. /**
  52984. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52985. */
  52986. static readonly MODE_TOPBOTTOM: number;
  52987. /**
  52988. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52989. */
  52990. static readonly MODE_SIDEBYSIDE: number;
  52991. private _halfDome;
  52992. private _useDirectMapping;
  52993. /**
  52994. * The video texture being displayed on the sphere
  52995. */
  52996. protected _videoTexture: VideoTexture;
  52997. /**
  52998. * Gets the video texture being displayed on the sphere
  52999. */
  53000. readonly videoTexture: VideoTexture;
  53001. /**
  53002. * The skybox material
  53003. */
  53004. protected _material: BackgroundMaterial;
  53005. /**
  53006. * The surface used for the skybox
  53007. */
  53008. protected _mesh: Mesh;
  53009. /**
  53010. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53011. */
  53012. private _halfDomeMask;
  53013. /**
  53014. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53015. * Also see the options.resolution property.
  53016. */
  53017. fovMultiplier: number;
  53018. private _videoMode;
  53019. /**
  53020. * Gets or set the current video mode for the video. It can be:
  53021. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53022. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53023. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53024. */
  53025. videoMode: number;
  53026. /**
  53027. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53028. *
  53029. */
  53030. /**
  53031. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53032. */
  53033. halfDome: boolean;
  53034. /**
  53035. * Oberserver used in Stereoscopic VR Mode.
  53036. */
  53037. private _onBeforeCameraRenderObserver;
  53038. /**
  53039. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53040. * @param name Element's name, child elements will append suffixes for their own names.
  53041. * @param urlsOrVideo defines the url(s) or the video element to use
  53042. * @param options An object containing optional or exposed sub element properties
  53043. */
  53044. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53045. resolution?: number;
  53046. clickToPlay?: boolean;
  53047. autoPlay?: boolean;
  53048. loop?: boolean;
  53049. size?: number;
  53050. poster?: string;
  53051. faceForward?: boolean;
  53052. useDirectMapping?: boolean;
  53053. halfDomeMode?: boolean;
  53054. }, scene: Scene);
  53055. private _changeVideoMode;
  53056. /**
  53057. * Releases resources associated with this node.
  53058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53060. */
  53061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53062. }
  53063. }
  53064. declare module "babylonjs/Helpers/index" {
  53065. export * from "babylonjs/Helpers/environmentHelper";
  53066. export * from "babylonjs/Helpers/photoDome";
  53067. export * from "babylonjs/Helpers/sceneHelpers";
  53068. export * from "babylonjs/Helpers/videoDome";
  53069. }
  53070. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53071. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53072. import { IDisposable } from "babylonjs/scene";
  53073. import { Engine } from "babylonjs/Engines/engine";
  53074. /**
  53075. * This class can be used to get instrumentation data from a Babylon engine
  53076. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53077. */
  53078. export class EngineInstrumentation implements IDisposable {
  53079. /**
  53080. * Define the instrumented engine.
  53081. */
  53082. engine: Engine;
  53083. private _captureGPUFrameTime;
  53084. private _gpuFrameTimeToken;
  53085. private _gpuFrameTime;
  53086. private _captureShaderCompilationTime;
  53087. private _shaderCompilationTime;
  53088. private _onBeginFrameObserver;
  53089. private _onEndFrameObserver;
  53090. private _onBeforeShaderCompilationObserver;
  53091. private _onAfterShaderCompilationObserver;
  53092. /**
  53093. * Gets the perf counter used for GPU frame time
  53094. */
  53095. readonly gpuFrameTimeCounter: PerfCounter;
  53096. /**
  53097. * Gets the GPU frame time capture status
  53098. */
  53099. /**
  53100. * Enable or disable the GPU frame time capture
  53101. */
  53102. captureGPUFrameTime: boolean;
  53103. /**
  53104. * Gets the perf counter used for shader compilation time
  53105. */
  53106. readonly shaderCompilationTimeCounter: PerfCounter;
  53107. /**
  53108. * Gets the shader compilation time capture status
  53109. */
  53110. /**
  53111. * Enable or disable the shader compilation time capture
  53112. */
  53113. captureShaderCompilationTime: boolean;
  53114. /**
  53115. * Instantiates a new engine instrumentation.
  53116. * This class can be used to get instrumentation data from a Babylon engine
  53117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53118. * @param engine Defines the engine to instrument
  53119. */
  53120. constructor(
  53121. /**
  53122. * Define the instrumented engine.
  53123. */
  53124. engine: Engine);
  53125. /**
  53126. * Dispose and release associated resources.
  53127. */
  53128. dispose(): void;
  53129. }
  53130. }
  53131. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53132. import { Scene, IDisposable } from "babylonjs/scene";
  53133. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53134. /**
  53135. * This class can be used to get instrumentation data from a Babylon engine
  53136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53137. */
  53138. export class SceneInstrumentation implements IDisposable {
  53139. /**
  53140. * Defines the scene to instrument
  53141. */
  53142. scene: Scene;
  53143. private _captureActiveMeshesEvaluationTime;
  53144. private _activeMeshesEvaluationTime;
  53145. private _captureRenderTargetsRenderTime;
  53146. private _renderTargetsRenderTime;
  53147. private _captureFrameTime;
  53148. private _frameTime;
  53149. private _captureRenderTime;
  53150. private _renderTime;
  53151. private _captureInterFrameTime;
  53152. private _interFrameTime;
  53153. private _captureParticlesRenderTime;
  53154. private _particlesRenderTime;
  53155. private _captureSpritesRenderTime;
  53156. private _spritesRenderTime;
  53157. private _capturePhysicsTime;
  53158. private _physicsTime;
  53159. private _captureAnimationsTime;
  53160. private _animationsTime;
  53161. private _captureCameraRenderTime;
  53162. private _cameraRenderTime;
  53163. private _onBeforeActiveMeshesEvaluationObserver;
  53164. private _onAfterActiveMeshesEvaluationObserver;
  53165. private _onBeforeRenderTargetsRenderObserver;
  53166. private _onAfterRenderTargetsRenderObserver;
  53167. private _onAfterRenderObserver;
  53168. private _onBeforeDrawPhaseObserver;
  53169. private _onAfterDrawPhaseObserver;
  53170. private _onBeforeAnimationsObserver;
  53171. private _onBeforeParticlesRenderingObserver;
  53172. private _onAfterParticlesRenderingObserver;
  53173. private _onBeforeSpritesRenderingObserver;
  53174. private _onAfterSpritesRenderingObserver;
  53175. private _onBeforePhysicsObserver;
  53176. private _onAfterPhysicsObserver;
  53177. private _onAfterAnimationsObserver;
  53178. private _onBeforeCameraRenderObserver;
  53179. private _onAfterCameraRenderObserver;
  53180. /**
  53181. * Gets the perf counter used for active meshes evaluation time
  53182. */
  53183. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  53184. /**
  53185. * Gets the active meshes evaluation time capture status
  53186. */
  53187. /**
  53188. * Enable or disable the active meshes evaluation time capture
  53189. */
  53190. captureActiveMeshesEvaluationTime: boolean;
  53191. /**
  53192. * Gets the perf counter used for render targets render time
  53193. */
  53194. readonly renderTargetsRenderTimeCounter: PerfCounter;
  53195. /**
  53196. * Gets the render targets render time capture status
  53197. */
  53198. /**
  53199. * Enable or disable the render targets render time capture
  53200. */
  53201. captureRenderTargetsRenderTime: boolean;
  53202. /**
  53203. * Gets the perf counter used for particles render time
  53204. */
  53205. readonly particlesRenderTimeCounter: PerfCounter;
  53206. /**
  53207. * Gets the particles render time capture status
  53208. */
  53209. /**
  53210. * Enable or disable the particles render time capture
  53211. */
  53212. captureParticlesRenderTime: boolean;
  53213. /**
  53214. * Gets the perf counter used for sprites render time
  53215. */
  53216. readonly spritesRenderTimeCounter: PerfCounter;
  53217. /**
  53218. * Gets the sprites render time capture status
  53219. */
  53220. /**
  53221. * Enable or disable the sprites render time capture
  53222. */
  53223. captureSpritesRenderTime: boolean;
  53224. /**
  53225. * Gets the perf counter used for physics time
  53226. */
  53227. readonly physicsTimeCounter: PerfCounter;
  53228. /**
  53229. * Gets the physics time capture status
  53230. */
  53231. /**
  53232. * Enable or disable the physics time capture
  53233. */
  53234. capturePhysicsTime: boolean;
  53235. /**
  53236. * Gets the perf counter used for animations time
  53237. */
  53238. readonly animationsTimeCounter: PerfCounter;
  53239. /**
  53240. * Gets the animations time capture status
  53241. */
  53242. /**
  53243. * Enable or disable the animations time capture
  53244. */
  53245. captureAnimationsTime: boolean;
  53246. /**
  53247. * Gets the perf counter used for frame time capture
  53248. */
  53249. readonly frameTimeCounter: PerfCounter;
  53250. /**
  53251. * Gets the frame time capture status
  53252. */
  53253. /**
  53254. * Enable or disable the frame time capture
  53255. */
  53256. captureFrameTime: boolean;
  53257. /**
  53258. * Gets the perf counter used for inter-frames time capture
  53259. */
  53260. readonly interFrameTimeCounter: PerfCounter;
  53261. /**
  53262. * Gets the inter-frames time capture status
  53263. */
  53264. /**
  53265. * Enable or disable the inter-frames time capture
  53266. */
  53267. captureInterFrameTime: boolean;
  53268. /**
  53269. * Gets the perf counter used for render time capture
  53270. */
  53271. readonly renderTimeCounter: PerfCounter;
  53272. /**
  53273. * Gets the render time capture status
  53274. */
  53275. /**
  53276. * Enable or disable the render time capture
  53277. */
  53278. captureRenderTime: boolean;
  53279. /**
  53280. * Gets the perf counter used for camera render time capture
  53281. */
  53282. readonly cameraRenderTimeCounter: PerfCounter;
  53283. /**
  53284. * Gets the camera render time capture status
  53285. */
  53286. /**
  53287. * Enable or disable the camera render time capture
  53288. */
  53289. captureCameraRenderTime: boolean;
  53290. /**
  53291. * Gets the perf counter used for draw calls
  53292. */
  53293. readonly drawCallsCounter: PerfCounter;
  53294. /**
  53295. * Instantiates a new scene instrumentation.
  53296. * This class can be used to get instrumentation data from a Babylon engine
  53297. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53298. * @param scene Defines the scene to instrument
  53299. */
  53300. constructor(
  53301. /**
  53302. * Defines the scene to instrument
  53303. */
  53304. scene: Scene);
  53305. /**
  53306. * Dispose and release associated resources.
  53307. */
  53308. dispose(): void;
  53309. }
  53310. }
  53311. declare module "babylonjs/Instrumentation/index" {
  53312. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53313. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53314. export * from "babylonjs/Instrumentation/timeToken";
  53315. }
  53316. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53317. /** @hidden */
  53318. export var glowMapGenerationPixelShader: {
  53319. name: string;
  53320. shader: string;
  53321. };
  53322. }
  53323. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53324. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53331. /** @hidden */
  53332. export var glowMapGenerationVertexShader: {
  53333. name: string;
  53334. shader: string;
  53335. };
  53336. }
  53337. declare module "babylonjs/Layers/effectLayer" {
  53338. import { Observable } from "babylonjs/Misc/observable";
  53339. import { Nullable } from "babylonjs/types";
  53340. import { Camera } from "babylonjs/Cameras/camera";
  53341. import { Scene } from "babylonjs/scene";
  53342. import { ISize } from "babylonjs/Maths/math.size";
  53343. import { Color4 } from "babylonjs/Maths/math.color";
  53344. import { Engine } from "babylonjs/Engines/engine";
  53345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53347. import { Mesh } from "babylonjs/Meshes/mesh";
  53348. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53351. import { Effect } from "babylonjs/Materials/effect";
  53352. import { Material } from "babylonjs/Materials/material";
  53353. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53354. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53355. /**
  53356. * Effect layer options. This helps customizing the behaviour
  53357. * of the effect layer.
  53358. */
  53359. export interface IEffectLayerOptions {
  53360. /**
  53361. * Multiplication factor apply to the canvas size to compute the render target size
  53362. * used to generated the objects (the smaller the faster).
  53363. */
  53364. mainTextureRatio: number;
  53365. /**
  53366. * Enforces a fixed size texture to ensure effect stability across devices.
  53367. */
  53368. mainTextureFixedSize?: number;
  53369. /**
  53370. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53371. */
  53372. alphaBlendingMode: number;
  53373. /**
  53374. * The camera attached to the layer.
  53375. */
  53376. camera: Nullable<Camera>;
  53377. /**
  53378. * The rendering group to draw the layer in.
  53379. */
  53380. renderingGroupId: number;
  53381. }
  53382. /**
  53383. * The effect layer Helps adding post process effect blended with the main pass.
  53384. *
  53385. * This can be for instance use to generate glow or higlight effects on the scene.
  53386. *
  53387. * The effect layer class can not be used directly and is intented to inherited from to be
  53388. * customized per effects.
  53389. */
  53390. export abstract class EffectLayer {
  53391. private _vertexBuffers;
  53392. private _indexBuffer;
  53393. private _cachedDefines;
  53394. private _effectLayerMapGenerationEffect;
  53395. private _effectLayerOptions;
  53396. private _mergeEffect;
  53397. protected _scene: Scene;
  53398. protected _engine: Engine;
  53399. protected _maxSize: number;
  53400. protected _mainTextureDesiredSize: ISize;
  53401. protected _mainTexture: RenderTargetTexture;
  53402. protected _shouldRender: boolean;
  53403. protected _postProcesses: PostProcess[];
  53404. protected _textures: BaseTexture[];
  53405. protected _emissiveTextureAndColor: {
  53406. texture: Nullable<BaseTexture>;
  53407. color: Color4;
  53408. };
  53409. /**
  53410. * The name of the layer
  53411. */
  53412. name: string;
  53413. /**
  53414. * The clear color of the texture used to generate the glow map.
  53415. */
  53416. neutralColor: Color4;
  53417. /**
  53418. * Specifies wether the highlight layer is enabled or not.
  53419. */
  53420. isEnabled: boolean;
  53421. /**
  53422. * Gets the camera attached to the layer.
  53423. */
  53424. readonly camera: Nullable<Camera>;
  53425. /**
  53426. * Gets the rendering group id the layer should render in.
  53427. */
  53428. renderingGroupId: number;
  53429. /**
  53430. * An event triggered when the effect layer has been disposed.
  53431. */
  53432. onDisposeObservable: Observable<EffectLayer>;
  53433. /**
  53434. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53435. */
  53436. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53437. /**
  53438. * An event triggered when the generated texture is being merged in the scene.
  53439. */
  53440. onBeforeComposeObservable: Observable<EffectLayer>;
  53441. /**
  53442. * An event triggered when the mesh is rendered into the effect render target.
  53443. */
  53444. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53445. /**
  53446. * An event triggered after the mesh has been rendered into the effect render target.
  53447. */
  53448. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53449. /**
  53450. * An event triggered when the generated texture has been merged in the scene.
  53451. */
  53452. onAfterComposeObservable: Observable<EffectLayer>;
  53453. /**
  53454. * An event triggered when the efffect layer changes its size.
  53455. */
  53456. onSizeChangedObservable: Observable<EffectLayer>;
  53457. /** @hidden */
  53458. static _SceneComponentInitialization: (scene: Scene) => void;
  53459. /**
  53460. * Instantiates a new effect Layer and references it in the scene.
  53461. * @param name The name of the layer
  53462. * @param scene The scene to use the layer in
  53463. */
  53464. constructor(
  53465. /** The Friendly of the effect in the scene */
  53466. name: string, scene: Scene);
  53467. /**
  53468. * Get the effect name of the layer.
  53469. * @return The effect name
  53470. */
  53471. abstract getEffectName(): string;
  53472. /**
  53473. * Checks for the readiness of the element composing the layer.
  53474. * @param subMesh the mesh to check for
  53475. * @param useInstances specify wether or not to use instances to render the mesh
  53476. * @return true if ready otherwise, false
  53477. */
  53478. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53479. /**
  53480. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53481. * @returns true if the effect requires stencil during the main canvas render pass.
  53482. */
  53483. abstract needStencil(): boolean;
  53484. /**
  53485. * Create the merge effect. This is the shader use to blit the information back
  53486. * to the main canvas at the end of the scene rendering.
  53487. * @returns The effect containing the shader used to merge the effect on the main canvas
  53488. */
  53489. protected abstract _createMergeEffect(): Effect;
  53490. /**
  53491. * Creates the render target textures and post processes used in the effect layer.
  53492. */
  53493. protected abstract _createTextureAndPostProcesses(): void;
  53494. /**
  53495. * Implementation specific of rendering the generating effect on the main canvas.
  53496. * @param effect The effect used to render through
  53497. */
  53498. protected abstract _internalRender(effect: Effect): void;
  53499. /**
  53500. * Sets the required values for both the emissive texture and and the main color.
  53501. */
  53502. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53503. /**
  53504. * Free any resources and references associated to a mesh.
  53505. * Internal use
  53506. * @param mesh The mesh to free.
  53507. */
  53508. abstract _disposeMesh(mesh: Mesh): void;
  53509. /**
  53510. * Serializes this layer (Glow or Highlight for example)
  53511. * @returns a serialized layer object
  53512. */
  53513. abstract serialize?(): any;
  53514. /**
  53515. * Initializes the effect layer with the required options.
  53516. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53517. */
  53518. protected _init(options: Partial<IEffectLayerOptions>): void;
  53519. /**
  53520. * Generates the index buffer of the full screen quad blending to the main canvas.
  53521. */
  53522. private _generateIndexBuffer;
  53523. /**
  53524. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53525. */
  53526. private _generateVertexBuffer;
  53527. /**
  53528. * Sets the main texture desired size which is the closest power of two
  53529. * of the engine canvas size.
  53530. */
  53531. private _setMainTextureSize;
  53532. /**
  53533. * Creates the main texture for the effect layer.
  53534. */
  53535. protected _createMainTexture(): void;
  53536. /**
  53537. * Adds specific effects defines.
  53538. * @param defines The defines to add specifics to.
  53539. */
  53540. protected _addCustomEffectDefines(defines: string[]): void;
  53541. /**
  53542. * Checks for the readiness of the element composing the layer.
  53543. * @param subMesh the mesh to check for
  53544. * @param useInstances specify wether or not to use instances to render the mesh
  53545. * @param emissiveTexture the associated emissive texture used to generate the glow
  53546. * @return true if ready otherwise, false
  53547. */
  53548. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53549. /**
  53550. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53551. */
  53552. render(): void;
  53553. /**
  53554. * Determine if a given mesh will be used in the current effect.
  53555. * @param mesh mesh to test
  53556. * @returns true if the mesh will be used
  53557. */
  53558. hasMesh(mesh: AbstractMesh): boolean;
  53559. /**
  53560. * Returns true if the layer contains information to display, otherwise false.
  53561. * @returns true if the glow layer should be rendered
  53562. */
  53563. shouldRender(): boolean;
  53564. /**
  53565. * Returns true if the mesh should render, otherwise false.
  53566. * @param mesh The mesh to render
  53567. * @returns true if it should render otherwise false
  53568. */
  53569. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53570. /**
  53571. * Returns true if the mesh can be rendered, otherwise false.
  53572. * @param mesh The mesh to render
  53573. * @param material The material used on the mesh
  53574. * @returns true if it can be rendered otherwise false
  53575. */
  53576. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53577. /**
  53578. * Returns true if the mesh should render, otherwise false.
  53579. * @param mesh The mesh to render
  53580. * @returns true if it should render otherwise false
  53581. */
  53582. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53583. /**
  53584. * Renders the submesh passed in parameter to the generation map.
  53585. */
  53586. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53587. /**
  53588. * Defines wether the current material of the mesh should be use to render the effect.
  53589. * @param mesh defines the current mesh to render
  53590. */
  53591. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53592. /**
  53593. * Rebuild the required buffers.
  53594. * @hidden Internal use only.
  53595. */
  53596. _rebuild(): void;
  53597. /**
  53598. * Dispose only the render target textures and post process.
  53599. */
  53600. private _disposeTextureAndPostProcesses;
  53601. /**
  53602. * Dispose the highlight layer and free resources.
  53603. */
  53604. dispose(): void;
  53605. /**
  53606. * Gets the class name of the effect layer
  53607. * @returns the string with the class name of the effect layer
  53608. */
  53609. getClassName(): string;
  53610. /**
  53611. * Creates an effect layer from parsed effect layer data
  53612. * @param parsedEffectLayer defines effect layer data
  53613. * @param scene defines the current scene
  53614. * @param rootUrl defines the root URL containing the effect layer information
  53615. * @returns a parsed effect Layer
  53616. */
  53617. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53618. }
  53619. }
  53620. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  53621. import { Scene } from "babylonjs/scene";
  53622. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53623. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53624. import { AbstractScene } from "babylonjs/abstractScene";
  53625. module "babylonjs/abstractScene" {
  53626. interface AbstractScene {
  53627. /**
  53628. * The list of effect layers (highlights/glow) added to the scene
  53629. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53630. * @see http://doc.babylonjs.com/how_to/glow_layer
  53631. */
  53632. effectLayers: Array<EffectLayer>;
  53633. /**
  53634. * Removes the given effect layer from this scene.
  53635. * @param toRemove defines the effect layer to remove
  53636. * @returns the index of the removed effect layer
  53637. */
  53638. removeEffectLayer(toRemove: EffectLayer): number;
  53639. /**
  53640. * Adds the given effect layer to this scene
  53641. * @param newEffectLayer defines the effect layer to add
  53642. */
  53643. addEffectLayer(newEffectLayer: EffectLayer): void;
  53644. }
  53645. }
  53646. /**
  53647. * Defines the layer scene component responsible to manage any effect layers
  53648. * in a given scene.
  53649. */
  53650. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53651. /**
  53652. * The component name helpfull to identify the component in the list of scene components.
  53653. */
  53654. readonly name: string;
  53655. /**
  53656. * The scene the component belongs to.
  53657. */
  53658. scene: Scene;
  53659. private _engine;
  53660. private _renderEffects;
  53661. private _needStencil;
  53662. private _previousStencilState;
  53663. /**
  53664. * Creates a new instance of the component for the given scene
  53665. * @param scene Defines the scene to register the component in
  53666. */
  53667. constructor(scene: Scene);
  53668. /**
  53669. * Registers the component in a given scene
  53670. */
  53671. register(): void;
  53672. /**
  53673. * Rebuilds the elements related to this component in case of
  53674. * context lost for instance.
  53675. */
  53676. rebuild(): void;
  53677. /**
  53678. * Serializes the component data to the specified json object
  53679. * @param serializationObject The object to serialize to
  53680. */
  53681. serialize(serializationObject: any): void;
  53682. /**
  53683. * Adds all the elements from the container to the scene
  53684. * @param container the container holding the elements
  53685. */
  53686. addFromContainer(container: AbstractScene): void;
  53687. /**
  53688. * Removes all the elements in the container from the scene
  53689. * @param container contains the elements to remove
  53690. * @param dispose if the removed element should be disposed (default: false)
  53691. */
  53692. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53693. /**
  53694. * Disposes the component and the associated ressources.
  53695. */
  53696. dispose(): void;
  53697. private _isReadyForMesh;
  53698. private _renderMainTexture;
  53699. private _setStencil;
  53700. private _setStencilBack;
  53701. private _draw;
  53702. private _drawCamera;
  53703. private _drawRenderingGroup;
  53704. }
  53705. }
  53706. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  53707. /** @hidden */
  53708. export var glowMapMergePixelShader: {
  53709. name: string;
  53710. shader: string;
  53711. };
  53712. }
  53713. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  53714. /** @hidden */
  53715. export var glowMapMergeVertexShader: {
  53716. name: string;
  53717. shader: string;
  53718. };
  53719. }
  53720. declare module "babylonjs/Layers/glowLayer" {
  53721. import { Nullable } from "babylonjs/types";
  53722. import { Camera } from "babylonjs/Cameras/camera";
  53723. import { Scene } from "babylonjs/scene";
  53724. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53726. import { Mesh } from "babylonjs/Meshes/mesh";
  53727. import { Texture } from "babylonjs/Materials/Textures/texture";
  53728. import { Effect } from "babylonjs/Materials/effect";
  53729. import { Material } from "babylonjs/Materials/material";
  53730. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53731. import { Color4 } from "babylonjs/Maths/math.color";
  53732. import "babylonjs/Shaders/glowMapMerge.fragment";
  53733. import "babylonjs/Shaders/glowMapMerge.vertex";
  53734. import "babylonjs/Layers/effectLayerSceneComponent";
  53735. module "babylonjs/abstractScene" {
  53736. interface AbstractScene {
  53737. /**
  53738. * Return a the first highlight layer of the scene with a given name.
  53739. * @param name The name of the highlight layer to look for.
  53740. * @return The highlight layer if found otherwise null.
  53741. */
  53742. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53743. }
  53744. }
  53745. /**
  53746. * Glow layer options. This helps customizing the behaviour
  53747. * of the glow layer.
  53748. */
  53749. export interface IGlowLayerOptions {
  53750. /**
  53751. * Multiplication factor apply to the canvas size to compute the render target size
  53752. * used to generated the glowing objects (the smaller the faster).
  53753. */
  53754. mainTextureRatio: number;
  53755. /**
  53756. * Enforces a fixed size texture to ensure resize independant blur.
  53757. */
  53758. mainTextureFixedSize?: number;
  53759. /**
  53760. * How big is the kernel of the blur texture.
  53761. */
  53762. blurKernelSize: number;
  53763. /**
  53764. * The camera attached to the layer.
  53765. */
  53766. camera: Nullable<Camera>;
  53767. /**
  53768. * Enable MSAA by chosing the number of samples.
  53769. */
  53770. mainTextureSamples?: number;
  53771. /**
  53772. * The rendering group to draw the layer in.
  53773. */
  53774. renderingGroupId: number;
  53775. }
  53776. /**
  53777. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53778. *
  53779. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53780. *
  53781. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53782. */
  53783. export class GlowLayer extends EffectLayer {
  53784. /**
  53785. * Effect Name of the layer.
  53786. */
  53787. static readonly EffectName: string;
  53788. /**
  53789. * The default blur kernel size used for the glow.
  53790. */
  53791. static DefaultBlurKernelSize: number;
  53792. /**
  53793. * The default texture size ratio used for the glow.
  53794. */
  53795. static DefaultTextureRatio: number;
  53796. /**
  53797. * Sets the kernel size of the blur.
  53798. */
  53799. /**
  53800. * Gets the kernel size of the blur.
  53801. */
  53802. blurKernelSize: number;
  53803. /**
  53804. * Sets the glow intensity.
  53805. */
  53806. /**
  53807. * Gets the glow intensity.
  53808. */
  53809. intensity: number;
  53810. private _options;
  53811. private _intensity;
  53812. private _horizontalBlurPostprocess1;
  53813. private _verticalBlurPostprocess1;
  53814. private _horizontalBlurPostprocess2;
  53815. private _verticalBlurPostprocess2;
  53816. private _blurTexture1;
  53817. private _blurTexture2;
  53818. private _postProcesses1;
  53819. private _postProcesses2;
  53820. private _includedOnlyMeshes;
  53821. private _excludedMeshes;
  53822. private _meshesUsingTheirOwnMaterials;
  53823. /**
  53824. * Callback used to let the user override the color selection on a per mesh basis
  53825. */
  53826. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53827. /**
  53828. * Callback used to let the user override the texture selection on a per mesh basis
  53829. */
  53830. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53831. /**
  53832. * Instantiates a new glow Layer and references it to the scene.
  53833. * @param name The name of the layer
  53834. * @param scene The scene to use the layer in
  53835. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53836. */
  53837. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53838. /**
  53839. * Get the effect name of the layer.
  53840. * @return The effect name
  53841. */
  53842. getEffectName(): string;
  53843. /**
  53844. * Create the merge effect. This is the shader use to blit the information back
  53845. * to the main canvas at the end of the scene rendering.
  53846. */
  53847. protected _createMergeEffect(): Effect;
  53848. /**
  53849. * Creates the render target textures and post processes used in the glow layer.
  53850. */
  53851. protected _createTextureAndPostProcesses(): void;
  53852. /**
  53853. * Checks for the readiness of the element composing the layer.
  53854. * @param subMesh the mesh to check for
  53855. * @param useInstances specify wether or not to use instances to render the mesh
  53856. * @param emissiveTexture the associated emissive texture used to generate the glow
  53857. * @return true if ready otherwise, false
  53858. */
  53859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53860. /**
  53861. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53862. */
  53863. needStencil(): boolean;
  53864. /**
  53865. * Returns true if the mesh can be rendered, otherwise false.
  53866. * @param mesh The mesh to render
  53867. * @param material The material used on the mesh
  53868. * @returns true if it can be rendered otherwise false
  53869. */
  53870. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53871. /**
  53872. * Implementation specific of rendering the generating effect on the main canvas.
  53873. * @param effect The effect used to render through
  53874. */
  53875. protected _internalRender(effect: Effect): void;
  53876. /**
  53877. * Sets the required values for both the emissive texture and and the main color.
  53878. */
  53879. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53880. /**
  53881. * Returns true if the mesh should render, otherwise false.
  53882. * @param mesh The mesh to render
  53883. * @returns true if it should render otherwise false
  53884. */
  53885. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53886. /**
  53887. * Adds specific effects defines.
  53888. * @param defines The defines to add specifics to.
  53889. */
  53890. protected _addCustomEffectDefines(defines: string[]): void;
  53891. /**
  53892. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53893. * @param mesh The mesh to exclude from the glow layer
  53894. */
  53895. addExcludedMesh(mesh: Mesh): void;
  53896. /**
  53897. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53898. * @param mesh The mesh to remove
  53899. */
  53900. removeExcludedMesh(mesh: Mesh): void;
  53901. /**
  53902. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53903. * @param mesh The mesh to include in the glow layer
  53904. */
  53905. addIncludedOnlyMesh(mesh: Mesh): void;
  53906. /**
  53907. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53908. * @param mesh The mesh to remove
  53909. */
  53910. removeIncludedOnlyMesh(mesh: Mesh): void;
  53911. /**
  53912. * Determine if a given mesh will be used in the glow layer
  53913. * @param mesh The mesh to test
  53914. * @returns true if the mesh will be highlighted by the current glow layer
  53915. */
  53916. hasMesh(mesh: AbstractMesh): boolean;
  53917. /**
  53918. * Defines wether the current material of the mesh should be use to render the effect.
  53919. * @param mesh defines the current mesh to render
  53920. */
  53921. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53922. /**
  53923. * Add a mesh to be rendered through its own material and not with emissive only.
  53924. * @param mesh The mesh for which we need to use its material
  53925. */
  53926. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53927. /**
  53928. * Remove a mesh from being rendered through its own material and not with emissive only.
  53929. * @param mesh The mesh for which we need to not use its material
  53930. */
  53931. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53932. /**
  53933. * Free any resources and references associated to a mesh.
  53934. * Internal use
  53935. * @param mesh The mesh to free.
  53936. * @hidden
  53937. */
  53938. _disposeMesh(mesh: Mesh): void;
  53939. /**
  53940. * Gets the class name of the effect layer
  53941. * @returns the string with the class name of the effect layer
  53942. */
  53943. getClassName(): string;
  53944. /**
  53945. * Serializes this glow layer
  53946. * @returns a serialized glow layer object
  53947. */
  53948. serialize(): any;
  53949. /**
  53950. * Creates a Glow Layer from parsed glow layer data
  53951. * @param parsedGlowLayer defines glow layer data
  53952. * @param scene defines the current scene
  53953. * @param rootUrl defines the root URL containing the glow layer information
  53954. * @returns a parsed Glow Layer
  53955. */
  53956. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53957. }
  53958. }
  53959. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53960. /** @hidden */
  53961. export var glowBlurPostProcessPixelShader: {
  53962. name: string;
  53963. shader: string;
  53964. };
  53965. }
  53966. declare module "babylonjs/Layers/highlightLayer" {
  53967. import { Observable } from "babylonjs/Misc/observable";
  53968. import { Nullable } from "babylonjs/types";
  53969. import { Camera } from "babylonjs/Cameras/camera";
  53970. import { Scene } from "babylonjs/scene";
  53971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53973. import { Mesh } from "babylonjs/Meshes/mesh";
  53974. import { Effect } from "babylonjs/Materials/effect";
  53975. import { Material } from "babylonjs/Materials/material";
  53976. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53977. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53978. import "babylonjs/Shaders/glowMapMerge.fragment";
  53979. import "babylonjs/Shaders/glowMapMerge.vertex";
  53980. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53981. module "babylonjs/abstractScene" {
  53982. interface AbstractScene {
  53983. /**
  53984. * Return a the first highlight layer of the scene with a given name.
  53985. * @param name The name of the highlight layer to look for.
  53986. * @return The highlight layer if found otherwise null.
  53987. */
  53988. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53989. }
  53990. }
  53991. /**
  53992. * Highlight layer options. This helps customizing the behaviour
  53993. * of the highlight layer.
  53994. */
  53995. export interface IHighlightLayerOptions {
  53996. /**
  53997. * Multiplication factor apply to the canvas size to compute the render target size
  53998. * used to generated the glowing objects (the smaller the faster).
  53999. */
  54000. mainTextureRatio: number;
  54001. /**
  54002. * Enforces a fixed size texture to ensure resize independant blur.
  54003. */
  54004. mainTextureFixedSize?: number;
  54005. /**
  54006. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54007. * of the picture to blur (the smaller the faster).
  54008. */
  54009. blurTextureSizeRatio: number;
  54010. /**
  54011. * How big in texel of the blur texture is the vertical blur.
  54012. */
  54013. blurVerticalSize: number;
  54014. /**
  54015. * How big in texel of the blur texture is the horizontal blur.
  54016. */
  54017. blurHorizontalSize: number;
  54018. /**
  54019. * Alpha blending mode used to apply the blur. Default is combine.
  54020. */
  54021. alphaBlendingMode: number;
  54022. /**
  54023. * The camera attached to the layer.
  54024. */
  54025. camera: Nullable<Camera>;
  54026. /**
  54027. * Should we display highlight as a solid stroke?
  54028. */
  54029. isStroke?: boolean;
  54030. /**
  54031. * The rendering group to draw the layer in.
  54032. */
  54033. renderingGroupId: number;
  54034. }
  54035. /**
  54036. * The highlight layer Helps adding a glow effect around a mesh.
  54037. *
  54038. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54039. * glowy meshes to your scene.
  54040. *
  54041. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54042. */
  54043. export class HighlightLayer extends EffectLayer {
  54044. name: string;
  54045. /**
  54046. * Effect Name of the highlight layer.
  54047. */
  54048. static readonly EffectName: string;
  54049. /**
  54050. * The neutral color used during the preparation of the glow effect.
  54051. * This is black by default as the blend operation is a blend operation.
  54052. */
  54053. static NeutralColor: Color4;
  54054. /**
  54055. * Stencil value used for glowing meshes.
  54056. */
  54057. static GlowingMeshStencilReference: number;
  54058. /**
  54059. * Stencil value used for the other meshes in the scene.
  54060. */
  54061. static NormalMeshStencilReference: number;
  54062. /**
  54063. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54064. */
  54065. innerGlow: boolean;
  54066. /**
  54067. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54068. */
  54069. outerGlow: boolean;
  54070. /**
  54071. * Specifies the horizontal size of the blur.
  54072. */
  54073. /**
  54074. * Gets the horizontal size of the blur.
  54075. */
  54076. blurHorizontalSize: number;
  54077. /**
  54078. * Specifies the vertical size of the blur.
  54079. */
  54080. /**
  54081. * Gets the vertical size of the blur.
  54082. */
  54083. blurVerticalSize: number;
  54084. /**
  54085. * An event triggered when the highlight layer is being blurred.
  54086. */
  54087. onBeforeBlurObservable: Observable<HighlightLayer>;
  54088. /**
  54089. * An event triggered when the highlight layer has been blurred.
  54090. */
  54091. onAfterBlurObservable: Observable<HighlightLayer>;
  54092. private _instanceGlowingMeshStencilReference;
  54093. private _options;
  54094. private _downSamplePostprocess;
  54095. private _horizontalBlurPostprocess;
  54096. private _verticalBlurPostprocess;
  54097. private _blurTexture;
  54098. private _meshes;
  54099. private _excludedMeshes;
  54100. /**
  54101. * Instantiates a new highlight Layer and references it to the scene..
  54102. * @param name The name of the layer
  54103. * @param scene The scene to use the layer in
  54104. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54105. */
  54106. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54107. /**
  54108. * Get the effect name of the layer.
  54109. * @return The effect name
  54110. */
  54111. getEffectName(): string;
  54112. /**
  54113. * Create the merge effect. This is the shader use to blit the information back
  54114. * to the main canvas at the end of the scene rendering.
  54115. */
  54116. protected _createMergeEffect(): Effect;
  54117. /**
  54118. * Creates the render target textures and post processes used in the highlight layer.
  54119. */
  54120. protected _createTextureAndPostProcesses(): void;
  54121. /**
  54122. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54123. */
  54124. needStencil(): boolean;
  54125. /**
  54126. * Checks for the readiness of the element composing the layer.
  54127. * @param subMesh the mesh to check for
  54128. * @param useInstances specify wether or not to use instances to render the mesh
  54129. * @param emissiveTexture the associated emissive texture used to generate the glow
  54130. * @return true if ready otherwise, false
  54131. */
  54132. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54133. /**
  54134. * Implementation specific of rendering the generating effect on the main canvas.
  54135. * @param effect The effect used to render through
  54136. */
  54137. protected _internalRender(effect: Effect): void;
  54138. /**
  54139. * Returns true if the layer contains information to display, otherwise false.
  54140. */
  54141. shouldRender(): boolean;
  54142. /**
  54143. * Returns true if the mesh should render, otherwise false.
  54144. * @param mesh The mesh to render
  54145. * @returns true if it should render otherwise false
  54146. */
  54147. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54148. /**
  54149. * Sets the required values for both the emissive texture and and the main color.
  54150. */
  54151. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54152. /**
  54153. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54154. * @param mesh The mesh to exclude from the highlight layer
  54155. */
  54156. addExcludedMesh(mesh: Mesh): void;
  54157. /**
  54158. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54159. * @param mesh The mesh to highlight
  54160. */
  54161. removeExcludedMesh(mesh: Mesh): void;
  54162. /**
  54163. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54164. * @param mesh mesh to test
  54165. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54166. */
  54167. hasMesh(mesh: AbstractMesh): boolean;
  54168. /**
  54169. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54170. * @param mesh The mesh to highlight
  54171. * @param color The color of the highlight
  54172. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54173. */
  54174. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54175. /**
  54176. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54177. * @param mesh The mesh to highlight
  54178. */
  54179. removeMesh(mesh: Mesh): void;
  54180. /**
  54181. * Force the stencil to the normal expected value for none glowing parts
  54182. */
  54183. private _defaultStencilReference;
  54184. /**
  54185. * Free any resources and references associated to a mesh.
  54186. * Internal use
  54187. * @param mesh The mesh to free.
  54188. * @hidden
  54189. */
  54190. _disposeMesh(mesh: Mesh): void;
  54191. /**
  54192. * Dispose the highlight layer and free resources.
  54193. */
  54194. dispose(): void;
  54195. /**
  54196. * Gets the class name of the effect layer
  54197. * @returns the string with the class name of the effect layer
  54198. */
  54199. getClassName(): string;
  54200. /**
  54201. * Serializes this Highlight layer
  54202. * @returns a serialized Highlight layer object
  54203. */
  54204. serialize(): any;
  54205. /**
  54206. * Creates a Highlight layer from parsed Highlight layer data
  54207. * @param parsedHightlightLayer defines the Highlight layer data
  54208. * @param scene defines the current scene
  54209. * @param rootUrl defines the root URL containing the Highlight layer information
  54210. * @returns a parsed Highlight layer
  54211. */
  54212. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54213. }
  54214. }
  54215. declare module "babylonjs/Layers/layerSceneComponent" {
  54216. import { Scene } from "babylonjs/scene";
  54217. import { ISceneComponent } from "babylonjs/sceneComponent";
  54218. import { Layer } from "babylonjs/Layers/layer";
  54219. import { AbstractScene } from "babylonjs/abstractScene";
  54220. module "babylonjs/abstractScene" {
  54221. interface AbstractScene {
  54222. /**
  54223. * The list of layers (background and foreground) of the scene
  54224. */
  54225. layers: Array<Layer>;
  54226. }
  54227. }
  54228. /**
  54229. * Defines the layer scene component responsible to manage any layers
  54230. * in a given scene.
  54231. */
  54232. export class LayerSceneComponent implements ISceneComponent {
  54233. /**
  54234. * The component name helpfull to identify the component in the list of scene components.
  54235. */
  54236. readonly name: string;
  54237. /**
  54238. * The scene the component belongs to.
  54239. */
  54240. scene: Scene;
  54241. private _engine;
  54242. /**
  54243. * Creates a new instance of the component for the given scene
  54244. * @param scene Defines the scene to register the component in
  54245. */
  54246. constructor(scene: Scene);
  54247. /**
  54248. * Registers the component in a given scene
  54249. */
  54250. register(): void;
  54251. /**
  54252. * Rebuilds the elements related to this component in case of
  54253. * context lost for instance.
  54254. */
  54255. rebuild(): void;
  54256. /**
  54257. * Disposes the component and the associated ressources.
  54258. */
  54259. dispose(): void;
  54260. private _draw;
  54261. private _drawCameraPredicate;
  54262. private _drawCameraBackground;
  54263. private _drawCameraForeground;
  54264. private _drawRenderTargetPredicate;
  54265. private _drawRenderTargetBackground;
  54266. private _drawRenderTargetForeground;
  54267. /**
  54268. * Adds all the elements from the container to the scene
  54269. * @param container the container holding the elements
  54270. */
  54271. addFromContainer(container: AbstractScene): void;
  54272. /**
  54273. * Removes all the elements in the container from the scene
  54274. * @param container contains the elements to remove
  54275. * @param dispose if the removed element should be disposed (default: false)
  54276. */
  54277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54278. }
  54279. }
  54280. declare module "babylonjs/Shaders/layer.fragment" {
  54281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54282. /** @hidden */
  54283. export var layerPixelShader: {
  54284. name: string;
  54285. shader: string;
  54286. };
  54287. }
  54288. declare module "babylonjs/Shaders/layer.vertex" {
  54289. /** @hidden */
  54290. export var layerVertexShader: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module "babylonjs/Layers/layer" {
  54296. import { Observable } from "babylonjs/Misc/observable";
  54297. import { Nullable } from "babylonjs/types";
  54298. import { Scene } from "babylonjs/scene";
  54299. import { Vector2 } from "babylonjs/Maths/math.vector";
  54300. import { Color4 } from "babylonjs/Maths/math.color";
  54301. import { Texture } from "babylonjs/Materials/Textures/texture";
  54302. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54303. import "babylonjs/Shaders/layer.fragment";
  54304. import "babylonjs/Shaders/layer.vertex";
  54305. /**
  54306. * This represents a full screen 2d layer.
  54307. * This can be useful to display a picture in the background of your scene for instance.
  54308. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54309. */
  54310. export class Layer {
  54311. /**
  54312. * Define the name of the layer.
  54313. */
  54314. name: string;
  54315. /**
  54316. * Define the texture the layer should display.
  54317. */
  54318. texture: Nullable<Texture>;
  54319. /**
  54320. * Is the layer in background or foreground.
  54321. */
  54322. isBackground: boolean;
  54323. /**
  54324. * Define the color of the layer (instead of texture).
  54325. */
  54326. color: Color4;
  54327. /**
  54328. * Define the scale of the layer in order to zoom in out of the texture.
  54329. */
  54330. scale: Vector2;
  54331. /**
  54332. * Define an offset for the layer in order to shift the texture.
  54333. */
  54334. offset: Vector2;
  54335. /**
  54336. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54337. */
  54338. alphaBlendingMode: number;
  54339. /**
  54340. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54341. * Alpha test will not mix with the background color in case of transparency.
  54342. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54343. */
  54344. alphaTest: boolean;
  54345. /**
  54346. * Define a mask to restrict the layer to only some of the scene cameras.
  54347. */
  54348. layerMask: number;
  54349. /**
  54350. * Define the list of render target the layer is visible into.
  54351. */
  54352. renderTargetTextures: RenderTargetTexture[];
  54353. /**
  54354. * Define if the layer is only used in renderTarget or if it also
  54355. * renders in the main frame buffer of the canvas.
  54356. */
  54357. renderOnlyInRenderTargetTextures: boolean;
  54358. private _scene;
  54359. private _vertexBuffers;
  54360. private _indexBuffer;
  54361. private _effect;
  54362. private _previousDefines;
  54363. /**
  54364. * An event triggered when the layer is disposed.
  54365. */
  54366. onDisposeObservable: Observable<Layer>;
  54367. private _onDisposeObserver;
  54368. /**
  54369. * Back compatibility with callback before the onDisposeObservable existed.
  54370. * The set callback will be triggered when the layer has been disposed.
  54371. */
  54372. onDispose: () => void;
  54373. /**
  54374. * An event triggered before rendering the scene
  54375. */
  54376. onBeforeRenderObservable: Observable<Layer>;
  54377. private _onBeforeRenderObserver;
  54378. /**
  54379. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54380. * The set callback will be triggered just before rendering the layer.
  54381. */
  54382. onBeforeRender: () => void;
  54383. /**
  54384. * An event triggered after rendering the scene
  54385. */
  54386. onAfterRenderObservable: Observable<Layer>;
  54387. private _onAfterRenderObserver;
  54388. /**
  54389. * Back compatibility with callback before the onAfterRenderObservable existed.
  54390. * The set callback will be triggered just after rendering the layer.
  54391. */
  54392. onAfterRender: () => void;
  54393. /**
  54394. * Instantiates a new layer.
  54395. * This represents a full screen 2d layer.
  54396. * This can be useful to display a picture in the background of your scene for instance.
  54397. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54398. * @param name Define the name of the layer in the scene
  54399. * @param imgUrl Define the url of the texture to display in the layer
  54400. * @param scene Define the scene the layer belongs to
  54401. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54402. * @param color Defines a color for the layer
  54403. */
  54404. constructor(
  54405. /**
  54406. * Define the name of the layer.
  54407. */
  54408. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54409. private _createIndexBuffer;
  54410. /** @hidden */
  54411. _rebuild(): void;
  54412. /**
  54413. * Renders the layer in the scene.
  54414. */
  54415. render(): void;
  54416. /**
  54417. * Disposes and releases the associated ressources.
  54418. */
  54419. dispose(): void;
  54420. }
  54421. }
  54422. declare module "babylonjs/Layers/index" {
  54423. export * from "babylonjs/Layers/effectLayer";
  54424. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54425. export * from "babylonjs/Layers/glowLayer";
  54426. export * from "babylonjs/Layers/highlightLayer";
  54427. export * from "babylonjs/Layers/layer";
  54428. export * from "babylonjs/Layers/layerSceneComponent";
  54429. }
  54430. declare module "babylonjs/Shaders/lensFlare.fragment" {
  54431. /** @hidden */
  54432. export var lensFlarePixelShader: {
  54433. name: string;
  54434. shader: string;
  54435. };
  54436. }
  54437. declare module "babylonjs/Shaders/lensFlare.vertex" {
  54438. /** @hidden */
  54439. export var lensFlareVertexShader: {
  54440. name: string;
  54441. shader: string;
  54442. };
  54443. }
  54444. declare module "babylonjs/LensFlares/lensFlareSystem" {
  54445. import { Scene } from "babylonjs/scene";
  54446. import { Vector3 } from "babylonjs/Maths/math.vector";
  54447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54448. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  54449. import "babylonjs/Shaders/lensFlare.fragment";
  54450. import "babylonjs/Shaders/lensFlare.vertex";
  54451. import { Viewport } from "babylonjs/Maths/math.viewport";
  54452. /**
  54453. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54454. * It is usually composed of several `lensFlare`.
  54455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54456. */
  54457. export class LensFlareSystem {
  54458. /**
  54459. * Define the name of the lens flare system
  54460. */
  54461. name: string;
  54462. /**
  54463. * List of lens flares used in this system.
  54464. */
  54465. lensFlares: LensFlare[];
  54466. /**
  54467. * Define a limit from the border the lens flare can be visible.
  54468. */
  54469. borderLimit: number;
  54470. /**
  54471. * Define a viewport border we do not want to see the lens flare in.
  54472. */
  54473. viewportBorder: number;
  54474. /**
  54475. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54476. */
  54477. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54478. /**
  54479. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54480. */
  54481. layerMask: number;
  54482. /**
  54483. * Define the id of the lens flare system in the scene.
  54484. * (equal to name by default)
  54485. */
  54486. id: string;
  54487. private _scene;
  54488. private _emitter;
  54489. private _vertexBuffers;
  54490. private _indexBuffer;
  54491. private _effect;
  54492. private _positionX;
  54493. private _positionY;
  54494. private _isEnabled;
  54495. /** @hidden */
  54496. static _SceneComponentInitialization: (scene: Scene) => void;
  54497. /**
  54498. * Instantiates a lens flare system.
  54499. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54500. * It is usually composed of several `lensFlare`.
  54501. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54502. * @param name Define the name of the lens flare system in the scene
  54503. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54504. * @param scene Define the scene the lens flare system belongs to
  54505. */
  54506. constructor(
  54507. /**
  54508. * Define the name of the lens flare system
  54509. */
  54510. name: string, emitter: any, scene: Scene);
  54511. /**
  54512. * Define if the lens flare system is enabled.
  54513. */
  54514. isEnabled: boolean;
  54515. /**
  54516. * Get the scene the effects belongs to.
  54517. * @returns the scene holding the lens flare system
  54518. */
  54519. getScene(): Scene;
  54520. /**
  54521. * Get the emitter of the lens flare system.
  54522. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54523. * @returns the emitter of the lens flare system
  54524. */
  54525. getEmitter(): any;
  54526. /**
  54527. * Set the emitter of the lens flare system.
  54528. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54529. * @param newEmitter Define the new emitter of the system
  54530. */
  54531. setEmitter(newEmitter: any): void;
  54532. /**
  54533. * Get the lens flare system emitter position.
  54534. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54535. * @returns the position
  54536. */
  54537. getEmitterPosition(): Vector3;
  54538. /**
  54539. * @hidden
  54540. */
  54541. computeEffectivePosition(globalViewport: Viewport): boolean;
  54542. /** @hidden */
  54543. _isVisible(): boolean;
  54544. /**
  54545. * @hidden
  54546. */
  54547. render(): boolean;
  54548. /**
  54549. * Dispose and release the lens flare with its associated resources.
  54550. */
  54551. dispose(): void;
  54552. /**
  54553. * Parse a lens flare system from a JSON repressentation
  54554. * @param parsedLensFlareSystem Define the JSON to parse
  54555. * @param scene Define the scene the parsed system should be instantiated in
  54556. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54557. * @returns the parsed system
  54558. */
  54559. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54560. /**
  54561. * Serialize the current Lens Flare System into a JSON representation.
  54562. * @returns the serialized JSON
  54563. */
  54564. serialize(): any;
  54565. }
  54566. }
  54567. declare module "babylonjs/LensFlares/lensFlare" {
  54568. import { Nullable } from "babylonjs/types";
  54569. import { Color3 } from "babylonjs/Maths/math.color";
  54570. import { Texture } from "babylonjs/Materials/Textures/texture";
  54571. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  54572. /**
  54573. * This represents one of the lens effect in a `lensFlareSystem`.
  54574. * It controls one of the indiviual texture used in the effect.
  54575. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54576. */
  54577. export class LensFlare {
  54578. /**
  54579. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54580. */
  54581. size: number;
  54582. /**
  54583. * 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.
  54584. */
  54585. position: number;
  54586. /**
  54587. * Define the lens color.
  54588. */
  54589. color: Color3;
  54590. /**
  54591. * Define the lens texture.
  54592. */
  54593. texture: Nullable<Texture>;
  54594. /**
  54595. * Define the alpha mode to render this particular lens.
  54596. */
  54597. alphaMode: number;
  54598. private _system;
  54599. /**
  54600. * Creates a new Lens Flare.
  54601. * This represents one of the lens effect in a `lensFlareSystem`.
  54602. * It controls one of the indiviual texture used in the effect.
  54603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54604. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54605. * @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.
  54606. * @param color Define the lens color
  54607. * @param imgUrl Define the lens texture url
  54608. * @param system Define the `lensFlareSystem` this flare is part of
  54609. * @returns The newly created Lens Flare
  54610. */
  54611. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54612. /**
  54613. * Instantiates a new Lens Flare.
  54614. * This represents one of the lens effect in a `lensFlareSystem`.
  54615. * It controls one of the indiviual texture used in the effect.
  54616. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54617. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54618. * @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.
  54619. * @param color Define the lens color
  54620. * @param imgUrl Define the lens texture url
  54621. * @param system Define the `lensFlareSystem` this flare is part of
  54622. */
  54623. constructor(
  54624. /**
  54625. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54626. */
  54627. size: number,
  54628. /**
  54629. * 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.
  54630. */
  54631. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54632. /**
  54633. * Dispose and release the lens flare with its associated resources.
  54634. */
  54635. dispose(): void;
  54636. }
  54637. }
  54638. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  54639. import { Nullable } from "babylonjs/types";
  54640. import { Scene } from "babylonjs/scene";
  54641. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54642. import { AbstractScene } from "babylonjs/abstractScene";
  54643. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  54644. module "babylonjs/abstractScene" {
  54645. interface AbstractScene {
  54646. /**
  54647. * The list of lens flare system added to the scene
  54648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54649. */
  54650. lensFlareSystems: Array<LensFlareSystem>;
  54651. /**
  54652. * Removes the given lens flare system from this scene.
  54653. * @param toRemove The lens flare system to remove
  54654. * @returns The index of the removed lens flare system
  54655. */
  54656. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54657. /**
  54658. * Adds the given lens flare system to this scene
  54659. * @param newLensFlareSystem The lens flare system to add
  54660. */
  54661. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54662. /**
  54663. * Gets a lens flare system using its name
  54664. * @param name defines the name to look for
  54665. * @returns the lens flare system or null if not found
  54666. */
  54667. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54668. /**
  54669. * Gets a lens flare system using its id
  54670. * @param id defines the id to look for
  54671. * @returns the lens flare system or null if not found
  54672. */
  54673. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54674. }
  54675. }
  54676. /**
  54677. * Defines the lens flare scene component responsible to manage any lens flares
  54678. * in a given scene.
  54679. */
  54680. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54681. /**
  54682. * The component name helpfull to identify the component in the list of scene components.
  54683. */
  54684. readonly name: string;
  54685. /**
  54686. * The scene the component belongs to.
  54687. */
  54688. scene: Scene;
  54689. /**
  54690. * Creates a new instance of the component for the given scene
  54691. * @param scene Defines the scene to register the component in
  54692. */
  54693. constructor(scene: Scene);
  54694. /**
  54695. * Registers the component in a given scene
  54696. */
  54697. register(): void;
  54698. /**
  54699. * Rebuilds the elements related to this component in case of
  54700. * context lost for instance.
  54701. */
  54702. rebuild(): void;
  54703. /**
  54704. * Adds all the elements from the container to the scene
  54705. * @param container the container holding the elements
  54706. */
  54707. addFromContainer(container: AbstractScene): void;
  54708. /**
  54709. * Removes all the elements in the container from the scene
  54710. * @param container contains the elements to remove
  54711. * @param dispose if the removed element should be disposed (default: false)
  54712. */
  54713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54714. /**
  54715. * Serializes the component data to the specified json object
  54716. * @param serializationObject The object to serialize to
  54717. */
  54718. serialize(serializationObject: any): void;
  54719. /**
  54720. * Disposes the component and the associated ressources.
  54721. */
  54722. dispose(): void;
  54723. private _draw;
  54724. }
  54725. }
  54726. declare module "babylonjs/LensFlares/index" {
  54727. export * from "babylonjs/LensFlares/lensFlare";
  54728. export * from "babylonjs/LensFlares/lensFlareSystem";
  54729. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  54730. }
  54731. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  54732. import { Scene } from "babylonjs/scene";
  54733. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54734. import { AbstractScene } from "babylonjs/abstractScene";
  54735. /**
  54736. * Defines the shadow generator component responsible to manage any shadow generators
  54737. * in a given scene.
  54738. */
  54739. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54740. /**
  54741. * The component name helpfull to identify the component in the list of scene components.
  54742. */
  54743. readonly name: string;
  54744. /**
  54745. * The scene the component belongs to.
  54746. */
  54747. scene: Scene;
  54748. /**
  54749. * Creates a new instance of the component for the given scene
  54750. * @param scene Defines the scene to register the component in
  54751. */
  54752. constructor(scene: Scene);
  54753. /**
  54754. * Registers the component in a given scene
  54755. */
  54756. register(): void;
  54757. /**
  54758. * Rebuilds the elements related to this component in case of
  54759. * context lost for instance.
  54760. */
  54761. rebuild(): void;
  54762. /**
  54763. * Serializes the component data to the specified json object
  54764. * @param serializationObject The object to serialize to
  54765. */
  54766. serialize(serializationObject: any): void;
  54767. /**
  54768. * Adds all the elements from the container to the scene
  54769. * @param container the container holding the elements
  54770. */
  54771. addFromContainer(container: AbstractScene): void;
  54772. /**
  54773. * Removes all the elements in the container from the scene
  54774. * @param container contains the elements to remove
  54775. * @param dispose if the removed element should be disposed (default: false)
  54776. */
  54777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54778. /**
  54779. * Rebuilds the elements related to this component in case of
  54780. * context lost for instance.
  54781. */
  54782. dispose(): void;
  54783. private _gatherRenderTargets;
  54784. }
  54785. }
  54786. declare module "babylonjs/Lights/Shadows/index" {
  54787. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54788. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54789. }
  54790. declare module "babylonjs/Lights/pointLight" {
  54791. import { Scene } from "babylonjs/scene";
  54792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54794. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54795. import { Effect } from "babylonjs/Materials/effect";
  54796. /**
  54797. * A point light is a light defined by an unique point in world space.
  54798. * The light is emitted in every direction from this point.
  54799. * A good example of a point light is a standard light bulb.
  54800. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54801. */
  54802. export class PointLight extends ShadowLight {
  54803. private _shadowAngle;
  54804. /**
  54805. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54806. * This specifies what angle the shadow will use to be created.
  54807. *
  54808. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54809. */
  54810. /**
  54811. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54812. * This specifies what angle the shadow will use to be created.
  54813. *
  54814. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54815. */
  54816. shadowAngle: number;
  54817. /**
  54818. * Gets the direction if it has been set.
  54819. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54820. */
  54821. /**
  54822. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54823. */
  54824. direction: Vector3;
  54825. /**
  54826. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54827. * A PointLight emits the light in every direction.
  54828. * It can cast shadows.
  54829. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54830. * ```javascript
  54831. * var pointLight = new PointLight("pl", camera.position, scene);
  54832. * ```
  54833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54834. * @param name The light friendly name
  54835. * @param position The position of the point light in the scene
  54836. * @param scene The scene the lights belongs to
  54837. */
  54838. constructor(name: string, position: Vector3, scene: Scene);
  54839. /**
  54840. * Returns the string "PointLight"
  54841. * @returns the class name
  54842. */
  54843. getClassName(): string;
  54844. /**
  54845. * Returns the integer 0.
  54846. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54847. */
  54848. getTypeID(): number;
  54849. /**
  54850. * Specifies wether or not the shadowmap should be a cube texture.
  54851. * @returns true if the shadowmap needs to be a cube texture.
  54852. */
  54853. needCube(): boolean;
  54854. /**
  54855. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54856. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54857. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54858. */
  54859. getShadowDirection(faceIndex?: number): Vector3;
  54860. /**
  54861. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54862. * - fov = PI / 2
  54863. * - aspect ratio : 1.0
  54864. * - z-near and far equal to the active camera minZ and maxZ.
  54865. * Returns the PointLight.
  54866. */
  54867. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54868. protected _buildUniformLayout(): void;
  54869. /**
  54870. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54871. * @param effect The effect to update
  54872. * @param lightIndex The index of the light in the effect to update
  54873. * @returns The point light
  54874. */
  54875. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54876. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54877. /**
  54878. * Prepares the list of defines specific to the light type.
  54879. * @param defines the list of defines
  54880. * @param lightIndex defines the index of the light for the effect
  54881. */
  54882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54883. }
  54884. }
  54885. declare module "babylonjs/Lights/index" {
  54886. export * from "babylonjs/Lights/light";
  54887. export * from "babylonjs/Lights/shadowLight";
  54888. export * from "babylonjs/Lights/Shadows/index";
  54889. export * from "babylonjs/Lights/directionalLight";
  54890. export * from "babylonjs/Lights/hemisphericLight";
  54891. export * from "babylonjs/Lights/pointLight";
  54892. export * from "babylonjs/Lights/spotLight";
  54893. }
  54894. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54895. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54896. /**
  54897. * Header information of HDR texture files.
  54898. */
  54899. export interface HDRInfo {
  54900. /**
  54901. * The height of the texture in pixels.
  54902. */
  54903. height: number;
  54904. /**
  54905. * The width of the texture in pixels.
  54906. */
  54907. width: number;
  54908. /**
  54909. * The index of the beginning of the data in the binary file.
  54910. */
  54911. dataPosition: number;
  54912. }
  54913. /**
  54914. * This groups tools to convert HDR texture to native colors array.
  54915. */
  54916. export class HDRTools {
  54917. private static Ldexp;
  54918. private static Rgbe2float;
  54919. private static readStringLine;
  54920. /**
  54921. * Reads header information from an RGBE texture stored in a native array.
  54922. * More information on this format are available here:
  54923. * https://en.wikipedia.org/wiki/RGBE_image_format
  54924. *
  54925. * @param uint8array The binary file stored in native array.
  54926. * @return The header information.
  54927. */
  54928. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54929. /**
  54930. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54931. * This RGBE texture needs to store the information as a panorama.
  54932. *
  54933. * More information on this format are available here:
  54934. * https://en.wikipedia.org/wiki/RGBE_image_format
  54935. *
  54936. * @param buffer The binary file stored in an array buffer.
  54937. * @param size The expected size of the extracted cubemap.
  54938. * @return The Cube Map information.
  54939. */
  54940. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54941. /**
  54942. * Returns the pixels data extracted from an RGBE texture.
  54943. * This pixels will be stored left to right up to down in the R G B order in one array.
  54944. *
  54945. * More information on this format are available here:
  54946. * https://en.wikipedia.org/wiki/RGBE_image_format
  54947. *
  54948. * @param uint8array The binary file stored in an array buffer.
  54949. * @param hdrInfo The header information of the file.
  54950. * @return The pixels data in RGB right to left up to down order.
  54951. */
  54952. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54953. private static RGBE_ReadPixels_RLE;
  54954. }
  54955. }
  54956. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54957. import { Nullable } from "babylonjs/types";
  54958. import { Scene } from "babylonjs/scene";
  54959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54961. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54962. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54963. /**
  54964. * This represents a texture coming from an HDR input.
  54965. *
  54966. * The only supported format is currently panorama picture stored in RGBE format.
  54967. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54968. */
  54969. export class HDRCubeTexture extends BaseTexture {
  54970. private static _facesMapping;
  54971. private _generateHarmonics;
  54972. private _noMipmap;
  54973. private _textureMatrix;
  54974. private _size;
  54975. private _onLoad;
  54976. private _onError;
  54977. /**
  54978. * The texture URL.
  54979. */
  54980. url: string;
  54981. /**
  54982. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54983. */
  54984. coordinatesMode: number;
  54985. protected _isBlocking: boolean;
  54986. /**
  54987. * Sets wether or not the texture is blocking during loading.
  54988. */
  54989. /**
  54990. * Gets wether or not the texture is blocking during loading.
  54991. */
  54992. isBlocking: boolean;
  54993. protected _rotationY: number;
  54994. /**
  54995. * Sets texture matrix rotation angle around Y axis in radians.
  54996. */
  54997. /**
  54998. * Gets texture matrix rotation angle around Y axis radians.
  54999. */
  55000. rotationY: number;
  55001. /**
  55002. * Gets or sets the center of the bounding box associated with the cube texture
  55003. * It must define where the camera used to render the texture was set
  55004. */
  55005. boundingBoxPosition: Vector3;
  55006. private _boundingBoxSize;
  55007. /**
  55008. * Gets or sets the size of the bounding box associated with the cube texture
  55009. * When defined, the cubemap will switch to local mode
  55010. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55011. * @example https://www.babylonjs-playground.com/#RNASML
  55012. */
  55013. boundingBoxSize: Vector3;
  55014. /**
  55015. * Instantiates an HDRTexture from the following parameters.
  55016. *
  55017. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55018. * @param scene The scene the texture will be used in
  55019. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55020. * @param noMipmap Forces to not generate the mipmap if true
  55021. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55022. * @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)
  55023. * @param reserved Reserved flag for internal use.
  55024. */
  55025. 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>);
  55026. /**
  55027. * Get the current class name of the texture useful for serialization or dynamic coding.
  55028. * @returns "HDRCubeTexture"
  55029. */
  55030. getClassName(): string;
  55031. /**
  55032. * Occurs when the file is raw .hdr file.
  55033. */
  55034. private loadTexture;
  55035. clone(): HDRCubeTexture;
  55036. delayLoad(): void;
  55037. /**
  55038. * Get the texture reflection matrix used to rotate/transform the reflection.
  55039. * @returns the reflection matrix
  55040. */
  55041. getReflectionTextureMatrix(): Matrix;
  55042. /**
  55043. * Set the texture reflection matrix used to rotate/transform the reflection.
  55044. * @param value Define the reflection matrix to set
  55045. */
  55046. setReflectionTextureMatrix(value: Matrix): void;
  55047. /**
  55048. * Parses a JSON representation of an HDR Texture in order to create the texture
  55049. * @param parsedTexture Define the JSON representation
  55050. * @param scene Define the scene the texture should be created in
  55051. * @param rootUrl Define the root url in case we need to load relative dependencies
  55052. * @returns the newly created texture after parsing
  55053. */
  55054. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55055. serialize(): any;
  55056. }
  55057. }
  55058. declare module "babylonjs/Physics/physicsEngine" {
  55059. import { Nullable } from "babylonjs/types";
  55060. import { Vector3 } from "babylonjs/Maths/math.vector";
  55061. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55062. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55063. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55064. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55065. /**
  55066. * Class used to control physics engine
  55067. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55068. */
  55069. export class PhysicsEngine implements IPhysicsEngine {
  55070. private _physicsPlugin;
  55071. /**
  55072. * Global value used to control the smallest number supported by the simulation
  55073. */
  55074. static Epsilon: number;
  55075. private _impostors;
  55076. private _joints;
  55077. private _subTimeStep;
  55078. /**
  55079. * Gets the gravity vector used by the simulation
  55080. */
  55081. gravity: Vector3;
  55082. /**
  55083. * Factory used to create the default physics plugin.
  55084. * @returns The default physics plugin
  55085. */
  55086. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55087. /**
  55088. * Creates a new Physics Engine
  55089. * @param gravity defines the gravity vector used by the simulation
  55090. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55091. */
  55092. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55093. /**
  55094. * Sets the gravity vector used by the simulation
  55095. * @param gravity defines the gravity vector to use
  55096. */
  55097. setGravity(gravity: Vector3): void;
  55098. /**
  55099. * Set the time step of the physics engine.
  55100. * Default is 1/60.
  55101. * To slow it down, enter 1/600 for example.
  55102. * To speed it up, 1/30
  55103. * @param newTimeStep defines the new timestep to apply to this world.
  55104. */
  55105. setTimeStep(newTimeStep?: number): void;
  55106. /**
  55107. * Get the time step of the physics engine.
  55108. * @returns the current time step
  55109. */
  55110. getTimeStep(): number;
  55111. /**
  55112. * Set the sub time step of the physics engine.
  55113. * Default is 0 meaning there is no sub steps
  55114. * To increase physics resolution precision, set a small value (like 1 ms)
  55115. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55116. */
  55117. setSubTimeStep(subTimeStep?: number): void;
  55118. /**
  55119. * Get the sub time step of the physics engine.
  55120. * @returns the current sub time step
  55121. */
  55122. getSubTimeStep(): number;
  55123. /**
  55124. * Release all resources
  55125. */
  55126. dispose(): void;
  55127. /**
  55128. * Gets the name of the current physics plugin
  55129. * @returns the name of the plugin
  55130. */
  55131. getPhysicsPluginName(): string;
  55132. /**
  55133. * Adding a new impostor for the impostor tracking.
  55134. * This will be done by the impostor itself.
  55135. * @param impostor the impostor to add
  55136. */
  55137. addImpostor(impostor: PhysicsImpostor): void;
  55138. /**
  55139. * Remove an impostor from the engine.
  55140. * This impostor and its mesh will not longer be updated by the physics engine.
  55141. * @param impostor the impostor to remove
  55142. */
  55143. removeImpostor(impostor: PhysicsImpostor): void;
  55144. /**
  55145. * Add a joint to the physics engine
  55146. * @param mainImpostor defines the main impostor to which the joint is added.
  55147. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55148. * @param joint defines the joint that will connect both impostors.
  55149. */
  55150. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55151. /**
  55152. * Removes a joint from the simulation
  55153. * @param mainImpostor defines the impostor used with the joint
  55154. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55155. * @param joint defines the joint to remove
  55156. */
  55157. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55158. /**
  55159. * Called by the scene. No need to call it.
  55160. * @param delta defines the timespam between frames
  55161. */
  55162. _step(delta: number): void;
  55163. /**
  55164. * Gets the current plugin used to run the simulation
  55165. * @returns current plugin
  55166. */
  55167. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55168. /**
  55169. * Gets the list of physic impostors
  55170. * @returns an array of PhysicsImpostor
  55171. */
  55172. getImpostors(): Array<PhysicsImpostor>;
  55173. /**
  55174. * Gets the impostor for a physics enabled object
  55175. * @param object defines the object impersonated by the impostor
  55176. * @returns the PhysicsImpostor or null if not found
  55177. */
  55178. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55179. /**
  55180. * Gets the impostor for a physics body object
  55181. * @param body defines physics body used by the impostor
  55182. * @returns the PhysicsImpostor or null if not found
  55183. */
  55184. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55185. /**
  55186. * Does a raycast in the physics world
  55187. * @param from when should the ray start?
  55188. * @param to when should the ray end?
  55189. * @returns PhysicsRaycastResult
  55190. */
  55191. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55192. }
  55193. }
  55194. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55195. import { Nullable } from "babylonjs/types";
  55196. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55198. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55199. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55200. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55201. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55202. /** @hidden */
  55203. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55204. private _useDeltaForWorldStep;
  55205. world: any;
  55206. name: string;
  55207. private _physicsMaterials;
  55208. private _fixedTimeStep;
  55209. private _cannonRaycastResult;
  55210. private _raycastResult;
  55211. private _physicsBodysToRemoveAfterStep;
  55212. BJSCANNON: any;
  55213. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55214. setGravity(gravity: Vector3): void;
  55215. setTimeStep(timeStep: number): void;
  55216. getTimeStep(): number;
  55217. executeStep(delta: number): void;
  55218. private _removeMarkedPhysicsBodiesFromWorld;
  55219. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55220. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55221. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55222. private _processChildMeshes;
  55223. removePhysicsBody(impostor: PhysicsImpostor): void;
  55224. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55225. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55226. private _addMaterial;
  55227. private _checkWithEpsilon;
  55228. private _createShape;
  55229. private _createHeightmap;
  55230. private _minus90X;
  55231. private _plus90X;
  55232. private _tmpPosition;
  55233. private _tmpDeltaPosition;
  55234. private _tmpUnityRotation;
  55235. private _updatePhysicsBodyTransformation;
  55236. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55237. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55238. isSupported(): boolean;
  55239. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55240. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55241. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55242. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55243. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55244. getBodyMass(impostor: PhysicsImpostor): number;
  55245. getBodyFriction(impostor: PhysicsImpostor): number;
  55246. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55247. getBodyRestitution(impostor: PhysicsImpostor): number;
  55248. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55249. sleepBody(impostor: PhysicsImpostor): void;
  55250. wakeUpBody(impostor: PhysicsImpostor): void;
  55251. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55252. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55253. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55254. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55255. getRadius(impostor: PhysicsImpostor): number;
  55256. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55257. dispose(): void;
  55258. private _extendNamespace;
  55259. /**
  55260. * Does a raycast in the physics world
  55261. * @param from when should the ray start?
  55262. * @param to when should the ray end?
  55263. * @returns PhysicsRaycastResult
  55264. */
  55265. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55266. }
  55267. }
  55268. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55269. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55270. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55271. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55273. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55274. import { Nullable } from "babylonjs/types";
  55275. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55276. /** @hidden */
  55277. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55278. world: any;
  55279. name: string;
  55280. BJSOIMO: any;
  55281. private _raycastResult;
  55282. constructor(iterations?: number, oimoInjection?: any);
  55283. setGravity(gravity: Vector3): void;
  55284. setTimeStep(timeStep: number): void;
  55285. getTimeStep(): number;
  55286. private _tmpImpostorsArray;
  55287. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55289. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55291. private _tmpPositionVector;
  55292. removePhysicsBody(impostor: PhysicsImpostor): void;
  55293. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55294. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55295. isSupported(): boolean;
  55296. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55297. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55298. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55299. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55300. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55301. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55302. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55303. getBodyMass(impostor: PhysicsImpostor): number;
  55304. getBodyFriction(impostor: PhysicsImpostor): number;
  55305. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55306. getBodyRestitution(impostor: PhysicsImpostor): number;
  55307. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55308. sleepBody(impostor: PhysicsImpostor): void;
  55309. wakeUpBody(impostor: PhysicsImpostor): void;
  55310. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55311. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55312. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55313. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55314. getRadius(impostor: PhysicsImpostor): number;
  55315. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55316. dispose(): void;
  55317. /**
  55318. * Does a raycast in the physics world
  55319. * @param from when should the ray start?
  55320. * @param to when should the ray end?
  55321. * @returns PhysicsRaycastResult
  55322. */
  55323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55324. }
  55325. }
  55326. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55327. import { Nullable } from "babylonjs/types";
  55328. import { Scene } from "babylonjs/scene";
  55329. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55330. import { Color4 } from "babylonjs/Maths/math.color";
  55331. import { Mesh } from "babylonjs/Meshes/mesh";
  55332. /**
  55333. * Class containing static functions to help procedurally build meshes
  55334. */
  55335. export class RibbonBuilder {
  55336. /**
  55337. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55338. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55339. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55340. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55341. * * 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
  55342. * * 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
  55343. * * 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
  55344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55347. * * 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
  55348. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55349. * * 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
  55350. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55352. * @param name defines the name of the mesh
  55353. * @param options defines the options used to create the mesh
  55354. * @param scene defines the hosting scene
  55355. * @returns the ribbon mesh
  55356. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55357. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55358. */
  55359. static CreateRibbon(name: string, options: {
  55360. pathArray: Vector3[][];
  55361. closeArray?: boolean;
  55362. closePath?: boolean;
  55363. offset?: number;
  55364. updatable?: boolean;
  55365. sideOrientation?: number;
  55366. frontUVs?: Vector4;
  55367. backUVs?: Vector4;
  55368. instance?: Mesh;
  55369. invertUV?: boolean;
  55370. uvs?: Vector2[];
  55371. colors?: Color4[];
  55372. }, scene?: Nullable<Scene>): Mesh;
  55373. }
  55374. }
  55375. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55376. import { Nullable } from "babylonjs/types";
  55377. import { Scene } from "babylonjs/scene";
  55378. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55379. import { Mesh } from "babylonjs/Meshes/mesh";
  55380. /**
  55381. * Class containing static functions to help procedurally build meshes
  55382. */
  55383. export class ShapeBuilder {
  55384. /**
  55385. * 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.
  55386. * * 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.
  55387. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55388. * * 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.
  55389. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55390. * * 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
  55391. * * 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
  55392. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55397. * @param name defines the name of the mesh
  55398. * @param options defines the options used to create the mesh
  55399. * @param scene defines the hosting scene
  55400. * @returns the extruded shape mesh
  55401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55403. */
  55404. static ExtrudeShape(name: string, options: {
  55405. shape: Vector3[];
  55406. path: Vector3[];
  55407. scale?: number;
  55408. rotation?: number;
  55409. cap?: number;
  55410. updatable?: boolean;
  55411. sideOrientation?: number;
  55412. frontUVs?: Vector4;
  55413. backUVs?: Vector4;
  55414. instance?: Mesh;
  55415. invertUV?: boolean;
  55416. }, scene?: Nullable<Scene>): Mesh;
  55417. /**
  55418. * Creates an custom extruded shape mesh.
  55419. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55420. * * 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.
  55421. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55422. * * 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
  55423. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55424. * * 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
  55425. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55426. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55427. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55428. * * 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
  55429. * * 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
  55430. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55435. * @param name defines the name of the mesh
  55436. * @param options defines the options used to create the mesh
  55437. * @param scene defines the hosting scene
  55438. * @returns the custom extruded shape mesh
  55439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55440. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55442. */
  55443. static ExtrudeShapeCustom(name: string, options: {
  55444. shape: Vector3[];
  55445. path: Vector3[];
  55446. scaleFunction?: any;
  55447. rotationFunction?: any;
  55448. ribbonCloseArray?: boolean;
  55449. ribbonClosePath?: boolean;
  55450. cap?: number;
  55451. updatable?: boolean;
  55452. sideOrientation?: number;
  55453. frontUVs?: Vector4;
  55454. backUVs?: Vector4;
  55455. instance?: Mesh;
  55456. invertUV?: boolean;
  55457. }, scene?: Nullable<Scene>): Mesh;
  55458. private static _ExtrudeShapeGeneric;
  55459. }
  55460. }
  55461. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  55462. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  55463. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55464. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55465. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55466. import { Nullable } from "babylonjs/types";
  55467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55468. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55469. /**
  55470. * AmmoJS Physics plugin
  55471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55472. * @see https://github.com/kripken/ammo.js/
  55473. */
  55474. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55475. private _useDeltaForWorldStep;
  55476. /**
  55477. * Reference to the Ammo library
  55478. */
  55479. bjsAMMO: any;
  55480. /**
  55481. * Created ammoJS world which physics bodies are added to
  55482. */
  55483. world: any;
  55484. /**
  55485. * Name of the plugin
  55486. */
  55487. name: string;
  55488. private _timeStep;
  55489. private _fixedTimeStep;
  55490. private _maxSteps;
  55491. private _tmpQuaternion;
  55492. private _tmpAmmoTransform;
  55493. private _tmpAmmoQuaternion;
  55494. private _tmpAmmoConcreteContactResultCallback;
  55495. private _collisionConfiguration;
  55496. private _dispatcher;
  55497. private _overlappingPairCache;
  55498. private _solver;
  55499. private _softBodySolver;
  55500. private _tmpAmmoVectorA;
  55501. private _tmpAmmoVectorB;
  55502. private _tmpAmmoVectorC;
  55503. private _tmpAmmoVectorD;
  55504. private _tmpContactCallbackResult;
  55505. private _tmpAmmoVectorRCA;
  55506. private _tmpAmmoVectorRCB;
  55507. private _raycastResult;
  55508. private static readonly DISABLE_COLLISION_FLAG;
  55509. private static readonly KINEMATIC_FLAG;
  55510. private static readonly DISABLE_DEACTIVATION_FLAG;
  55511. /**
  55512. * Initializes the ammoJS plugin
  55513. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55514. * @param ammoInjection can be used to inject your own ammo reference
  55515. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55516. */
  55517. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55518. /**
  55519. * Sets the gravity of the physics world (m/(s^2))
  55520. * @param gravity Gravity to set
  55521. */
  55522. setGravity(gravity: Vector3): void;
  55523. /**
  55524. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55525. * @param timeStep timestep to use in seconds
  55526. */
  55527. setTimeStep(timeStep: number): void;
  55528. /**
  55529. * 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)
  55530. * @param fixedTimeStep fixedTimeStep to use in seconds
  55531. */
  55532. setFixedTimeStep(fixedTimeStep: number): void;
  55533. /**
  55534. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55535. * @param maxSteps the maximum number of steps by the physics engine per frame
  55536. */
  55537. setMaxSteps(maxSteps: number): void;
  55538. /**
  55539. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55540. * @returns the current timestep in seconds
  55541. */
  55542. getTimeStep(): number;
  55543. /**
  55544. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55545. */
  55546. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55547. private _isImpostorInContact;
  55548. private _isImpostorPairInContact;
  55549. private _stepSimulation;
  55550. /**
  55551. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55552. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55553. * After the step the babylon meshes are set to the position of the physics imposters
  55554. * @param delta amount of time to step forward
  55555. * @param impostors array of imposters to update before/after the step
  55556. */
  55557. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55558. /**
  55559. * Update babylon mesh to match physics world object
  55560. * @param impostor imposter to match
  55561. */
  55562. private _afterSoftStep;
  55563. /**
  55564. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55565. * @param impostor imposter to match
  55566. */
  55567. private _ropeStep;
  55568. /**
  55569. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55570. * @param impostor imposter to match
  55571. */
  55572. private _softbodyOrClothStep;
  55573. private _tmpVector;
  55574. private _tmpMatrix;
  55575. /**
  55576. * Applies an impulse on the imposter
  55577. * @param impostor imposter to apply impulse to
  55578. * @param force amount of force to be applied to the imposter
  55579. * @param contactPoint the location to apply the impulse on the imposter
  55580. */
  55581. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55582. /**
  55583. * Applies a force on the imposter
  55584. * @param impostor imposter to apply force
  55585. * @param force amount of force to be applied to the imposter
  55586. * @param contactPoint the location to apply the force on the imposter
  55587. */
  55588. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55589. /**
  55590. * Creates a physics body using the plugin
  55591. * @param impostor the imposter to create the physics body on
  55592. */
  55593. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55594. /**
  55595. * Removes the physics body from the imposter and disposes of the body's memory
  55596. * @param impostor imposter to remove the physics body from
  55597. */
  55598. removePhysicsBody(impostor: PhysicsImpostor): void;
  55599. /**
  55600. * Generates a joint
  55601. * @param impostorJoint the imposter joint to create the joint with
  55602. */
  55603. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55604. /**
  55605. * Removes a joint
  55606. * @param impostorJoint the imposter joint to remove the joint from
  55607. */
  55608. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55609. private _addMeshVerts;
  55610. /**
  55611. * Initialise the soft body vertices to match its object's (mesh) vertices
  55612. * Softbody vertices (nodes) are in world space and to match this
  55613. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55614. * @param impostor to create the softbody for
  55615. */
  55616. private _softVertexData;
  55617. /**
  55618. * Create an impostor's soft body
  55619. * @param impostor to create the softbody for
  55620. */
  55621. private _createSoftbody;
  55622. /**
  55623. * Create cloth for an impostor
  55624. * @param impostor to create the softbody for
  55625. */
  55626. private _createCloth;
  55627. /**
  55628. * Create rope for an impostor
  55629. * @param impostor to create the softbody for
  55630. */
  55631. private _createRope;
  55632. /**
  55633. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55634. * @param impostor to create the custom physics shape for
  55635. */
  55636. private _createCustom;
  55637. private _addHullVerts;
  55638. private _createShape;
  55639. /**
  55640. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55641. * @param impostor imposter containing the physics body and babylon object
  55642. */
  55643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55644. /**
  55645. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55646. * @param impostor imposter containing the physics body and babylon object
  55647. * @param newPosition new position
  55648. * @param newRotation new rotation
  55649. */
  55650. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55651. /**
  55652. * If this plugin is supported
  55653. * @returns true if its supported
  55654. */
  55655. isSupported(): boolean;
  55656. /**
  55657. * Sets the linear velocity of the physics body
  55658. * @param impostor imposter to set the velocity on
  55659. * @param velocity velocity to set
  55660. */
  55661. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55662. /**
  55663. * Sets the angular velocity of the physics body
  55664. * @param impostor imposter to set the velocity on
  55665. * @param velocity velocity to set
  55666. */
  55667. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55668. /**
  55669. * gets the linear velocity
  55670. * @param impostor imposter to get linear velocity from
  55671. * @returns linear velocity
  55672. */
  55673. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55674. /**
  55675. * gets the angular velocity
  55676. * @param impostor imposter to get angular velocity from
  55677. * @returns angular velocity
  55678. */
  55679. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55680. /**
  55681. * Sets the mass of physics body
  55682. * @param impostor imposter to set the mass on
  55683. * @param mass mass to set
  55684. */
  55685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55686. /**
  55687. * Gets the mass of the physics body
  55688. * @param impostor imposter to get the mass from
  55689. * @returns mass
  55690. */
  55691. getBodyMass(impostor: PhysicsImpostor): number;
  55692. /**
  55693. * Gets friction of the impostor
  55694. * @param impostor impostor to get friction from
  55695. * @returns friction value
  55696. */
  55697. getBodyFriction(impostor: PhysicsImpostor): number;
  55698. /**
  55699. * Sets friction of the impostor
  55700. * @param impostor impostor to set friction on
  55701. * @param friction friction value
  55702. */
  55703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55704. /**
  55705. * Gets restitution of the impostor
  55706. * @param impostor impostor to get restitution from
  55707. * @returns restitution value
  55708. */
  55709. getBodyRestitution(impostor: PhysicsImpostor): number;
  55710. /**
  55711. * Sets resitution of the impostor
  55712. * @param impostor impostor to set resitution on
  55713. * @param restitution resitution value
  55714. */
  55715. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55716. /**
  55717. * Gets pressure inside the impostor
  55718. * @param impostor impostor to get pressure from
  55719. * @returns pressure value
  55720. */
  55721. getBodyPressure(impostor: PhysicsImpostor): number;
  55722. /**
  55723. * Sets pressure inside a soft body impostor
  55724. * Cloth and rope must remain 0 pressure
  55725. * @param impostor impostor to set pressure on
  55726. * @param pressure pressure value
  55727. */
  55728. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55729. /**
  55730. * Gets stiffness of the impostor
  55731. * @param impostor impostor to get stiffness from
  55732. * @returns pressure value
  55733. */
  55734. getBodyStiffness(impostor: PhysicsImpostor): number;
  55735. /**
  55736. * Sets stiffness of the impostor
  55737. * @param impostor impostor to set stiffness on
  55738. * @param stiffness stiffness value from 0 to 1
  55739. */
  55740. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55741. /**
  55742. * Gets velocityIterations of the impostor
  55743. * @param impostor impostor to get velocity iterations from
  55744. * @returns velocityIterations value
  55745. */
  55746. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55747. /**
  55748. * Sets velocityIterations of the impostor
  55749. * @param impostor impostor to set velocity iterations on
  55750. * @param velocityIterations velocityIterations value
  55751. */
  55752. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55753. /**
  55754. * Gets positionIterations of the impostor
  55755. * @param impostor impostor to get position iterations from
  55756. * @returns positionIterations value
  55757. */
  55758. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55759. /**
  55760. * Sets positionIterations of the impostor
  55761. * @param impostor impostor to set position on
  55762. * @param positionIterations positionIterations value
  55763. */
  55764. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55765. /**
  55766. * Append an anchor to a cloth object
  55767. * @param impostor is the cloth impostor to add anchor to
  55768. * @param otherImpostor is the rigid impostor to anchor to
  55769. * @param width ratio across width from 0 to 1
  55770. * @param height ratio up height from 0 to 1
  55771. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55772. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55773. */
  55774. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55775. /**
  55776. * Append an hook to a rope object
  55777. * @param impostor is the rope impostor to add hook to
  55778. * @param otherImpostor is the rigid impostor to hook to
  55779. * @param length ratio along the rope from 0 to 1
  55780. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55781. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55782. */
  55783. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55784. /**
  55785. * Sleeps the physics body and stops it from being active
  55786. * @param impostor impostor to sleep
  55787. */
  55788. sleepBody(impostor: PhysicsImpostor): void;
  55789. /**
  55790. * Activates the physics body
  55791. * @param impostor impostor to activate
  55792. */
  55793. wakeUpBody(impostor: PhysicsImpostor): void;
  55794. /**
  55795. * Updates the distance parameters of the joint
  55796. * @param joint joint to update
  55797. * @param maxDistance maximum distance of the joint
  55798. * @param minDistance minimum distance of the joint
  55799. */
  55800. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55801. /**
  55802. * Sets a motor on the joint
  55803. * @param joint joint to set motor on
  55804. * @param speed speed of the motor
  55805. * @param maxForce maximum force of the motor
  55806. * @param motorIndex index of the motor
  55807. */
  55808. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55809. /**
  55810. * Sets the motors limit
  55811. * @param joint joint to set limit on
  55812. * @param upperLimit upper limit
  55813. * @param lowerLimit lower limit
  55814. */
  55815. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55816. /**
  55817. * Syncs the position and rotation of a mesh with the impostor
  55818. * @param mesh mesh to sync
  55819. * @param impostor impostor to update the mesh with
  55820. */
  55821. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55822. /**
  55823. * Gets the radius of the impostor
  55824. * @param impostor impostor to get radius from
  55825. * @returns the radius
  55826. */
  55827. getRadius(impostor: PhysicsImpostor): number;
  55828. /**
  55829. * Gets the box size of the impostor
  55830. * @param impostor impostor to get box size from
  55831. * @param result the resulting box size
  55832. */
  55833. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55834. /**
  55835. * Disposes of the impostor
  55836. */
  55837. dispose(): void;
  55838. /**
  55839. * Does a raycast in the physics world
  55840. * @param from when should the ray start?
  55841. * @param to when should the ray end?
  55842. * @returns PhysicsRaycastResult
  55843. */
  55844. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55845. }
  55846. }
  55847. declare module "babylonjs/Probes/reflectionProbe" {
  55848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55849. import { Vector3 } from "babylonjs/Maths/math.vector";
  55850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55851. import { Nullable } from "babylonjs/types";
  55852. import { Scene } from "babylonjs/scene";
  55853. module "babylonjs/abstractScene" {
  55854. interface AbstractScene {
  55855. /**
  55856. * The list of reflection probes added to the scene
  55857. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55858. */
  55859. reflectionProbes: Array<ReflectionProbe>;
  55860. /**
  55861. * Removes the given reflection probe from this scene.
  55862. * @param toRemove The reflection probe to remove
  55863. * @returns The index of the removed reflection probe
  55864. */
  55865. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55866. /**
  55867. * Adds the given reflection probe to this scene.
  55868. * @param newReflectionProbe The reflection probe to add
  55869. */
  55870. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55871. }
  55872. }
  55873. /**
  55874. * Class used to generate realtime reflection / refraction cube textures
  55875. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55876. */
  55877. export class ReflectionProbe {
  55878. /** defines the name of the probe */
  55879. name: string;
  55880. private _scene;
  55881. private _renderTargetTexture;
  55882. private _projectionMatrix;
  55883. private _viewMatrix;
  55884. private _target;
  55885. private _add;
  55886. private _attachedMesh;
  55887. private _invertYAxis;
  55888. /** Gets or sets probe position (center of the cube map) */
  55889. position: Vector3;
  55890. /**
  55891. * Creates a new reflection probe
  55892. * @param name defines the name of the probe
  55893. * @param size defines the texture resolution (for each face)
  55894. * @param scene defines the hosting scene
  55895. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55896. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55897. */
  55898. constructor(
  55899. /** defines the name of the probe */
  55900. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55901. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55902. samples: number;
  55903. /** Gets or sets the refresh rate to use (on every frame by default) */
  55904. refreshRate: number;
  55905. /**
  55906. * Gets the hosting scene
  55907. * @returns a Scene
  55908. */
  55909. getScene(): Scene;
  55910. /** Gets the internal CubeTexture used to render to */
  55911. readonly cubeTexture: RenderTargetTexture;
  55912. /** Gets the list of meshes to render */
  55913. readonly renderList: Nullable<AbstractMesh[]>;
  55914. /**
  55915. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55916. * @param mesh defines the mesh to attach to
  55917. */
  55918. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55919. /**
  55920. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55921. * @param renderingGroupId The rendering group id corresponding to its index
  55922. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55923. */
  55924. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55925. /**
  55926. * Clean all associated resources
  55927. */
  55928. dispose(): void;
  55929. /**
  55930. * Converts the reflection probe information to a readable string for debug purpose.
  55931. * @param fullDetails Supports for multiple levels of logging within scene loading
  55932. * @returns the human readable reflection probe info
  55933. */
  55934. toString(fullDetails?: boolean): string;
  55935. /**
  55936. * Get the class name of the relfection probe.
  55937. * @returns "ReflectionProbe"
  55938. */
  55939. getClassName(): string;
  55940. /**
  55941. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55942. * @returns The JSON representation of the texture
  55943. */
  55944. serialize(): any;
  55945. /**
  55946. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55947. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55948. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55949. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55950. * @returns The parsed reflection probe if successful
  55951. */
  55952. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55953. }
  55954. }
  55955. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55956. /** @hidden */
  55957. export var _BabylonLoaderRegistered: boolean;
  55958. /**
  55959. * Helps setting up some configuration for the babylon file loader.
  55960. */
  55961. export class BabylonFileLoaderConfiguration {
  55962. /**
  55963. * The loader does not allow injecting custom physix engine into the plugins.
  55964. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55965. * So you could set this variable to your engine import to make it work.
  55966. */
  55967. static LoaderInjectedPhysicsEngine: any;
  55968. }
  55969. }
  55970. declare module "babylonjs/Loading/Plugins/index" {
  55971. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55972. }
  55973. declare module "babylonjs/Loading/index" {
  55974. export * from "babylonjs/Loading/loadingScreen";
  55975. export * from "babylonjs/Loading/Plugins/index";
  55976. export * from "babylonjs/Loading/sceneLoader";
  55977. export * from "babylonjs/Loading/sceneLoaderFlags";
  55978. }
  55979. declare module "babylonjs/Materials/Background/index" {
  55980. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55981. }
  55982. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55983. import { Scene } from "babylonjs/scene";
  55984. import { Color3 } from "babylonjs/Maths/math.color";
  55985. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55987. /**
  55988. * The Physically based simple base material of BJS.
  55989. *
  55990. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55991. * It is used as the base class for both the specGloss and metalRough conventions.
  55992. */
  55993. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55994. /**
  55995. * Number of Simultaneous lights allowed on the material.
  55996. */
  55997. maxSimultaneousLights: number;
  55998. /**
  55999. * If sets to true, disables all the lights affecting the material.
  56000. */
  56001. disableLighting: boolean;
  56002. /**
  56003. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56004. */
  56005. environmentTexture: BaseTexture;
  56006. /**
  56007. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56008. */
  56009. invertNormalMapX: boolean;
  56010. /**
  56011. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56012. */
  56013. invertNormalMapY: boolean;
  56014. /**
  56015. * Normal map used in the model.
  56016. */
  56017. normalTexture: BaseTexture;
  56018. /**
  56019. * Emissivie color used to self-illuminate the model.
  56020. */
  56021. emissiveColor: Color3;
  56022. /**
  56023. * Emissivie texture used to self-illuminate the model.
  56024. */
  56025. emissiveTexture: BaseTexture;
  56026. /**
  56027. * Occlusion Channel Strenght.
  56028. */
  56029. occlusionStrength: number;
  56030. /**
  56031. * Occlusion Texture of the material (adding extra occlusion effects).
  56032. */
  56033. occlusionTexture: BaseTexture;
  56034. /**
  56035. * Defines the alpha limits in alpha test mode.
  56036. */
  56037. alphaCutOff: number;
  56038. /**
  56039. * Gets the current double sided mode.
  56040. */
  56041. /**
  56042. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56043. */
  56044. doubleSided: boolean;
  56045. /**
  56046. * Stores the pre-calculated light information of a mesh in a texture.
  56047. */
  56048. lightmapTexture: BaseTexture;
  56049. /**
  56050. * If true, the light map contains occlusion information instead of lighting info.
  56051. */
  56052. useLightmapAsShadowmap: boolean;
  56053. /**
  56054. * Instantiates a new PBRMaterial instance.
  56055. *
  56056. * @param name The material name
  56057. * @param scene The scene the material will be use in.
  56058. */
  56059. constructor(name: string, scene: Scene);
  56060. getClassName(): string;
  56061. }
  56062. }
  56063. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56064. import { Scene } from "babylonjs/scene";
  56065. import { Color3 } from "babylonjs/Maths/math.color";
  56066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56067. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56068. /**
  56069. * The PBR material of BJS following the metal roughness convention.
  56070. *
  56071. * This fits to the PBR convention in the GLTF definition:
  56072. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56073. */
  56074. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56075. /**
  56076. * The base color has two different interpretations depending on the value of metalness.
  56077. * When the material is a metal, the base color is the specific measured reflectance value
  56078. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56079. * of the material.
  56080. */
  56081. baseColor: Color3;
  56082. /**
  56083. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56084. * well as opacity information in the alpha channel.
  56085. */
  56086. baseTexture: BaseTexture;
  56087. /**
  56088. * Specifies the metallic scalar value of the material.
  56089. * Can also be used to scale the metalness values of the metallic texture.
  56090. */
  56091. metallic: number;
  56092. /**
  56093. * Specifies the roughness scalar value of the material.
  56094. * Can also be used to scale the roughness values of the metallic texture.
  56095. */
  56096. roughness: number;
  56097. /**
  56098. * Texture containing both the metallic value in the B channel and the
  56099. * roughness value in the G channel to keep better precision.
  56100. */
  56101. metallicRoughnessTexture: BaseTexture;
  56102. /**
  56103. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56104. *
  56105. * @param name The material name
  56106. * @param scene The scene the material will be use in.
  56107. */
  56108. constructor(name: string, scene: Scene);
  56109. /**
  56110. * Return the currrent class name of the material.
  56111. */
  56112. getClassName(): string;
  56113. /**
  56114. * Makes a duplicate of the current material.
  56115. * @param name - name to use for the new material.
  56116. */
  56117. clone(name: string): PBRMetallicRoughnessMaterial;
  56118. /**
  56119. * Serialize the material to a parsable JSON object.
  56120. */
  56121. serialize(): any;
  56122. /**
  56123. * Parses a JSON object correponding to the serialize function.
  56124. */
  56125. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56126. }
  56127. }
  56128. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56129. import { Scene } from "babylonjs/scene";
  56130. import { Color3 } from "babylonjs/Maths/math.color";
  56131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56132. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56133. /**
  56134. * The PBR material of BJS following the specular glossiness convention.
  56135. *
  56136. * This fits to the PBR convention in the GLTF definition:
  56137. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56138. */
  56139. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56140. /**
  56141. * Specifies the diffuse color of the material.
  56142. */
  56143. diffuseColor: Color3;
  56144. /**
  56145. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56146. * channel.
  56147. */
  56148. diffuseTexture: BaseTexture;
  56149. /**
  56150. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56151. */
  56152. specularColor: Color3;
  56153. /**
  56154. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56155. */
  56156. glossiness: number;
  56157. /**
  56158. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56159. */
  56160. specularGlossinessTexture: BaseTexture;
  56161. /**
  56162. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56163. *
  56164. * @param name The material name
  56165. * @param scene The scene the material will be use in.
  56166. */
  56167. constructor(name: string, scene: Scene);
  56168. /**
  56169. * Return the currrent class name of the material.
  56170. */
  56171. getClassName(): string;
  56172. /**
  56173. * Makes a duplicate of the current material.
  56174. * @param name - name to use for the new material.
  56175. */
  56176. clone(name: string): PBRSpecularGlossinessMaterial;
  56177. /**
  56178. * Serialize the material to a parsable JSON object.
  56179. */
  56180. serialize(): any;
  56181. /**
  56182. * Parses a JSON object correponding to the serialize function.
  56183. */
  56184. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56185. }
  56186. }
  56187. declare module "babylonjs/Materials/PBR/index" {
  56188. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56189. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56190. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56191. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56192. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56193. }
  56194. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56195. import { Nullable } from "babylonjs/types";
  56196. import { Scene } from "babylonjs/scene";
  56197. import { Matrix } from "babylonjs/Maths/math.vector";
  56198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56199. /**
  56200. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56201. * It can help converting any input color in a desired output one. This can then be used to create effects
  56202. * from sepia, black and white to sixties or futuristic rendering...
  56203. *
  56204. * The only supported format is currently 3dl.
  56205. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56206. */
  56207. export class ColorGradingTexture extends BaseTexture {
  56208. /**
  56209. * The current texture matrix. (will always be identity in color grading texture)
  56210. */
  56211. private _textureMatrix;
  56212. /**
  56213. * The texture URL.
  56214. */
  56215. url: string;
  56216. /**
  56217. * Empty line regex stored for GC.
  56218. */
  56219. private static _noneEmptyLineRegex;
  56220. private _engine;
  56221. /**
  56222. * Instantiates a ColorGradingTexture from the following parameters.
  56223. *
  56224. * @param url The location of the color gradind data (currently only supporting 3dl)
  56225. * @param scene The scene the texture will be used in
  56226. */
  56227. constructor(url: string, scene: Scene);
  56228. /**
  56229. * Returns the texture matrix used in most of the material.
  56230. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56231. */
  56232. getTextureMatrix(): Matrix;
  56233. /**
  56234. * Occurs when the file being loaded is a .3dl LUT file.
  56235. */
  56236. private load3dlTexture;
  56237. /**
  56238. * Starts the loading process of the texture.
  56239. */
  56240. private loadTexture;
  56241. /**
  56242. * Clones the color gradind texture.
  56243. */
  56244. clone(): ColorGradingTexture;
  56245. /**
  56246. * Called during delayed load for textures.
  56247. */
  56248. delayLoad(): void;
  56249. /**
  56250. * Parses a color grading texture serialized by Babylon.
  56251. * @param parsedTexture The texture information being parsedTexture
  56252. * @param scene The scene to load the texture in
  56253. * @param rootUrl The root url of the data assets to load
  56254. * @return A color gradind texture
  56255. */
  56256. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56257. /**
  56258. * Serializes the LUT texture to json format.
  56259. */
  56260. serialize(): any;
  56261. }
  56262. }
  56263. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56265. import { Scene } from "babylonjs/scene";
  56266. import { Nullable } from "babylonjs/types";
  56267. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56268. /**
  56269. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56270. */
  56271. export class EquiRectangularCubeTexture extends BaseTexture {
  56272. /** The six faces of the cube. */
  56273. private static _FacesMapping;
  56274. private _noMipmap;
  56275. private _onLoad;
  56276. private _onError;
  56277. /** The size of the cubemap. */
  56278. private _size;
  56279. /** The buffer of the image. */
  56280. private _buffer;
  56281. /** The width of the input image. */
  56282. private _width;
  56283. /** The height of the input image. */
  56284. private _height;
  56285. /** The URL to the image. */
  56286. url: string;
  56287. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56288. coordinatesMode: number;
  56289. /**
  56290. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56291. * @param url The location of the image
  56292. * @param scene The scene the texture will be used in
  56293. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56294. * @param noMipmap Forces to not generate the mipmap if true
  56295. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56296. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56297. * @param onLoad — defines a callback called when texture is loaded
  56298. * @param onError — defines a callback called if there is an error
  56299. */
  56300. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56301. /**
  56302. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56303. */
  56304. private loadImage;
  56305. /**
  56306. * Convert the image buffer into a cubemap and create a CubeTexture.
  56307. */
  56308. private loadTexture;
  56309. /**
  56310. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56311. * @param buffer The ArrayBuffer that should be converted.
  56312. * @returns The buffer as Float32Array.
  56313. */
  56314. private getFloat32ArrayFromArrayBuffer;
  56315. /**
  56316. * Get the current class name of the texture useful for serialization or dynamic coding.
  56317. * @returns "EquiRectangularCubeTexture"
  56318. */
  56319. getClassName(): string;
  56320. /**
  56321. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56322. * @returns A clone of the current EquiRectangularCubeTexture.
  56323. */
  56324. clone(): EquiRectangularCubeTexture;
  56325. }
  56326. }
  56327. declare module "babylonjs/Misc/tga" {
  56328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56329. /**
  56330. * Based on jsTGALoader - Javascript loader for TGA file
  56331. * By Vincent Thibault
  56332. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56333. */
  56334. export class TGATools {
  56335. private static _TYPE_INDEXED;
  56336. private static _TYPE_RGB;
  56337. private static _TYPE_GREY;
  56338. private static _TYPE_RLE_INDEXED;
  56339. private static _TYPE_RLE_RGB;
  56340. private static _TYPE_RLE_GREY;
  56341. private static _ORIGIN_MASK;
  56342. private static _ORIGIN_SHIFT;
  56343. private static _ORIGIN_BL;
  56344. private static _ORIGIN_BR;
  56345. private static _ORIGIN_UL;
  56346. private static _ORIGIN_UR;
  56347. /**
  56348. * Gets the header of a TGA file
  56349. * @param data defines the TGA data
  56350. * @returns the header
  56351. */
  56352. static GetTGAHeader(data: Uint8Array): any;
  56353. /**
  56354. * Uploads TGA content to a Babylon Texture
  56355. * @hidden
  56356. */
  56357. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56358. /** @hidden */
  56359. 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;
  56360. /** @hidden */
  56361. 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;
  56362. /** @hidden */
  56363. 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;
  56364. /** @hidden */
  56365. 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;
  56366. /** @hidden */
  56367. 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;
  56368. /** @hidden */
  56369. 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;
  56370. }
  56371. }
  56372. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56373. import { Nullable } from "babylonjs/types";
  56374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56375. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56376. /**
  56377. * Implementation of the TGA Texture Loader.
  56378. * @hidden
  56379. */
  56380. export class _TGATextureLoader implements IInternalTextureLoader {
  56381. /**
  56382. * Defines wether the loader supports cascade loading the different faces.
  56383. */
  56384. readonly supportCascades: boolean;
  56385. /**
  56386. * This returns if the loader support the current file information.
  56387. * @param extension defines the file extension of the file being loaded
  56388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56389. * @param fallback defines the fallback internal texture if any
  56390. * @param isBase64 defines whether the texture is encoded as a base64
  56391. * @param isBuffer defines whether the texture data are stored as a buffer
  56392. * @returns true if the loader can load the specified file
  56393. */
  56394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56395. /**
  56396. * Transform the url before loading if required.
  56397. * @param rootUrl the url of the texture
  56398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56399. * @returns the transformed texture
  56400. */
  56401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56402. /**
  56403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56404. * @param rootUrl the url of the texture
  56405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56406. * @returns the fallback texture
  56407. */
  56408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56409. /**
  56410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56411. * @param data contains the texture data
  56412. * @param texture defines the BabylonJS internal texture
  56413. * @param createPolynomials will be true if polynomials have been requested
  56414. * @param onLoad defines the callback to trigger once the texture is ready
  56415. * @param onError defines the callback to trigger in case of error
  56416. */
  56417. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56418. /**
  56419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56420. * @param data contains the texture data
  56421. * @param texture defines the BabylonJS internal texture
  56422. * @param callback defines the method to call once ready to upload
  56423. */
  56424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56425. }
  56426. }
  56427. declare module "babylonjs/Misc/basis" {
  56428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56429. /**
  56430. * Info about the .basis files
  56431. */
  56432. class BasisFileInfo {
  56433. /**
  56434. * If the file has alpha
  56435. */
  56436. hasAlpha: boolean;
  56437. /**
  56438. * Info about each image of the basis file
  56439. */
  56440. images: Array<{
  56441. levels: Array<{
  56442. width: number;
  56443. height: number;
  56444. transcodedPixels: ArrayBufferView;
  56445. }>;
  56446. }>;
  56447. }
  56448. /**
  56449. * Result of transcoding a basis file
  56450. */
  56451. class TranscodeResult {
  56452. /**
  56453. * Info about the .basis file
  56454. */
  56455. fileInfo: BasisFileInfo;
  56456. /**
  56457. * Format to use when loading the file
  56458. */
  56459. format: number;
  56460. }
  56461. /**
  56462. * Configuration options for the Basis transcoder
  56463. */
  56464. export class BasisTranscodeConfiguration {
  56465. /**
  56466. * Supported compression formats used to determine the supported output format of the transcoder
  56467. */
  56468. supportedCompressionFormats?: {
  56469. /**
  56470. * etc1 compression format
  56471. */
  56472. etc1?: boolean;
  56473. /**
  56474. * s3tc compression format
  56475. */
  56476. s3tc?: boolean;
  56477. /**
  56478. * pvrtc compression format
  56479. */
  56480. pvrtc?: boolean;
  56481. /**
  56482. * etc2 compression format
  56483. */
  56484. etc2?: boolean;
  56485. };
  56486. /**
  56487. * If mipmap levels should be loaded for transcoded images (Default: true)
  56488. */
  56489. loadMipmapLevels?: boolean;
  56490. /**
  56491. * Index of a single image to load (Default: all images)
  56492. */
  56493. loadSingleImage?: number;
  56494. }
  56495. /**
  56496. * Used to load .Basis files
  56497. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56498. */
  56499. export class BasisTools {
  56500. private static _IgnoreSupportedFormats;
  56501. /**
  56502. * URL to use when loading the basis transcoder
  56503. */
  56504. static JSModuleURL: string;
  56505. /**
  56506. * URL to use when loading the wasm module for the transcoder
  56507. */
  56508. static WasmModuleURL: string;
  56509. /**
  56510. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56511. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56512. * @returns internal format corresponding to the Basis format
  56513. */
  56514. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56515. private static _WorkerPromise;
  56516. private static _Worker;
  56517. private static _actionId;
  56518. private static _CreateWorkerAsync;
  56519. /**
  56520. * Transcodes a loaded image file to compressed pixel data
  56521. * @param imageData image data to transcode
  56522. * @param config configuration options for the transcoding
  56523. * @returns a promise resulting in the transcoded image
  56524. */
  56525. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56526. /**
  56527. * Loads a texture from the transcode result
  56528. * @param texture texture load to
  56529. * @param transcodeResult the result of transcoding the basis file to load from
  56530. */
  56531. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56532. }
  56533. }
  56534. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  56535. import { Nullable } from "babylonjs/types";
  56536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56537. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56538. /**
  56539. * Loader for .basis file format
  56540. */
  56541. export class _BasisTextureLoader implements IInternalTextureLoader {
  56542. /**
  56543. * Defines whether the loader supports cascade loading the different faces.
  56544. */
  56545. readonly supportCascades: boolean;
  56546. /**
  56547. * This returns if the loader support the current file information.
  56548. * @param extension defines the file extension of the file being loaded
  56549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56550. * @param fallback defines the fallback internal texture if any
  56551. * @param isBase64 defines whether the texture is encoded as a base64
  56552. * @param isBuffer defines whether the texture data are stored as a buffer
  56553. * @returns true if the loader can load the specified file
  56554. */
  56555. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56556. /**
  56557. * Transform the url before loading if required.
  56558. * @param rootUrl the url of the texture
  56559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56560. * @returns the transformed texture
  56561. */
  56562. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56563. /**
  56564. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56565. * @param rootUrl the url of the texture
  56566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56567. * @returns the fallback texture
  56568. */
  56569. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56570. /**
  56571. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56572. * @param data contains the texture data
  56573. * @param texture defines the BabylonJS internal texture
  56574. * @param createPolynomials will be true if polynomials have been requested
  56575. * @param onLoad defines the callback to trigger once the texture is ready
  56576. * @param onError defines the callback to trigger in case of error
  56577. */
  56578. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56579. /**
  56580. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56581. * @param data contains the texture data
  56582. * @param texture defines the BabylonJS internal texture
  56583. * @param callback defines the method to call once ready to upload
  56584. */
  56585. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56586. }
  56587. }
  56588. declare module "babylonjs/Materials/Textures/Loaders/index" {
  56589. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  56590. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  56591. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  56592. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  56593. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  56594. }
  56595. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  56596. import { Scene } from "babylonjs/scene";
  56597. import { Texture } from "babylonjs/Materials/Textures/texture";
  56598. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56599. /**
  56600. * 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.
  56601. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56602. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56603. */
  56604. export class CustomProceduralTexture extends ProceduralTexture {
  56605. private _animate;
  56606. private _time;
  56607. private _config;
  56608. private _texturePath;
  56609. /**
  56610. * Instantiates a new Custom Procedural Texture.
  56611. * 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.
  56612. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56613. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56614. * @param name Define the name of the texture
  56615. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56616. * @param size Define the size of the texture to create
  56617. * @param scene Define the scene the texture belongs to
  56618. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56619. * @param generateMipMaps Define if the texture should creates mip maps or not
  56620. */
  56621. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56622. private _loadJson;
  56623. /**
  56624. * Is the texture ready to be used ? (rendered at least once)
  56625. * @returns true if ready, otherwise, false.
  56626. */
  56627. isReady(): boolean;
  56628. /**
  56629. * Render the texture to its associated render target.
  56630. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56631. */
  56632. render(useCameraPostProcess?: boolean): void;
  56633. /**
  56634. * Update the list of dependant textures samplers in the shader.
  56635. */
  56636. updateTextures(): void;
  56637. /**
  56638. * Update the uniform values of the procedural texture in the shader.
  56639. */
  56640. updateShaderUniforms(): void;
  56641. /**
  56642. * Define if the texture animates or not.
  56643. */
  56644. animate: boolean;
  56645. }
  56646. }
  56647. declare module "babylonjs/Shaders/noise.fragment" {
  56648. /** @hidden */
  56649. export var noisePixelShader: {
  56650. name: string;
  56651. shader: string;
  56652. };
  56653. }
  56654. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  56655. import { Nullable } from "babylonjs/types";
  56656. import { Scene } from "babylonjs/scene";
  56657. import { Texture } from "babylonjs/Materials/Textures/texture";
  56658. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56659. import "babylonjs/Shaders/noise.fragment";
  56660. /**
  56661. * Class used to generate noise procedural textures
  56662. */
  56663. export class NoiseProceduralTexture extends ProceduralTexture {
  56664. private _time;
  56665. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56666. brightness: number;
  56667. /** Defines the number of octaves to process */
  56668. octaves: number;
  56669. /** Defines the level of persistence (0.8 by default) */
  56670. persistence: number;
  56671. /** Gets or sets animation speed factor (default is 1) */
  56672. animationSpeedFactor: number;
  56673. /**
  56674. * Creates a new NoiseProceduralTexture
  56675. * @param name defines the name fo the texture
  56676. * @param size defines the size of the texture (default is 256)
  56677. * @param scene defines the hosting scene
  56678. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56679. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56680. */
  56681. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56682. private _updateShaderUniforms;
  56683. protected _getDefines(): string;
  56684. /** Generate the current state of the procedural texture */
  56685. render(useCameraPostProcess?: boolean): void;
  56686. /**
  56687. * Serializes this noise procedural texture
  56688. * @returns a serialized noise procedural texture object
  56689. */
  56690. serialize(): any;
  56691. /**
  56692. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56693. * @param parsedTexture defines parsed texture data
  56694. * @param scene defines the current scene
  56695. * @param rootUrl defines the root URL containing noise procedural texture information
  56696. * @returns a parsed NoiseProceduralTexture
  56697. */
  56698. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56699. }
  56700. }
  56701. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  56702. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  56703. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  56704. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56705. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  56706. }
  56707. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  56708. import { Nullable } from "babylonjs/types";
  56709. import { Scene } from "babylonjs/scene";
  56710. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  56711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56712. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56713. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56714. /**
  56715. * Raw cube texture where the raw buffers are passed in
  56716. */
  56717. export class RawCubeTexture extends CubeTexture {
  56718. /**
  56719. * Creates a cube texture where the raw buffers are passed in.
  56720. * @param scene defines the scene the texture is attached to
  56721. * @param data defines the array of data to use to create each face
  56722. * @param size defines the size of the textures
  56723. * @param format defines the format of the data
  56724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56725. * @param generateMipMaps defines if the engine should generate the mip levels
  56726. * @param invertY defines if data must be stored with Y axis inverted
  56727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56728. * @param compression defines the compression used (null by default)
  56729. */
  56730. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56731. /**
  56732. * Updates the raw cube texture.
  56733. * @param data defines the data to store
  56734. * @param format defines the data format
  56735. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56736. * @param invertY defines if data must be stored with Y axis inverted
  56737. * @param compression defines the compression used (null by default)
  56738. * @param level defines which level of the texture to update
  56739. */
  56740. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56741. /**
  56742. * Updates a raw cube texture with RGBD encoded data.
  56743. * @param data defines the array of data [mipmap][face] to use to create each face
  56744. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56745. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56746. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56747. * @returns a promsie that resolves when the operation is complete
  56748. */
  56749. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56750. /**
  56751. * Clones the raw cube texture.
  56752. * @return a new cube texture
  56753. */
  56754. clone(): CubeTexture;
  56755. /** @hidden */
  56756. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56757. }
  56758. }
  56759. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56760. import { Scene } from "babylonjs/scene";
  56761. import { Texture } from "babylonjs/Materials/Textures/texture";
  56762. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56763. /**
  56764. * Class used to store 3D textures containing user data
  56765. */
  56766. export class RawTexture3D extends Texture {
  56767. /** Gets or sets the texture format to use */
  56768. format: number;
  56769. private _engine;
  56770. /**
  56771. * Create a new RawTexture3D
  56772. * @param data defines the data of the texture
  56773. * @param width defines the width of the texture
  56774. * @param height defines the height of the texture
  56775. * @param depth defines the depth of the texture
  56776. * @param format defines the texture format to use
  56777. * @param scene defines the hosting scene
  56778. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56779. * @param invertY defines if texture must be stored with Y axis inverted
  56780. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56782. */
  56783. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56784. /** Gets or sets the texture format to use */
  56785. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56786. /**
  56787. * Update the texture with new data
  56788. * @param data defines the data to store in the texture
  56789. */
  56790. update(data: ArrayBufferView): void;
  56791. }
  56792. }
  56793. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56794. import { Scene } from "babylonjs/scene";
  56795. import { Texture } from "babylonjs/Materials/Textures/texture";
  56796. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56797. /**
  56798. * Class used to store 2D array textures containing user data
  56799. */
  56800. export class RawTexture2DArray extends Texture {
  56801. /** Gets or sets the texture format to use */
  56802. format: number;
  56803. private _engine;
  56804. /**
  56805. * Create a new RawTexture2DArray
  56806. * @param data defines the data of the texture
  56807. * @param width defines the width of the texture
  56808. * @param height defines the height of the texture
  56809. * @param depth defines the number of layers of the texture
  56810. * @param format defines the texture format to use
  56811. * @param scene defines the hosting scene
  56812. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56813. * @param invertY defines if texture must be stored with Y axis inverted
  56814. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56815. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56816. */
  56817. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56818. /** Gets or sets the texture format to use */
  56819. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56820. /**
  56821. * Update the texture with new data
  56822. * @param data defines the data to store in the texture
  56823. */
  56824. update(data: ArrayBufferView): void;
  56825. }
  56826. }
  56827. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56828. import { Scene } from "babylonjs/scene";
  56829. import { Plane } from "babylonjs/Maths/math.plane";
  56830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56831. /**
  56832. * Creates a refraction texture used by refraction channel of the standard material.
  56833. * It is like a mirror but to see through a material.
  56834. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56835. */
  56836. export class RefractionTexture extends RenderTargetTexture {
  56837. /**
  56838. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56839. * 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.
  56840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56841. */
  56842. refractionPlane: Plane;
  56843. /**
  56844. * Define how deep under the surface we should see.
  56845. */
  56846. depth: number;
  56847. /**
  56848. * Creates a refraction texture used by refraction channel of the standard material.
  56849. * It is like a mirror but to see through a material.
  56850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56851. * @param name Define the texture name
  56852. * @param size Define the size of the underlying texture
  56853. * @param scene Define the scene the refraction belongs to
  56854. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56855. */
  56856. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56857. /**
  56858. * Clone the refraction texture.
  56859. * @returns the cloned texture
  56860. */
  56861. clone(): RefractionTexture;
  56862. /**
  56863. * Serialize the texture to a JSON representation you could use in Parse later on
  56864. * @returns the serialized JSON representation
  56865. */
  56866. serialize(): any;
  56867. }
  56868. }
  56869. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56870. import { Nullable } from "babylonjs/types";
  56871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56872. import { Matrix } from "babylonjs/Maths/math.vector";
  56873. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56874. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56875. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56876. import { Scene } from "babylonjs/scene";
  56877. /**
  56878. * Defines the options related to the creation of an HtmlElementTexture
  56879. */
  56880. export interface IHtmlElementTextureOptions {
  56881. /**
  56882. * Defines wether mip maps should be created or not.
  56883. */
  56884. generateMipMaps?: boolean;
  56885. /**
  56886. * Defines the sampling mode of the texture.
  56887. */
  56888. samplingMode?: number;
  56889. /**
  56890. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56891. */
  56892. engine: Nullable<ThinEngine>;
  56893. /**
  56894. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56895. */
  56896. scene: Nullable<Scene>;
  56897. }
  56898. /**
  56899. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56900. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56901. * is automatically managed.
  56902. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56903. * in your application.
  56904. *
  56905. * As the update is not automatic, you need to call them manually.
  56906. */
  56907. export class HtmlElementTexture extends BaseTexture {
  56908. /**
  56909. * The texture URL.
  56910. */
  56911. element: HTMLVideoElement | HTMLCanvasElement;
  56912. private static readonly DefaultOptions;
  56913. private _textureMatrix;
  56914. private _engine;
  56915. private _isVideo;
  56916. private _generateMipMaps;
  56917. private _samplingMode;
  56918. /**
  56919. * Instantiates a HtmlElementTexture from the following parameters.
  56920. *
  56921. * @param name Defines the name of the texture
  56922. * @param element Defines the video or canvas the texture is filled with
  56923. * @param options Defines the other none mandatory texture creation options
  56924. */
  56925. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56926. private _createInternalTexture;
  56927. /**
  56928. * Returns the texture matrix used in most of the material.
  56929. */
  56930. getTextureMatrix(): Matrix;
  56931. /**
  56932. * Updates the content of the texture.
  56933. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56934. */
  56935. update(invertY?: Nullable<boolean>): void;
  56936. }
  56937. }
  56938. declare module "babylonjs/Materials/Textures/index" {
  56939. export * from "babylonjs/Materials/Textures/baseTexture";
  56940. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56941. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56942. export * from "babylonjs/Materials/Textures/cubeTexture";
  56943. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56944. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56945. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56946. export * from "babylonjs/Materials/Textures/internalTexture";
  56947. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56948. export * from "babylonjs/Materials/Textures/Loaders/index";
  56949. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56950. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56951. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56952. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56953. export * from "babylonjs/Materials/Textures/rawTexture";
  56954. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56955. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56956. export * from "babylonjs/Materials/Textures/refractionTexture";
  56957. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56958. export * from "babylonjs/Materials/Textures/texture";
  56959. export * from "babylonjs/Materials/Textures/videoTexture";
  56960. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56961. }
  56962. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56963. /**
  56964. * Enum used to define the target of a block
  56965. */
  56966. export enum NodeMaterialBlockTargets {
  56967. /** Vertex shader */
  56968. Vertex = 1,
  56969. /** Fragment shader */
  56970. Fragment = 2,
  56971. /** Neutral */
  56972. Neutral = 4,
  56973. /** Vertex and Fragment */
  56974. VertexAndFragment = 3
  56975. }
  56976. }
  56977. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56978. /**
  56979. * Defines the kind of connection point for node based material
  56980. */
  56981. export enum NodeMaterialBlockConnectionPointTypes {
  56982. /** Float */
  56983. Float = 1,
  56984. /** Int */
  56985. Int = 2,
  56986. /** Vector2 */
  56987. Vector2 = 4,
  56988. /** Vector3 */
  56989. Vector3 = 8,
  56990. /** Vector4 */
  56991. Vector4 = 16,
  56992. /** Color3 */
  56993. Color3 = 32,
  56994. /** Color4 */
  56995. Color4 = 64,
  56996. /** Matrix */
  56997. Matrix = 128,
  56998. /** Detect type based on connection */
  56999. AutoDetect = 1024,
  57000. /** Output type that will be defined by input type */
  57001. BasedOnInput = 2048
  57002. }
  57003. }
  57004. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57005. /**
  57006. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57007. */
  57008. export enum NodeMaterialBlockConnectionPointMode {
  57009. /** Value is an uniform */
  57010. Uniform = 0,
  57011. /** Value is a mesh attribute */
  57012. Attribute = 1,
  57013. /** Value is a varying between vertex and fragment shaders */
  57014. Varying = 2,
  57015. /** Mode is undefined */
  57016. Undefined = 3
  57017. }
  57018. }
  57019. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57020. /**
  57021. * Enum used to define system values e.g. values automatically provided by the system
  57022. */
  57023. export enum NodeMaterialSystemValues {
  57024. /** World */
  57025. World = 1,
  57026. /** View */
  57027. View = 2,
  57028. /** Projection */
  57029. Projection = 3,
  57030. /** ViewProjection */
  57031. ViewProjection = 4,
  57032. /** WorldView */
  57033. WorldView = 5,
  57034. /** WorldViewProjection */
  57035. WorldViewProjection = 6,
  57036. /** CameraPosition */
  57037. CameraPosition = 7,
  57038. /** Fog Color */
  57039. FogColor = 8,
  57040. /** Delta time */
  57041. DeltaTime = 9
  57042. }
  57043. }
  57044. declare module "babylonjs/Materials/Node/Enums/index" {
  57045. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57046. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57047. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57048. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57049. }
  57050. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57052. /**
  57053. * Root class for all node material optimizers
  57054. */
  57055. export class NodeMaterialOptimizer {
  57056. /**
  57057. * Function used to optimize a NodeMaterial graph
  57058. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57059. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57060. */
  57061. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57062. }
  57063. }
  57064. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57068. import { Scene } from "babylonjs/scene";
  57069. /**
  57070. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57071. */
  57072. export class TransformBlock extends NodeMaterialBlock {
  57073. /**
  57074. * Defines the value to use to complement W value to transform it to a Vector4
  57075. */
  57076. complementW: number;
  57077. /**
  57078. * Defines the value to use to complement z value to transform it to a Vector4
  57079. */
  57080. complementZ: number;
  57081. /**
  57082. * Creates a new TransformBlock
  57083. * @param name defines the block name
  57084. */
  57085. constructor(name: string);
  57086. /**
  57087. * Gets the current class name
  57088. * @returns the class name
  57089. */
  57090. getClassName(): string;
  57091. /**
  57092. * Gets the vector input
  57093. */
  57094. readonly vector: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the output component
  57097. */
  57098. readonly output: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the matrix transform input
  57101. */
  57102. readonly transform: NodeMaterialConnectionPoint;
  57103. protected _buildBlock(state: NodeMaterialBuildState): this;
  57104. serialize(): any;
  57105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57106. protected _dumpPropertiesCode(): string;
  57107. }
  57108. }
  57109. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57113. /**
  57114. * Block used to output the vertex position
  57115. */
  57116. export class VertexOutputBlock extends NodeMaterialBlock {
  57117. /**
  57118. * Creates a new VertexOutputBlock
  57119. * @param name defines the block name
  57120. */
  57121. constructor(name: string);
  57122. /**
  57123. * Gets the current class name
  57124. * @returns the class name
  57125. */
  57126. getClassName(): string;
  57127. /**
  57128. * Gets the vector input component
  57129. */
  57130. readonly vector: NodeMaterialConnectionPoint;
  57131. protected _buildBlock(state: NodeMaterialBuildState): this;
  57132. }
  57133. }
  57134. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57138. /**
  57139. * Block used to output the final color
  57140. */
  57141. export class FragmentOutputBlock extends NodeMaterialBlock {
  57142. /**
  57143. * Create a new FragmentOutputBlock
  57144. * @param name defines the block name
  57145. */
  57146. constructor(name: string);
  57147. /**
  57148. * Gets the current class name
  57149. * @returns the class name
  57150. */
  57151. getClassName(): string;
  57152. /**
  57153. * Gets the rgba input component
  57154. */
  57155. readonly rgba: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the rgb input component
  57158. */
  57159. readonly rgb: NodeMaterialConnectionPoint;
  57160. /**
  57161. * Gets the a input component
  57162. */
  57163. readonly a: NodeMaterialConnectionPoint;
  57164. protected _buildBlock(state: NodeMaterialBuildState): this;
  57165. }
  57166. }
  57167. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57173. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57174. import { Effect } from "babylonjs/Materials/effect";
  57175. import { Mesh } from "babylonjs/Meshes/mesh";
  57176. import { Nullable } from "babylonjs/types";
  57177. import { Scene } from "babylonjs/scene";
  57178. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57179. /**
  57180. * Block used to read a reflection texture from a sampler
  57181. */
  57182. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57183. private _define3DName;
  57184. private _defineCubicName;
  57185. private _defineExplicitName;
  57186. private _defineProjectionName;
  57187. private _defineLocalCubicName;
  57188. private _defineSphericalName;
  57189. private _definePlanarName;
  57190. private _defineEquirectangularName;
  57191. private _defineMirroredEquirectangularFixedName;
  57192. private _defineEquirectangularFixedName;
  57193. private _defineSkyboxName;
  57194. private _cubeSamplerName;
  57195. private _2DSamplerName;
  57196. private _positionUVWName;
  57197. private _directionWName;
  57198. private _reflectionCoordsName;
  57199. private _reflection2DCoordsName;
  57200. private _reflectionColorName;
  57201. private _reflectionMatrixName;
  57202. /**
  57203. * Gets or sets the texture associated with the node
  57204. */
  57205. texture: Nullable<BaseTexture>;
  57206. /**
  57207. * Create a new TextureBlock
  57208. * @param name defines the block name
  57209. */
  57210. constructor(name: string);
  57211. /**
  57212. * Gets the current class name
  57213. * @returns the class name
  57214. */
  57215. getClassName(): string;
  57216. /**
  57217. * Gets the world position input component
  57218. */
  57219. readonly position: NodeMaterialConnectionPoint;
  57220. /**
  57221. * Gets the world position input component
  57222. */
  57223. readonly worldPosition: NodeMaterialConnectionPoint;
  57224. /**
  57225. * Gets the world normal input component
  57226. */
  57227. readonly worldNormal: NodeMaterialConnectionPoint;
  57228. /**
  57229. * Gets the world input component
  57230. */
  57231. readonly world: NodeMaterialConnectionPoint;
  57232. /**
  57233. * Gets the camera (or eye) position component
  57234. */
  57235. readonly cameraPosition: NodeMaterialConnectionPoint;
  57236. /**
  57237. * Gets the view input component
  57238. */
  57239. readonly view: NodeMaterialConnectionPoint;
  57240. /**
  57241. * Gets the rgb output component
  57242. */
  57243. readonly rgb: NodeMaterialConnectionPoint;
  57244. /**
  57245. * Gets the r output component
  57246. */
  57247. readonly r: NodeMaterialConnectionPoint;
  57248. /**
  57249. * Gets the g output component
  57250. */
  57251. readonly g: NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the b output component
  57254. */
  57255. readonly b: NodeMaterialConnectionPoint;
  57256. autoConfigure(material: NodeMaterial): void;
  57257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57258. isReady(): boolean;
  57259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57260. private _injectVertexCode;
  57261. private _writeOutput;
  57262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57263. protected _dumpPropertiesCode(): string;
  57264. serialize(): any;
  57265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57266. }
  57267. }
  57268. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57270. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57271. import { Scene } from "babylonjs/scene";
  57272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57273. import { Matrix } from "babylonjs/Maths/math.vector";
  57274. import { Mesh } from "babylonjs/Meshes/mesh";
  57275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57276. import { Observable } from "babylonjs/Misc/observable";
  57277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57278. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57279. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57280. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57281. import { Nullable } from "babylonjs/types";
  57282. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57283. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57284. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57285. /**
  57286. * Interface used to configure the node material editor
  57287. */
  57288. export interface INodeMaterialEditorOptions {
  57289. /** Define the URl to load node editor script */
  57290. editorURL?: string;
  57291. }
  57292. /** @hidden */
  57293. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57294. /** BONES */
  57295. NUM_BONE_INFLUENCERS: number;
  57296. BonesPerMesh: number;
  57297. BONETEXTURE: boolean;
  57298. /** MORPH TARGETS */
  57299. MORPHTARGETS: boolean;
  57300. MORPHTARGETS_NORMAL: boolean;
  57301. MORPHTARGETS_TANGENT: boolean;
  57302. MORPHTARGETS_UV: boolean;
  57303. NUM_MORPH_INFLUENCERS: number;
  57304. /** IMAGE PROCESSING */
  57305. IMAGEPROCESSING: boolean;
  57306. VIGNETTE: boolean;
  57307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57308. VIGNETTEBLENDMODEOPAQUE: boolean;
  57309. TONEMAPPING: boolean;
  57310. TONEMAPPING_ACES: boolean;
  57311. CONTRAST: boolean;
  57312. EXPOSURE: boolean;
  57313. COLORCURVES: boolean;
  57314. COLORGRADING: boolean;
  57315. COLORGRADING3D: boolean;
  57316. SAMPLER3DGREENDEPTH: boolean;
  57317. SAMPLER3DBGRMAP: boolean;
  57318. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57319. /** MISC. */
  57320. BUMPDIRECTUV: number;
  57321. constructor();
  57322. setValue(name: string, value: boolean): void;
  57323. }
  57324. /**
  57325. * Class used to configure NodeMaterial
  57326. */
  57327. export interface INodeMaterialOptions {
  57328. /**
  57329. * Defines if blocks should emit comments
  57330. */
  57331. emitComments: boolean;
  57332. }
  57333. /**
  57334. * Class used to create a node based material built by assembling shader blocks
  57335. */
  57336. export class NodeMaterial extends PushMaterial {
  57337. private static _BuildIdGenerator;
  57338. private _options;
  57339. private _vertexCompilationState;
  57340. private _fragmentCompilationState;
  57341. private _sharedData;
  57342. private _buildId;
  57343. private _buildWasSuccessful;
  57344. private _cachedWorldViewMatrix;
  57345. private _cachedWorldViewProjectionMatrix;
  57346. private _optimizers;
  57347. private _animationFrame;
  57348. /** Define the URl to load node editor script */
  57349. static EditorURL: string;
  57350. private BJSNODEMATERIALEDITOR;
  57351. /** Get the inspector from bundle or global */
  57352. private _getGlobalNodeMaterialEditor;
  57353. /**
  57354. * Gets or sets data used by visual editor
  57355. * @see https://nme.babylonjs.com
  57356. */
  57357. editorData: any;
  57358. /**
  57359. * 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)
  57360. */
  57361. ignoreAlpha: boolean;
  57362. /**
  57363. * Defines the maximum number of lights that can be used in the material
  57364. */
  57365. maxSimultaneousLights: number;
  57366. /**
  57367. * Observable raised when the material is built
  57368. */
  57369. onBuildObservable: Observable<NodeMaterial>;
  57370. /**
  57371. * Gets or sets the root nodes of the material vertex shader
  57372. */
  57373. _vertexOutputNodes: NodeMaterialBlock[];
  57374. /**
  57375. * Gets or sets the root nodes of the material fragment (pixel) shader
  57376. */
  57377. _fragmentOutputNodes: NodeMaterialBlock[];
  57378. /** Gets or sets options to control the node material overall behavior */
  57379. options: INodeMaterialOptions;
  57380. /**
  57381. * Default configuration related to image processing available in the standard Material.
  57382. */
  57383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57384. /**
  57385. * Gets the image processing configuration used either in this material.
  57386. */
  57387. /**
  57388. * Sets the Default image processing configuration used either in the this material.
  57389. *
  57390. * If sets to null, the scene one is in use.
  57391. */
  57392. imageProcessingConfiguration: ImageProcessingConfiguration;
  57393. /**
  57394. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57395. */
  57396. attachedBlocks: NodeMaterialBlock[];
  57397. /**
  57398. * Create a new node based material
  57399. * @param name defines the material name
  57400. * @param scene defines the hosting scene
  57401. * @param options defines creation option
  57402. */
  57403. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57404. /**
  57405. * Gets the current class name of the material e.g. "NodeMaterial"
  57406. * @returns the class name
  57407. */
  57408. getClassName(): string;
  57409. /**
  57410. * Keep track of the image processing observer to allow dispose and replace.
  57411. */
  57412. private _imageProcessingObserver;
  57413. /**
  57414. * Attaches a new image processing configuration to the Standard Material.
  57415. * @param configuration
  57416. */
  57417. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57418. /**
  57419. * Get a block by its name
  57420. * @param name defines the name of the block to retrieve
  57421. * @returns the required block or null if not found
  57422. */
  57423. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57424. /**
  57425. * Get a block by its name
  57426. * @param predicate defines the predicate used to find the good candidate
  57427. * @returns the required block or null if not found
  57428. */
  57429. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57430. /**
  57431. * Get an input block by its name
  57432. * @param predicate defines the predicate used to find the good candidate
  57433. * @returns the required input block or null if not found
  57434. */
  57435. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57436. /**
  57437. * Gets the list of input blocks attached to this material
  57438. * @returns an array of InputBlocks
  57439. */
  57440. getInputBlocks(): InputBlock[];
  57441. /**
  57442. * Adds a new optimizer to the list of optimizers
  57443. * @param optimizer defines the optimizers to add
  57444. * @returns the current material
  57445. */
  57446. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57447. /**
  57448. * Remove an optimizer from the list of optimizers
  57449. * @param optimizer defines the optimizers to remove
  57450. * @returns the current material
  57451. */
  57452. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57453. /**
  57454. * Add a new block to the list of output nodes
  57455. * @param node defines the node to add
  57456. * @returns the current material
  57457. */
  57458. addOutputNode(node: NodeMaterialBlock): this;
  57459. /**
  57460. * Remove a block from the list of root nodes
  57461. * @param node defines the node to remove
  57462. * @returns the current material
  57463. */
  57464. removeOutputNode(node: NodeMaterialBlock): this;
  57465. private _addVertexOutputNode;
  57466. private _removeVertexOutputNode;
  57467. private _addFragmentOutputNode;
  57468. private _removeFragmentOutputNode;
  57469. /**
  57470. * Specifies if the material will require alpha blending
  57471. * @returns a boolean specifying if alpha blending is needed
  57472. */
  57473. needAlphaBlending(): boolean;
  57474. /**
  57475. * Specifies if this material should be rendered in alpha test mode
  57476. * @returns a boolean specifying if an alpha test is needed.
  57477. */
  57478. needAlphaTesting(): boolean;
  57479. private _initializeBlock;
  57480. private _resetDualBlocks;
  57481. /**
  57482. * Remove a block from the current node material
  57483. * @param block defines the block to remove
  57484. */
  57485. removeBlock(block: NodeMaterialBlock): void;
  57486. /**
  57487. * Build the material and generates the inner effect
  57488. * @param verbose defines if the build should log activity
  57489. */
  57490. build(verbose?: boolean): void;
  57491. /**
  57492. * Runs an otpimization phase to try to improve the shader code
  57493. */
  57494. optimize(): void;
  57495. private _prepareDefinesForAttributes;
  57496. /**
  57497. * Get if the submesh is ready to be used and all its information available.
  57498. * Child classes can use it to update shaders
  57499. * @param mesh defines the mesh to check
  57500. * @param subMesh defines which submesh to check
  57501. * @param useInstances specifies that instances should be used
  57502. * @returns a boolean indicating that the submesh is ready or not
  57503. */
  57504. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57505. /**
  57506. * Get a string representing the shaders built by the current node graph
  57507. */
  57508. readonly compiledShaders: string;
  57509. /**
  57510. * Binds the world matrix to the material
  57511. * @param world defines the world transformation matrix
  57512. */
  57513. bindOnlyWorldMatrix(world: Matrix): void;
  57514. /**
  57515. * Binds the submesh to this material by preparing the effect and shader to draw
  57516. * @param world defines the world transformation matrix
  57517. * @param mesh defines the mesh containing the submesh
  57518. * @param subMesh defines the submesh to bind the material to
  57519. */
  57520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57521. /**
  57522. * Gets the active textures from the material
  57523. * @returns an array of textures
  57524. */
  57525. getActiveTextures(): BaseTexture[];
  57526. /**
  57527. * Gets the list of texture blocks
  57528. * @returns an array of texture blocks
  57529. */
  57530. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57531. /**
  57532. * Specifies if the material uses a texture
  57533. * @param texture defines the texture to check against the material
  57534. * @returns a boolean specifying if the material uses the texture
  57535. */
  57536. hasTexture(texture: BaseTexture): boolean;
  57537. /**
  57538. * Disposes the material
  57539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57542. */
  57543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57544. /** Creates the node editor window. */
  57545. private _createNodeEditor;
  57546. /**
  57547. * Launch the node material editor
  57548. * @param config Define the configuration of the editor
  57549. * @return a promise fulfilled when the node editor is visible
  57550. */
  57551. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57552. /**
  57553. * Clear the current material
  57554. */
  57555. clear(): void;
  57556. /**
  57557. * Clear the current material and set it to a default state
  57558. */
  57559. setToDefault(): void;
  57560. /**
  57561. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57562. * @param url defines the url to load from
  57563. * @returns a promise that will fullfil when the material is fully loaded
  57564. */
  57565. loadAsync(url: string): Promise<void>;
  57566. private _gatherBlocks;
  57567. /**
  57568. * Generate a string containing the code declaration required to create an equivalent of this material
  57569. * @returns a string
  57570. */
  57571. generateCode(): string;
  57572. /**
  57573. * Serializes this material in a JSON representation
  57574. * @returns the serialized material object
  57575. */
  57576. serialize(): any;
  57577. private _restoreConnections;
  57578. /**
  57579. * Clear the current graph and load a new one from a serialization object
  57580. * @param source defines the JSON representation of the material
  57581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57582. */
  57583. loadFromSerialization(source: any, rootUrl?: string): void;
  57584. /**
  57585. * Creates a node material from parsed material data
  57586. * @param source defines the JSON representation of the material
  57587. * @param scene defines the hosting scene
  57588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57589. * @returns a new node material
  57590. */
  57591. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57592. /**
  57593. * Creates a new node material set to default basic configuration
  57594. * @param name defines the name of the material
  57595. * @param scene defines the hosting scene
  57596. * @returns a new NodeMaterial
  57597. */
  57598. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57599. }
  57600. }
  57601. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  57602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57604. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57607. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57608. import { Effect } from "babylonjs/Materials/effect";
  57609. import { Mesh } from "babylonjs/Meshes/mesh";
  57610. import { Nullable } from "babylonjs/types";
  57611. import { Texture } from "babylonjs/Materials/Textures/texture";
  57612. import { Scene } from "babylonjs/scene";
  57613. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57614. /**
  57615. * Block used to read a texture from a sampler
  57616. */
  57617. export class TextureBlock extends NodeMaterialBlock {
  57618. private _defineName;
  57619. private _linearDefineName;
  57620. private _tempTextureRead;
  57621. private _samplerName;
  57622. private _transformedUVName;
  57623. private _textureTransformName;
  57624. private _textureInfoName;
  57625. private _mainUVName;
  57626. private _mainUVDefineName;
  57627. /**
  57628. * Gets or sets the texture associated with the node
  57629. */
  57630. texture: Nullable<Texture>;
  57631. /**
  57632. * Create a new TextureBlock
  57633. * @param name defines the block name
  57634. */
  57635. constructor(name: string);
  57636. /**
  57637. * Gets the current class name
  57638. * @returns the class name
  57639. */
  57640. getClassName(): string;
  57641. /**
  57642. * Gets the uv input component
  57643. */
  57644. readonly uv: NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the rgba output component
  57647. */
  57648. readonly rgba: NodeMaterialConnectionPoint;
  57649. /**
  57650. * Gets the rgb output component
  57651. */
  57652. readonly rgb: NodeMaterialConnectionPoint;
  57653. /**
  57654. * Gets the r output component
  57655. */
  57656. readonly r: NodeMaterialConnectionPoint;
  57657. /**
  57658. * Gets the g output component
  57659. */
  57660. readonly g: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the b output component
  57663. */
  57664. readonly b: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the a output component
  57667. */
  57668. readonly a: NodeMaterialConnectionPoint;
  57669. readonly target: NodeMaterialBlockTargets;
  57670. autoConfigure(material: NodeMaterial): void;
  57671. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57672. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57673. private _getTextureBase;
  57674. isReady(): boolean;
  57675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57676. private readonly _isMixed;
  57677. private _injectVertexCode;
  57678. private _writeTextureRead;
  57679. private _writeOutput;
  57680. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57681. protected _dumpPropertiesCode(): string;
  57682. serialize(): any;
  57683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57684. }
  57685. }
  57686. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  57687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57689. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57690. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57691. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57692. import { Scene } from "babylonjs/scene";
  57693. /**
  57694. * Class used to store shared data between 2 NodeMaterialBuildState
  57695. */
  57696. export class NodeMaterialBuildStateSharedData {
  57697. /**
  57698. * Gets the list of emitted varyings
  57699. */
  57700. temps: string[];
  57701. /**
  57702. * Gets the list of emitted varyings
  57703. */
  57704. varyings: string[];
  57705. /**
  57706. * Gets the varying declaration string
  57707. */
  57708. varyingDeclaration: string;
  57709. /**
  57710. * Input blocks
  57711. */
  57712. inputBlocks: InputBlock[];
  57713. /**
  57714. * Input blocks
  57715. */
  57716. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57717. /**
  57718. * Bindable blocks (Blocks that need to set data to the effect)
  57719. */
  57720. bindableBlocks: NodeMaterialBlock[];
  57721. /**
  57722. * List of blocks that can provide a compilation fallback
  57723. */
  57724. blocksWithFallbacks: NodeMaterialBlock[];
  57725. /**
  57726. * List of blocks that can provide a define update
  57727. */
  57728. blocksWithDefines: NodeMaterialBlock[];
  57729. /**
  57730. * List of blocks that can provide a repeatable content
  57731. */
  57732. repeatableContentBlocks: NodeMaterialBlock[];
  57733. /**
  57734. * List of blocks that can provide a dynamic list of uniforms
  57735. */
  57736. dynamicUniformBlocks: NodeMaterialBlock[];
  57737. /**
  57738. * List of blocks that can block the isReady function for the material
  57739. */
  57740. blockingBlocks: NodeMaterialBlock[];
  57741. /**
  57742. * Gets the list of animated inputs
  57743. */
  57744. animatedInputs: InputBlock[];
  57745. /**
  57746. * Build Id used to avoid multiple recompilations
  57747. */
  57748. buildId: number;
  57749. /** List of emitted variables */
  57750. variableNames: {
  57751. [key: string]: number;
  57752. };
  57753. /** List of emitted defines */
  57754. defineNames: {
  57755. [key: string]: number;
  57756. };
  57757. /** Should emit comments? */
  57758. emitComments: boolean;
  57759. /** Emit build activity */
  57760. verbose: boolean;
  57761. /** Gets or sets the hosting scene */
  57762. scene: Scene;
  57763. /**
  57764. * Gets the compilation hints emitted at compilation time
  57765. */
  57766. hints: {
  57767. needWorldViewMatrix: boolean;
  57768. needWorldViewProjectionMatrix: boolean;
  57769. needAlphaBlending: boolean;
  57770. needAlphaTesting: boolean;
  57771. };
  57772. /**
  57773. * List of compilation checks
  57774. */
  57775. checks: {
  57776. emitVertex: boolean;
  57777. emitFragment: boolean;
  57778. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57779. };
  57780. /** Creates a new shared data */
  57781. constructor();
  57782. /**
  57783. * Emits console errors and exceptions if there is a failing check
  57784. */
  57785. emitErrors(): void;
  57786. }
  57787. }
  57788. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57789. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57790. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57791. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57792. /**
  57793. * Class used to store node based material build state
  57794. */
  57795. export class NodeMaterialBuildState {
  57796. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57797. supportUniformBuffers: boolean;
  57798. /**
  57799. * Gets the list of emitted attributes
  57800. */
  57801. attributes: string[];
  57802. /**
  57803. * Gets the list of emitted uniforms
  57804. */
  57805. uniforms: string[];
  57806. /**
  57807. * Gets the list of emitted constants
  57808. */
  57809. constants: string[];
  57810. /**
  57811. * Gets the list of emitted samplers
  57812. */
  57813. samplers: string[];
  57814. /**
  57815. * Gets the list of emitted functions
  57816. */
  57817. functions: {
  57818. [key: string]: string;
  57819. };
  57820. /**
  57821. * Gets the list of emitted extensions
  57822. */
  57823. extensions: {
  57824. [key: string]: string;
  57825. };
  57826. /**
  57827. * Gets the target of the compilation state
  57828. */
  57829. target: NodeMaterialBlockTargets;
  57830. /**
  57831. * Gets the list of emitted counters
  57832. */
  57833. counters: {
  57834. [key: string]: number;
  57835. };
  57836. /**
  57837. * Shared data between multiple NodeMaterialBuildState instances
  57838. */
  57839. sharedData: NodeMaterialBuildStateSharedData;
  57840. /** @hidden */
  57841. _vertexState: NodeMaterialBuildState;
  57842. /** @hidden */
  57843. _attributeDeclaration: string;
  57844. /** @hidden */
  57845. _uniformDeclaration: string;
  57846. /** @hidden */
  57847. _constantDeclaration: string;
  57848. /** @hidden */
  57849. _samplerDeclaration: string;
  57850. /** @hidden */
  57851. _varyingTransfer: string;
  57852. private _repeatableContentAnchorIndex;
  57853. /** @hidden */
  57854. _builtCompilationString: string;
  57855. /**
  57856. * Gets the emitted compilation strings
  57857. */
  57858. compilationString: string;
  57859. /**
  57860. * Finalize the compilation strings
  57861. * @param state defines the current compilation state
  57862. */
  57863. finalize(state: NodeMaterialBuildState): void;
  57864. /** @hidden */
  57865. readonly _repeatableContentAnchor: string;
  57866. /** @hidden */
  57867. _getFreeVariableName(prefix: string): string;
  57868. /** @hidden */
  57869. _getFreeDefineName(prefix: string): string;
  57870. /** @hidden */
  57871. _excludeVariableName(name: string): void;
  57872. /** @hidden */
  57873. _emit2DSampler(name: string): void;
  57874. /** @hidden */
  57875. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57876. /** @hidden */
  57877. _emitExtension(name: string, extension: string): void;
  57878. /** @hidden */
  57879. _emitFunction(name: string, code: string, comments: string): void;
  57880. /** @hidden */
  57881. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57882. replaceStrings?: {
  57883. search: RegExp;
  57884. replace: string;
  57885. }[];
  57886. repeatKey?: string;
  57887. }): string;
  57888. /** @hidden */
  57889. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57890. repeatKey?: string;
  57891. removeAttributes?: boolean;
  57892. removeUniforms?: boolean;
  57893. removeVaryings?: boolean;
  57894. removeIfDef?: boolean;
  57895. replaceStrings?: {
  57896. search: RegExp;
  57897. replace: string;
  57898. }[];
  57899. }, storeKey?: string): void;
  57900. /** @hidden */
  57901. _registerTempVariable(name: string): boolean;
  57902. /** @hidden */
  57903. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57904. /** @hidden */
  57905. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57906. /** @hidden */
  57907. _emitFloat(value: number): string;
  57908. }
  57909. }
  57910. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57911. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57913. import { Nullable } from "babylonjs/types";
  57914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57915. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57916. import { Effect } from "babylonjs/Materials/effect";
  57917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57918. import { Mesh } from "babylonjs/Meshes/mesh";
  57919. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57920. import { Scene } from "babylonjs/scene";
  57921. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57922. /**
  57923. * Defines a block that can be used inside a node based material
  57924. */
  57925. export class NodeMaterialBlock {
  57926. private _buildId;
  57927. private _buildTarget;
  57928. private _target;
  57929. private _isFinalMerger;
  57930. private _isInput;
  57931. protected _isUnique: boolean;
  57932. /** @hidden */
  57933. _codeVariableName: string;
  57934. /** @hidden */
  57935. _inputs: NodeMaterialConnectionPoint[];
  57936. /** @hidden */
  57937. _outputs: NodeMaterialConnectionPoint[];
  57938. /** @hidden */
  57939. _preparationId: number;
  57940. /**
  57941. * Gets or sets the name of the block
  57942. */
  57943. name: string;
  57944. /**
  57945. * Gets or sets the unique id of the node
  57946. */
  57947. uniqueId: number;
  57948. /**
  57949. * Gets or sets the comments associated with this block
  57950. */
  57951. comments: string;
  57952. /**
  57953. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57954. */
  57955. readonly isUnique: boolean;
  57956. /**
  57957. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57958. */
  57959. readonly isFinalMerger: boolean;
  57960. /**
  57961. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57962. */
  57963. readonly isInput: boolean;
  57964. /**
  57965. * Gets or sets the build Id
  57966. */
  57967. buildId: number;
  57968. /**
  57969. * Gets or sets the target of the block
  57970. */
  57971. target: NodeMaterialBlockTargets;
  57972. /**
  57973. * Gets the list of input points
  57974. */
  57975. readonly inputs: NodeMaterialConnectionPoint[];
  57976. /** Gets the list of output points */
  57977. readonly outputs: NodeMaterialConnectionPoint[];
  57978. /**
  57979. * Find an input by its name
  57980. * @param name defines the name of the input to look for
  57981. * @returns the input or null if not found
  57982. */
  57983. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57984. /**
  57985. * Find an output by its name
  57986. * @param name defines the name of the outputto look for
  57987. * @returns the output or null if not found
  57988. */
  57989. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57990. /**
  57991. * Creates a new NodeMaterialBlock
  57992. * @param name defines the block name
  57993. * @param target defines the target of that block (Vertex by default)
  57994. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57995. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57996. */
  57997. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57998. /**
  57999. * Initialize the block and prepare the context for build
  58000. * @param state defines the state that will be used for the build
  58001. */
  58002. initialize(state: NodeMaterialBuildState): void;
  58003. /**
  58004. * Bind data to effect. Will only be called for blocks with isBindable === true
  58005. * @param effect defines the effect to bind data to
  58006. * @param nodeMaterial defines the hosting NodeMaterial
  58007. * @param mesh defines the mesh that will be rendered
  58008. */
  58009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58010. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58011. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58012. protected _writeFloat(value: number): string;
  58013. /**
  58014. * Gets the current class name e.g. "NodeMaterialBlock"
  58015. * @returns the class name
  58016. */
  58017. getClassName(): string;
  58018. /**
  58019. * Register a new input. Must be called inside a block constructor
  58020. * @param name defines the connection point name
  58021. * @param type defines the connection point type
  58022. * @param isOptional defines a boolean indicating that this input can be omitted
  58023. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58024. * @returns the current block
  58025. */
  58026. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58027. /**
  58028. * Register a new output. Must be called inside a block constructor
  58029. * @param name defines the connection point name
  58030. * @param type defines the connection point type
  58031. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58032. * @returns the current block
  58033. */
  58034. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58035. /**
  58036. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58037. * @param forOutput defines an optional connection point to check compatibility with
  58038. * @returns the first available input or null
  58039. */
  58040. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58041. /**
  58042. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58043. * @param forBlock defines an optional block to check compatibility with
  58044. * @returns the first available input or null
  58045. */
  58046. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58047. /**
  58048. * Gets the sibling of the given output
  58049. * @param current defines the current output
  58050. * @returns the next output in the list or null
  58051. */
  58052. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58053. /**
  58054. * Connect current block with another block
  58055. * @param other defines the block to connect with
  58056. * @param options define the various options to help pick the right connections
  58057. * @returns the current block
  58058. */
  58059. connectTo(other: NodeMaterialBlock, options?: {
  58060. input?: string;
  58061. output?: string;
  58062. outputSwizzle?: string;
  58063. }): this | undefined;
  58064. protected _buildBlock(state: NodeMaterialBuildState): void;
  58065. /**
  58066. * Add uniforms, samplers and uniform buffers at compilation time
  58067. * @param state defines the state to update
  58068. * @param nodeMaterial defines the node material requesting the update
  58069. * @param defines defines the material defines to update
  58070. * @param uniformBuffers defines the list of uniform buffer names
  58071. */
  58072. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58073. /**
  58074. * Add potential fallbacks if shader compilation fails
  58075. * @param mesh defines the mesh to be rendered
  58076. * @param fallbacks defines the current prioritized list of fallbacks
  58077. */
  58078. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58079. /**
  58080. * Initialize defines for shader compilation
  58081. * @param mesh defines the mesh to be rendered
  58082. * @param nodeMaterial defines the node material requesting the update
  58083. * @param defines defines the material defines to update
  58084. * @param useInstances specifies that instances should be used
  58085. */
  58086. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58087. /**
  58088. * Update defines for shader compilation
  58089. * @param mesh defines the mesh to be rendered
  58090. * @param nodeMaterial defines the node material requesting the update
  58091. * @param defines defines the material defines to update
  58092. * @param useInstances specifies that instances should be used
  58093. */
  58094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58095. /**
  58096. * Lets the block try to connect some inputs automatically
  58097. * @param material defines the hosting NodeMaterial
  58098. */
  58099. autoConfigure(material: NodeMaterial): void;
  58100. /**
  58101. * Function called when a block is declared as repeatable content generator
  58102. * @param vertexShaderState defines the current compilation state for the vertex shader
  58103. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58104. * @param mesh defines the mesh to be rendered
  58105. * @param defines defines the material defines to update
  58106. */
  58107. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58108. /**
  58109. * Checks if the block is ready
  58110. * @param mesh defines the mesh to be rendered
  58111. * @param nodeMaterial defines the node material requesting the update
  58112. * @param defines defines the material defines to update
  58113. * @param useInstances specifies that instances should be used
  58114. * @returns true if the block is ready
  58115. */
  58116. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58117. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58118. private _processBuild;
  58119. /**
  58120. * Compile the current node and generate the shader code
  58121. * @param state defines the current compilation state (uniforms, samplers, current string)
  58122. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58123. * @returns true if already built
  58124. */
  58125. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58126. protected _inputRename(name: string): string;
  58127. protected _outputRename(name: string): string;
  58128. protected _dumpPropertiesCode(): string;
  58129. /** @hidden */
  58130. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58131. /** @hidden */
  58132. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58133. /**
  58134. * Clone the current block to a new identical block
  58135. * @param scene defines the hosting scene
  58136. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58137. * @returns a copy of the current block
  58138. */
  58139. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58140. /**
  58141. * Serializes this block in a JSON representation
  58142. * @returns the serialized block object
  58143. */
  58144. serialize(): any;
  58145. /** @hidden */
  58146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58147. /**
  58148. * Release resources
  58149. */
  58150. dispose(): void;
  58151. }
  58152. }
  58153. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58154. /**
  58155. * Enum defining the type of animations supported by InputBlock
  58156. */
  58157. export enum AnimatedInputBlockTypes {
  58158. /** No animation */
  58159. None = 0,
  58160. /** Time based animation. Will only work for floats */
  58161. Time = 1
  58162. }
  58163. }
  58164. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58166. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58167. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58168. import { Nullable } from "babylonjs/types";
  58169. import { Effect } from "babylonjs/Materials/effect";
  58170. import { Matrix } from "babylonjs/Maths/math.vector";
  58171. import { Scene } from "babylonjs/scene";
  58172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58174. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58175. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58176. /**
  58177. * Block used to expose an input value
  58178. */
  58179. export class InputBlock extends NodeMaterialBlock {
  58180. private _mode;
  58181. private _associatedVariableName;
  58182. private _storedValue;
  58183. private _valueCallback;
  58184. private _type;
  58185. private _animationType;
  58186. /** Gets or set a value used to limit the range of float values */
  58187. min: number;
  58188. /** Gets or set a value used to limit the range of float values */
  58189. max: number;
  58190. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58191. matrixMode: number;
  58192. /** @hidden */
  58193. _systemValue: Nullable<NodeMaterialSystemValues>;
  58194. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58195. visibleInInspector: boolean;
  58196. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58197. isConstant: boolean;
  58198. /** Gets or sets the group to use to display this block in the Inspector */
  58199. groupInInspector: string;
  58200. /**
  58201. * Gets or sets the connection point type (default is float)
  58202. */
  58203. readonly type: NodeMaterialBlockConnectionPointTypes;
  58204. /**
  58205. * Creates a new InputBlock
  58206. * @param name defines the block name
  58207. * @param target defines the target of that block (Vertex by default)
  58208. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58209. */
  58210. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58211. /**
  58212. * Gets the output component
  58213. */
  58214. readonly output: NodeMaterialConnectionPoint;
  58215. /**
  58216. * Set the source of this connection point to a vertex attribute
  58217. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58218. * @returns the current connection point
  58219. */
  58220. setAsAttribute(attributeName?: string): InputBlock;
  58221. /**
  58222. * Set the source of this connection point to a system value
  58223. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58224. * @returns the current connection point
  58225. */
  58226. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58227. /**
  58228. * Gets or sets the value of that point.
  58229. * Please note that this value will be ignored if valueCallback is defined
  58230. */
  58231. value: any;
  58232. /**
  58233. * Gets or sets a callback used to get the value of that point.
  58234. * Please note that setting this value will force the connection point to ignore the value property
  58235. */
  58236. valueCallback: () => any;
  58237. /**
  58238. * Gets or sets the associated variable name in the shader
  58239. */
  58240. associatedVariableName: string;
  58241. /** Gets or sets the type of animation applied to the input */
  58242. animationType: AnimatedInputBlockTypes;
  58243. /**
  58244. * Gets a boolean indicating that this connection point not defined yet
  58245. */
  58246. readonly isUndefined: boolean;
  58247. /**
  58248. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58249. * In this case the connection point name must be the name of the uniform to use.
  58250. * Can only be set on inputs
  58251. */
  58252. isUniform: boolean;
  58253. /**
  58254. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58255. * In this case the connection point name must be the name of the attribute to use
  58256. * Can only be set on inputs
  58257. */
  58258. isAttribute: boolean;
  58259. /**
  58260. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58261. * Can only be set on exit points
  58262. */
  58263. isVarying: boolean;
  58264. /**
  58265. * Gets a boolean indicating that the current connection point is a system value
  58266. */
  58267. readonly isSystemValue: boolean;
  58268. /**
  58269. * Gets or sets the current well known value or null if not defined as a system value
  58270. */
  58271. systemValue: Nullable<NodeMaterialSystemValues>;
  58272. /**
  58273. * Gets the current class name
  58274. * @returns the class name
  58275. */
  58276. getClassName(): string;
  58277. /**
  58278. * Animate the input if animationType !== None
  58279. * @param scene defines the rendering scene
  58280. */
  58281. animate(scene: Scene): void;
  58282. private _emitDefine;
  58283. initialize(state: NodeMaterialBuildState): void;
  58284. /**
  58285. * Set the input block to its default value (based on its type)
  58286. */
  58287. setDefaultValue(): void;
  58288. private _emitConstant;
  58289. private _emit;
  58290. /** @hidden */
  58291. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58292. /** @hidden */
  58293. _transmit(effect: Effect, scene: Scene): void;
  58294. protected _buildBlock(state: NodeMaterialBuildState): void;
  58295. protected _dumpPropertiesCode(): string;
  58296. serialize(): any;
  58297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58298. }
  58299. }
  58300. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58301. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58302. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58303. import { Nullable } from "babylonjs/types";
  58304. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58305. import { Observable } from "babylonjs/Misc/observable";
  58306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58307. /**
  58308. * Enum used to define the compatibility state between two connection points
  58309. */
  58310. export enum NodeMaterialConnectionPointCompatibilityStates {
  58311. /** Points are compatibles */
  58312. Compatible = 0,
  58313. /** Points are incompatible because of their types */
  58314. TypeIncompatible = 1,
  58315. /** Points are incompatible because of their targets (vertex vs fragment) */
  58316. TargetIncompatible = 2
  58317. }
  58318. /**
  58319. * Defines the direction of a connection point
  58320. */
  58321. export enum NodeMaterialConnectionPointDirection {
  58322. /** Input */
  58323. Input = 0,
  58324. /** Output */
  58325. Output = 1
  58326. }
  58327. /**
  58328. * Defines a connection point for a block
  58329. */
  58330. export class NodeMaterialConnectionPoint {
  58331. /** @hidden */
  58332. _ownerBlock: NodeMaterialBlock;
  58333. /** @hidden */
  58334. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58335. private _endpoints;
  58336. private _associatedVariableName;
  58337. private _direction;
  58338. /** @hidden */
  58339. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58340. /** @hidden */
  58341. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58342. private _type;
  58343. /** @hidden */
  58344. _enforceAssociatedVariableName: boolean;
  58345. /** Gets the direction of the point */
  58346. readonly direction: NodeMaterialConnectionPointDirection;
  58347. /**
  58348. * Gets or sets the additional types supported by this connection point
  58349. */
  58350. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58351. /**
  58352. * Gets or sets the additional types excluded by this connection point
  58353. */
  58354. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58355. /**
  58356. * Observable triggered when this point is connected
  58357. */
  58358. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58359. /**
  58360. * Gets or sets the associated variable name in the shader
  58361. */
  58362. associatedVariableName: string;
  58363. /**
  58364. * Gets or sets the connection point type (default is float)
  58365. */
  58366. type: NodeMaterialBlockConnectionPointTypes;
  58367. /**
  58368. * Gets or sets the connection point name
  58369. */
  58370. name: string;
  58371. /**
  58372. * Gets or sets a boolean indicating that this connection point can be omitted
  58373. */
  58374. isOptional: boolean;
  58375. /**
  58376. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58377. */
  58378. define: string;
  58379. /** @hidden */
  58380. _prioritizeVertex: boolean;
  58381. private _target;
  58382. /** Gets or sets the target of that connection point */
  58383. target: NodeMaterialBlockTargets;
  58384. /**
  58385. * Gets a boolean indicating that the current point is connected
  58386. */
  58387. readonly isConnected: boolean;
  58388. /**
  58389. * Gets a boolean indicating that the current point is connected to an input block
  58390. */
  58391. readonly isConnectedToInputBlock: boolean;
  58392. /**
  58393. * Gets a the connected input block (if any)
  58394. */
  58395. readonly connectInputBlock: Nullable<InputBlock>;
  58396. /** Get the other side of the connection (if any) */
  58397. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58398. /** Get the block that owns this connection point */
  58399. readonly ownerBlock: NodeMaterialBlock;
  58400. /** Get the block connected on the other side of this connection (if any) */
  58401. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  58402. /** Get the block connected on the endpoints of this connection (if any) */
  58403. readonly connectedBlocks: Array<NodeMaterialBlock>;
  58404. /** Gets the list of connected endpoints */
  58405. readonly endpoints: NodeMaterialConnectionPoint[];
  58406. /** Gets a boolean indicating if that output point is connected to at least one input */
  58407. readonly hasEndpoints: boolean;
  58408. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58409. readonly isConnectedInVertexShader: boolean;
  58410. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58411. readonly isConnectedInFragmentShader: boolean;
  58412. /**
  58413. * Creates a new connection point
  58414. * @param name defines the connection point name
  58415. * @param ownerBlock defines the block hosting this connection point
  58416. * @param direction defines the direction of the connection point
  58417. */
  58418. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58419. /**
  58420. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58421. * @returns the class name
  58422. */
  58423. getClassName(): string;
  58424. /**
  58425. * Gets a boolean indicating if the current point can be connected to another point
  58426. * @param connectionPoint defines the other connection point
  58427. * @returns a boolean
  58428. */
  58429. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58430. /**
  58431. * Gets a number indicating if the current point can be connected to another point
  58432. * @param connectionPoint defines the other connection point
  58433. * @returns a number defining the compatibility state
  58434. */
  58435. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58436. /**
  58437. * Connect this point to another connection point
  58438. * @param connectionPoint defines the other connection point
  58439. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58440. * @returns the current connection point
  58441. */
  58442. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58443. /**
  58444. * Disconnect this point from one of his endpoint
  58445. * @param endpoint defines the other connection point
  58446. * @returns the current connection point
  58447. */
  58448. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58449. /**
  58450. * Serializes this point in a JSON representation
  58451. * @returns the serialized point object
  58452. */
  58453. serialize(): any;
  58454. /**
  58455. * Release resources
  58456. */
  58457. dispose(): void;
  58458. }
  58459. }
  58460. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  58461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58464. import { Mesh } from "babylonjs/Meshes/mesh";
  58465. import { Effect } from "babylonjs/Materials/effect";
  58466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58467. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58468. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58469. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58470. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58471. /**
  58472. * Block used to add support for vertex skinning (bones)
  58473. */
  58474. export class BonesBlock extends NodeMaterialBlock {
  58475. /**
  58476. * Creates a new BonesBlock
  58477. * @param name defines the block name
  58478. */
  58479. constructor(name: string);
  58480. /**
  58481. * Initialize the block and prepare the context for build
  58482. * @param state defines the state that will be used for the build
  58483. */
  58484. initialize(state: NodeMaterialBuildState): void;
  58485. /**
  58486. * Gets the current class name
  58487. * @returns the class name
  58488. */
  58489. getClassName(): string;
  58490. /**
  58491. * Gets the matrix indices input component
  58492. */
  58493. readonly matricesIndices: NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the matrix weights input component
  58496. */
  58497. readonly matricesWeights: NodeMaterialConnectionPoint;
  58498. /**
  58499. * Gets the extra matrix indices input component
  58500. */
  58501. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  58502. /**
  58503. * Gets the extra matrix weights input component
  58504. */
  58505. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  58506. /**
  58507. * Gets the world input component
  58508. */
  58509. readonly world: NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the output component
  58512. */
  58513. readonly output: NodeMaterialConnectionPoint;
  58514. autoConfigure(material: NodeMaterial): void;
  58515. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58518. protected _buildBlock(state: NodeMaterialBuildState): this;
  58519. }
  58520. }
  58521. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  58522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58527. /**
  58528. * Block used to add support for instances
  58529. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58530. */
  58531. export class InstancesBlock extends NodeMaterialBlock {
  58532. /**
  58533. * Creates a new InstancesBlock
  58534. * @param name defines the block name
  58535. */
  58536. constructor(name: string);
  58537. /**
  58538. * Gets the current class name
  58539. * @returns the class name
  58540. */
  58541. getClassName(): string;
  58542. /**
  58543. * Gets the first world row input component
  58544. */
  58545. readonly world0: NodeMaterialConnectionPoint;
  58546. /**
  58547. * Gets the second world row input component
  58548. */
  58549. readonly world1: NodeMaterialConnectionPoint;
  58550. /**
  58551. * Gets the third world row input component
  58552. */
  58553. readonly world2: NodeMaterialConnectionPoint;
  58554. /**
  58555. * Gets the forth world row input component
  58556. */
  58557. readonly world3: NodeMaterialConnectionPoint;
  58558. /**
  58559. * Gets the world input component
  58560. */
  58561. readonly world: NodeMaterialConnectionPoint;
  58562. /**
  58563. * Gets the output component
  58564. */
  58565. readonly output: NodeMaterialConnectionPoint;
  58566. autoConfigure(material: NodeMaterial): void;
  58567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58568. protected _buildBlock(state: NodeMaterialBuildState): this;
  58569. }
  58570. }
  58571. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  58572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58576. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58577. import { Effect } from "babylonjs/Materials/effect";
  58578. import { Mesh } from "babylonjs/Meshes/mesh";
  58579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58581. /**
  58582. * Block used to add morph targets support to vertex shader
  58583. */
  58584. export class MorphTargetsBlock extends NodeMaterialBlock {
  58585. private _repeatableContentAnchor;
  58586. private _repeatebleContentGenerated;
  58587. /**
  58588. * Create a new MorphTargetsBlock
  58589. * @param name defines the block name
  58590. */
  58591. constructor(name: string);
  58592. /**
  58593. * Gets the current class name
  58594. * @returns the class name
  58595. */
  58596. getClassName(): string;
  58597. /**
  58598. * Gets the position input component
  58599. */
  58600. readonly position: NodeMaterialConnectionPoint;
  58601. /**
  58602. * Gets the normal input component
  58603. */
  58604. readonly normal: NodeMaterialConnectionPoint;
  58605. /**
  58606. * Gets the tangent input component
  58607. */
  58608. readonly tangent: NodeMaterialConnectionPoint;
  58609. /**
  58610. * Gets the tangent input component
  58611. */
  58612. readonly uv: NodeMaterialConnectionPoint;
  58613. /**
  58614. * Gets the position output component
  58615. */
  58616. readonly positionOutput: NodeMaterialConnectionPoint;
  58617. /**
  58618. * Gets the normal output component
  58619. */
  58620. readonly normalOutput: NodeMaterialConnectionPoint;
  58621. /**
  58622. * Gets the tangent output component
  58623. */
  58624. readonly tangentOutput: NodeMaterialConnectionPoint;
  58625. /**
  58626. * Gets the tangent output component
  58627. */
  58628. readonly uvOutput: NodeMaterialConnectionPoint;
  58629. initialize(state: NodeMaterialBuildState): void;
  58630. autoConfigure(material: NodeMaterial): void;
  58631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58633. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58634. protected _buildBlock(state: NodeMaterialBuildState): this;
  58635. }
  58636. }
  58637. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  58638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58641. import { Nullable } from "babylonjs/types";
  58642. import { Scene } from "babylonjs/scene";
  58643. import { Effect } from "babylonjs/Materials/effect";
  58644. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58645. import { Mesh } from "babylonjs/Meshes/mesh";
  58646. import { Light } from "babylonjs/Lights/light";
  58647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58648. /**
  58649. * Block used to get data information from a light
  58650. */
  58651. export class LightInformationBlock extends NodeMaterialBlock {
  58652. private _lightDataUniformName;
  58653. private _lightColorUniformName;
  58654. private _lightTypeDefineName;
  58655. /**
  58656. * Gets or sets the light associated with this block
  58657. */
  58658. light: Nullable<Light>;
  58659. /**
  58660. * Creates a new LightInformationBlock
  58661. * @param name defines the block name
  58662. */
  58663. constructor(name: string);
  58664. /**
  58665. * Gets the current class name
  58666. * @returns the class name
  58667. */
  58668. getClassName(): string;
  58669. /**
  58670. * Gets the world position input component
  58671. */
  58672. readonly worldPosition: NodeMaterialConnectionPoint;
  58673. /**
  58674. * Gets the direction output component
  58675. */
  58676. readonly direction: NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the direction output component
  58679. */
  58680. readonly color: NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the direction output component
  58683. */
  58684. readonly intensity: NodeMaterialConnectionPoint;
  58685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58687. protected _buildBlock(state: NodeMaterialBuildState): this;
  58688. serialize(): any;
  58689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58690. }
  58691. }
  58692. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  58693. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  58694. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  58695. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  58696. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  58697. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  58698. }
  58699. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  58700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58704. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58705. import { Effect } from "babylonjs/Materials/effect";
  58706. import { Mesh } from "babylonjs/Meshes/mesh";
  58707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58708. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58709. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58710. /**
  58711. * Block used to add image processing support to fragment shader
  58712. */
  58713. export class ImageProcessingBlock extends NodeMaterialBlock {
  58714. /**
  58715. * Create a new ImageProcessingBlock
  58716. * @param name defines the block name
  58717. */
  58718. constructor(name: string);
  58719. /**
  58720. * Gets the current class name
  58721. * @returns the class name
  58722. */
  58723. getClassName(): string;
  58724. /**
  58725. * Gets the color input component
  58726. */
  58727. readonly color: NodeMaterialConnectionPoint;
  58728. /**
  58729. * Gets the output component
  58730. */
  58731. readonly output: NodeMaterialConnectionPoint;
  58732. /**
  58733. * Initialize the block and prepare the context for build
  58734. * @param state defines the state that will be used for the build
  58735. */
  58736. initialize(state: NodeMaterialBuildState): void;
  58737. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58740. protected _buildBlock(state: NodeMaterialBuildState): this;
  58741. }
  58742. }
  58743. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  58744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58747. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58749. import { Effect } from "babylonjs/Materials/effect";
  58750. import { Mesh } from "babylonjs/Meshes/mesh";
  58751. import { Scene } from "babylonjs/scene";
  58752. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58753. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58754. /**
  58755. * Block used to pertub normals based on a normal map
  58756. */
  58757. export class PerturbNormalBlock extends NodeMaterialBlock {
  58758. private _tangentSpaceParameterName;
  58759. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58760. invertX: boolean;
  58761. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58762. invertY: boolean;
  58763. /**
  58764. * Create a new PerturbNormalBlock
  58765. * @param name defines the block name
  58766. */
  58767. constructor(name: string);
  58768. /**
  58769. * Gets the current class name
  58770. * @returns the class name
  58771. */
  58772. getClassName(): string;
  58773. /**
  58774. * Gets the world position input component
  58775. */
  58776. readonly worldPosition: NodeMaterialConnectionPoint;
  58777. /**
  58778. * Gets the world normal input component
  58779. */
  58780. readonly worldNormal: NodeMaterialConnectionPoint;
  58781. /**
  58782. * Gets the uv input component
  58783. */
  58784. readonly uv: NodeMaterialConnectionPoint;
  58785. /**
  58786. * Gets the normal map color input component
  58787. */
  58788. readonly normalMapColor: NodeMaterialConnectionPoint;
  58789. /**
  58790. * Gets the strength input component
  58791. */
  58792. readonly strength: NodeMaterialConnectionPoint;
  58793. /**
  58794. * Gets the output component
  58795. */
  58796. readonly output: NodeMaterialConnectionPoint;
  58797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58799. autoConfigure(material: NodeMaterial): void;
  58800. protected _buildBlock(state: NodeMaterialBuildState): this;
  58801. protected _dumpPropertiesCode(): string;
  58802. serialize(): any;
  58803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58804. }
  58805. }
  58806. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58810. /**
  58811. * Block used to discard a pixel if a value is smaller than a cutoff
  58812. */
  58813. export class DiscardBlock extends NodeMaterialBlock {
  58814. /**
  58815. * Create a new DiscardBlock
  58816. * @param name defines the block name
  58817. */
  58818. constructor(name: string);
  58819. /**
  58820. * Gets the current class name
  58821. * @returns the class name
  58822. */
  58823. getClassName(): string;
  58824. /**
  58825. * Gets the color input component
  58826. */
  58827. readonly value: NodeMaterialConnectionPoint;
  58828. /**
  58829. * Gets the cutoff input component
  58830. */
  58831. readonly cutoff: NodeMaterialConnectionPoint;
  58832. protected _buildBlock(state: NodeMaterialBuildState): this;
  58833. }
  58834. }
  58835. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58839. /**
  58840. * Block used to test if the fragment shader is front facing
  58841. */
  58842. export class FrontFacingBlock extends NodeMaterialBlock {
  58843. /**
  58844. * Creates a new FrontFacingBlock
  58845. * @param name defines the block name
  58846. */
  58847. constructor(name: string);
  58848. /**
  58849. * Gets the current class name
  58850. * @returns the class name
  58851. */
  58852. getClassName(): string;
  58853. /**
  58854. * Gets the output component
  58855. */
  58856. readonly output: NodeMaterialConnectionPoint;
  58857. protected _buildBlock(state: NodeMaterialBuildState): this;
  58858. }
  58859. }
  58860. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58864. /**
  58865. * Block used to get the derivative value on x and y of a given input
  58866. */
  58867. export class DerivativeBlock extends NodeMaterialBlock {
  58868. /**
  58869. * Create a new DerivativeBlock
  58870. * @param name defines the block name
  58871. */
  58872. constructor(name: string);
  58873. /**
  58874. * Gets the current class name
  58875. * @returns the class name
  58876. */
  58877. getClassName(): string;
  58878. /**
  58879. * Gets the input component
  58880. */
  58881. readonly input: NodeMaterialConnectionPoint;
  58882. /**
  58883. * Gets the derivative output on x
  58884. */
  58885. readonly dx: NodeMaterialConnectionPoint;
  58886. /**
  58887. * Gets the derivative output on y
  58888. */
  58889. readonly dy: NodeMaterialConnectionPoint;
  58890. protected _buildBlock(state: NodeMaterialBuildState): this;
  58891. }
  58892. }
  58893. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58894. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58895. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58896. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58897. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58898. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58899. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58900. }
  58901. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58904. import { Mesh } from "babylonjs/Meshes/mesh";
  58905. import { Effect } from "babylonjs/Materials/effect";
  58906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58908. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58909. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58910. /**
  58911. * Block used to add support for scene fog
  58912. */
  58913. export class FogBlock extends NodeMaterialBlock {
  58914. private _fogDistanceName;
  58915. private _fogParameters;
  58916. /**
  58917. * Create a new FogBlock
  58918. * @param name defines the block name
  58919. */
  58920. constructor(name: string);
  58921. /**
  58922. * Gets the current class name
  58923. * @returns the class name
  58924. */
  58925. getClassName(): string;
  58926. /**
  58927. * Gets the world position input component
  58928. */
  58929. readonly worldPosition: NodeMaterialConnectionPoint;
  58930. /**
  58931. * Gets the view input component
  58932. */
  58933. readonly view: NodeMaterialConnectionPoint;
  58934. /**
  58935. * Gets the color input component
  58936. */
  58937. readonly input: NodeMaterialConnectionPoint;
  58938. /**
  58939. * Gets the fog color input component
  58940. */
  58941. readonly fogColor: NodeMaterialConnectionPoint;
  58942. /**
  58943. * Gets the output component
  58944. */
  58945. readonly output: NodeMaterialConnectionPoint;
  58946. autoConfigure(material: NodeMaterial): void;
  58947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58949. protected _buildBlock(state: NodeMaterialBuildState): this;
  58950. }
  58951. }
  58952. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58957. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58958. import { Effect } from "babylonjs/Materials/effect";
  58959. import { Mesh } from "babylonjs/Meshes/mesh";
  58960. import { Light } from "babylonjs/Lights/light";
  58961. import { Nullable } from "babylonjs/types";
  58962. import { Scene } from "babylonjs/scene";
  58963. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58964. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58965. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58966. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58967. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58968. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58969. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58970. /**
  58971. * Block used to add light in the fragment shader
  58972. */
  58973. export class LightBlock extends NodeMaterialBlock {
  58974. private _lightId;
  58975. /**
  58976. * Gets or sets the light associated with this block
  58977. */
  58978. light: Nullable<Light>;
  58979. /**
  58980. * Create a new LightBlock
  58981. * @param name defines the block name
  58982. */
  58983. constructor(name: string);
  58984. /**
  58985. * Gets the current class name
  58986. * @returns the class name
  58987. */
  58988. getClassName(): string;
  58989. /**
  58990. * Gets the world position input component
  58991. */
  58992. readonly worldPosition: NodeMaterialConnectionPoint;
  58993. /**
  58994. * Gets the world normal input component
  58995. */
  58996. readonly worldNormal: NodeMaterialConnectionPoint;
  58997. /**
  58998. * Gets the camera (or eye) position component
  58999. */
  59000. readonly cameraPosition: NodeMaterialConnectionPoint;
  59001. /**
  59002. * Gets the glossiness component
  59003. */
  59004. readonly glossiness: NodeMaterialConnectionPoint;
  59005. /**
  59006. * Gets the glossinness power component
  59007. */
  59008. readonly glossPower: NodeMaterialConnectionPoint;
  59009. /**
  59010. * Gets the diffuse color component
  59011. */
  59012. readonly diffuseColor: NodeMaterialConnectionPoint;
  59013. /**
  59014. * Gets the specular color component
  59015. */
  59016. readonly specularColor: NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the diffuse output component
  59019. */
  59020. readonly diffuseOutput: NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the specular output component
  59023. */
  59024. readonly specularOutput: NodeMaterialConnectionPoint;
  59025. autoConfigure(material: NodeMaterial): void;
  59026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59027. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59029. private _injectVertexCode;
  59030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59031. serialize(): any;
  59032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59033. }
  59034. }
  59035. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59036. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59037. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59038. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59039. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59040. }
  59041. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59042. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59043. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59044. }
  59045. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59049. /**
  59050. * Block used to multiply 2 values
  59051. */
  59052. export class MultiplyBlock extends NodeMaterialBlock {
  59053. /**
  59054. * Creates a new MultiplyBlock
  59055. * @param name defines the block name
  59056. */
  59057. constructor(name: string);
  59058. /**
  59059. * Gets the current class name
  59060. * @returns the class name
  59061. */
  59062. getClassName(): string;
  59063. /**
  59064. * Gets the left operand input component
  59065. */
  59066. readonly left: NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the right operand input component
  59069. */
  59070. readonly right: NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the output component
  59073. */
  59074. readonly output: NodeMaterialConnectionPoint;
  59075. protected _buildBlock(state: NodeMaterialBuildState): this;
  59076. }
  59077. }
  59078. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59082. /**
  59083. * Block used to add 2 vectors
  59084. */
  59085. export class AddBlock extends NodeMaterialBlock {
  59086. /**
  59087. * Creates a new AddBlock
  59088. * @param name defines the block name
  59089. */
  59090. constructor(name: string);
  59091. /**
  59092. * Gets the current class name
  59093. * @returns the class name
  59094. */
  59095. getClassName(): string;
  59096. /**
  59097. * Gets the left operand input component
  59098. */
  59099. readonly left: NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the right operand input component
  59102. */
  59103. readonly right: NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the output component
  59106. */
  59107. readonly output: NodeMaterialConnectionPoint;
  59108. protected _buildBlock(state: NodeMaterialBuildState): this;
  59109. }
  59110. }
  59111. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59115. /**
  59116. * Block used to scale a vector by a float
  59117. */
  59118. export class ScaleBlock extends NodeMaterialBlock {
  59119. /**
  59120. * Creates a new ScaleBlock
  59121. * @param name defines the block name
  59122. */
  59123. constructor(name: string);
  59124. /**
  59125. * Gets the current class name
  59126. * @returns the class name
  59127. */
  59128. getClassName(): string;
  59129. /**
  59130. * Gets the input component
  59131. */
  59132. readonly input: NodeMaterialConnectionPoint;
  59133. /**
  59134. * Gets the factor input component
  59135. */
  59136. readonly factor: NodeMaterialConnectionPoint;
  59137. /**
  59138. * Gets the output component
  59139. */
  59140. readonly output: NodeMaterialConnectionPoint;
  59141. protected _buildBlock(state: NodeMaterialBuildState): this;
  59142. }
  59143. }
  59144. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59148. import { Scene } from "babylonjs/scene";
  59149. /**
  59150. * Block used to clamp a float
  59151. */
  59152. export class ClampBlock extends NodeMaterialBlock {
  59153. /** Gets or sets the minimum range */
  59154. minimum: number;
  59155. /** Gets or sets the maximum range */
  59156. maximum: number;
  59157. /**
  59158. * Creates a new ClampBlock
  59159. * @param name defines the block name
  59160. */
  59161. constructor(name: string);
  59162. /**
  59163. * Gets the current class name
  59164. * @returns the class name
  59165. */
  59166. getClassName(): string;
  59167. /**
  59168. * Gets the value input component
  59169. */
  59170. readonly value: NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the output component
  59173. */
  59174. readonly output: NodeMaterialConnectionPoint;
  59175. protected _buildBlock(state: NodeMaterialBuildState): this;
  59176. protected _dumpPropertiesCode(): string;
  59177. serialize(): any;
  59178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59179. }
  59180. }
  59181. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59185. /**
  59186. * Block used to apply a cross product between 2 vectors
  59187. */
  59188. export class CrossBlock extends NodeMaterialBlock {
  59189. /**
  59190. * Creates a new CrossBlock
  59191. * @param name defines the block name
  59192. */
  59193. constructor(name: string);
  59194. /**
  59195. * Gets the current class name
  59196. * @returns the class name
  59197. */
  59198. getClassName(): string;
  59199. /**
  59200. * Gets the left operand input component
  59201. */
  59202. readonly left: NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the right operand input component
  59205. */
  59206. readonly right: NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the output component
  59209. */
  59210. readonly output: NodeMaterialConnectionPoint;
  59211. protected _buildBlock(state: NodeMaterialBuildState): this;
  59212. }
  59213. }
  59214. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59218. /**
  59219. * Block used to apply a dot product between 2 vectors
  59220. */
  59221. export class DotBlock extends NodeMaterialBlock {
  59222. /**
  59223. * Creates a new DotBlock
  59224. * @param name defines the block name
  59225. */
  59226. constructor(name: string);
  59227. /**
  59228. * Gets the current class name
  59229. * @returns the class name
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Gets the left operand input component
  59234. */
  59235. readonly left: NodeMaterialConnectionPoint;
  59236. /**
  59237. * Gets the right operand input component
  59238. */
  59239. readonly right: NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the output component
  59242. */
  59243. readonly output: NodeMaterialConnectionPoint;
  59244. protected _buildBlock(state: NodeMaterialBuildState): this;
  59245. }
  59246. }
  59247. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59251. import { Vector2 } from "babylonjs/Maths/math.vector";
  59252. import { Scene } from "babylonjs/scene";
  59253. /**
  59254. * Block used to remap a float from a range to a new one
  59255. */
  59256. export class RemapBlock extends NodeMaterialBlock {
  59257. /**
  59258. * Gets or sets the source range
  59259. */
  59260. sourceRange: Vector2;
  59261. /**
  59262. * Gets or sets the target range
  59263. */
  59264. targetRange: Vector2;
  59265. /**
  59266. * Creates a new RemapBlock
  59267. * @param name defines the block name
  59268. */
  59269. constructor(name: string);
  59270. /**
  59271. * Gets the current class name
  59272. * @returns the class name
  59273. */
  59274. getClassName(): string;
  59275. /**
  59276. * Gets the input component
  59277. */
  59278. readonly input: NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the source min input component
  59281. */
  59282. readonly sourceMin: NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the source max input component
  59285. */
  59286. readonly sourceMax: NodeMaterialConnectionPoint;
  59287. /**
  59288. * Gets the target min input component
  59289. */
  59290. readonly targetMin: NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the target max input component
  59293. */
  59294. readonly targetMax: NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the output component
  59297. */
  59298. readonly output: NodeMaterialConnectionPoint;
  59299. protected _buildBlock(state: NodeMaterialBuildState): this;
  59300. protected _dumpPropertiesCode(): string;
  59301. serialize(): any;
  59302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59303. }
  59304. }
  59305. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59309. /**
  59310. * Block used to normalize a vector
  59311. */
  59312. export class NormalizeBlock extends NodeMaterialBlock {
  59313. /**
  59314. * Creates a new NormalizeBlock
  59315. * @param name defines the block name
  59316. */
  59317. constructor(name: string);
  59318. /**
  59319. * Gets the current class name
  59320. * @returns the class name
  59321. */
  59322. getClassName(): string;
  59323. /**
  59324. * Gets the input component
  59325. */
  59326. readonly input: NodeMaterialConnectionPoint;
  59327. /**
  59328. * Gets the output component
  59329. */
  59330. readonly output: NodeMaterialConnectionPoint;
  59331. protected _buildBlock(state: NodeMaterialBuildState): this;
  59332. }
  59333. }
  59334. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59338. import { Scene } from "babylonjs/scene";
  59339. /**
  59340. * Operations supported by the Trigonometry block
  59341. */
  59342. export enum TrigonometryBlockOperations {
  59343. /** Cos */
  59344. Cos = 0,
  59345. /** Sin */
  59346. Sin = 1,
  59347. /** Abs */
  59348. Abs = 2,
  59349. /** Exp */
  59350. Exp = 3,
  59351. /** Exp2 */
  59352. Exp2 = 4,
  59353. /** Round */
  59354. Round = 5,
  59355. /** Floor */
  59356. Floor = 6,
  59357. /** Ceiling */
  59358. Ceiling = 7,
  59359. /** Square root */
  59360. Sqrt = 8,
  59361. /** Log */
  59362. Log = 9,
  59363. /** Tangent */
  59364. Tan = 10,
  59365. /** Arc tangent */
  59366. ArcTan = 11,
  59367. /** Arc cosinus */
  59368. ArcCos = 12,
  59369. /** Arc sinus */
  59370. ArcSin = 13,
  59371. /** Fraction */
  59372. Fract = 14,
  59373. /** Sign */
  59374. Sign = 15,
  59375. /** To radians (from degrees) */
  59376. Radians = 16,
  59377. /** To degrees (from radians) */
  59378. Degrees = 17
  59379. }
  59380. /**
  59381. * Block used to apply trigonometry operation to floats
  59382. */
  59383. export class TrigonometryBlock extends NodeMaterialBlock {
  59384. /**
  59385. * Gets or sets the operation applied by the block
  59386. */
  59387. operation: TrigonometryBlockOperations;
  59388. /**
  59389. * Creates a new TrigonometryBlock
  59390. * @param name defines the block name
  59391. */
  59392. constructor(name: string);
  59393. /**
  59394. * Gets the current class name
  59395. * @returns the class name
  59396. */
  59397. getClassName(): string;
  59398. /**
  59399. * Gets the input component
  59400. */
  59401. readonly input: NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the output component
  59404. */
  59405. readonly output: NodeMaterialConnectionPoint;
  59406. protected _buildBlock(state: NodeMaterialBuildState): this;
  59407. serialize(): any;
  59408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59409. protected _dumpPropertiesCode(): string;
  59410. }
  59411. }
  59412. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  59413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59416. /**
  59417. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59418. */
  59419. export class ColorMergerBlock extends NodeMaterialBlock {
  59420. /**
  59421. * Create a new ColorMergerBlock
  59422. * @param name defines the block name
  59423. */
  59424. constructor(name: string);
  59425. /**
  59426. * Gets the current class name
  59427. * @returns the class name
  59428. */
  59429. getClassName(): string;
  59430. /**
  59431. * Gets the rgb component (input)
  59432. */
  59433. readonly rgbIn: NodeMaterialConnectionPoint;
  59434. /**
  59435. * Gets the r component (input)
  59436. */
  59437. readonly r: NodeMaterialConnectionPoint;
  59438. /**
  59439. * Gets the g component (input)
  59440. */
  59441. readonly g: NodeMaterialConnectionPoint;
  59442. /**
  59443. * Gets the b component (input)
  59444. */
  59445. readonly b: NodeMaterialConnectionPoint;
  59446. /**
  59447. * Gets the a component (input)
  59448. */
  59449. readonly a: NodeMaterialConnectionPoint;
  59450. /**
  59451. * Gets the rgba component (output)
  59452. */
  59453. readonly rgba: NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the rgb component (output)
  59456. */
  59457. readonly rgbOut: NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the rgb component (output)
  59460. * @deprecated Please use rgbOut instead.
  59461. */
  59462. readonly rgb: NodeMaterialConnectionPoint;
  59463. protected _buildBlock(state: NodeMaterialBuildState): this;
  59464. }
  59465. }
  59466. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  59467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59470. /**
  59471. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59472. */
  59473. export class VectorMergerBlock extends NodeMaterialBlock {
  59474. /**
  59475. * Create a new VectorMergerBlock
  59476. * @param name defines the block name
  59477. */
  59478. constructor(name: string);
  59479. /**
  59480. * Gets the current class name
  59481. * @returns the class name
  59482. */
  59483. getClassName(): string;
  59484. /**
  59485. * Gets the xyz component (input)
  59486. */
  59487. readonly xyzIn: NodeMaterialConnectionPoint;
  59488. /**
  59489. * Gets the xy component (input)
  59490. */
  59491. readonly xyIn: NodeMaterialConnectionPoint;
  59492. /**
  59493. * Gets the x component (input)
  59494. */
  59495. readonly x: NodeMaterialConnectionPoint;
  59496. /**
  59497. * Gets the y component (input)
  59498. */
  59499. readonly y: NodeMaterialConnectionPoint;
  59500. /**
  59501. * Gets the z component (input)
  59502. */
  59503. readonly z: NodeMaterialConnectionPoint;
  59504. /**
  59505. * Gets the w component (input)
  59506. */
  59507. readonly w: NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the xyzw component (output)
  59510. */
  59511. readonly xyzw: NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the xyz component (output)
  59514. */
  59515. readonly xyzOut: NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the xy component (output)
  59518. */
  59519. readonly xyOut: NodeMaterialConnectionPoint;
  59520. /**
  59521. * Gets the xy component (output)
  59522. * @deprecated Please use xyOut instead.
  59523. */
  59524. readonly xy: NodeMaterialConnectionPoint;
  59525. /**
  59526. * Gets the xyz component (output)
  59527. * @deprecated Please use xyzOut instead.
  59528. */
  59529. readonly xyz: NodeMaterialConnectionPoint;
  59530. protected _buildBlock(state: NodeMaterialBuildState): this;
  59531. }
  59532. }
  59533. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  59534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59537. /**
  59538. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59539. */
  59540. export class ColorSplitterBlock extends NodeMaterialBlock {
  59541. /**
  59542. * Create a new ColorSplitterBlock
  59543. * @param name defines the block name
  59544. */
  59545. constructor(name: string);
  59546. /**
  59547. * Gets the current class name
  59548. * @returns the class name
  59549. */
  59550. getClassName(): string;
  59551. /**
  59552. * Gets the rgba component (input)
  59553. */
  59554. readonly rgba: NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the rgb component (input)
  59557. */
  59558. readonly rgbIn: NodeMaterialConnectionPoint;
  59559. /**
  59560. * Gets the rgb component (output)
  59561. */
  59562. readonly rgbOut: NodeMaterialConnectionPoint;
  59563. /**
  59564. * Gets the r component (output)
  59565. */
  59566. readonly r: NodeMaterialConnectionPoint;
  59567. /**
  59568. * Gets the g component (output)
  59569. */
  59570. readonly g: NodeMaterialConnectionPoint;
  59571. /**
  59572. * Gets the b component (output)
  59573. */
  59574. readonly b: NodeMaterialConnectionPoint;
  59575. /**
  59576. * Gets the a component (output)
  59577. */
  59578. readonly a: NodeMaterialConnectionPoint;
  59579. protected _inputRename(name: string): string;
  59580. protected _outputRename(name: string): string;
  59581. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59582. }
  59583. }
  59584. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  59585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59588. /**
  59589. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59590. */
  59591. export class VectorSplitterBlock extends NodeMaterialBlock {
  59592. /**
  59593. * Create a new VectorSplitterBlock
  59594. * @param name defines the block name
  59595. */
  59596. constructor(name: string);
  59597. /**
  59598. * Gets the current class name
  59599. * @returns the class name
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Gets the xyzw component (input)
  59604. */
  59605. readonly xyzw: NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the xyz component (input)
  59608. */
  59609. readonly xyzIn: NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the xy component (input)
  59612. */
  59613. readonly xyIn: NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the xyz component (output)
  59616. */
  59617. readonly xyzOut: NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the xy component (output)
  59620. */
  59621. readonly xyOut: NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the x component (output)
  59624. */
  59625. readonly x: NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the y component (output)
  59628. */
  59629. readonly y: NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the z component (output)
  59632. */
  59633. readonly z: NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the w component (output)
  59636. */
  59637. readonly w: NodeMaterialConnectionPoint;
  59638. protected _inputRename(name: string): string;
  59639. protected _outputRename(name: string): string;
  59640. protected _buildBlock(state: NodeMaterialBuildState): this;
  59641. }
  59642. }
  59643. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  59644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59647. /**
  59648. * Block used to lerp between 2 values
  59649. */
  59650. export class LerpBlock extends NodeMaterialBlock {
  59651. /**
  59652. * Creates a new LerpBlock
  59653. * @param name defines the block name
  59654. */
  59655. constructor(name: string);
  59656. /**
  59657. * Gets the current class name
  59658. * @returns the class name
  59659. */
  59660. getClassName(): string;
  59661. /**
  59662. * Gets the left operand input component
  59663. */
  59664. readonly left: NodeMaterialConnectionPoint;
  59665. /**
  59666. * Gets the right operand input component
  59667. */
  59668. readonly right: NodeMaterialConnectionPoint;
  59669. /**
  59670. * Gets the gradient operand input component
  59671. */
  59672. readonly gradient: NodeMaterialConnectionPoint;
  59673. /**
  59674. * Gets the output component
  59675. */
  59676. readonly output: NodeMaterialConnectionPoint;
  59677. protected _buildBlock(state: NodeMaterialBuildState): this;
  59678. }
  59679. }
  59680. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  59681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59684. /**
  59685. * Block used to divide 2 vectors
  59686. */
  59687. export class DivideBlock extends NodeMaterialBlock {
  59688. /**
  59689. * Creates a new DivideBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the left operand input component
  59700. */
  59701. readonly left: NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the right operand input component
  59704. */
  59705. readonly right: NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the output component
  59708. */
  59709. readonly output: NodeMaterialConnectionPoint;
  59710. protected _buildBlock(state: NodeMaterialBuildState): this;
  59711. }
  59712. }
  59713. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  59714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59717. /**
  59718. * Block used to subtract 2 vectors
  59719. */
  59720. export class SubtractBlock extends NodeMaterialBlock {
  59721. /**
  59722. * Creates a new SubtractBlock
  59723. * @param name defines the block name
  59724. */
  59725. constructor(name: string);
  59726. /**
  59727. * Gets the current class name
  59728. * @returns the class name
  59729. */
  59730. getClassName(): string;
  59731. /**
  59732. * Gets the left operand input component
  59733. */
  59734. readonly left: NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the right operand input component
  59737. */
  59738. readonly right: NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the output component
  59741. */
  59742. readonly output: NodeMaterialConnectionPoint;
  59743. protected _buildBlock(state: NodeMaterialBuildState): this;
  59744. }
  59745. }
  59746. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59750. /**
  59751. * Block used to step a value
  59752. */
  59753. export class StepBlock extends NodeMaterialBlock {
  59754. /**
  59755. * Creates a new StepBlock
  59756. * @param name defines the block name
  59757. */
  59758. constructor(name: string);
  59759. /**
  59760. * Gets the current class name
  59761. * @returns the class name
  59762. */
  59763. getClassName(): string;
  59764. /**
  59765. * Gets the value operand input component
  59766. */
  59767. readonly value: NodeMaterialConnectionPoint;
  59768. /**
  59769. * Gets the edge operand input component
  59770. */
  59771. readonly edge: NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the output component
  59774. */
  59775. readonly output: NodeMaterialConnectionPoint;
  59776. protected _buildBlock(state: NodeMaterialBuildState): this;
  59777. }
  59778. }
  59779. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59783. /**
  59784. * Block used to get the opposite (1 - x) of a value
  59785. */
  59786. export class OneMinusBlock extends NodeMaterialBlock {
  59787. /**
  59788. * Creates a new OneMinusBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the input component
  59799. */
  59800. readonly input: NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the output component
  59803. */
  59804. readonly output: NodeMaterialConnectionPoint;
  59805. protected _buildBlock(state: NodeMaterialBuildState): this;
  59806. }
  59807. }
  59808. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59812. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59813. /**
  59814. * Block used to get the view direction
  59815. */
  59816. export class ViewDirectionBlock extends NodeMaterialBlock {
  59817. /**
  59818. * Creates a new ViewDirectionBlock
  59819. * @param name defines the block name
  59820. */
  59821. constructor(name: string);
  59822. /**
  59823. * Gets the current class name
  59824. * @returns the class name
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Gets the world position component
  59829. */
  59830. readonly worldPosition: NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the camera position component
  59833. */
  59834. readonly cameraPosition: NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the output component
  59837. */
  59838. readonly output: NodeMaterialConnectionPoint;
  59839. autoConfigure(material: NodeMaterial): void;
  59840. protected _buildBlock(state: NodeMaterialBuildState): this;
  59841. }
  59842. }
  59843. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59847. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59848. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59849. /**
  59850. * Block used to compute fresnel value
  59851. */
  59852. export class FresnelBlock extends NodeMaterialBlock {
  59853. /**
  59854. * Create a new FresnelBlock
  59855. * @param name defines the block name
  59856. */
  59857. constructor(name: string);
  59858. /**
  59859. * Gets the current class name
  59860. * @returns the class name
  59861. */
  59862. getClassName(): string;
  59863. /**
  59864. * Gets the world normal input component
  59865. */
  59866. readonly worldNormal: NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the view direction input component
  59869. */
  59870. readonly viewDirection: NodeMaterialConnectionPoint;
  59871. /**
  59872. * Gets the bias input component
  59873. */
  59874. readonly bias: NodeMaterialConnectionPoint;
  59875. /**
  59876. * Gets the camera (or eye) position component
  59877. */
  59878. readonly power: NodeMaterialConnectionPoint;
  59879. /**
  59880. * Gets the fresnel output component
  59881. */
  59882. readonly fresnel: NodeMaterialConnectionPoint;
  59883. autoConfigure(material: NodeMaterial): void;
  59884. protected _buildBlock(state: NodeMaterialBuildState): this;
  59885. }
  59886. }
  59887. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59891. /**
  59892. * Block used to get the max of 2 values
  59893. */
  59894. export class MaxBlock extends NodeMaterialBlock {
  59895. /**
  59896. * Creates a new MaxBlock
  59897. * @param name defines the block name
  59898. */
  59899. constructor(name: string);
  59900. /**
  59901. * Gets the current class name
  59902. * @returns the class name
  59903. */
  59904. getClassName(): string;
  59905. /**
  59906. * Gets the left operand input component
  59907. */
  59908. readonly left: NodeMaterialConnectionPoint;
  59909. /**
  59910. * Gets the right operand input component
  59911. */
  59912. readonly right: NodeMaterialConnectionPoint;
  59913. /**
  59914. * Gets the output component
  59915. */
  59916. readonly output: NodeMaterialConnectionPoint;
  59917. protected _buildBlock(state: NodeMaterialBuildState): this;
  59918. }
  59919. }
  59920. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59924. /**
  59925. * Block used to get the min of 2 values
  59926. */
  59927. export class MinBlock extends NodeMaterialBlock {
  59928. /**
  59929. * Creates a new MinBlock
  59930. * @param name defines the block name
  59931. */
  59932. constructor(name: string);
  59933. /**
  59934. * Gets the current class name
  59935. * @returns the class name
  59936. */
  59937. getClassName(): string;
  59938. /**
  59939. * Gets the left operand input component
  59940. */
  59941. readonly left: NodeMaterialConnectionPoint;
  59942. /**
  59943. * Gets the right operand input component
  59944. */
  59945. readonly right: NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the output component
  59948. */
  59949. readonly output: NodeMaterialConnectionPoint;
  59950. protected _buildBlock(state: NodeMaterialBuildState): this;
  59951. }
  59952. }
  59953. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59957. /**
  59958. * Block used to get the distance between 2 values
  59959. */
  59960. export class DistanceBlock extends NodeMaterialBlock {
  59961. /**
  59962. * Creates a new DistanceBlock
  59963. * @param name defines the block name
  59964. */
  59965. constructor(name: string);
  59966. /**
  59967. * Gets the current class name
  59968. * @returns the class name
  59969. */
  59970. getClassName(): string;
  59971. /**
  59972. * Gets the left operand input component
  59973. */
  59974. readonly left: NodeMaterialConnectionPoint;
  59975. /**
  59976. * Gets the right operand input component
  59977. */
  59978. readonly right: NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the output component
  59981. */
  59982. readonly output: NodeMaterialConnectionPoint;
  59983. protected _buildBlock(state: NodeMaterialBuildState): this;
  59984. }
  59985. }
  59986. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59990. /**
  59991. * Block used to get the length of a vector
  59992. */
  59993. export class LengthBlock extends NodeMaterialBlock {
  59994. /**
  59995. * Creates a new LengthBlock
  59996. * @param name defines the block name
  59997. */
  59998. constructor(name: string);
  59999. /**
  60000. * Gets the current class name
  60001. * @returns the class name
  60002. */
  60003. getClassName(): string;
  60004. /**
  60005. * Gets the value input component
  60006. */
  60007. readonly value: NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. readonly output: NodeMaterialConnectionPoint;
  60012. protected _buildBlock(state: NodeMaterialBuildState): this;
  60013. }
  60014. }
  60015. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60019. /**
  60020. * Block used to get negative version of a value (i.e. x * -1)
  60021. */
  60022. export class NegateBlock extends NodeMaterialBlock {
  60023. /**
  60024. * Creates a new NegateBlock
  60025. * @param name defines the block name
  60026. */
  60027. constructor(name: string);
  60028. /**
  60029. * Gets the current class name
  60030. * @returns the class name
  60031. */
  60032. getClassName(): string;
  60033. /**
  60034. * Gets the value input component
  60035. */
  60036. readonly value: NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the output component
  60039. */
  60040. readonly output: NodeMaterialConnectionPoint;
  60041. protected _buildBlock(state: NodeMaterialBuildState): this;
  60042. }
  60043. }
  60044. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60048. /**
  60049. * Block used to get the value of the first parameter raised to the power of the second
  60050. */
  60051. export class PowBlock extends NodeMaterialBlock {
  60052. /**
  60053. * Creates a new PowBlock
  60054. * @param name defines the block name
  60055. */
  60056. constructor(name: string);
  60057. /**
  60058. * Gets the current class name
  60059. * @returns the class name
  60060. */
  60061. getClassName(): string;
  60062. /**
  60063. * Gets the value operand input component
  60064. */
  60065. readonly value: NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the power operand input component
  60068. */
  60069. readonly power: NodeMaterialConnectionPoint;
  60070. /**
  60071. * Gets the output component
  60072. */
  60073. readonly output: NodeMaterialConnectionPoint;
  60074. protected _buildBlock(state: NodeMaterialBuildState): this;
  60075. }
  60076. }
  60077. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60081. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60082. /**
  60083. * Block used to get a random number
  60084. */
  60085. export class RandomNumberBlock extends NodeMaterialBlock {
  60086. /**
  60087. * Creates a new RandomNumberBlock
  60088. * @param name defines the block name
  60089. */
  60090. constructor(name: string);
  60091. /**
  60092. * Gets the current class name
  60093. * @returns the class name
  60094. */
  60095. getClassName(): string;
  60096. /**
  60097. * Gets the seed input component
  60098. */
  60099. readonly seed: NodeMaterialConnectionPoint;
  60100. /**
  60101. * Gets the output component
  60102. */
  60103. readonly output: NodeMaterialConnectionPoint;
  60104. protected _buildBlock(state: NodeMaterialBuildState): this;
  60105. }
  60106. }
  60107. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60111. /**
  60112. * Block used to compute arc tangent of 2 values
  60113. */
  60114. export class ArcTan2Block extends NodeMaterialBlock {
  60115. /**
  60116. * Creates a new ArcTan2Block
  60117. * @param name defines the block name
  60118. */
  60119. constructor(name: string);
  60120. /**
  60121. * Gets the current class name
  60122. * @returns the class name
  60123. */
  60124. getClassName(): string;
  60125. /**
  60126. * Gets the x operand input component
  60127. */
  60128. readonly x: NodeMaterialConnectionPoint;
  60129. /**
  60130. * Gets the y operand input component
  60131. */
  60132. readonly y: NodeMaterialConnectionPoint;
  60133. /**
  60134. * Gets the output component
  60135. */
  60136. readonly output: NodeMaterialConnectionPoint;
  60137. protected _buildBlock(state: NodeMaterialBuildState): this;
  60138. }
  60139. }
  60140. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60144. /**
  60145. * Block used to smooth step a value
  60146. */
  60147. export class SmoothStepBlock extends NodeMaterialBlock {
  60148. /**
  60149. * Creates a new SmoothStepBlock
  60150. * @param name defines the block name
  60151. */
  60152. constructor(name: string);
  60153. /**
  60154. * Gets the current class name
  60155. * @returns the class name
  60156. */
  60157. getClassName(): string;
  60158. /**
  60159. * Gets the value operand input component
  60160. */
  60161. readonly value: NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the first edge operand input component
  60164. */
  60165. readonly edge0: NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the second edge operand input component
  60168. */
  60169. readonly edge1: NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the output component
  60172. */
  60173. readonly output: NodeMaterialConnectionPoint;
  60174. protected _buildBlock(state: NodeMaterialBuildState): this;
  60175. }
  60176. }
  60177. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60181. /**
  60182. * Block used to get the reciprocal (1 / x) of a value
  60183. */
  60184. export class ReciprocalBlock extends NodeMaterialBlock {
  60185. /**
  60186. * Creates a new ReciprocalBlock
  60187. * @param name defines the block name
  60188. */
  60189. constructor(name: string);
  60190. /**
  60191. * Gets the current class name
  60192. * @returns the class name
  60193. */
  60194. getClassName(): string;
  60195. /**
  60196. * Gets the input component
  60197. */
  60198. readonly input: NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the output component
  60201. */
  60202. readonly output: NodeMaterialConnectionPoint;
  60203. protected _buildBlock(state: NodeMaterialBuildState): this;
  60204. }
  60205. }
  60206. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60210. /**
  60211. * Block used to replace a color by another one
  60212. */
  60213. export class ReplaceColorBlock extends NodeMaterialBlock {
  60214. /**
  60215. * Creates a new ReplaceColorBlock
  60216. * @param name defines the block name
  60217. */
  60218. constructor(name: string);
  60219. /**
  60220. * Gets the current class name
  60221. * @returns the class name
  60222. */
  60223. getClassName(): string;
  60224. /**
  60225. * Gets the value input component
  60226. */
  60227. readonly value: NodeMaterialConnectionPoint;
  60228. /**
  60229. * Gets the reference input component
  60230. */
  60231. readonly reference: NodeMaterialConnectionPoint;
  60232. /**
  60233. * Gets the distance input component
  60234. */
  60235. readonly distance: NodeMaterialConnectionPoint;
  60236. /**
  60237. * Gets the replacement input component
  60238. */
  60239. readonly replacement: NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the output component
  60242. */
  60243. readonly output: NodeMaterialConnectionPoint;
  60244. protected _buildBlock(state: NodeMaterialBuildState): this;
  60245. }
  60246. }
  60247. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60251. /**
  60252. * Block used to posterize a value
  60253. * @see https://en.wikipedia.org/wiki/Posterization
  60254. */
  60255. export class PosterizeBlock extends NodeMaterialBlock {
  60256. /**
  60257. * Creates a new PosterizeBlock
  60258. * @param name defines the block name
  60259. */
  60260. constructor(name: string);
  60261. /**
  60262. * Gets the current class name
  60263. * @returns the class name
  60264. */
  60265. getClassName(): string;
  60266. /**
  60267. * Gets the value input component
  60268. */
  60269. readonly value: NodeMaterialConnectionPoint;
  60270. /**
  60271. * Gets the steps input component
  60272. */
  60273. readonly steps: NodeMaterialConnectionPoint;
  60274. /**
  60275. * Gets the output component
  60276. */
  60277. readonly output: NodeMaterialConnectionPoint;
  60278. protected _buildBlock(state: NodeMaterialBuildState): this;
  60279. }
  60280. }
  60281. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60285. import { Scene } from "babylonjs/scene";
  60286. /**
  60287. * Operations supported by the Wave block
  60288. */
  60289. export enum WaveBlockKind {
  60290. /** SawTooth */
  60291. SawTooth = 0,
  60292. /** Square */
  60293. Square = 1,
  60294. /** Triangle */
  60295. Triangle = 2
  60296. }
  60297. /**
  60298. * Block used to apply wave operation to floats
  60299. */
  60300. export class WaveBlock extends NodeMaterialBlock {
  60301. /**
  60302. * Gets or sets the kibnd of wave to be applied by the block
  60303. */
  60304. kind: WaveBlockKind;
  60305. /**
  60306. * Creates a new WaveBlock
  60307. * @param name defines the block name
  60308. */
  60309. constructor(name: string);
  60310. /**
  60311. * Gets the current class name
  60312. * @returns the class name
  60313. */
  60314. getClassName(): string;
  60315. /**
  60316. * Gets the input component
  60317. */
  60318. readonly input: NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the output component
  60321. */
  60322. readonly output: NodeMaterialConnectionPoint;
  60323. protected _buildBlock(state: NodeMaterialBuildState): this;
  60324. serialize(): any;
  60325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60326. }
  60327. }
  60328. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60332. import { Color3 } from "babylonjs/Maths/math.color";
  60333. import { Scene } from "babylonjs/scene";
  60334. /**
  60335. * Class used to store a color step for the GradientBlock
  60336. */
  60337. export class GradientBlockColorStep {
  60338. /**
  60339. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60340. */
  60341. step: number;
  60342. /**
  60343. * Gets or sets the color associated with this step
  60344. */
  60345. color: Color3;
  60346. /**
  60347. * Creates a new GradientBlockColorStep
  60348. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60349. * @param color defines the color associated with this step
  60350. */
  60351. constructor(
  60352. /**
  60353. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60354. */
  60355. step: number,
  60356. /**
  60357. * Gets or sets the color associated with this step
  60358. */
  60359. color: Color3);
  60360. }
  60361. /**
  60362. * Block used to return a color from a gradient based on an input value between 0 and 1
  60363. */
  60364. export class GradientBlock extends NodeMaterialBlock {
  60365. /**
  60366. * Gets or sets the list of color steps
  60367. */
  60368. colorSteps: GradientBlockColorStep[];
  60369. /**
  60370. * Creates a new GradientBlock
  60371. * @param name defines the block name
  60372. */
  60373. constructor(name: string);
  60374. /**
  60375. * Gets the current class name
  60376. * @returns the class name
  60377. */
  60378. getClassName(): string;
  60379. /**
  60380. * Gets the gradient input component
  60381. */
  60382. readonly gradient: NodeMaterialConnectionPoint;
  60383. /**
  60384. * Gets the output component
  60385. */
  60386. readonly output: NodeMaterialConnectionPoint;
  60387. private _writeColorConstant;
  60388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60389. serialize(): any;
  60390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60391. protected _dumpPropertiesCode(): string;
  60392. }
  60393. }
  60394. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60398. /**
  60399. * Block used to normalize lerp between 2 values
  60400. */
  60401. export class NLerpBlock extends NodeMaterialBlock {
  60402. /**
  60403. * Creates a new NLerpBlock
  60404. * @param name defines the block name
  60405. */
  60406. constructor(name: string);
  60407. /**
  60408. * Gets the current class name
  60409. * @returns the class name
  60410. */
  60411. getClassName(): string;
  60412. /**
  60413. * Gets the left operand input component
  60414. */
  60415. readonly left: NodeMaterialConnectionPoint;
  60416. /**
  60417. * Gets the right operand input component
  60418. */
  60419. readonly right: NodeMaterialConnectionPoint;
  60420. /**
  60421. * Gets the gradient operand input component
  60422. */
  60423. readonly gradient: NodeMaterialConnectionPoint;
  60424. /**
  60425. * Gets the output component
  60426. */
  60427. readonly output: NodeMaterialConnectionPoint;
  60428. protected _buildBlock(state: NodeMaterialBuildState): this;
  60429. }
  60430. }
  60431. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  60432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60435. import { Scene } from "babylonjs/scene";
  60436. /**
  60437. * block used to Generate a Worley Noise 3D Noise Pattern
  60438. */
  60439. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60440. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60441. manhattanDistance: boolean;
  60442. /**
  60443. * Creates a new WorleyNoise3DBlock
  60444. * @param name defines the block name
  60445. */
  60446. constructor(name: string);
  60447. /**
  60448. * Gets the current class name
  60449. * @returns the class name
  60450. */
  60451. getClassName(): string;
  60452. /**
  60453. * Gets the seed input component
  60454. */
  60455. readonly seed: NodeMaterialConnectionPoint;
  60456. /**
  60457. * Gets the jitter input component
  60458. */
  60459. readonly jitter: NodeMaterialConnectionPoint;
  60460. /**
  60461. * Gets the output component
  60462. */
  60463. readonly output: NodeMaterialConnectionPoint;
  60464. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60465. /**
  60466. * Exposes the properties to the UI?
  60467. */
  60468. protected _dumpPropertiesCode(): string;
  60469. /**
  60470. * Exposes the properties to the Seralize?
  60471. */
  60472. serialize(): any;
  60473. /**
  60474. * Exposes the properties to the deseralize?
  60475. */
  60476. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60477. }
  60478. }
  60479. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  60480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60483. /**
  60484. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60485. */
  60486. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60487. /**
  60488. * Creates a new SimplexPerlin3DBlock
  60489. * @param name defines the block name
  60490. */
  60491. constructor(name: string);
  60492. /**
  60493. * Gets the current class name
  60494. * @returns the class name
  60495. */
  60496. getClassName(): string;
  60497. /**
  60498. * Gets the seed operand input component
  60499. */
  60500. readonly seed: NodeMaterialConnectionPoint;
  60501. /**
  60502. * Gets the output component
  60503. */
  60504. readonly output: NodeMaterialConnectionPoint;
  60505. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60506. }
  60507. }
  60508. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  60509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60512. /**
  60513. * Block used to blend normals
  60514. */
  60515. export class NormalBlendBlock extends NodeMaterialBlock {
  60516. /**
  60517. * Creates a new NormalBlendBlock
  60518. * @param name defines the block name
  60519. */
  60520. constructor(name: string);
  60521. /**
  60522. * Gets the current class name
  60523. * @returns the class name
  60524. */
  60525. getClassName(): string;
  60526. /**
  60527. * Gets the first input component
  60528. */
  60529. readonly normalMap0: NodeMaterialConnectionPoint;
  60530. /**
  60531. * Gets the second input component
  60532. */
  60533. readonly normalMap1: NodeMaterialConnectionPoint;
  60534. /**
  60535. * Gets the output component
  60536. */
  60537. readonly output: NodeMaterialConnectionPoint;
  60538. protected _buildBlock(state: NodeMaterialBuildState): this;
  60539. }
  60540. }
  60541. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  60542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60545. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60546. /**
  60547. * Block used to rotate a 2d vector by a given angle
  60548. */
  60549. export class Rotate2dBlock extends NodeMaterialBlock {
  60550. /**
  60551. * Creates a new Rotate2dBlock
  60552. * @param name defines the block name
  60553. */
  60554. constructor(name: string);
  60555. /**
  60556. * Gets the current class name
  60557. * @returns the class name
  60558. */
  60559. getClassName(): string;
  60560. /**
  60561. * Gets the input vector
  60562. */
  60563. readonly input: NodeMaterialConnectionPoint;
  60564. /**
  60565. * Gets the input angle
  60566. */
  60567. readonly angle: NodeMaterialConnectionPoint;
  60568. /**
  60569. * Gets the output component
  60570. */
  60571. readonly output: NodeMaterialConnectionPoint;
  60572. autoConfigure(material: NodeMaterial): void;
  60573. protected _buildBlock(state: NodeMaterialBuildState): this;
  60574. }
  60575. }
  60576. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  60577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60580. /**
  60581. * Block used to get the reflected vector from a direction and a normal
  60582. */
  60583. export class ReflectBlock extends NodeMaterialBlock {
  60584. /**
  60585. * Creates a new ReflectBlock
  60586. * @param name defines the block name
  60587. */
  60588. constructor(name: string);
  60589. /**
  60590. * Gets the current class name
  60591. * @returns the class name
  60592. */
  60593. getClassName(): string;
  60594. /**
  60595. * Gets the incident component
  60596. */
  60597. readonly incident: NodeMaterialConnectionPoint;
  60598. /**
  60599. * Gets the normal component
  60600. */
  60601. readonly normal: NodeMaterialConnectionPoint;
  60602. /**
  60603. * Gets the output component
  60604. */
  60605. readonly output: NodeMaterialConnectionPoint;
  60606. protected _buildBlock(state: NodeMaterialBuildState): this;
  60607. }
  60608. }
  60609. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  60610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60613. /**
  60614. * Block used to get the refracted vector from a direction and a normal
  60615. */
  60616. export class RefractBlock extends NodeMaterialBlock {
  60617. /**
  60618. * Creates a new RefractBlock
  60619. * @param name defines the block name
  60620. */
  60621. constructor(name: string);
  60622. /**
  60623. * Gets the current class name
  60624. * @returns the class name
  60625. */
  60626. getClassName(): string;
  60627. /**
  60628. * Gets the incident component
  60629. */
  60630. readonly incident: NodeMaterialConnectionPoint;
  60631. /**
  60632. * Gets the normal component
  60633. */
  60634. readonly normal: NodeMaterialConnectionPoint;
  60635. /**
  60636. * Gets the index of refraction component
  60637. */
  60638. readonly ior: NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the output component
  60641. */
  60642. readonly output: NodeMaterialConnectionPoint;
  60643. protected _buildBlock(state: NodeMaterialBuildState): this;
  60644. }
  60645. }
  60646. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  60647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60650. /**
  60651. * Block used to desaturate a color
  60652. */
  60653. export class DesaturateBlock extends NodeMaterialBlock {
  60654. /**
  60655. * Creates a new DesaturateBlock
  60656. * @param name defines the block name
  60657. */
  60658. constructor(name: string);
  60659. /**
  60660. * Gets the current class name
  60661. * @returns the class name
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Gets the color operand input component
  60666. */
  60667. readonly color: NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the level operand input component
  60670. */
  60671. readonly level: NodeMaterialConnectionPoint;
  60672. /**
  60673. * Gets the output component
  60674. */
  60675. readonly output: NodeMaterialConnectionPoint;
  60676. protected _buildBlock(state: NodeMaterialBuildState): this;
  60677. }
  60678. }
  60679. declare module "babylonjs/Materials/Node/Blocks/index" {
  60680. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  60681. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  60682. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  60683. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  60684. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  60685. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  60686. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  60687. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  60688. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  60689. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  60690. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  60691. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  60692. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  60693. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  60694. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  60695. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  60696. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  60697. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  60698. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  60699. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  60700. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  60701. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  60702. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  60703. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  60704. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  60705. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  60706. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  60707. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  60708. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  60709. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  60710. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  60711. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  60712. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  60713. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  60714. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  60715. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  60716. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  60717. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  60718. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  60719. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  60720. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  60721. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  60722. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  60723. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  60724. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  60725. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  60726. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  60727. }
  60728. declare module "babylonjs/Materials/Node/Optimizers/index" {
  60729. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60730. }
  60731. declare module "babylonjs/Materials/Node/index" {
  60732. export * from "babylonjs/Materials/Node/Enums/index";
  60733. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60734. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  60735. export * from "babylonjs/Materials/Node/nodeMaterial";
  60736. export * from "babylonjs/Materials/Node/Blocks/index";
  60737. export * from "babylonjs/Materials/Node/Optimizers/index";
  60738. }
  60739. declare module "babylonjs/Materials/effectRenderer" {
  60740. import { Nullable } from "babylonjs/types";
  60741. import { Texture } from "babylonjs/Materials/Textures/texture";
  60742. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60743. import { Viewport } from "babylonjs/Maths/math.viewport";
  60744. import { Observable } from "babylonjs/Misc/observable";
  60745. import { Effect } from "babylonjs/Materials/effect";
  60746. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60747. import "babylonjs/Shaders/postprocess.vertex";
  60748. /**
  60749. * Effect Render Options
  60750. */
  60751. export interface IEffectRendererOptions {
  60752. /**
  60753. * Defines the vertices positions.
  60754. */
  60755. positions?: number[];
  60756. /**
  60757. * Defines the indices.
  60758. */
  60759. indices?: number[];
  60760. }
  60761. /**
  60762. * Helper class to render one or more effects
  60763. */
  60764. export class EffectRenderer {
  60765. private engine;
  60766. private static _DefaultOptions;
  60767. private _vertexBuffers;
  60768. private _indexBuffer;
  60769. private _ringBufferIndex;
  60770. private _ringScreenBuffer;
  60771. private _fullscreenViewport;
  60772. private _getNextFrameBuffer;
  60773. /**
  60774. * Creates an effect renderer
  60775. * @param engine the engine to use for rendering
  60776. * @param options defines the options of the effect renderer
  60777. */
  60778. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60779. /**
  60780. * Sets the current viewport in normalized coordinates 0-1
  60781. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60782. */
  60783. setViewport(viewport?: Viewport): void;
  60784. /**
  60785. * Binds the embedded attributes buffer to the effect.
  60786. * @param effect Defines the effect to bind the attributes for
  60787. */
  60788. bindBuffers(effect: Effect): void;
  60789. /**
  60790. * Sets the current effect wrapper to use during draw.
  60791. * The effect needs to be ready before calling this api.
  60792. * This also sets the default full screen position attribute.
  60793. * @param effectWrapper Defines the effect to draw with
  60794. */
  60795. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60796. /**
  60797. * Draws a full screen quad.
  60798. */
  60799. draw(): void;
  60800. /**
  60801. * renders one or more effects to a specified texture
  60802. * @param effectWrappers list of effects to renderer
  60803. * @param outputTexture texture to draw to, if null it will render to the screen
  60804. */
  60805. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60806. /**
  60807. * Disposes of the effect renderer
  60808. */
  60809. dispose(): void;
  60810. }
  60811. /**
  60812. * Options to create an EffectWrapper
  60813. */
  60814. interface EffectWrapperCreationOptions {
  60815. /**
  60816. * Engine to use to create the effect
  60817. */
  60818. engine: ThinEngine;
  60819. /**
  60820. * Fragment shader for the effect
  60821. */
  60822. fragmentShader: string;
  60823. /**
  60824. * Vertex shader for the effect
  60825. */
  60826. vertexShader?: string;
  60827. /**
  60828. * Attributes to use in the shader
  60829. */
  60830. attributeNames?: Array<string>;
  60831. /**
  60832. * Uniforms to use in the shader
  60833. */
  60834. uniformNames?: Array<string>;
  60835. /**
  60836. * Texture sampler names to use in the shader
  60837. */
  60838. samplerNames?: Array<string>;
  60839. /**
  60840. * The friendly name of the effect displayed in Spector.
  60841. */
  60842. name?: string;
  60843. }
  60844. /**
  60845. * Wraps an effect to be used for rendering
  60846. */
  60847. export class EffectWrapper {
  60848. /**
  60849. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60850. */
  60851. onApplyObservable: Observable<{}>;
  60852. /**
  60853. * The underlying effect
  60854. */
  60855. effect: Effect;
  60856. /**
  60857. * Creates an effect to be renderer
  60858. * @param creationOptions options to create the effect
  60859. */
  60860. constructor(creationOptions: EffectWrapperCreationOptions);
  60861. /**
  60862. * Disposes of the effect wrapper
  60863. */
  60864. dispose(): void;
  60865. }
  60866. }
  60867. declare module "babylonjs/Materials/index" {
  60868. export * from "babylonjs/Materials/Background/index";
  60869. export * from "babylonjs/Materials/colorCurves";
  60870. export * from "babylonjs/Materials/iEffectFallbacks";
  60871. export * from "babylonjs/Materials/effectFallbacks";
  60872. export * from "babylonjs/Materials/effect";
  60873. export * from "babylonjs/Materials/fresnelParameters";
  60874. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60875. export * from "babylonjs/Materials/material";
  60876. export * from "babylonjs/Materials/materialDefines";
  60877. export * from "babylonjs/Materials/materialHelper";
  60878. export * from "babylonjs/Materials/multiMaterial";
  60879. export * from "babylonjs/Materials/PBR/index";
  60880. export * from "babylonjs/Materials/pushMaterial";
  60881. export * from "babylonjs/Materials/shaderMaterial";
  60882. export * from "babylonjs/Materials/standardMaterial";
  60883. export * from "babylonjs/Materials/Textures/index";
  60884. export * from "babylonjs/Materials/uniformBuffer";
  60885. export * from "babylonjs/Materials/materialFlags";
  60886. export * from "babylonjs/Materials/Node/index";
  60887. export * from "babylonjs/Materials/effectRenderer";
  60888. }
  60889. declare module "babylonjs/Maths/index" {
  60890. export * from "babylonjs/Maths/math.scalar";
  60891. export * from "babylonjs/Maths/math";
  60892. export * from "babylonjs/Maths/sphericalPolynomial";
  60893. }
  60894. declare module "babylonjs/Misc/workerPool" {
  60895. import { IDisposable } from "babylonjs/scene";
  60896. /**
  60897. * Helper class to push actions to a pool of workers.
  60898. */
  60899. export class WorkerPool implements IDisposable {
  60900. private _workerInfos;
  60901. private _pendingActions;
  60902. /**
  60903. * Constructor
  60904. * @param workers Array of workers to use for actions
  60905. */
  60906. constructor(workers: Array<Worker>);
  60907. /**
  60908. * Terminates all workers and clears any pending actions.
  60909. */
  60910. dispose(): void;
  60911. /**
  60912. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60913. * pended until a worker has completed its action.
  60914. * @param action The action to perform. Call onComplete when the action is complete.
  60915. */
  60916. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60917. private _execute;
  60918. }
  60919. }
  60920. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60921. import { IDisposable } from "babylonjs/scene";
  60922. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60923. /**
  60924. * Configuration for Draco compression
  60925. */
  60926. export interface IDracoCompressionConfiguration {
  60927. /**
  60928. * Configuration for the decoder.
  60929. */
  60930. decoder: {
  60931. /**
  60932. * The url to the WebAssembly module.
  60933. */
  60934. wasmUrl?: string;
  60935. /**
  60936. * The url to the WebAssembly binary.
  60937. */
  60938. wasmBinaryUrl?: string;
  60939. /**
  60940. * The url to the fallback JavaScript module.
  60941. */
  60942. fallbackUrl?: string;
  60943. };
  60944. }
  60945. /**
  60946. * Draco compression (https://google.github.io/draco/)
  60947. *
  60948. * This class wraps the Draco module.
  60949. *
  60950. * **Encoder**
  60951. *
  60952. * The encoder is not currently implemented.
  60953. *
  60954. * **Decoder**
  60955. *
  60956. * 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.
  60957. *
  60958. * To update the configuration, use the following code:
  60959. * ```javascript
  60960. * DracoCompression.Configuration = {
  60961. * decoder: {
  60962. * wasmUrl: "<url to the WebAssembly library>",
  60963. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60964. * fallbackUrl: "<url to the fallback JavaScript library>",
  60965. * }
  60966. * };
  60967. * ```
  60968. *
  60969. * 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.
  60970. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60971. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60972. *
  60973. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60974. * ```javascript
  60975. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60976. * ```
  60977. *
  60978. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60979. */
  60980. export class DracoCompression implements IDisposable {
  60981. private _workerPoolPromise?;
  60982. private _decoderModulePromise?;
  60983. /**
  60984. * The configuration. Defaults to the following urls:
  60985. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60986. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60987. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60988. */
  60989. static Configuration: IDracoCompressionConfiguration;
  60990. /**
  60991. * Returns true if the decoder configuration is available.
  60992. */
  60993. static readonly DecoderAvailable: boolean;
  60994. /**
  60995. * Default number of workers to create when creating the draco compression object.
  60996. */
  60997. static DefaultNumWorkers: number;
  60998. private static GetDefaultNumWorkers;
  60999. private static _Default;
  61000. /**
  61001. * Default instance for the draco compression object.
  61002. */
  61003. static readonly Default: DracoCompression;
  61004. /**
  61005. * Constructor
  61006. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61007. */
  61008. constructor(numWorkers?: number);
  61009. /**
  61010. * Stop all async operations and release resources.
  61011. */
  61012. dispose(): void;
  61013. /**
  61014. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61015. * @returns a promise that resolves when ready
  61016. */
  61017. whenReadyAsync(): Promise<void>;
  61018. /**
  61019. * Decode Draco compressed mesh data to vertex data.
  61020. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61021. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61022. * @returns A promise that resolves with the decoded vertex data
  61023. */
  61024. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61025. [kind: string]: number;
  61026. }): Promise<VertexData>;
  61027. }
  61028. }
  61029. declare module "babylonjs/Meshes/Compression/index" {
  61030. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61031. }
  61032. declare module "babylonjs/Meshes/csg" {
  61033. import { Nullable } from "babylonjs/types";
  61034. import { Scene } from "babylonjs/scene";
  61035. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61036. import { Mesh } from "babylonjs/Meshes/mesh";
  61037. import { Material } from "babylonjs/Materials/material";
  61038. /**
  61039. * Class for building Constructive Solid Geometry
  61040. */
  61041. export class CSG {
  61042. private polygons;
  61043. /**
  61044. * The world matrix
  61045. */
  61046. matrix: Matrix;
  61047. /**
  61048. * Stores the position
  61049. */
  61050. position: Vector3;
  61051. /**
  61052. * Stores the rotation
  61053. */
  61054. rotation: Vector3;
  61055. /**
  61056. * Stores the rotation quaternion
  61057. */
  61058. rotationQuaternion: Nullable<Quaternion>;
  61059. /**
  61060. * Stores the scaling vector
  61061. */
  61062. scaling: Vector3;
  61063. /**
  61064. * Convert the Mesh to CSG
  61065. * @param mesh The Mesh to convert to CSG
  61066. * @returns A new CSG from the Mesh
  61067. */
  61068. static FromMesh(mesh: Mesh): CSG;
  61069. /**
  61070. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61071. * @param polygons Polygons used to construct a CSG solid
  61072. */
  61073. private static FromPolygons;
  61074. /**
  61075. * Clones, or makes a deep copy, of the CSG
  61076. * @returns A new CSG
  61077. */
  61078. clone(): CSG;
  61079. /**
  61080. * Unions this CSG with another CSG
  61081. * @param csg The CSG to union against this CSG
  61082. * @returns The unioned CSG
  61083. */
  61084. union(csg: CSG): CSG;
  61085. /**
  61086. * Unions this CSG with another CSG in place
  61087. * @param csg The CSG to union against this CSG
  61088. */
  61089. unionInPlace(csg: CSG): void;
  61090. /**
  61091. * Subtracts this CSG with another CSG
  61092. * @param csg The CSG to subtract against this CSG
  61093. * @returns A new CSG
  61094. */
  61095. subtract(csg: CSG): CSG;
  61096. /**
  61097. * Subtracts this CSG with another CSG in place
  61098. * @param csg The CSG to subtact against this CSG
  61099. */
  61100. subtractInPlace(csg: CSG): void;
  61101. /**
  61102. * Intersect this CSG with another CSG
  61103. * @param csg The CSG to intersect against this CSG
  61104. * @returns A new CSG
  61105. */
  61106. intersect(csg: CSG): CSG;
  61107. /**
  61108. * Intersects this CSG with another CSG in place
  61109. * @param csg The CSG to intersect against this CSG
  61110. */
  61111. intersectInPlace(csg: CSG): void;
  61112. /**
  61113. * Return a new CSG solid with solid and empty space switched. This solid is
  61114. * not modified.
  61115. * @returns A new CSG solid with solid and empty space switched
  61116. */
  61117. inverse(): CSG;
  61118. /**
  61119. * Inverses the CSG in place
  61120. */
  61121. inverseInPlace(): void;
  61122. /**
  61123. * This is used to keep meshes transformations so they can be restored
  61124. * when we build back a Babylon Mesh
  61125. * NB : All CSG operations are performed in world coordinates
  61126. * @param csg The CSG to copy the transform attributes from
  61127. * @returns This CSG
  61128. */
  61129. copyTransformAttributes(csg: CSG): CSG;
  61130. /**
  61131. * Build Raw mesh from CSG
  61132. * Coordinates here are in world space
  61133. * @param name The name of the mesh geometry
  61134. * @param scene The Scene
  61135. * @param keepSubMeshes Specifies if the submeshes should be kept
  61136. * @returns A new Mesh
  61137. */
  61138. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61139. /**
  61140. * Build Mesh from CSG taking material and transforms into account
  61141. * @param name The name of the Mesh
  61142. * @param material The material of the Mesh
  61143. * @param scene The Scene
  61144. * @param keepSubMeshes Specifies if submeshes should be kept
  61145. * @returns The new Mesh
  61146. */
  61147. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61148. }
  61149. }
  61150. declare module "babylonjs/Meshes/trailMesh" {
  61151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61152. import { Mesh } from "babylonjs/Meshes/mesh";
  61153. import { Scene } from "babylonjs/scene";
  61154. /**
  61155. * Class used to create a trail following a mesh
  61156. */
  61157. export class TrailMesh extends Mesh {
  61158. private _generator;
  61159. private _autoStart;
  61160. private _running;
  61161. private _diameter;
  61162. private _length;
  61163. private _sectionPolygonPointsCount;
  61164. private _sectionVectors;
  61165. private _sectionNormalVectors;
  61166. private _beforeRenderObserver;
  61167. /**
  61168. * @constructor
  61169. * @param name The value used by scene.getMeshByName() to do a lookup.
  61170. * @param generator The mesh to generate a trail.
  61171. * @param scene The scene to add this mesh to.
  61172. * @param diameter Diameter of trailing mesh. Default is 1.
  61173. * @param length Length of trailing mesh. Default is 60.
  61174. * @param autoStart Automatically start trailing mesh. Default true.
  61175. */
  61176. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61177. /**
  61178. * "TrailMesh"
  61179. * @returns "TrailMesh"
  61180. */
  61181. getClassName(): string;
  61182. private _createMesh;
  61183. /**
  61184. * Start trailing mesh.
  61185. */
  61186. start(): void;
  61187. /**
  61188. * Stop trailing mesh.
  61189. */
  61190. stop(): void;
  61191. /**
  61192. * Update trailing mesh geometry.
  61193. */
  61194. update(): void;
  61195. /**
  61196. * Returns a new TrailMesh object.
  61197. * @param name is a string, the name given to the new mesh
  61198. * @param newGenerator use new generator object for cloned trail mesh
  61199. * @returns a new mesh
  61200. */
  61201. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61202. /**
  61203. * Serializes this trail mesh
  61204. * @param serializationObject object to write serialization to
  61205. */
  61206. serialize(serializationObject: any): void;
  61207. /**
  61208. * Parses a serialized trail mesh
  61209. * @param parsedMesh the serialized mesh
  61210. * @param scene the scene to create the trail mesh in
  61211. * @returns the created trail mesh
  61212. */
  61213. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61214. }
  61215. }
  61216. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61217. import { Nullable } from "babylonjs/types";
  61218. import { Scene } from "babylonjs/scene";
  61219. import { Vector4 } from "babylonjs/Maths/math.vector";
  61220. import { Color4 } from "babylonjs/Maths/math.color";
  61221. import { Mesh } from "babylonjs/Meshes/mesh";
  61222. /**
  61223. * Class containing static functions to help procedurally build meshes
  61224. */
  61225. export class TiledBoxBuilder {
  61226. /**
  61227. * Creates a box mesh
  61228. * 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)
  61229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61233. * @param name defines the name of the mesh
  61234. * @param options defines the options used to create the mesh
  61235. * @param scene defines the hosting scene
  61236. * @returns the box mesh
  61237. */
  61238. static CreateTiledBox(name: string, options: {
  61239. pattern?: number;
  61240. width?: number;
  61241. height?: number;
  61242. depth?: number;
  61243. tileSize?: number;
  61244. tileWidth?: number;
  61245. tileHeight?: number;
  61246. alignHorizontal?: number;
  61247. alignVertical?: number;
  61248. faceUV?: Vector4[];
  61249. faceColors?: Color4[];
  61250. sideOrientation?: number;
  61251. updatable?: boolean;
  61252. }, scene?: Nullable<Scene>): Mesh;
  61253. }
  61254. }
  61255. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61256. import { Vector4 } from "babylonjs/Maths/math.vector";
  61257. import { Mesh } from "babylonjs/Meshes/mesh";
  61258. /**
  61259. * Class containing static functions to help procedurally build meshes
  61260. */
  61261. export class TorusKnotBuilder {
  61262. /**
  61263. * Creates a torus knot mesh
  61264. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61265. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61266. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61267. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61271. * @param name defines the name of the mesh
  61272. * @param options defines the options used to create the mesh
  61273. * @param scene defines the hosting scene
  61274. * @returns the torus knot mesh
  61275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61276. */
  61277. static CreateTorusKnot(name: string, options: {
  61278. radius?: number;
  61279. tube?: number;
  61280. radialSegments?: number;
  61281. tubularSegments?: number;
  61282. p?: number;
  61283. q?: number;
  61284. updatable?: boolean;
  61285. sideOrientation?: number;
  61286. frontUVs?: Vector4;
  61287. backUVs?: Vector4;
  61288. }, scene: any): Mesh;
  61289. }
  61290. }
  61291. declare module "babylonjs/Meshes/polygonMesh" {
  61292. import { Scene } from "babylonjs/scene";
  61293. import { Vector2 } from "babylonjs/Maths/math.vector";
  61294. import { Mesh } from "babylonjs/Meshes/mesh";
  61295. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61296. import { Path2 } from "babylonjs/Maths/math.path";
  61297. /**
  61298. * Polygon
  61299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61300. */
  61301. export class Polygon {
  61302. /**
  61303. * Creates a rectangle
  61304. * @param xmin bottom X coord
  61305. * @param ymin bottom Y coord
  61306. * @param xmax top X coord
  61307. * @param ymax top Y coord
  61308. * @returns points that make the resulting rectation
  61309. */
  61310. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61311. /**
  61312. * Creates a circle
  61313. * @param radius radius of circle
  61314. * @param cx scale in x
  61315. * @param cy scale in y
  61316. * @param numberOfSides number of sides that make up the circle
  61317. * @returns points that make the resulting circle
  61318. */
  61319. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61320. /**
  61321. * Creates a polygon from input string
  61322. * @param input Input polygon data
  61323. * @returns the parsed points
  61324. */
  61325. static Parse(input: string): Vector2[];
  61326. /**
  61327. * Starts building a polygon from x and y coordinates
  61328. * @param x x coordinate
  61329. * @param y y coordinate
  61330. * @returns the started path2
  61331. */
  61332. static StartingAt(x: number, y: number): Path2;
  61333. }
  61334. /**
  61335. * Builds a polygon
  61336. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61337. */
  61338. export class PolygonMeshBuilder {
  61339. private _points;
  61340. private _outlinepoints;
  61341. private _holes;
  61342. private _name;
  61343. private _scene;
  61344. private _epoints;
  61345. private _eholes;
  61346. private _addToepoint;
  61347. /**
  61348. * Babylon reference to the earcut plugin.
  61349. */
  61350. bjsEarcut: any;
  61351. /**
  61352. * Creates a PolygonMeshBuilder
  61353. * @param name name of the builder
  61354. * @param contours Path of the polygon
  61355. * @param scene scene to add to when creating the mesh
  61356. * @param earcutInjection can be used to inject your own earcut reference
  61357. */
  61358. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61359. /**
  61360. * Adds a whole within the polygon
  61361. * @param hole Array of points defining the hole
  61362. * @returns this
  61363. */
  61364. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61365. /**
  61366. * Creates the polygon
  61367. * @param updatable If the mesh should be updatable
  61368. * @param depth The depth of the mesh created
  61369. * @returns the created mesh
  61370. */
  61371. build(updatable?: boolean, depth?: number): Mesh;
  61372. /**
  61373. * Creates the polygon
  61374. * @param depth The depth of the mesh created
  61375. * @returns the created VertexData
  61376. */
  61377. buildVertexData(depth?: number): VertexData;
  61378. /**
  61379. * Adds a side to the polygon
  61380. * @param positions points that make the polygon
  61381. * @param normals normals of the polygon
  61382. * @param uvs uvs of the polygon
  61383. * @param indices indices of the polygon
  61384. * @param bounds bounds of the polygon
  61385. * @param points points of the polygon
  61386. * @param depth depth of the polygon
  61387. * @param flip flip of the polygon
  61388. */
  61389. private addSide;
  61390. }
  61391. }
  61392. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61393. import { Scene } from "babylonjs/scene";
  61394. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61395. import { Color4 } from "babylonjs/Maths/math.color";
  61396. import { Mesh } from "babylonjs/Meshes/mesh";
  61397. import { Nullable } from "babylonjs/types";
  61398. /**
  61399. * Class containing static functions to help procedurally build meshes
  61400. */
  61401. export class PolygonBuilder {
  61402. /**
  61403. * Creates a polygon mesh
  61404. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61405. * * 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
  61406. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61409. * * Remember you can only change the shape positions, not their number when updating a polygon
  61410. * @param name defines the name of the mesh
  61411. * @param options defines the options used to create the mesh
  61412. * @param scene defines the hosting scene
  61413. * @param earcutInjection can be used to inject your own earcut reference
  61414. * @returns the polygon mesh
  61415. */
  61416. static CreatePolygon(name: string, options: {
  61417. shape: Vector3[];
  61418. holes?: Vector3[][];
  61419. depth?: number;
  61420. faceUV?: Vector4[];
  61421. faceColors?: Color4[];
  61422. updatable?: boolean;
  61423. sideOrientation?: number;
  61424. frontUVs?: Vector4;
  61425. backUVs?: Vector4;
  61426. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61427. /**
  61428. * Creates an extruded polygon mesh, with depth in the Y direction.
  61429. * * 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)
  61430. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61431. * @param name defines the name of the mesh
  61432. * @param options defines the options used to create the mesh
  61433. * @param scene defines the hosting scene
  61434. * @param earcutInjection can be used to inject your own earcut reference
  61435. * @returns the polygon mesh
  61436. */
  61437. static ExtrudePolygon(name: string, options: {
  61438. shape: Vector3[];
  61439. holes?: Vector3[][];
  61440. depth?: number;
  61441. faceUV?: Vector4[];
  61442. faceColors?: Color4[];
  61443. updatable?: boolean;
  61444. sideOrientation?: number;
  61445. frontUVs?: Vector4;
  61446. backUVs?: Vector4;
  61447. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61448. }
  61449. }
  61450. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  61451. import { Scene } from "babylonjs/scene";
  61452. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61453. import { Mesh } from "babylonjs/Meshes/mesh";
  61454. import { Nullable } from "babylonjs/types";
  61455. /**
  61456. * Class containing static functions to help procedurally build meshes
  61457. */
  61458. export class LatheBuilder {
  61459. /**
  61460. * Creates lathe mesh.
  61461. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61462. * * 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
  61463. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61464. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61465. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61466. * * 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
  61467. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61468. * * 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
  61469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61471. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61473. * @param name defines the name of the mesh
  61474. * @param options defines the options used to create the mesh
  61475. * @param scene defines the hosting scene
  61476. * @returns the lathe mesh
  61477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61478. */
  61479. static CreateLathe(name: string, options: {
  61480. shape: Vector3[];
  61481. radius?: number;
  61482. tessellation?: number;
  61483. clip?: number;
  61484. arc?: number;
  61485. closed?: boolean;
  61486. updatable?: boolean;
  61487. sideOrientation?: number;
  61488. frontUVs?: Vector4;
  61489. backUVs?: Vector4;
  61490. cap?: number;
  61491. invertUV?: boolean;
  61492. }, scene?: Nullable<Scene>): Mesh;
  61493. }
  61494. }
  61495. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  61496. import { Nullable } from "babylonjs/types";
  61497. import { Scene } from "babylonjs/scene";
  61498. import { Vector4 } from "babylonjs/Maths/math.vector";
  61499. import { Mesh } from "babylonjs/Meshes/mesh";
  61500. /**
  61501. * Class containing static functions to help procedurally build meshes
  61502. */
  61503. export class TiledPlaneBuilder {
  61504. /**
  61505. * Creates a tiled plane mesh
  61506. * * The parameter `pattern` will, depending on value, do nothing or
  61507. * * * flip (reflect about central vertical) alternate tiles across and up
  61508. * * * flip every tile on alternate rows
  61509. * * * rotate (180 degs) alternate tiles across and up
  61510. * * * rotate every tile on alternate rows
  61511. * * * flip and rotate alternate tiles across and up
  61512. * * * flip and rotate every tile on alternate rows
  61513. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61514. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61517. * * 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)
  61518. * * 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)
  61519. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61520. * @param name defines the name of the mesh
  61521. * @param options defines the options used to create the mesh
  61522. * @param scene defines the hosting scene
  61523. * @returns the box mesh
  61524. */
  61525. static CreateTiledPlane(name: string, options: {
  61526. pattern?: number;
  61527. tileSize?: number;
  61528. tileWidth?: number;
  61529. tileHeight?: number;
  61530. size?: number;
  61531. width?: number;
  61532. height?: number;
  61533. alignHorizontal?: number;
  61534. alignVertical?: number;
  61535. sideOrientation?: number;
  61536. frontUVs?: Vector4;
  61537. backUVs?: Vector4;
  61538. updatable?: boolean;
  61539. }, scene?: Nullable<Scene>): Mesh;
  61540. }
  61541. }
  61542. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  61543. import { Nullable } from "babylonjs/types";
  61544. import { Scene } from "babylonjs/scene";
  61545. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61546. import { Mesh } from "babylonjs/Meshes/mesh";
  61547. /**
  61548. * Class containing static functions to help procedurally build meshes
  61549. */
  61550. export class TubeBuilder {
  61551. /**
  61552. * Creates a tube mesh.
  61553. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61554. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61555. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61556. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61557. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61558. * * 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)
  61559. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61560. * * 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
  61561. * * 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
  61562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61566. * @param name defines the name of the mesh
  61567. * @param options defines the options used to create the mesh
  61568. * @param scene defines the hosting scene
  61569. * @returns the tube mesh
  61570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61571. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61572. */
  61573. static CreateTube(name: string, options: {
  61574. path: Vector3[];
  61575. radius?: number;
  61576. tessellation?: number;
  61577. radiusFunction?: {
  61578. (i: number, distance: number): number;
  61579. };
  61580. cap?: number;
  61581. arc?: number;
  61582. updatable?: boolean;
  61583. sideOrientation?: number;
  61584. frontUVs?: Vector4;
  61585. backUVs?: Vector4;
  61586. instance?: Mesh;
  61587. invertUV?: boolean;
  61588. }, scene?: Nullable<Scene>): Mesh;
  61589. }
  61590. }
  61591. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  61592. import { Scene } from "babylonjs/scene";
  61593. import { Vector4 } from "babylonjs/Maths/math.vector";
  61594. import { Mesh } from "babylonjs/Meshes/mesh";
  61595. import { Nullable } from "babylonjs/types";
  61596. /**
  61597. * Class containing static functions to help procedurally build meshes
  61598. */
  61599. export class IcoSphereBuilder {
  61600. /**
  61601. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61602. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61603. * * 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`)
  61604. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61605. * * 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
  61606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61609. * @param name defines the name of the mesh
  61610. * @param options defines the options used to create the mesh
  61611. * @param scene defines the hosting scene
  61612. * @returns the icosahedron mesh
  61613. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61614. */
  61615. static CreateIcoSphere(name: string, options: {
  61616. radius?: number;
  61617. radiusX?: number;
  61618. radiusY?: number;
  61619. radiusZ?: number;
  61620. flat?: boolean;
  61621. subdivisions?: number;
  61622. sideOrientation?: number;
  61623. frontUVs?: Vector4;
  61624. backUVs?: Vector4;
  61625. updatable?: boolean;
  61626. }, scene?: Nullable<Scene>): Mesh;
  61627. }
  61628. }
  61629. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  61630. import { Vector3 } from "babylonjs/Maths/math.vector";
  61631. import { Mesh } from "babylonjs/Meshes/mesh";
  61632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61633. /**
  61634. * Class containing static functions to help procedurally build meshes
  61635. */
  61636. export class DecalBuilder {
  61637. /**
  61638. * Creates a decal mesh.
  61639. * 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
  61640. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61641. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61642. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61643. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61644. * @param name defines the name of the mesh
  61645. * @param sourceMesh defines the mesh where the decal must be applied
  61646. * @param options defines the options used to create the mesh
  61647. * @param scene defines the hosting scene
  61648. * @returns the decal mesh
  61649. * @see https://doc.babylonjs.com/how_to/decals
  61650. */
  61651. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61652. position?: Vector3;
  61653. normal?: Vector3;
  61654. size?: Vector3;
  61655. angle?: number;
  61656. }): Mesh;
  61657. }
  61658. }
  61659. declare module "babylonjs/Meshes/meshBuilder" {
  61660. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  61661. import { Nullable } from "babylonjs/types";
  61662. import { Scene } from "babylonjs/scene";
  61663. import { Mesh } from "babylonjs/Meshes/mesh";
  61664. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  61665. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  61666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61667. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61668. import { Plane } from "babylonjs/Maths/math.plane";
  61669. /**
  61670. * Class containing static functions to help procedurally build meshes
  61671. */
  61672. export class MeshBuilder {
  61673. /**
  61674. * Creates a box mesh
  61675. * * The parameter `size` sets the size (float) of each box side (default 1)
  61676. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61677. * * 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)
  61678. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61682. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61683. * @param name defines the name of the mesh
  61684. * @param options defines the options used to create the mesh
  61685. * @param scene defines the hosting scene
  61686. * @returns the box mesh
  61687. */
  61688. static CreateBox(name: string, options: {
  61689. size?: number;
  61690. width?: number;
  61691. height?: number;
  61692. depth?: number;
  61693. faceUV?: Vector4[];
  61694. faceColors?: Color4[];
  61695. sideOrientation?: number;
  61696. frontUVs?: Vector4;
  61697. backUVs?: Vector4;
  61698. updatable?: boolean;
  61699. }, scene?: Nullable<Scene>): Mesh;
  61700. /**
  61701. * Creates a tiled box mesh
  61702. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61704. * @param name defines the name of the mesh
  61705. * @param options defines the options used to create the mesh
  61706. * @param scene defines the hosting scene
  61707. * @returns the tiled box mesh
  61708. */
  61709. static CreateTiledBox(name: string, options: {
  61710. pattern?: number;
  61711. size?: number;
  61712. width?: number;
  61713. height?: number;
  61714. depth: number;
  61715. tileSize?: number;
  61716. tileWidth?: number;
  61717. tileHeight?: number;
  61718. faceUV?: Vector4[];
  61719. faceColors?: Color4[];
  61720. alignHorizontal?: number;
  61721. alignVertical?: number;
  61722. sideOrientation?: number;
  61723. updatable?: boolean;
  61724. }, scene?: Nullable<Scene>): Mesh;
  61725. /**
  61726. * Creates a sphere mesh
  61727. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61728. * * 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`)
  61729. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61730. * * 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
  61731. * * 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)
  61732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61735. * @param name defines the name of the mesh
  61736. * @param options defines the options used to create the mesh
  61737. * @param scene defines the hosting scene
  61738. * @returns the sphere mesh
  61739. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61740. */
  61741. static CreateSphere(name: string, options: {
  61742. segments?: number;
  61743. diameter?: number;
  61744. diameterX?: number;
  61745. diameterY?: number;
  61746. diameterZ?: number;
  61747. arc?: number;
  61748. slice?: number;
  61749. sideOrientation?: number;
  61750. frontUVs?: Vector4;
  61751. backUVs?: Vector4;
  61752. updatable?: boolean;
  61753. }, scene?: Nullable<Scene>): Mesh;
  61754. /**
  61755. * Creates a plane polygonal mesh. By default, this is a disc
  61756. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61757. * * 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
  61758. * * 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
  61759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61762. * @param name defines the name of the mesh
  61763. * @param options defines the options used to create the mesh
  61764. * @param scene defines the hosting scene
  61765. * @returns the plane polygonal mesh
  61766. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61767. */
  61768. static CreateDisc(name: string, options: {
  61769. radius?: number;
  61770. tessellation?: number;
  61771. arc?: number;
  61772. updatable?: boolean;
  61773. sideOrientation?: number;
  61774. frontUVs?: Vector4;
  61775. backUVs?: Vector4;
  61776. }, scene?: Nullable<Scene>): Mesh;
  61777. /**
  61778. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61779. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61780. * * 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`)
  61781. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61782. * * 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
  61783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61786. * @param name defines the name of the mesh
  61787. * @param options defines the options used to create the mesh
  61788. * @param scene defines the hosting scene
  61789. * @returns the icosahedron mesh
  61790. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61791. */
  61792. static CreateIcoSphere(name: string, options: {
  61793. radius?: number;
  61794. radiusX?: number;
  61795. radiusY?: number;
  61796. radiusZ?: number;
  61797. flat?: boolean;
  61798. subdivisions?: number;
  61799. sideOrientation?: number;
  61800. frontUVs?: Vector4;
  61801. backUVs?: Vector4;
  61802. updatable?: boolean;
  61803. }, scene?: Nullable<Scene>): Mesh;
  61804. /**
  61805. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61806. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61807. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61808. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61809. * * 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
  61810. * * 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
  61811. * * 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
  61812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61815. * * 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
  61816. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61817. * * 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
  61818. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61820. * @param name defines the name of the mesh
  61821. * @param options defines the options used to create the mesh
  61822. * @param scene defines the hosting scene
  61823. * @returns the ribbon mesh
  61824. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61826. */
  61827. static CreateRibbon(name: string, options: {
  61828. pathArray: Vector3[][];
  61829. closeArray?: boolean;
  61830. closePath?: boolean;
  61831. offset?: number;
  61832. updatable?: boolean;
  61833. sideOrientation?: number;
  61834. frontUVs?: Vector4;
  61835. backUVs?: Vector4;
  61836. instance?: Mesh;
  61837. invertUV?: boolean;
  61838. uvs?: Vector2[];
  61839. colors?: Color4[];
  61840. }, scene?: Nullable<Scene>): Mesh;
  61841. /**
  61842. * Creates a cylinder or a cone mesh
  61843. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61844. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61845. * * 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.
  61846. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61847. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61848. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61849. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61850. * * 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).
  61851. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61852. * * 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).
  61853. * * 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
  61854. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61855. * * 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
  61856. * * 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.
  61857. * * If `enclose` is false, a ring surface is one element.
  61858. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61859. * * 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
  61860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61863. * @param name defines the name of the mesh
  61864. * @param options defines the options used to create the mesh
  61865. * @param scene defines the hosting scene
  61866. * @returns the cylinder mesh
  61867. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61868. */
  61869. static CreateCylinder(name: string, options: {
  61870. height?: number;
  61871. diameterTop?: number;
  61872. diameterBottom?: number;
  61873. diameter?: number;
  61874. tessellation?: number;
  61875. subdivisions?: number;
  61876. arc?: number;
  61877. faceColors?: Color4[];
  61878. faceUV?: Vector4[];
  61879. updatable?: boolean;
  61880. hasRings?: boolean;
  61881. enclose?: boolean;
  61882. cap?: number;
  61883. sideOrientation?: number;
  61884. frontUVs?: Vector4;
  61885. backUVs?: Vector4;
  61886. }, scene?: Nullable<Scene>): Mesh;
  61887. /**
  61888. * Creates a torus mesh
  61889. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61890. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61891. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61895. * @param name defines the name of the mesh
  61896. * @param options defines the options used to create the mesh
  61897. * @param scene defines the hosting scene
  61898. * @returns the torus mesh
  61899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61900. */
  61901. static CreateTorus(name: string, options: {
  61902. diameter?: number;
  61903. thickness?: number;
  61904. tessellation?: number;
  61905. updatable?: boolean;
  61906. sideOrientation?: number;
  61907. frontUVs?: Vector4;
  61908. backUVs?: Vector4;
  61909. }, scene?: Nullable<Scene>): Mesh;
  61910. /**
  61911. * Creates a torus knot mesh
  61912. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61913. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61914. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61915. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61919. * @param name defines the name of the mesh
  61920. * @param options defines the options used to create the mesh
  61921. * @param scene defines the hosting scene
  61922. * @returns the torus knot mesh
  61923. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61924. */
  61925. static CreateTorusKnot(name: string, options: {
  61926. radius?: number;
  61927. tube?: number;
  61928. radialSegments?: number;
  61929. tubularSegments?: number;
  61930. p?: number;
  61931. q?: number;
  61932. updatable?: boolean;
  61933. sideOrientation?: number;
  61934. frontUVs?: Vector4;
  61935. backUVs?: Vector4;
  61936. }, scene?: Nullable<Scene>): Mesh;
  61937. /**
  61938. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61939. * * 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
  61940. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61941. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61942. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61943. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61944. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61945. * * 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
  61946. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61949. * @param name defines the name of the new line system
  61950. * @param options defines the options used to create the line system
  61951. * @param scene defines the hosting scene
  61952. * @returns a new line system mesh
  61953. */
  61954. static CreateLineSystem(name: string, options: {
  61955. lines: Vector3[][];
  61956. updatable?: boolean;
  61957. instance?: Nullable<LinesMesh>;
  61958. colors?: Nullable<Color4[][]>;
  61959. useVertexAlpha?: boolean;
  61960. }, scene: Nullable<Scene>): LinesMesh;
  61961. /**
  61962. * Creates a line mesh
  61963. * 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
  61964. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61965. * * The parameter `points` is an array successive Vector3
  61966. * * 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
  61967. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61968. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61969. * * When updating an instance, remember that only point positions can change, not the number of points
  61970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61972. * @param name defines the name of the new line system
  61973. * @param options defines the options used to create the line system
  61974. * @param scene defines the hosting scene
  61975. * @returns a new line mesh
  61976. */
  61977. static CreateLines(name: string, options: {
  61978. points: Vector3[];
  61979. updatable?: boolean;
  61980. instance?: Nullable<LinesMesh>;
  61981. colors?: Color4[];
  61982. useVertexAlpha?: boolean;
  61983. }, scene?: Nullable<Scene>): LinesMesh;
  61984. /**
  61985. * Creates a dashed line mesh
  61986. * * 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
  61987. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61988. * * The parameter `points` is an array successive Vector3
  61989. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61990. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61991. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61992. * * 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
  61993. * * When updating an instance, remember that only point positions can change, not the number of points
  61994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61995. * @param name defines the name of the mesh
  61996. * @param options defines the options used to create the mesh
  61997. * @param scene defines the hosting scene
  61998. * @returns the dashed line mesh
  61999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62000. */
  62001. static CreateDashedLines(name: string, options: {
  62002. points: Vector3[];
  62003. dashSize?: number;
  62004. gapSize?: number;
  62005. dashNb?: number;
  62006. updatable?: boolean;
  62007. instance?: LinesMesh;
  62008. }, scene?: Nullable<Scene>): LinesMesh;
  62009. /**
  62010. * 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.
  62011. * * 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.
  62012. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62013. * * 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.
  62014. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62015. * * 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
  62016. * * 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
  62017. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62022. * @param name defines the name of the mesh
  62023. * @param options defines the options used to create the mesh
  62024. * @param scene defines the hosting scene
  62025. * @returns the extruded shape mesh
  62026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62028. */
  62029. static ExtrudeShape(name: string, options: {
  62030. shape: Vector3[];
  62031. path: Vector3[];
  62032. scale?: number;
  62033. rotation?: number;
  62034. cap?: number;
  62035. updatable?: boolean;
  62036. sideOrientation?: number;
  62037. frontUVs?: Vector4;
  62038. backUVs?: Vector4;
  62039. instance?: Mesh;
  62040. invertUV?: boolean;
  62041. }, scene?: Nullable<Scene>): Mesh;
  62042. /**
  62043. * Creates an custom extruded shape mesh.
  62044. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62045. * * 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.
  62046. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62047. * * 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
  62048. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62049. * * 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
  62050. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62051. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62052. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62053. * * 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
  62054. * * 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
  62055. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62060. * @param name defines the name of the mesh
  62061. * @param options defines the options used to create the mesh
  62062. * @param scene defines the hosting scene
  62063. * @returns the custom extruded shape mesh
  62064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62067. */
  62068. static ExtrudeShapeCustom(name: string, options: {
  62069. shape: Vector3[];
  62070. path: Vector3[];
  62071. scaleFunction?: any;
  62072. rotationFunction?: any;
  62073. ribbonCloseArray?: boolean;
  62074. ribbonClosePath?: boolean;
  62075. cap?: number;
  62076. updatable?: boolean;
  62077. sideOrientation?: number;
  62078. frontUVs?: Vector4;
  62079. backUVs?: Vector4;
  62080. instance?: Mesh;
  62081. invertUV?: boolean;
  62082. }, scene?: Nullable<Scene>): Mesh;
  62083. /**
  62084. * Creates lathe mesh.
  62085. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62086. * * 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
  62087. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62088. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62089. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62090. * * 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
  62091. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62092. * * 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
  62093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62097. * @param name defines the name of the mesh
  62098. * @param options defines the options used to create the mesh
  62099. * @param scene defines the hosting scene
  62100. * @returns the lathe mesh
  62101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62102. */
  62103. static CreateLathe(name: string, options: {
  62104. shape: Vector3[];
  62105. radius?: number;
  62106. tessellation?: number;
  62107. clip?: number;
  62108. arc?: number;
  62109. closed?: boolean;
  62110. updatable?: boolean;
  62111. sideOrientation?: number;
  62112. frontUVs?: Vector4;
  62113. backUVs?: Vector4;
  62114. cap?: number;
  62115. invertUV?: boolean;
  62116. }, scene?: Nullable<Scene>): Mesh;
  62117. /**
  62118. * Creates a tiled plane mesh
  62119. * * You can set a limited pattern arrangement with the tiles
  62120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62123. * @param name defines the name of the mesh
  62124. * @param options defines the options used to create the mesh
  62125. * @param scene defines the hosting scene
  62126. * @returns the plane mesh
  62127. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62128. */
  62129. static CreateTiledPlane(name: string, options: {
  62130. pattern?: number;
  62131. tileSize?: number;
  62132. tileWidth?: number;
  62133. tileHeight?: number;
  62134. size?: number;
  62135. width?: number;
  62136. height?: number;
  62137. alignHorizontal?: number;
  62138. alignVertical?: number;
  62139. sideOrientation?: number;
  62140. frontUVs?: Vector4;
  62141. backUVs?: Vector4;
  62142. updatable?: boolean;
  62143. }, scene?: Nullable<Scene>): Mesh;
  62144. /**
  62145. * Creates a plane mesh
  62146. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62147. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62148. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62152. * @param name defines the name of the mesh
  62153. * @param options defines the options used to create the mesh
  62154. * @param scene defines the hosting scene
  62155. * @returns the plane mesh
  62156. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62157. */
  62158. static CreatePlane(name: string, options: {
  62159. size?: number;
  62160. width?: number;
  62161. height?: number;
  62162. sideOrientation?: number;
  62163. frontUVs?: Vector4;
  62164. backUVs?: Vector4;
  62165. updatable?: boolean;
  62166. sourcePlane?: Plane;
  62167. }, scene?: Nullable<Scene>): Mesh;
  62168. /**
  62169. * Creates a ground mesh
  62170. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62171. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62173. * @param name defines the name of the mesh
  62174. * @param options defines the options used to create the mesh
  62175. * @param scene defines the hosting scene
  62176. * @returns the ground mesh
  62177. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62178. */
  62179. static CreateGround(name: string, options: {
  62180. width?: number;
  62181. height?: number;
  62182. subdivisions?: number;
  62183. subdivisionsX?: number;
  62184. subdivisionsY?: number;
  62185. updatable?: boolean;
  62186. }, scene?: Nullable<Scene>): Mesh;
  62187. /**
  62188. * Creates a tiled ground mesh
  62189. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62190. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62191. * * 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
  62192. * * 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
  62193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62194. * @param name defines the name of the mesh
  62195. * @param options defines the options used to create the mesh
  62196. * @param scene defines the hosting scene
  62197. * @returns the tiled ground mesh
  62198. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62199. */
  62200. static CreateTiledGround(name: string, options: {
  62201. xmin: number;
  62202. zmin: number;
  62203. xmax: number;
  62204. zmax: number;
  62205. subdivisions?: {
  62206. w: number;
  62207. h: number;
  62208. };
  62209. precision?: {
  62210. w: number;
  62211. h: number;
  62212. };
  62213. updatable?: boolean;
  62214. }, scene?: Nullable<Scene>): Mesh;
  62215. /**
  62216. * Creates a ground mesh from a height map
  62217. * * The parameter `url` sets the URL of the height map image resource.
  62218. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62219. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62220. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62221. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62222. * * 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.
  62223. * * 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).
  62224. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62226. * @param name defines the name of the mesh
  62227. * @param url defines the url to the height map
  62228. * @param options defines the options used to create the mesh
  62229. * @param scene defines the hosting scene
  62230. * @returns the ground mesh
  62231. * @see https://doc.babylonjs.com/babylon101/height_map
  62232. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62233. */
  62234. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62235. width?: number;
  62236. height?: number;
  62237. subdivisions?: number;
  62238. minHeight?: number;
  62239. maxHeight?: number;
  62240. colorFilter?: Color3;
  62241. alphaFilter?: number;
  62242. updatable?: boolean;
  62243. onReady?: (mesh: GroundMesh) => void;
  62244. }, scene?: Nullable<Scene>): GroundMesh;
  62245. /**
  62246. * Creates a polygon mesh
  62247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62248. * * 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
  62249. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62252. * * Remember you can only change the shape positions, not their number when updating a polygon
  62253. * @param name defines the name of the mesh
  62254. * @param options defines the options used to create the mesh
  62255. * @param scene defines the hosting scene
  62256. * @param earcutInjection can be used to inject your own earcut reference
  62257. * @returns the polygon mesh
  62258. */
  62259. static CreatePolygon(name: string, options: {
  62260. shape: Vector3[];
  62261. holes?: Vector3[][];
  62262. depth?: number;
  62263. faceUV?: Vector4[];
  62264. faceColors?: Color4[];
  62265. updatable?: boolean;
  62266. sideOrientation?: number;
  62267. frontUVs?: Vector4;
  62268. backUVs?: Vector4;
  62269. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62270. /**
  62271. * Creates an extruded polygon mesh, with depth in the Y direction.
  62272. * * 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)
  62273. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62274. * @param name defines the name of the mesh
  62275. * @param options defines the options used to create the mesh
  62276. * @param scene defines the hosting scene
  62277. * @param earcutInjection can be used to inject your own earcut reference
  62278. * @returns the polygon mesh
  62279. */
  62280. static ExtrudePolygon(name: string, options: {
  62281. shape: Vector3[];
  62282. holes?: Vector3[][];
  62283. depth?: number;
  62284. faceUV?: Vector4[];
  62285. faceColors?: Color4[];
  62286. updatable?: boolean;
  62287. sideOrientation?: number;
  62288. frontUVs?: Vector4;
  62289. backUVs?: Vector4;
  62290. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62291. /**
  62292. * Creates a tube mesh.
  62293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62298. * * 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)
  62299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62300. * * 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
  62301. * * 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
  62302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62306. * @param name defines the name of the mesh
  62307. * @param options defines the options used to create the mesh
  62308. * @param scene defines the hosting scene
  62309. * @returns the tube mesh
  62310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62311. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62312. */
  62313. static CreateTube(name: string, options: {
  62314. path: Vector3[];
  62315. radius?: number;
  62316. tessellation?: number;
  62317. radiusFunction?: {
  62318. (i: number, distance: number): number;
  62319. };
  62320. cap?: number;
  62321. arc?: number;
  62322. updatable?: boolean;
  62323. sideOrientation?: number;
  62324. frontUVs?: Vector4;
  62325. backUVs?: Vector4;
  62326. instance?: Mesh;
  62327. invertUV?: boolean;
  62328. }, scene?: Nullable<Scene>): Mesh;
  62329. /**
  62330. * Creates a polyhedron mesh
  62331. * * 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
  62332. * * The parameter `size` (positive float, default 1) sets the polygon size
  62333. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62334. * * 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`
  62335. * * 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
  62336. * * 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)`)
  62337. * * 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
  62338. * * 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
  62339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62342. * @param name defines the name of the mesh
  62343. * @param options defines the options used to create the mesh
  62344. * @param scene defines the hosting scene
  62345. * @returns the polyhedron mesh
  62346. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62347. */
  62348. static CreatePolyhedron(name: string, options: {
  62349. type?: number;
  62350. size?: number;
  62351. sizeX?: number;
  62352. sizeY?: number;
  62353. sizeZ?: number;
  62354. custom?: any;
  62355. faceUV?: Vector4[];
  62356. faceColors?: Color4[];
  62357. flat?: boolean;
  62358. updatable?: boolean;
  62359. sideOrientation?: number;
  62360. frontUVs?: Vector4;
  62361. backUVs?: Vector4;
  62362. }, scene?: Nullable<Scene>): Mesh;
  62363. /**
  62364. * Creates a decal mesh.
  62365. * 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
  62366. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62367. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62368. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62369. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62370. * @param name defines the name of the mesh
  62371. * @param sourceMesh defines the mesh where the decal must be applied
  62372. * @param options defines the options used to create the mesh
  62373. * @param scene defines the hosting scene
  62374. * @returns the decal mesh
  62375. * @see https://doc.babylonjs.com/how_to/decals
  62376. */
  62377. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62378. position?: Vector3;
  62379. normal?: Vector3;
  62380. size?: Vector3;
  62381. angle?: number;
  62382. }): Mesh;
  62383. }
  62384. }
  62385. declare module "babylonjs/Meshes/meshSimplification" {
  62386. import { Mesh } from "babylonjs/Meshes/mesh";
  62387. /**
  62388. * A simplifier interface for future simplification implementations
  62389. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62390. */
  62391. export interface ISimplifier {
  62392. /**
  62393. * Simplification of a given mesh according to the given settings.
  62394. * Since this requires computation, it is assumed that the function runs async.
  62395. * @param settings The settings of the simplification, including quality and distance
  62396. * @param successCallback A callback that will be called after the mesh was simplified.
  62397. * @param errorCallback in case of an error, this callback will be called. optional.
  62398. */
  62399. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62400. }
  62401. /**
  62402. * Expected simplification settings.
  62403. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62404. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62405. */
  62406. export interface ISimplificationSettings {
  62407. /**
  62408. * Gets or sets the expected quality
  62409. */
  62410. quality: number;
  62411. /**
  62412. * Gets or sets the distance when this optimized version should be used
  62413. */
  62414. distance: number;
  62415. /**
  62416. * Gets an already optimized mesh
  62417. */
  62418. optimizeMesh?: boolean;
  62419. }
  62420. /**
  62421. * Class used to specify simplification options
  62422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62423. */
  62424. export class SimplificationSettings implements ISimplificationSettings {
  62425. /** expected quality */
  62426. quality: number;
  62427. /** distance when this optimized version should be used */
  62428. distance: number;
  62429. /** already optimized mesh */
  62430. optimizeMesh?: boolean | undefined;
  62431. /**
  62432. * Creates a SimplificationSettings
  62433. * @param quality expected quality
  62434. * @param distance distance when this optimized version should be used
  62435. * @param optimizeMesh already optimized mesh
  62436. */
  62437. constructor(
  62438. /** expected quality */
  62439. quality: number,
  62440. /** distance when this optimized version should be used */
  62441. distance: number,
  62442. /** already optimized mesh */
  62443. optimizeMesh?: boolean | undefined);
  62444. }
  62445. /**
  62446. * Interface used to define a simplification task
  62447. */
  62448. export interface ISimplificationTask {
  62449. /**
  62450. * Array of settings
  62451. */
  62452. settings: Array<ISimplificationSettings>;
  62453. /**
  62454. * Simplification type
  62455. */
  62456. simplificationType: SimplificationType;
  62457. /**
  62458. * Mesh to simplify
  62459. */
  62460. mesh: Mesh;
  62461. /**
  62462. * Callback called on success
  62463. */
  62464. successCallback?: () => void;
  62465. /**
  62466. * Defines if parallel processing can be used
  62467. */
  62468. parallelProcessing: boolean;
  62469. }
  62470. /**
  62471. * Queue used to order the simplification tasks
  62472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62473. */
  62474. export class SimplificationQueue {
  62475. private _simplificationArray;
  62476. /**
  62477. * Gets a boolean indicating that the process is still running
  62478. */
  62479. running: boolean;
  62480. /**
  62481. * Creates a new queue
  62482. */
  62483. constructor();
  62484. /**
  62485. * Adds a new simplification task
  62486. * @param task defines a task to add
  62487. */
  62488. addTask(task: ISimplificationTask): void;
  62489. /**
  62490. * Execute next task
  62491. */
  62492. executeNext(): void;
  62493. /**
  62494. * Execute a simplification task
  62495. * @param task defines the task to run
  62496. */
  62497. runSimplification(task: ISimplificationTask): void;
  62498. private getSimplifier;
  62499. }
  62500. /**
  62501. * The implemented types of simplification
  62502. * At the moment only Quadratic Error Decimation is implemented
  62503. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62504. */
  62505. export enum SimplificationType {
  62506. /** Quadratic error decimation */
  62507. QUADRATIC = 0
  62508. }
  62509. }
  62510. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  62511. import { Scene } from "babylonjs/scene";
  62512. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  62513. import { ISceneComponent } from "babylonjs/sceneComponent";
  62514. module "babylonjs/scene" {
  62515. interface Scene {
  62516. /** @hidden (Backing field) */
  62517. _simplificationQueue: SimplificationQueue;
  62518. /**
  62519. * Gets or sets the simplification queue attached to the scene
  62520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62521. */
  62522. simplificationQueue: SimplificationQueue;
  62523. }
  62524. }
  62525. module "babylonjs/Meshes/mesh" {
  62526. interface Mesh {
  62527. /**
  62528. * Simplify the mesh according to the given array of settings.
  62529. * Function will return immediately and will simplify async
  62530. * @param settings a collection of simplification settings
  62531. * @param parallelProcessing should all levels calculate parallel or one after the other
  62532. * @param simplificationType the type of simplification to run
  62533. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62534. * @returns the current mesh
  62535. */
  62536. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62537. }
  62538. }
  62539. /**
  62540. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62541. * created in a scene
  62542. */
  62543. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62544. /**
  62545. * The component name helpfull to identify the component in the list of scene components.
  62546. */
  62547. readonly name: string;
  62548. /**
  62549. * The scene the component belongs to.
  62550. */
  62551. scene: Scene;
  62552. /**
  62553. * Creates a new instance of the component for the given scene
  62554. * @param scene Defines the scene to register the component in
  62555. */
  62556. constructor(scene: Scene);
  62557. /**
  62558. * Registers the component in a given scene
  62559. */
  62560. register(): void;
  62561. /**
  62562. * Rebuilds the elements related to this component in case of
  62563. * context lost for instance.
  62564. */
  62565. rebuild(): void;
  62566. /**
  62567. * Disposes the component and the associated ressources
  62568. */
  62569. dispose(): void;
  62570. private _beforeCameraUpdate;
  62571. }
  62572. }
  62573. declare module "babylonjs/Meshes/Builders/index" {
  62574. export * from "babylonjs/Meshes/Builders/boxBuilder";
  62575. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  62576. export * from "babylonjs/Meshes/Builders/discBuilder";
  62577. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  62578. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  62579. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  62580. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  62581. export * from "babylonjs/Meshes/Builders/torusBuilder";
  62582. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  62583. export * from "babylonjs/Meshes/Builders/linesBuilder";
  62584. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  62585. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  62586. export * from "babylonjs/Meshes/Builders/latheBuilder";
  62587. export * from "babylonjs/Meshes/Builders/planeBuilder";
  62588. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  62589. export * from "babylonjs/Meshes/Builders/groundBuilder";
  62590. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  62591. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  62592. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  62593. export * from "babylonjs/Meshes/Builders/decalBuilder";
  62594. }
  62595. declare module "babylonjs/Meshes/index" {
  62596. export * from "babylonjs/Meshes/abstractMesh";
  62597. export * from "babylonjs/Meshes/buffer";
  62598. export * from "babylonjs/Meshes/Compression/index";
  62599. export * from "babylonjs/Meshes/csg";
  62600. export * from "babylonjs/Meshes/geometry";
  62601. export * from "babylonjs/Meshes/groundMesh";
  62602. export * from "babylonjs/Meshes/trailMesh";
  62603. export * from "babylonjs/Meshes/instancedMesh";
  62604. export * from "babylonjs/Meshes/linesMesh";
  62605. export * from "babylonjs/Meshes/mesh";
  62606. export * from "babylonjs/Meshes/mesh.vertexData";
  62607. export * from "babylonjs/Meshes/meshBuilder";
  62608. export * from "babylonjs/Meshes/meshSimplification";
  62609. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  62610. export * from "babylonjs/Meshes/polygonMesh";
  62611. export * from "babylonjs/Meshes/subMesh";
  62612. export * from "babylonjs/Meshes/meshLODLevel";
  62613. export * from "babylonjs/Meshes/transformNode";
  62614. export * from "babylonjs/Meshes/Builders/index";
  62615. export * from "babylonjs/Meshes/dataBuffer";
  62616. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  62617. }
  62618. declare module "babylonjs/Morph/index" {
  62619. export * from "babylonjs/Morph/morphTarget";
  62620. export * from "babylonjs/Morph/morphTargetManager";
  62621. }
  62622. declare module "babylonjs/Navigation/INavigationEngine" {
  62623. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62624. import { Vector3 } from "babylonjs/Maths/math";
  62625. import { Mesh } from "babylonjs/Meshes/mesh";
  62626. import { Scene } from "babylonjs/scene";
  62627. /**
  62628. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62629. */
  62630. export interface INavigationEnginePlugin {
  62631. /**
  62632. * plugin name
  62633. */
  62634. name: string;
  62635. /**
  62636. * Creates a navigation mesh
  62637. * @param meshes array of all the geometry used to compute the navigatio mesh
  62638. * @param parameters bunch of parameters used to filter geometry
  62639. */
  62640. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62641. /**
  62642. * Create a navigation mesh debug mesh
  62643. * @param scene is where the mesh will be added
  62644. * @returns debug display mesh
  62645. */
  62646. createDebugNavMesh(scene: Scene): Mesh;
  62647. /**
  62648. * Get a navigation mesh constrained position, closest to the parameter position
  62649. * @param position world position
  62650. * @returns the closest point to position constrained by the navigation mesh
  62651. */
  62652. getClosestPoint(position: Vector3): Vector3;
  62653. /**
  62654. * Get a navigation mesh constrained position, within a particular radius
  62655. * @param position world position
  62656. * @param maxRadius the maximum distance to the constrained world position
  62657. * @returns the closest point to position constrained by the navigation mesh
  62658. */
  62659. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62660. /**
  62661. * Compute the final position from a segment made of destination-position
  62662. * @param position world position
  62663. * @param destination world position
  62664. * @returns the resulting point along the navmesh
  62665. */
  62666. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62667. /**
  62668. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62669. * @param start world position
  62670. * @param end world position
  62671. * @returns array containing world position composing the path
  62672. */
  62673. computePath(start: Vector3, end: Vector3): Vector3[];
  62674. /**
  62675. * If this plugin is supported
  62676. * @returns true if plugin is supported
  62677. */
  62678. isSupported(): boolean;
  62679. /**
  62680. * Create a new Crowd so you can add agents
  62681. * @param maxAgents the maximum agent count in the crowd
  62682. * @param maxAgentRadius the maximum radius an agent can have
  62683. * @param scene to attach the crowd to
  62684. * @returns the crowd you can add agents to
  62685. */
  62686. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62687. /**
  62688. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62689. * The queries will try to find a solution within those bounds
  62690. * default is (1,1,1)
  62691. * @param extent x,y,z value that define the extent around the queries point of reference
  62692. */
  62693. setDefaultQueryExtent(extent: Vector3): void;
  62694. /**
  62695. * Get the Bounding box extent specified by setDefaultQueryExtent
  62696. * @returns the box extent values
  62697. */
  62698. getDefaultQueryExtent(): Vector3;
  62699. /**
  62700. * Release all resources
  62701. */
  62702. dispose(): void;
  62703. }
  62704. /**
  62705. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62706. */
  62707. export interface ICrowd {
  62708. /**
  62709. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62710. * You can attach anything to that node. The node position is updated in the scene update tick.
  62711. * @param pos world position that will be constrained by the navigation mesh
  62712. * @param parameters agent parameters
  62713. * @param transform hooked to the agent that will be update by the scene
  62714. * @returns agent index
  62715. */
  62716. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62717. /**
  62718. * Returns the agent position in world space
  62719. * @param index agent index returned by addAgent
  62720. * @returns world space position
  62721. */
  62722. getAgentPosition(index: number): Vector3;
  62723. /**
  62724. * Gets the agent velocity in world space
  62725. * @param index agent index returned by addAgent
  62726. * @returns world space velocity
  62727. */
  62728. getAgentVelocity(index: number): Vector3;
  62729. /**
  62730. * remove a particular agent previously created
  62731. * @param index agent index returned by addAgent
  62732. */
  62733. removeAgent(index: number): void;
  62734. /**
  62735. * get the list of all agents attached to this crowd
  62736. * @returns list of agent indices
  62737. */
  62738. getAgents(): number[];
  62739. /**
  62740. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62741. * @param deltaTime in seconds
  62742. */
  62743. update(deltaTime: number): void;
  62744. /**
  62745. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62746. * @param index agent index returned by addAgent
  62747. * @param destination targeted world position
  62748. */
  62749. agentGoto(index: number, destination: Vector3): void;
  62750. /**
  62751. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62752. * The queries will try to find a solution within those bounds
  62753. * default is (1,1,1)
  62754. * @param extent x,y,z value that define the extent around the queries point of reference
  62755. */
  62756. setDefaultQueryExtent(extent: Vector3): void;
  62757. /**
  62758. * Get the Bounding box extent specified by setDefaultQueryExtent
  62759. * @returns the box extent values
  62760. */
  62761. getDefaultQueryExtent(): Vector3;
  62762. /**
  62763. * Release all resources
  62764. */
  62765. dispose(): void;
  62766. }
  62767. /**
  62768. * Configures an agent
  62769. */
  62770. export interface IAgentParameters {
  62771. /**
  62772. * Agent radius. [Limit: >= 0]
  62773. */
  62774. radius: number;
  62775. /**
  62776. * Agent height. [Limit: > 0]
  62777. */
  62778. height: number;
  62779. /**
  62780. * Maximum allowed acceleration. [Limit: >= 0]
  62781. */
  62782. maxAcceleration: number;
  62783. /**
  62784. * Maximum allowed speed. [Limit: >= 0]
  62785. */
  62786. maxSpeed: number;
  62787. /**
  62788. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62789. */
  62790. collisionQueryRange: number;
  62791. /**
  62792. * The path visibility optimization range. [Limit: > 0]
  62793. */
  62794. pathOptimizationRange: number;
  62795. /**
  62796. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62797. */
  62798. separationWeight: number;
  62799. }
  62800. /**
  62801. * Configures the navigation mesh creation
  62802. */
  62803. export interface INavMeshParameters {
  62804. /**
  62805. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62806. */
  62807. cs: number;
  62808. /**
  62809. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62810. */
  62811. ch: number;
  62812. /**
  62813. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62814. */
  62815. walkableSlopeAngle: number;
  62816. /**
  62817. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62818. * be considered walkable. [Limit: >= 3] [Units: vx]
  62819. */
  62820. walkableHeight: number;
  62821. /**
  62822. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62823. */
  62824. walkableClimb: number;
  62825. /**
  62826. * The distance to erode/shrink the walkable area of the heightfield away from
  62827. * obstructions. [Limit: >=0] [Units: vx]
  62828. */
  62829. walkableRadius: number;
  62830. /**
  62831. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62832. */
  62833. maxEdgeLen: number;
  62834. /**
  62835. * The maximum distance a simplfied contour's border edges should deviate
  62836. * the original raw contour. [Limit: >=0] [Units: vx]
  62837. */
  62838. maxSimplificationError: number;
  62839. /**
  62840. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62841. */
  62842. minRegionArea: number;
  62843. /**
  62844. * Any regions with a span count smaller than this value will, if possible,
  62845. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62846. */
  62847. mergeRegionArea: number;
  62848. /**
  62849. * The maximum number of vertices allowed for polygons generated during the
  62850. * contour to polygon conversion process. [Limit: >= 3]
  62851. */
  62852. maxVertsPerPoly: number;
  62853. /**
  62854. * Sets the sampling distance to use when generating the detail mesh.
  62855. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62856. */
  62857. detailSampleDist: number;
  62858. /**
  62859. * The maximum distance the detail mesh surface should deviate from heightfield
  62860. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62861. */
  62862. detailSampleMaxError: number;
  62863. }
  62864. }
  62865. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62866. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62867. import { Mesh } from "babylonjs/Meshes/mesh";
  62868. import { Scene } from "babylonjs/scene";
  62869. import { Vector3 } from "babylonjs/Maths/math";
  62870. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62871. /**
  62872. * RecastJS navigation plugin
  62873. */
  62874. export class RecastJSPlugin implements INavigationEnginePlugin {
  62875. /**
  62876. * Reference to the Recast library
  62877. */
  62878. bjsRECAST: any;
  62879. /**
  62880. * plugin name
  62881. */
  62882. name: string;
  62883. /**
  62884. * the first navmesh created. We might extend this to support multiple navmeshes
  62885. */
  62886. navMesh: any;
  62887. /**
  62888. * Initializes the recastJS plugin
  62889. * @param recastInjection can be used to inject your own recast reference
  62890. */
  62891. constructor(recastInjection?: any);
  62892. /**
  62893. * Creates a navigation mesh
  62894. * @param meshes array of all the geometry used to compute the navigatio mesh
  62895. * @param parameters bunch of parameters used to filter geometry
  62896. */
  62897. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62898. /**
  62899. * Create a navigation mesh debug mesh
  62900. * @param scene is where the mesh will be added
  62901. * @returns debug display mesh
  62902. */
  62903. createDebugNavMesh(scene: Scene): Mesh;
  62904. /**
  62905. * Get a navigation mesh constrained position, closest to the parameter position
  62906. * @param position world position
  62907. * @returns the closest point to position constrained by the navigation mesh
  62908. */
  62909. getClosestPoint(position: Vector3): Vector3;
  62910. /**
  62911. * Get a navigation mesh constrained position, within a particular radius
  62912. * @param position world position
  62913. * @param maxRadius the maximum distance to the constrained world position
  62914. * @returns the closest point to position constrained by the navigation mesh
  62915. */
  62916. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62917. /**
  62918. * Compute the final position from a segment made of destination-position
  62919. * @param position world position
  62920. * @param destination world position
  62921. * @returns the resulting point along the navmesh
  62922. */
  62923. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62924. /**
  62925. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62926. * @param start world position
  62927. * @param end world position
  62928. * @returns array containing world position composing the path
  62929. */
  62930. computePath(start: Vector3, end: Vector3): Vector3[];
  62931. /**
  62932. * Create a new Crowd so you can add agents
  62933. * @param maxAgents the maximum agent count in the crowd
  62934. * @param maxAgentRadius the maximum radius an agent can have
  62935. * @param scene to attach the crowd to
  62936. * @returns the crowd you can add agents to
  62937. */
  62938. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62939. /**
  62940. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62941. * The queries will try to find a solution within those bounds
  62942. * default is (1,1,1)
  62943. * @param extent x,y,z value that define the extent around the queries point of reference
  62944. */
  62945. setDefaultQueryExtent(extent: Vector3): void;
  62946. /**
  62947. * Get the Bounding box extent specified by setDefaultQueryExtent
  62948. * @returns the box extent values
  62949. */
  62950. getDefaultQueryExtent(): Vector3;
  62951. /**
  62952. * Disposes
  62953. */
  62954. dispose(): void;
  62955. /**
  62956. * If this plugin is supported
  62957. * @returns true if plugin is supported
  62958. */
  62959. isSupported(): boolean;
  62960. }
  62961. /**
  62962. * Recast detour crowd implementation
  62963. */
  62964. export class RecastJSCrowd implements ICrowd {
  62965. /**
  62966. * Recast/detour plugin
  62967. */
  62968. bjsRECASTPlugin: RecastJSPlugin;
  62969. /**
  62970. * Link to the detour crowd
  62971. */
  62972. recastCrowd: any;
  62973. /**
  62974. * One transform per agent
  62975. */
  62976. transforms: TransformNode[];
  62977. /**
  62978. * All agents created
  62979. */
  62980. agents: number[];
  62981. /**
  62982. * Link to the scene is kept to unregister the crowd from the scene
  62983. */
  62984. private _scene;
  62985. /**
  62986. * Observer for crowd updates
  62987. */
  62988. private _onBeforeAnimationsObserver;
  62989. /**
  62990. * Constructor
  62991. * @param plugin recastJS plugin
  62992. * @param maxAgents the maximum agent count in the crowd
  62993. * @param maxAgentRadius the maximum radius an agent can have
  62994. * @param scene to attach the crowd to
  62995. * @returns the crowd you can add agents to
  62996. */
  62997. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62998. /**
  62999. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63000. * You can attach anything to that node. The node position is updated in the scene update tick.
  63001. * @param pos world position that will be constrained by the navigation mesh
  63002. * @param parameters agent parameters
  63003. * @param transform hooked to the agent that will be update by the scene
  63004. * @returns agent index
  63005. */
  63006. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63007. /**
  63008. * Returns the agent position in world space
  63009. * @param index agent index returned by addAgent
  63010. * @returns world space position
  63011. */
  63012. getAgentPosition(index: number): Vector3;
  63013. /**
  63014. * Returns the agent velocity in world space
  63015. * @param index agent index returned by addAgent
  63016. * @returns world space velocity
  63017. */
  63018. getAgentVelocity(index: number): Vector3;
  63019. /**
  63020. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63021. * @param index agent index returned by addAgent
  63022. * @param destination targeted world position
  63023. */
  63024. agentGoto(index: number, destination: Vector3): void;
  63025. /**
  63026. * remove a particular agent previously created
  63027. * @param index agent index returned by addAgent
  63028. */
  63029. removeAgent(index: number): void;
  63030. /**
  63031. * get the list of all agents attached to this crowd
  63032. * @returns list of agent indices
  63033. */
  63034. getAgents(): number[];
  63035. /**
  63036. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63037. * @param deltaTime in seconds
  63038. */
  63039. update(deltaTime: number): void;
  63040. /**
  63041. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63042. * The queries will try to find a solution within those bounds
  63043. * default is (1,1,1)
  63044. * @param extent x,y,z value that define the extent around the queries point of reference
  63045. */
  63046. setDefaultQueryExtent(extent: Vector3): void;
  63047. /**
  63048. * Get the Bounding box extent specified by setDefaultQueryExtent
  63049. * @returns the box extent values
  63050. */
  63051. getDefaultQueryExtent(): Vector3;
  63052. /**
  63053. * Release all resources
  63054. */
  63055. dispose(): void;
  63056. }
  63057. }
  63058. declare module "babylonjs/Navigation/Plugins/index" {
  63059. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63060. }
  63061. declare module "babylonjs/Navigation/index" {
  63062. export * from "babylonjs/Navigation/INavigationEngine";
  63063. export * from "babylonjs/Navigation/Plugins/index";
  63064. }
  63065. declare module "babylonjs/Offline/database" {
  63066. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63067. /**
  63068. * Class used to enable access to IndexedDB
  63069. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63070. */
  63071. export class Database implements IOfflineProvider {
  63072. private _callbackManifestChecked;
  63073. private _currentSceneUrl;
  63074. private _db;
  63075. private _enableSceneOffline;
  63076. private _enableTexturesOffline;
  63077. private _manifestVersionFound;
  63078. private _mustUpdateRessources;
  63079. private _hasReachedQuota;
  63080. private _isSupported;
  63081. private _idbFactory;
  63082. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63083. private static IsUASupportingBlobStorage;
  63084. /**
  63085. * Gets a boolean indicating if Database storate is enabled (off by default)
  63086. */
  63087. static IDBStorageEnabled: boolean;
  63088. /**
  63089. * Gets a boolean indicating if scene must be saved in the database
  63090. */
  63091. readonly enableSceneOffline: boolean;
  63092. /**
  63093. * Gets a boolean indicating if textures must be saved in the database
  63094. */
  63095. readonly enableTexturesOffline: boolean;
  63096. /**
  63097. * Creates a new Database
  63098. * @param urlToScene defines the url to load the scene
  63099. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63100. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63101. */
  63102. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63103. private static _ParseURL;
  63104. private static _ReturnFullUrlLocation;
  63105. private _checkManifestFile;
  63106. /**
  63107. * Open the database and make it available
  63108. * @param successCallback defines the callback to call on success
  63109. * @param errorCallback defines the callback to call on error
  63110. */
  63111. open(successCallback: () => void, errorCallback: () => void): void;
  63112. /**
  63113. * Loads an image from the database
  63114. * @param url defines the url to load from
  63115. * @param image defines the target DOM image
  63116. */
  63117. loadImage(url: string, image: HTMLImageElement): void;
  63118. private _loadImageFromDBAsync;
  63119. private _saveImageIntoDBAsync;
  63120. private _checkVersionFromDB;
  63121. private _loadVersionFromDBAsync;
  63122. private _saveVersionIntoDBAsync;
  63123. /**
  63124. * Loads a file from database
  63125. * @param url defines the URL to load from
  63126. * @param sceneLoaded defines a callback to call on success
  63127. * @param progressCallBack defines a callback to call when progress changed
  63128. * @param errorCallback defines a callback to call on error
  63129. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63130. */
  63131. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63132. private _loadFileAsync;
  63133. private _saveFileAsync;
  63134. /**
  63135. * Validates if xhr data is correct
  63136. * @param xhr defines the request to validate
  63137. * @param dataType defines the expected data type
  63138. * @returns true if data is correct
  63139. */
  63140. private static _ValidateXHRData;
  63141. }
  63142. }
  63143. declare module "babylonjs/Offline/index" {
  63144. export * from "babylonjs/Offline/database";
  63145. export * from "babylonjs/Offline/IOfflineProvider";
  63146. }
  63147. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63148. /** @hidden */
  63149. export var gpuUpdateParticlesPixelShader: {
  63150. name: string;
  63151. shader: string;
  63152. };
  63153. }
  63154. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63155. /** @hidden */
  63156. export var gpuUpdateParticlesVertexShader: {
  63157. name: string;
  63158. shader: string;
  63159. };
  63160. }
  63161. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63162. /** @hidden */
  63163. export var clipPlaneFragmentDeclaration2: {
  63164. name: string;
  63165. shader: string;
  63166. };
  63167. }
  63168. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63169. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63170. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63171. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63172. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63173. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63174. /** @hidden */
  63175. export var gpuRenderParticlesPixelShader: {
  63176. name: string;
  63177. shader: string;
  63178. };
  63179. }
  63180. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63181. /** @hidden */
  63182. export var clipPlaneVertexDeclaration2: {
  63183. name: string;
  63184. shader: string;
  63185. };
  63186. }
  63187. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63188. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63189. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63190. /** @hidden */
  63191. export var gpuRenderParticlesVertexShader: {
  63192. name: string;
  63193. shader: string;
  63194. };
  63195. }
  63196. declare module "babylonjs/Particles/gpuParticleSystem" {
  63197. import { Nullable } from "babylonjs/types";
  63198. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63199. import { Observable } from "babylonjs/Misc/observable";
  63200. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63201. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63202. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63203. import { Scene, IDisposable } from "babylonjs/scene";
  63204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63205. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63206. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63207. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63208. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63209. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63210. /**
  63211. * This represents a GPU particle system in Babylon
  63212. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63213. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63214. */
  63215. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63216. /**
  63217. * The layer mask we are rendering the particles through.
  63218. */
  63219. layerMask: number;
  63220. private _capacity;
  63221. private _activeCount;
  63222. private _currentActiveCount;
  63223. private _accumulatedCount;
  63224. private _renderEffect;
  63225. private _updateEffect;
  63226. private _buffer0;
  63227. private _buffer1;
  63228. private _spriteBuffer;
  63229. private _updateVAO;
  63230. private _renderVAO;
  63231. private _targetIndex;
  63232. private _sourceBuffer;
  63233. private _targetBuffer;
  63234. private _engine;
  63235. private _currentRenderId;
  63236. private _started;
  63237. private _stopped;
  63238. private _timeDelta;
  63239. private _randomTexture;
  63240. private _randomTexture2;
  63241. private _attributesStrideSize;
  63242. private _updateEffectOptions;
  63243. private _randomTextureSize;
  63244. private _actualFrame;
  63245. private readonly _rawTextureWidth;
  63246. /**
  63247. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63248. */
  63249. static readonly IsSupported: boolean;
  63250. /**
  63251. * An event triggered when the system is disposed.
  63252. */
  63253. onDisposeObservable: Observable<GPUParticleSystem>;
  63254. /**
  63255. * Gets the maximum number of particles active at the same time.
  63256. * @returns The max number of active particles.
  63257. */
  63258. getCapacity(): number;
  63259. /**
  63260. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63261. * to override the particles.
  63262. */
  63263. forceDepthWrite: boolean;
  63264. /**
  63265. * Gets or set the number of active particles
  63266. */
  63267. activeParticleCount: number;
  63268. private _preWarmDone;
  63269. /**
  63270. * Is this system ready to be used/rendered
  63271. * @return true if the system is ready
  63272. */
  63273. isReady(): boolean;
  63274. /**
  63275. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63276. * @returns True if it has been started, otherwise false.
  63277. */
  63278. isStarted(): boolean;
  63279. /**
  63280. * Starts the particle system and begins to emit
  63281. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63282. */
  63283. start(delay?: number): void;
  63284. /**
  63285. * Stops the particle system.
  63286. */
  63287. stop(): void;
  63288. /**
  63289. * Remove all active particles
  63290. */
  63291. reset(): void;
  63292. /**
  63293. * Returns the string "GPUParticleSystem"
  63294. * @returns a string containing the class name
  63295. */
  63296. getClassName(): string;
  63297. private _colorGradientsTexture;
  63298. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63299. /**
  63300. * Adds a new color gradient
  63301. * @param gradient defines the gradient to use (between 0 and 1)
  63302. * @param color1 defines the color to affect to the specified gradient
  63303. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63304. * @returns the current particle system
  63305. */
  63306. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63307. /**
  63308. * Remove a specific color gradient
  63309. * @param gradient defines the gradient to remove
  63310. * @returns the current particle system
  63311. */
  63312. removeColorGradient(gradient: number): GPUParticleSystem;
  63313. private _angularSpeedGradientsTexture;
  63314. private _sizeGradientsTexture;
  63315. private _velocityGradientsTexture;
  63316. private _limitVelocityGradientsTexture;
  63317. private _dragGradientsTexture;
  63318. private _addFactorGradient;
  63319. /**
  63320. * Adds a new size gradient
  63321. * @param gradient defines the gradient to use (between 0 and 1)
  63322. * @param factor defines the size factor to affect to the specified gradient
  63323. * @returns the current particle system
  63324. */
  63325. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63326. /**
  63327. * Remove a specific size gradient
  63328. * @param gradient defines the gradient to remove
  63329. * @returns the current particle system
  63330. */
  63331. removeSizeGradient(gradient: number): GPUParticleSystem;
  63332. /**
  63333. * Adds a new angular speed gradient
  63334. * @param gradient defines the gradient to use (between 0 and 1)
  63335. * @param factor defines the angular speed to affect to the specified gradient
  63336. * @returns the current particle system
  63337. */
  63338. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63339. /**
  63340. * Remove a specific angular speed gradient
  63341. * @param gradient defines the gradient to remove
  63342. * @returns the current particle system
  63343. */
  63344. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63345. /**
  63346. * Adds a new velocity gradient
  63347. * @param gradient defines the gradient to use (between 0 and 1)
  63348. * @param factor defines the velocity to affect to the specified gradient
  63349. * @returns the current particle system
  63350. */
  63351. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63352. /**
  63353. * Remove a specific velocity gradient
  63354. * @param gradient defines the gradient to remove
  63355. * @returns the current particle system
  63356. */
  63357. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63358. /**
  63359. * Adds a new limit velocity gradient
  63360. * @param gradient defines the gradient to use (between 0 and 1)
  63361. * @param factor defines the limit velocity value to affect to the specified gradient
  63362. * @returns the current particle system
  63363. */
  63364. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63365. /**
  63366. * Remove a specific limit velocity gradient
  63367. * @param gradient defines the gradient to remove
  63368. * @returns the current particle system
  63369. */
  63370. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63371. /**
  63372. * Adds a new drag gradient
  63373. * @param gradient defines the gradient to use (between 0 and 1)
  63374. * @param factor defines the drag value to affect to the specified gradient
  63375. * @returns the current particle system
  63376. */
  63377. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63378. /**
  63379. * Remove a specific drag gradient
  63380. * @param gradient defines the gradient to remove
  63381. * @returns the current particle system
  63382. */
  63383. removeDragGradient(gradient: number): GPUParticleSystem;
  63384. /**
  63385. * Not supported by GPUParticleSystem
  63386. * @param gradient defines the gradient to use (between 0 and 1)
  63387. * @param factor defines the emit rate value to affect to the specified gradient
  63388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63389. * @returns the current particle system
  63390. */
  63391. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63392. /**
  63393. * Not supported by GPUParticleSystem
  63394. * @param gradient defines the gradient to remove
  63395. * @returns the current particle system
  63396. */
  63397. removeEmitRateGradient(gradient: number): IParticleSystem;
  63398. /**
  63399. * Not supported by GPUParticleSystem
  63400. * @param gradient defines the gradient to use (between 0 and 1)
  63401. * @param factor defines the start size value to affect to the specified gradient
  63402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63403. * @returns the current particle system
  63404. */
  63405. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63406. /**
  63407. * Not supported by GPUParticleSystem
  63408. * @param gradient defines the gradient to remove
  63409. * @returns the current particle system
  63410. */
  63411. removeStartSizeGradient(gradient: number): IParticleSystem;
  63412. /**
  63413. * Not supported by GPUParticleSystem
  63414. * @param gradient defines the gradient to use (between 0 and 1)
  63415. * @param min defines the color remap minimal range
  63416. * @param max defines the color remap maximal range
  63417. * @returns the current particle system
  63418. */
  63419. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63420. /**
  63421. * Not supported by GPUParticleSystem
  63422. * @param gradient defines the gradient to remove
  63423. * @returns the current particle system
  63424. */
  63425. removeColorRemapGradient(): IParticleSystem;
  63426. /**
  63427. * Not supported by GPUParticleSystem
  63428. * @param gradient defines the gradient to use (between 0 and 1)
  63429. * @param min defines the alpha remap minimal range
  63430. * @param max defines the alpha remap maximal range
  63431. * @returns the current particle system
  63432. */
  63433. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63434. /**
  63435. * Not supported by GPUParticleSystem
  63436. * @param gradient defines the gradient to remove
  63437. * @returns the current particle system
  63438. */
  63439. removeAlphaRemapGradient(): IParticleSystem;
  63440. /**
  63441. * Not supported by GPUParticleSystem
  63442. * @param gradient defines the gradient to use (between 0 and 1)
  63443. * @param color defines the color to affect to the specified gradient
  63444. * @returns the current particle system
  63445. */
  63446. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63447. /**
  63448. * Not supported by GPUParticleSystem
  63449. * @param gradient defines the gradient to remove
  63450. * @returns the current particle system
  63451. */
  63452. removeRampGradient(): IParticleSystem;
  63453. /**
  63454. * Not supported by GPUParticleSystem
  63455. * @returns the list of ramp gradients
  63456. */
  63457. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63458. /**
  63459. * Not supported by GPUParticleSystem
  63460. * Gets or sets a boolean indicating that ramp gradients must be used
  63461. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63462. */
  63463. useRampGradients: boolean;
  63464. /**
  63465. * Not supported by GPUParticleSystem
  63466. * @param gradient defines the gradient to use (between 0 and 1)
  63467. * @param factor defines the life time factor to affect to the specified gradient
  63468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63469. * @returns the current particle system
  63470. */
  63471. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63472. /**
  63473. * Not supported by GPUParticleSystem
  63474. * @param gradient defines the gradient to remove
  63475. * @returns the current particle system
  63476. */
  63477. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63478. /**
  63479. * Instantiates a GPU particle system.
  63480. * 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.
  63481. * @param name The name of the particle system
  63482. * @param options The options used to create the system
  63483. * @param scene The scene the particle system belongs to
  63484. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63485. */
  63486. constructor(name: string, options: Partial<{
  63487. capacity: number;
  63488. randomTextureSize: number;
  63489. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63490. protected _reset(): void;
  63491. private _createUpdateVAO;
  63492. private _createRenderVAO;
  63493. private _initialize;
  63494. /** @hidden */
  63495. _recreateUpdateEffect(): void;
  63496. /** @hidden */
  63497. _recreateRenderEffect(): void;
  63498. /**
  63499. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63500. * @param preWarm defines if we are in the pre-warmimg phase
  63501. */
  63502. animate(preWarm?: boolean): void;
  63503. private _createFactorGradientTexture;
  63504. private _createSizeGradientTexture;
  63505. private _createAngularSpeedGradientTexture;
  63506. private _createVelocityGradientTexture;
  63507. private _createLimitVelocityGradientTexture;
  63508. private _createDragGradientTexture;
  63509. private _createColorGradientTexture;
  63510. /**
  63511. * Renders the particle system in its current state
  63512. * @param preWarm defines if the system should only update the particles but not render them
  63513. * @returns the current number of particles
  63514. */
  63515. render(preWarm?: boolean): number;
  63516. /**
  63517. * Rebuilds the particle system
  63518. */
  63519. rebuild(): void;
  63520. private _releaseBuffers;
  63521. private _releaseVAOs;
  63522. /**
  63523. * Disposes the particle system and free the associated resources
  63524. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63525. */
  63526. dispose(disposeTexture?: boolean): void;
  63527. /**
  63528. * Clones the particle system.
  63529. * @param name The name of the cloned object
  63530. * @param newEmitter The new emitter to use
  63531. * @returns the cloned particle system
  63532. */
  63533. clone(name: string, newEmitter: any): GPUParticleSystem;
  63534. /**
  63535. * Serializes the particle system to a JSON object.
  63536. * @returns the JSON object
  63537. */
  63538. serialize(): any;
  63539. /**
  63540. * Parses a JSON object to create a GPU particle system.
  63541. * @param parsedParticleSystem The JSON object to parse
  63542. * @param scene The scene to create the particle system in
  63543. * @param rootUrl The root url to use to load external dependencies like texture
  63544. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63545. * @returns the parsed GPU particle system
  63546. */
  63547. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63548. }
  63549. }
  63550. declare module "babylonjs/Particles/particleSystemSet" {
  63551. import { Nullable } from "babylonjs/types";
  63552. import { Color3 } from "babylonjs/Maths/math.color";
  63553. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63555. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63556. import { Scene, IDisposable } from "babylonjs/scene";
  63557. /**
  63558. * Represents a set of particle systems working together to create a specific effect
  63559. */
  63560. export class ParticleSystemSet implements IDisposable {
  63561. /**
  63562. * Gets or sets base Assets URL
  63563. */
  63564. static BaseAssetsUrl: string;
  63565. private _emitterCreationOptions;
  63566. private _emitterNode;
  63567. /**
  63568. * Gets the particle system list
  63569. */
  63570. systems: IParticleSystem[];
  63571. /**
  63572. * Gets the emitter node used with this set
  63573. */
  63574. readonly emitterNode: Nullable<TransformNode>;
  63575. /**
  63576. * Creates a new emitter mesh as a sphere
  63577. * @param options defines the options used to create the sphere
  63578. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63579. * @param scene defines the hosting scene
  63580. */
  63581. setEmitterAsSphere(options: {
  63582. diameter: number;
  63583. segments: number;
  63584. color: Color3;
  63585. }, renderingGroupId: number, scene: Scene): void;
  63586. /**
  63587. * Starts all particle systems of the set
  63588. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63589. */
  63590. start(emitter?: AbstractMesh): void;
  63591. /**
  63592. * Release all associated resources
  63593. */
  63594. dispose(): void;
  63595. /**
  63596. * Serialize the set into a JSON compatible object
  63597. * @returns a JSON compatible representation of the set
  63598. */
  63599. serialize(): any;
  63600. /**
  63601. * Parse a new ParticleSystemSet from a serialized source
  63602. * @param data defines a JSON compatible representation of the set
  63603. * @param scene defines the hosting scene
  63604. * @param gpu defines if we want GPU particles or CPU particles
  63605. * @returns a new ParticleSystemSet
  63606. */
  63607. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63608. }
  63609. }
  63610. declare module "babylonjs/Particles/particleHelper" {
  63611. import { Nullable } from "babylonjs/types";
  63612. import { Scene } from "babylonjs/scene";
  63613. import { Vector3 } from "babylonjs/Maths/math.vector";
  63614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63615. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63616. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  63617. /**
  63618. * This class is made for on one-liner static method to help creating particle system set.
  63619. */
  63620. export class ParticleHelper {
  63621. /**
  63622. * Gets or sets base Assets URL
  63623. */
  63624. static BaseAssetsUrl: string;
  63625. /**
  63626. * Create a default particle system that you can tweak
  63627. * @param emitter defines the emitter to use
  63628. * @param capacity defines the system capacity (default is 500 particles)
  63629. * @param scene defines the hosting scene
  63630. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63631. * @returns the new Particle system
  63632. */
  63633. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63634. /**
  63635. * This is the main static method (one-liner) of this helper to create different particle systems
  63636. * @param type This string represents the type to the particle system to create
  63637. * @param scene The scene where the particle system should live
  63638. * @param gpu If the system will use gpu
  63639. * @returns the ParticleSystemSet created
  63640. */
  63641. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63642. /**
  63643. * Static function used to export a particle system to a ParticleSystemSet variable.
  63644. * Please note that the emitter shape is not exported
  63645. * @param systems defines the particle systems to export
  63646. * @returns the created particle system set
  63647. */
  63648. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63649. }
  63650. }
  63651. declare module "babylonjs/Particles/particleSystemComponent" {
  63652. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63653. import { Effect } from "babylonjs/Materials/effect";
  63654. import "babylonjs/Shaders/particles.vertex";
  63655. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63656. module "babylonjs/Engines/engine" {
  63657. interface Engine {
  63658. /**
  63659. * Create an effect to use with particle systems.
  63660. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63661. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63662. * @param uniformsNames defines a list of attribute names
  63663. * @param samplers defines an array of string used to represent textures
  63664. * @param defines defines the string containing the defines to use to compile the shaders
  63665. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63666. * @param onCompiled defines a function to call when the effect creation is successful
  63667. * @param onError defines a function to call when the effect creation has failed
  63668. * @returns the new Effect
  63669. */
  63670. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63671. }
  63672. }
  63673. module "babylonjs/Meshes/mesh" {
  63674. interface Mesh {
  63675. /**
  63676. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63677. * @returns an array of IParticleSystem
  63678. */
  63679. getEmittedParticleSystems(): IParticleSystem[];
  63680. /**
  63681. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63682. * @returns an array of IParticleSystem
  63683. */
  63684. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63685. }
  63686. }
  63687. /**
  63688. * @hidden
  63689. */
  63690. export var _IDoNeedToBeInTheBuild: number;
  63691. }
  63692. declare module "babylonjs/Particles/pointsCloudSystem" {
  63693. import { Color4 } from "babylonjs/Maths/math";
  63694. import { Mesh } from "babylonjs/Meshes/mesh";
  63695. import { Scene, IDisposable } from "babylonjs/scene";
  63696. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  63697. /** Defines the 4 color options */
  63698. export enum PointColor {
  63699. /** color value */
  63700. Color = 2,
  63701. /** uv value */
  63702. UV = 1,
  63703. /** random value */
  63704. Random = 0,
  63705. /** stated value */
  63706. Stated = 3
  63707. }
  63708. /**
  63709. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63710. * 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.
  63711. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63712. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63713. *
  63714. * Full documentation here : TO BE ENTERED
  63715. */
  63716. export class PointsCloudSystem implements IDisposable {
  63717. /**
  63718. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63719. * Example : var p = SPS.particles[i];
  63720. */
  63721. particles: CloudPoint[];
  63722. /**
  63723. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63724. */
  63725. nbParticles: number;
  63726. /**
  63727. * This a counter for your own usage. It's not set by any SPS functions.
  63728. */
  63729. counter: number;
  63730. /**
  63731. * The PCS name. This name is also given to the underlying mesh.
  63732. */
  63733. name: string;
  63734. /**
  63735. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63736. */
  63737. mesh: Mesh;
  63738. /**
  63739. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63740. * Please read :
  63741. */
  63742. vars: any;
  63743. /**
  63744. * @hidden
  63745. */
  63746. _size: number;
  63747. private _scene;
  63748. private _promises;
  63749. private _positions;
  63750. private _indices;
  63751. private _normals;
  63752. private _colors;
  63753. private _uvs;
  63754. private _indices32;
  63755. private _positions32;
  63756. private _colors32;
  63757. private _uvs32;
  63758. private _updatable;
  63759. private _isVisibilityBoxLocked;
  63760. private _alwaysVisible;
  63761. private _groups;
  63762. private _groupCounter;
  63763. private _computeParticleColor;
  63764. private _computeParticleTexture;
  63765. private _computeParticleRotation;
  63766. private _computeBoundingBox;
  63767. private _isReady;
  63768. /**
  63769. * Creates a PCS (Points Cloud System) object
  63770. * @param name (String) is the PCS name, this will be the underlying mesh name
  63771. * @param pointSize (number) is the size for each point
  63772. * @param scene (Scene) is the scene in which the PCS is added
  63773. * @param options defines the options of the PCS e.g.
  63774. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63775. */
  63776. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63777. updatable?: boolean;
  63778. });
  63779. /**
  63780. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63781. * If no points were added to the PCS, the returned mesh is just a single point.
  63782. * @returns a promise for the created mesh
  63783. */
  63784. buildMeshAsync(): Promise<Mesh>;
  63785. /**
  63786. * @hidden
  63787. */
  63788. private _buildMesh;
  63789. private _addParticle;
  63790. private _randomUnitVector;
  63791. private _getColorIndicesForCoord;
  63792. private _setPointsColorOrUV;
  63793. private _colorFromTexture;
  63794. private _calculateDensity;
  63795. /**
  63796. * Adds points to the PCS in random positions within a unit sphere
  63797. * @param nb (positive integer) the number of particles to be created from this model
  63798. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63799. * @returns the number of groups in the system
  63800. */
  63801. addPoints(nb: number, pointFunction?: any): number;
  63802. /**
  63803. * Adds points to the PCS from the surface of the model shape
  63804. * @param mesh is any Mesh object that will be used as a surface model for the points
  63805. * @param nb (positive integer) the number of particles to be created from this model
  63806. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63807. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63808. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63809. * @returns the number of groups in the system
  63810. */
  63811. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63812. /**
  63813. * Adds points to the PCS inside the model shape
  63814. * @param mesh is any Mesh object that will be used as a surface model for the points
  63815. * @param nb (positive integer) the number of particles to be created from this model
  63816. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63817. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63818. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63819. * @returns the number of groups in the system
  63820. */
  63821. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63822. /**
  63823. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63824. * This method calls `updateParticle()` for each particle of the SPS.
  63825. * For an animated SPS, it is usually called within the render loop.
  63826. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63827. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63828. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63829. * @returns the PCS.
  63830. */
  63831. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63832. /**
  63833. * Disposes the PCS.
  63834. */
  63835. dispose(): void;
  63836. /**
  63837. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63838. * doc :
  63839. * @returns the PCS.
  63840. */
  63841. refreshVisibleSize(): PointsCloudSystem;
  63842. /**
  63843. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63844. * @param size the size (float) of the visibility box
  63845. * note : this doesn't lock the PCS mesh bounding box.
  63846. * doc :
  63847. */
  63848. setVisibilityBox(size: number): void;
  63849. /**
  63850. * Gets whether the PCS is always visible or not
  63851. * doc :
  63852. */
  63853. /**
  63854. * Sets the PCS as always visible or not
  63855. * doc :
  63856. */
  63857. isAlwaysVisible: boolean;
  63858. /**
  63859. * Tells to `setParticles()` to compute the particle rotations or not
  63860. * Default value : false. The PCS is faster when it's set to false
  63861. * Note : particle rotations are only applied to parent particles
  63862. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63863. */
  63864. computeParticleRotation: boolean;
  63865. /**
  63866. * Tells to `setParticles()` to compute the particle colors or not.
  63867. * Default value : true. The PCS is faster when it's set to false.
  63868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63869. */
  63870. /**
  63871. * Gets if `setParticles()` computes the particle colors or not.
  63872. * Default value : false. The PCS is faster when it's set to false.
  63873. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63874. */
  63875. computeParticleColor: boolean;
  63876. /**
  63877. * Gets if `setParticles()` computes the particle textures or not.
  63878. * Default value : false. The PCS is faster when it's set to false.
  63879. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63880. */
  63881. computeParticleTexture: boolean;
  63882. /**
  63883. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63884. */
  63885. /**
  63886. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63887. */
  63888. computeBoundingBox: boolean;
  63889. /**
  63890. * This function does nothing. It may be overwritten to set all the particle first values.
  63891. * The PCS doesn't call this function, you may have to call it by your own.
  63892. * doc :
  63893. */
  63894. initParticles(): void;
  63895. /**
  63896. * This function does nothing. It may be overwritten to recycle a particle
  63897. * The PCS doesn't call this function, you can to call it
  63898. * doc :
  63899. * @param particle The particle to recycle
  63900. * @returns the recycled particle
  63901. */
  63902. recycleParticle(particle: CloudPoint): CloudPoint;
  63903. /**
  63904. * Updates a particle : this function should be overwritten by the user.
  63905. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63906. * doc :
  63907. * @example : just set a particle position or velocity and recycle conditions
  63908. * @param particle The particle to update
  63909. * @returns the updated particle
  63910. */
  63911. updateParticle(particle: CloudPoint): CloudPoint;
  63912. /**
  63913. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63914. * This does nothing and may be overwritten by the user.
  63915. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63917. * @param update the boolean update value actually passed to setParticles()
  63918. */
  63919. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63920. /**
  63921. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63922. * This will be passed three parameters.
  63923. * This does nothing and may be overwritten by the user.
  63924. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63925. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63926. * @param update the boolean update value actually passed to setParticles()
  63927. */
  63928. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63929. }
  63930. }
  63931. declare module "babylonjs/Particles/cloudPoint" {
  63932. import { Nullable } from "babylonjs/types";
  63933. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63934. import { Mesh } from "babylonjs/Meshes/mesh";
  63935. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63936. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63937. /**
  63938. * Represents one particle of a points cloud system.
  63939. */
  63940. export class CloudPoint {
  63941. /**
  63942. * particle global index
  63943. */
  63944. idx: number;
  63945. /**
  63946. * The color of the particle
  63947. */
  63948. color: Nullable<Color4>;
  63949. /**
  63950. * The world space position of the particle.
  63951. */
  63952. position: Vector3;
  63953. /**
  63954. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63955. */
  63956. rotation: Vector3;
  63957. /**
  63958. * The world space rotation quaternion of the particle.
  63959. */
  63960. rotationQuaternion: Nullable<Quaternion>;
  63961. /**
  63962. * The uv of the particle.
  63963. */
  63964. uv: Nullable<Vector2>;
  63965. /**
  63966. * The current speed of the particle.
  63967. */
  63968. velocity: Vector3;
  63969. /**
  63970. * The pivot point in the particle local space.
  63971. */
  63972. pivot: Vector3;
  63973. /**
  63974. * Must the particle be translated from its pivot point in its local space ?
  63975. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63976. * Default : false
  63977. */
  63978. translateFromPivot: boolean;
  63979. /**
  63980. * Index of this particle in the global "positions" array (Internal use)
  63981. * @hidden
  63982. */
  63983. _pos: number;
  63984. /**
  63985. * @hidden Index of this particle in the global "indices" array (Internal use)
  63986. */
  63987. _ind: number;
  63988. /**
  63989. * Group this particle belongs to
  63990. */
  63991. _group: PointsGroup;
  63992. /**
  63993. * Group id of this particle
  63994. */
  63995. groupId: number;
  63996. /**
  63997. * Index of the particle in its group id (Internal use)
  63998. */
  63999. idxInGroup: number;
  64000. /**
  64001. * @hidden Particle BoundingInfo object (Internal use)
  64002. */
  64003. _boundingInfo: BoundingInfo;
  64004. /**
  64005. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64006. */
  64007. _pcs: PointsCloudSystem;
  64008. /**
  64009. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64010. */
  64011. _stillInvisible: boolean;
  64012. /**
  64013. * @hidden Last computed particle rotation matrix
  64014. */
  64015. _rotationMatrix: number[];
  64016. /**
  64017. * Parent particle Id, if any.
  64018. * Default null.
  64019. */
  64020. parentId: Nullable<number>;
  64021. /**
  64022. * @hidden Internal global position in the PCS.
  64023. */
  64024. _globalPosition: Vector3;
  64025. /**
  64026. * Creates a Point Cloud object.
  64027. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64028. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64029. * @param group (PointsGroup) is the group the particle belongs to
  64030. * @param groupId (integer) is the group identifier in the PCS.
  64031. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64032. * @param pcs defines the PCS it is associated to
  64033. */
  64034. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64035. /**
  64036. * get point size
  64037. */
  64038. /**
  64039. * Set point size
  64040. */
  64041. size: Vector3;
  64042. /**
  64043. * Legacy support, changed quaternion to rotationQuaternion
  64044. */
  64045. /**
  64046. * Legacy support, changed quaternion to rotationQuaternion
  64047. */
  64048. quaternion: Nullable<Quaternion>;
  64049. /**
  64050. * Returns a boolean. True if the particle intersects a mesh, else false
  64051. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64052. * @param target is the object (point or mesh) what the intersection is computed against
  64053. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64054. * @returns true if it intersects
  64055. */
  64056. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64057. /**
  64058. * get the rotation matrix of the particle
  64059. * @hidden
  64060. */
  64061. getRotationMatrix(m: Matrix): void;
  64062. }
  64063. /**
  64064. * Represents a group of points in a points cloud system
  64065. * * PCS internal tool, don't use it manually.
  64066. */
  64067. export class PointsGroup {
  64068. /**
  64069. * The group id
  64070. * @hidden
  64071. */
  64072. groupID: number;
  64073. /**
  64074. * image data for group (internal use)
  64075. * @hidden
  64076. */
  64077. _groupImageData: Nullable<ArrayBufferView>;
  64078. /**
  64079. * Image Width (internal use)
  64080. * @hidden
  64081. */
  64082. _groupImgWidth: number;
  64083. /**
  64084. * Image Height (internal use)
  64085. * @hidden
  64086. */
  64087. _groupImgHeight: number;
  64088. /**
  64089. * Custom position function (internal use)
  64090. * @hidden
  64091. */
  64092. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64093. /**
  64094. * density per facet for surface points
  64095. * @hidden
  64096. */
  64097. _groupDensity: number[];
  64098. /**
  64099. * Only when points are colored by texture carries pointer to texture list array
  64100. * @hidden
  64101. */
  64102. _textureNb: number;
  64103. /**
  64104. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64105. * PCS internal tool, don't use it manually.
  64106. * @hidden
  64107. */
  64108. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64109. }
  64110. }
  64111. declare module "babylonjs/Particles/index" {
  64112. export * from "babylonjs/Particles/baseParticleSystem";
  64113. export * from "babylonjs/Particles/EmitterTypes/index";
  64114. export * from "babylonjs/Particles/gpuParticleSystem";
  64115. export * from "babylonjs/Particles/IParticleSystem";
  64116. export * from "babylonjs/Particles/particle";
  64117. export * from "babylonjs/Particles/particleHelper";
  64118. export * from "babylonjs/Particles/particleSystem";
  64119. export * from "babylonjs/Particles/particleSystemComponent";
  64120. export * from "babylonjs/Particles/particleSystemSet";
  64121. export * from "babylonjs/Particles/solidParticle";
  64122. export * from "babylonjs/Particles/solidParticleSystem";
  64123. export * from "babylonjs/Particles/cloudPoint";
  64124. export * from "babylonjs/Particles/pointsCloudSystem";
  64125. export * from "babylonjs/Particles/subEmitter";
  64126. }
  64127. declare module "babylonjs/Physics/physicsEngineComponent" {
  64128. import { Nullable } from "babylonjs/types";
  64129. import { Observable, Observer } from "babylonjs/Misc/observable";
  64130. import { Vector3 } from "babylonjs/Maths/math.vector";
  64131. import { Mesh } from "babylonjs/Meshes/mesh";
  64132. import { ISceneComponent } from "babylonjs/sceneComponent";
  64133. import { Scene } from "babylonjs/scene";
  64134. import { Node } from "babylonjs/node";
  64135. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64136. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64137. module "babylonjs/scene" {
  64138. interface Scene {
  64139. /** @hidden (Backing field) */
  64140. _physicsEngine: Nullable<IPhysicsEngine>;
  64141. /** @hidden */
  64142. _physicsTimeAccumulator: number;
  64143. /**
  64144. * Gets the current physics engine
  64145. * @returns a IPhysicsEngine or null if none attached
  64146. */
  64147. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64148. /**
  64149. * Enables physics to the current scene
  64150. * @param gravity defines the scene's gravity for the physics engine
  64151. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64152. * @return a boolean indicating if the physics engine was initialized
  64153. */
  64154. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64155. /**
  64156. * Disables and disposes the physics engine associated with the scene
  64157. */
  64158. disablePhysicsEngine(): void;
  64159. /**
  64160. * Gets a boolean indicating if there is an active physics engine
  64161. * @returns a boolean indicating if there is an active physics engine
  64162. */
  64163. isPhysicsEnabled(): boolean;
  64164. /**
  64165. * Deletes a physics compound impostor
  64166. * @param compound defines the compound to delete
  64167. */
  64168. deleteCompoundImpostor(compound: any): void;
  64169. /**
  64170. * An event triggered when physic simulation is about to be run
  64171. */
  64172. onBeforePhysicsObservable: Observable<Scene>;
  64173. /**
  64174. * An event triggered when physic simulation has been done
  64175. */
  64176. onAfterPhysicsObservable: Observable<Scene>;
  64177. }
  64178. }
  64179. module "babylonjs/Meshes/abstractMesh" {
  64180. interface AbstractMesh {
  64181. /** @hidden */
  64182. _physicsImpostor: Nullable<PhysicsImpostor>;
  64183. /**
  64184. * Gets or sets impostor used for physic simulation
  64185. * @see http://doc.babylonjs.com/features/physics_engine
  64186. */
  64187. physicsImpostor: Nullable<PhysicsImpostor>;
  64188. /**
  64189. * Gets the current physics impostor
  64190. * @see http://doc.babylonjs.com/features/physics_engine
  64191. * @returns a physics impostor or null
  64192. */
  64193. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64194. /** Apply a physic impulse to the mesh
  64195. * @param force defines the force to apply
  64196. * @param contactPoint defines where to apply the force
  64197. * @returns the current mesh
  64198. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64199. */
  64200. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64201. /**
  64202. * Creates a physic joint between two meshes
  64203. * @param otherMesh defines the other mesh to use
  64204. * @param pivot1 defines the pivot to use on this mesh
  64205. * @param pivot2 defines the pivot to use on the other mesh
  64206. * @param options defines additional options (can be plugin dependent)
  64207. * @returns the current mesh
  64208. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64209. */
  64210. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64211. /** @hidden */
  64212. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64213. }
  64214. }
  64215. /**
  64216. * Defines the physics engine scene component responsible to manage a physics engine
  64217. */
  64218. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64219. /**
  64220. * The component name helpful to identify the component in the list of scene components.
  64221. */
  64222. readonly name: string;
  64223. /**
  64224. * The scene the component belongs to.
  64225. */
  64226. scene: Scene;
  64227. /**
  64228. * Creates a new instance of the component for the given scene
  64229. * @param scene Defines the scene to register the component in
  64230. */
  64231. constructor(scene: Scene);
  64232. /**
  64233. * Registers the component in a given scene
  64234. */
  64235. register(): void;
  64236. /**
  64237. * Rebuilds the elements related to this component in case of
  64238. * context lost for instance.
  64239. */
  64240. rebuild(): void;
  64241. /**
  64242. * Disposes the component and the associated ressources
  64243. */
  64244. dispose(): void;
  64245. }
  64246. }
  64247. declare module "babylonjs/Physics/physicsHelper" {
  64248. import { Nullable } from "babylonjs/types";
  64249. import { Vector3 } from "babylonjs/Maths/math.vector";
  64250. import { Mesh } from "babylonjs/Meshes/mesh";
  64251. import { Scene } from "babylonjs/scene";
  64252. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64253. /**
  64254. * A helper for physics simulations
  64255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64256. */
  64257. export class PhysicsHelper {
  64258. private _scene;
  64259. private _physicsEngine;
  64260. /**
  64261. * Initializes the Physics helper
  64262. * @param scene Babylon.js scene
  64263. */
  64264. constructor(scene: Scene);
  64265. /**
  64266. * Applies a radial explosion impulse
  64267. * @param origin the origin of the explosion
  64268. * @param radiusOrEventOptions the radius or the options of radial explosion
  64269. * @param strength the explosion strength
  64270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64271. * @returns A physics radial explosion event, or null
  64272. */
  64273. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64274. /**
  64275. * Applies a radial explosion force
  64276. * @param origin the origin of the explosion
  64277. * @param radiusOrEventOptions the radius or the options of radial explosion
  64278. * @param strength the explosion strength
  64279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64280. * @returns A physics radial explosion event, or null
  64281. */
  64282. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64283. /**
  64284. * Creates a gravitational field
  64285. * @param origin the origin of the explosion
  64286. * @param radiusOrEventOptions the radius or the options of radial explosion
  64287. * @param strength the explosion strength
  64288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64289. * @returns A physics gravitational field event, or null
  64290. */
  64291. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64292. /**
  64293. * Creates a physics updraft event
  64294. * @param origin the origin of the updraft
  64295. * @param radiusOrEventOptions the radius or the options of the updraft
  64296. * @param strength the strength of the updraft
  64297. * @param height the height of the updraft
  64298. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64299. * @returns A physics updraft event, or null
  64300. */
  64301. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64302. /**
  64303. * Creates a physics vortex event
  64304. * @param origin the of the vortex
  64305. * @param radiusOrEventOptions the radius or the options of the vortex
  64306. * @param strength the strength of the vortex
  64307. * @param height the height of the vortex
  64308. * @returns a Physics vortex event, or null
  64309. * A physics vortex event or null
  64310. */
  64311. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64312. }
  64313. /**
  64314. * Represents a physics radial explosion event
  64315. */
  64316. class PhysicsRadialExplosionEvent {
  64317. private _scene;
  64318. private _options;
  64319. private _sphere;
  64320. private _dataFetched;
  64321. /**
  64322. * Initializes a radial explosioin event
  64323. * @param _scene BabylonJS scene
  64324. * @param _options The options for the vortex event
  64325. */
  64326. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64327. /**
  64328. * Returns the data related to the radial explosion event (sphere).
  64329. * @returns The radial explosion event data
  64330. */
  64331. getData(): PhysicsRadialExplosionEventData;
  64332. /**
  64333. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64334. * @param impostor A physics imposter
  64335. * @param origin the origin of the explosion
  64336. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64337. */
  64338. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64339. /**
  64340. * Triggers affecterd impostors callbacks
  64341. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64342. */
  64343. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64344. /**
  64345. * Disposes the sphere.
  64346. * @param force Specifies if the sphere should be disposed by force
  64347. */
  64348. dispose(force?: boolean): void;
  64349. /*** Helpers ***/
  64350. private _prepareSphere;
  64351. private _intersectsWithSphere;
  64352. }
  64353. /**
  64354. * Represents a gravitational field event
  64355. */
  64356. class PhysicsGravitationalFieldEvent {
  64357. private _physicsHelper;
  64358. private _scene;
  64359. private _origin;
  64360. private _options;
  64361. private _tickCallback;
  64362. private _sphere;
  64363. private _dataFetched;
  64364. /**
  64365. * Initializes the physics gravitational field event
  64366. * @param _physicsHelper A physics helper
  64367. * @param _scene BabylonJS scene
  64368. * @param _origin The origin position of the gravitational field event
  64369. * @param _options The options for the vortex event
  64370. */
  64371. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64372. /**
  64373. * Returns the data related to the gravitational field event (sphere).
  64374. * @returns A gravitational field event
  64375. */
  64376. getData(): PhysicsGravitationalFieldEventData;
  64377. /**
  64378. * Enables the gravitational field.
  64379. */
  64380. enable(): void;
  64381. /**
  64382. * Disables the gravitational field.
  64383. */
  64384. disable(): void;
  64385. /**
  64386. * Disposes the sphere.
  64387. * @param force The force to dispose from the gravitational field event
  64388. */
  64389. dispose(force?: boolean): void;
  64390. private _tick;
  64391. }
  64392. /**
  64393. * Represents a physics updraft event
  64394. */
  64395. class PhysicsUpdraftEvent {
  64396. private _scene;
  64397. private _origin;
  64398. private _options;
  64399. private _physicsEngine;
  64400. private _originTop;
  64401. private _originDirection;
  64402. private _tickCallback;
  64403. private _cylinder;
  64404. private _cylinderPosition;
  64405. private _dataFetched;
  64406. /**
  64407. * Initializes the physics updraft event
  64408. * @param _scene BabylonJS scene
  64409. * @param _origin The origin position of the updraft
  64410. * @param _options The options for the updraft event
  64411. */
  64412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64413. /**
  64414. * Returns the data related to the updraft event (cylinder).
  64415. * @returns A physics updraft event
  64416. */
  64417. getData(): PhysicsUpdraftEventData;
  64418. /**
  64419. * Enables the updraft.
  64420. */
  64421. enable(): void;
  64422. /**
  64423. * Disables the updraft.
  64424. */
  64425. disable(): void;
  64426. /**
  64427. * Disposes the cylinder.
  64428. * @param force Specifies if the updraft should be disposed by force
  64429. */
  64430. dispose(force?: boolean): void;
  64431. private getImpostorHitData;
  64432. private _tick;
  64433. /*** Helpers ***/
  64434. private _prepareCylinder;
  64435. private _intersectsWithCylinder;
  64436. }
  64437. /**
  64438. * Represents a physics vortex event
  64439. */
  64440. class PhysicsVortexEvent {
  64441. private _scene;
  64442. private _origin;
  64443. private _options;
  64444. private _physicsEngine;
  64445. private _originTop;
  64446. private _tickCallback;
  64447. private _cylinder;
  64448. private _cylinderPosition;
  64449. private _dataFetched;
  64450. /**
  64451. * Initializes the physics vortex event
  64452. * @param _scene The BabylonJS scene
  64453. * @param _origin The origin position of the vortex
  64454. * @param _options The options for the vortex event
  64455. */
  64456. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64457. /**
  64458. * Returns the data related to the vortex event (cylinder).
  64459. * @returns The physics vortex event data
  64460. */
  64461. getData(): PhysicsVortexEventData;
  64462. /**
  64463. * Enables the vortex.
  64464. */
  64465. enable(): void;
  64466. /**
  64467. * Disables the cortex.
  64468. */
  64469. disable(): void;
  64470. /**
  64471. * Disposes the sphere.
  64472. * @param force
  64473. */
  64474. dispose(force?: boolean): void;
  64475. private getImpostorHitData;
  64476. private _tick;
  64477. /*** Helpers ***/
  64478. private _prepareCylinder;
  64479. private _intersectsWithCylinder;
  64480. }
  64481. /**
  64482. * Options fot the radial explosion event
  64483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64484. */
  64485. export class PhysicsRadialExplosionEventOptions {
  64486. /**
  64487. * The radius of the sphere for the radial explosion.
  64488. */
  64489. radius: number;
  64490. /**
  64491. * The strenth of the explosion.
  64492. */
  64493. strength: number;
  64494. /**
  64495. * The strenght of the force in correspondence to the distance of the affected object
  64496. */
  64497. falloff: PhysicsRadialImpulseFalloff;
  64498. /**
  64499. * Sphere options for the radial explosion.
  64500. */
  64501. sphere: {
  64502. segments: number;
  64503. diameter: number;
  64504. };
  64505. /**
  64506. * Sphere options for the radial explosion.
  64507. */
  64508. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64509. }
  64510. /**
  64511. * Options fot the updraft event
  64512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64513. */
  64514. export class PhysicsUpdraftEventOptions {
  64515. /**
  64516. * The radius of the cylinder for the vortex
  64517. */
  64518. radius: number;
  64519. /**
  64520. * The strenth of the updraft.
  64521. */
  64522. strength: number;
  64523. /**
  64524. * The height of the cylinder for the updraft.
  64525. */
  64526. height: number;
  64527. /**
  64528. * The mode for the the updraft.
  64529. */
  64530. updraftMode: PhysicsUpdraftMode;
  64531. }
  64532. /**
  64533. * Options fot the vortex event
  64534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64535. */
  64536. export class PhysicsVortexEventOptions {
  64537. /**
  64538. * The radius of the cylinder for the vortex
  64539. */
  64540. radius: number;
  64541. /**
  64542. * The strenth of the vortex.
  64543. */
  64544. strength: number;
  64545. /**
  64546. * The height of the cylinder for the vortex.
  64547. */
  64548. height: number;
  64549. /**
  64550. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64551. */
  64552. centripetalForceThreshold: number;
  64553. /**
  64554. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64555. */
  64556. centripetalForceMultiplier: number;
  64557. /**
  64558. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64559. */
  64560. centrifugalForceMultiplier: number;
  64561. /**
  64562. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64563. */
  64564. updraftForceMultiplier: number;
  64565. }
  64566. /**
  64567. * The strenght of the force in correspondence to the distance of the affected object
  64568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64569. */
  64570. export enum PhysicsRadialImpulseFalloff {
  64571. /** Defines that impulse is constant in strength across it's whole radius */
  64572. Constant = 0,
  64573. /** Defines that impulse gets weaker if it's further from the origin */
  64574. Linear = 1
  64575. }
  64576. /**
  64577. * The strength of the force in correspondence to the distance of the affected object
  64578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64579. */
  64580. export enum PhysicsUpdraftMode {
  64581. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64582. Center = 0,
  64583. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64584. Perpendicular = 1
  64585. }
  64586. /**
  64587. * Interface for a physics hit data
  64588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64589. */
  64590. export interface PhysicsHitData {
  64591. /**
  64592. * The force applied at the contact point
  64593. */
  64594. force: Vector3;
  64595. /**
  64596. * The contact point
  64597. */
  64598. contactPoint: Vector3;
  64599. /**
  64600. * The distance from the origin to the contact point
  64601. */
  64602. distanceFromOrigin: number;
  64603. }
  64604. /**
  64605. * Interface for radial explosion event data
  64606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64607. */
  64608. export interface PhysicsRadialExplosionEventData {
  64609. /**
  64610. * A sphere used for the radial explosion event
  64611. */
  64612. sphere: Mesh;
  64613. }
  64614. /**
  64615. * Interface for gravitational field event data
  64616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64617. */
  64618. export interface PhysicsGravitationalFieldEventData {
  64619. /**
  64620. * A sphere mesh used for the gravitational field event
  64621. */
  64622. sphere: Mesh;
  64623. }
  64624. /**
  64625. * Interface for updraft event data
  64626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64627. */
  64628. export interface PhysicsUpdraftEventData {
  64629. /**
  64630. * A cylinder used for the updraft event
  64631. */
  64632. cylinder: Mesh;
  64633. }
  64634. /**
  64635. * Interface for vortex event data
  64636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64637. */
  64638. export interface PhysicsVortexEventData {
  64639. /**
  64640. * A cylinder used for the vortex event
  64641. */
  64642. cylinder: Mesh;
  64643. }
  64644. /**
  64645. * Interface for an affected physics impostor
  64646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64647. */
  64648. export interface PhysicsAffectedImpostorWithData {
  64649. /**
  64650. * The impostor affected by the effect
  64651. */
  64652. impostor: PhysicsImpostor;
  64653. /**
  64654. * The data about the hit/horce from the explosion
  64655. */
  64656. hitData: PhysicsHitData;
  64657. }
  64658. }
  64659. declare module "babylonjs/Physics/Plugins/index" {
  64660. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  64661. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  64662. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  64663. }
  64664. declare module "babylonjs/Physics/index" {
  64665. export * from "babylonjs/Physics/IPhysicsEngine";
  64666. export * from "babylonjs/Physics/physicsEngine";
  64667. export * from "babylonjs/Physics/physicsEngineComponent";
  64668. export * from "babylonjs/Physics/physicsHelper";
  64669. export * from "babylonjs/Physics/physicsImpostor";
  64670. export * from "babylonjs/Physics/physicsJoint";
  64671. export * from "babylonjs/Physics/Plugins/index";
  64672. }
  64673. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  64674. /** @hidden */
  64675. export var blackAndWhitePixelShader: {
  64676. name: string;
  64677. shader: string;
  64678. };
  64679. }
  64680. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  64681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64682. import { Camera } from "babylonjs/Cameras/camera";
  64683. import { Engine } from "babylonjs/Engines/engine";
  64684. import "babylonjs/Shaders/blackAndWhite.fragment";
  64685. /**
  64686. * Post process used to render in black and white
  64687. */
  64688. export class BlackAndWhitePostProcess extends PostProcess {
  64689. /**
  64690. * Linear about to convert he result to black and white (default: 1)
  64691. */
  64692. degree: number;
  64693. /**
  64694. * Creates a black and white post process
  64695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64696. * @param name The name of the effect.
  64697. * @param options The required width/height ratio to downsize to before computing the render pass.
  64698. * @param camera The camera to apply the render pass to.
  64699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64700. * @param engine The engine which the post process will be applied. (default: current engine)
  64701. * @param reusable If the post process can be reused on the same frame. (default: false)
  64702. */
  64703. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64704. }
  64705. }
  64706. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  64707. import { Nullable } from "babylonjs/types";
  64708. import { Camera } from "babylonjs/Cameras/camera";
  64709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64710. import { Engine } from "babylonjs/Engines/engine";
  64711. /**
  64712. * This represents a set of one or more post processes in Babylon.
  64713. * A post process can be used to apply a shader to a texture after it is rendered.
  64714. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64715. */
  64716. export class PostProcessRenderEffect {
  64717. private _postProcesses;
  64718. private _getPostProcesses;
  64719. private _singleInstance;
  64720. private _cameras;
  64721. private _indicesForCamera;
  64722. /**
  64723. * Name of the effect
  64724. * @hidden
  64725. */
  64726. _name: string;
  64727. /**
  64728. * Instantiates a post process render effect.
  64729. * A post process can be used to apply a shader to a texture after it is rendered.
  64730. * @param engine The engine the effect is tied to
  64731. * @param name The name of the effect
  64732. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64733. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64734. */
  64735. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64736. /**
  64737. * Checks if all the post processes in the effect are supported.
  64738. */
  64739. readonly isSupported: boolean;
  64740. /**
  64741. * Updates the current state of the effect
  64742. * @hidden
  64743. */
  64744. _update(): void;
  64745. /**
  64746. * Attaches the effect on cameras
  64747. * @param cameras The camera to attach to.
  64748. * @hidden
  64749. */
  64750. _attachCameras(cameras: Camera): void;
  64751. /**
  64752. * Attaches the effect on cameras
  64753. * @param cameras The camera to attach to.
  64754. * @hidden
  64755. */
  64756. _attachCameras(cameras: Camera[]): void;
  64757. /**
  64758. * Detaches the effect on cameras
  64759. * @param cameras The camera to detatch from.
  64760. * @hidden
  64761. */
  64762. _detachCameras(cameras: Camera): void;
  64763. /**
  64764. * Detatches the effect on cameras
  64765. * @param cameras The camera to detatch from.
  64766. * @hidden
  64767. */
  64768. _detachCameras(cameras: Camera[]): void;
  64769. /**
  64770. * Enables the effect on given cameras
  64771. * @param cameras The camera to enable.
  64772. * @hidden
  64773. */
  64774. _enable(cameras: Camera): void;
  64775. /**
  64776. * Enables the effect on given cameras
  64777. * @param cameras The camera to enable.
  64778. * @hidden
  64779. */
  64780. _enable(cameras: Nullable<Camera[]>): void;
  64781. /**
  64782. * Disables the effect on the given cameras
  64783. * @param cameras The camera to disable.
  64784. * @hidden
  64785. */
  64786. _disable(cameras: Camera): void;
  64787. /**
  64788. * Disables the effect on the given cameras
  64789. * @param cameras The camera to disable.
  64790. * @hidden
  64791. */
  64792. _disable(cameras: Nullable<Camera[]>): void;
  64793. /**
  64794. * Gets a list of the post processes contained in the effect.
  64795. * @param camera The camera to get the post processes on.
  64796. * @returns The list of the post processes in the effect.
  64797. */
  64798. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64799. }
  64800. }
  64801. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64802. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64803. /** @hidden */
  64804. export var extractHighlightsPixelShader: {
  64805. name: string;
  64806. shader: string;
  64807. };
  64808. }
  64809. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64810. import { Nullable } from "babylonjs/types";
  64811. import { Camera } from "babylonjs/Cameras/camera";
  64812. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64813. import { Engine } from "babylonjs/Engines/engine";
  64814. import "babylonjs/Shaders/extractHighlights.fragment";
  64815. /**
  64816. * 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.
  64817. */
  64818. export class ExtractHighlightsPostProcess extends PostProcess {
  64819. /**
  64820. * The luminance threshold, pixels below this value will be set to black.
  64821. */
  64822. threshold: number;
  64823. /** @hidden */
  64824. _exposure: number;
  64825. /**
  64826. * Post process which has the input texture to be used when performing highlight extraction
  64827. * @hidden
  64828. */
  64829. _inputPostProcess: Nullable<PostProcess>;
  64830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64831. }
  64832. }
  64833. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64834. /** @hidden */
  64835. export var bloomMergePixelShader: {
  64836. name: string;
  64837. shader: string;
  64838. };
  64839. }
  64840. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64842. import { Nullable } from "babylonjs/types";
  64843. import { Engine } from "babylonjs/Engines/engine";
  64844. import { Camera } from "babylonjs/Cameras/camera";
  64845. import "babylonjs/Shaders/bloomMerge.fragment";
  64846. /**
  64847. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64848. */
  64849. export class BloomMergePostProcess extends PostProcess {
  64850. /** Weight of the bloom to be added to the original input. */
  64851. weight: number;
  64852. /**
  64853. * Creates a new instance of @see BloomMergePostProcess
  64854. * @param name The name of the effect.
  64855. * @param originalFromInput Post process which's input will be used for the merge.
  64856. * @param blurred Blurred highlights post process which's output will be used.
  64857. * @param weight Weight of the bloom to be added to the original input.
  64858. * @param options The required width/height ratio to downsize to before computing the render pass.
  64859. * @param camera The camera to apply the render pass to.
  64860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64861. * @param engine The engine which the post process will be applied. (default: current engine)
  64862. * @param reusable If the post process can be reused on the same frame. (default: false)
  64863. * @param textureType Type of textures used when performing the post process. (default: 0)
  64864. * @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)
  64865. */
  64866. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64867. /** Weight of the bloom to be added to the original input. */
  64868. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64869. }
  64870. }
  64871. declare module "babylonjs/PostProcesses/bloomEffect" {
  64872. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64874. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64875. import { Camera } from "babylonjs/Cameras/camera";
  64876. import { Scene } from "babylonjs/scene";
  64877. /**
  64878. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64879. */
  64880. export class BloomEffect extends PostProcessRenderEffect {
  64881. private bloomScale;
  64882. /**
  64883. * @hidden Internal
  64884. */
  64885. _effects: Array<PostProcess>;
  64886. /**
  64887. * @hidden Internal
  64888. */
  64889. _downscale: ExtractHighlightsPostProcess;
  64890. private _blurX;
  64891. private _blurY;
  64892. private _merge;
  64893. /**
  64894. * The luminance threshold to find bright areas of the image to bloom.
  64895. */
  64896. threshold: number;
  64897. /**
  64898. * The strength of the bloom.
  64899. */
  64900. weight: number;
  64901. /**
  64902. * Specifies the size of the bloom blur kernel, relative to the final output size
  64903. */
  64904. kernel: number;
  64905. /**
  64906. * Creates a new instance of @see BloomEffect
  64907. * @param scene The scene the effect belongs to.
  64908. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64909. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64910. * @param bloomWeight The the strength of bloom.
  64911. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64912. * @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)
  64913. */
  64914. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64915. /**
  64916. * Disposes each of the internal effects for a given camera.
  64917. * @param camera The camera to dispose the effect on.
  64918. */
  64919. disposeEffects(camera: Camera): void;
  64920. /**
  64921. * @hidden Internal
  64922. */
  64923. _updateEffects(): void;
  64924. /**
  64925. * Internal
  64926. * @returns if all the contained post processes are ready.
  64927. * @hidden
  64928. */
  64929. _isReady(): boolean;
  64930. }
  64931. }
  64932. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64933. /** @hidden */
  64934. export var chromaticAberrationPixelShader: {
  64935. name: string;
  64936. shader: string;
  64937. };
  64938. }
  64939. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64940. import { Vector2 } from "babylonjs/Maths/math.vector";
  64941. import { Nullable } from "babylonjs/types";
  64942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64943. import { Camera } from "babylonjs/Cameras/camera";
  64944. import { Engine } from "babylonjs/Engines/engine";
  64945. import "babylonjs/Shaders/chromaticAberration.fragment";
  64946. /**
  64947. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64948. */
  64949. export class ChromaticAberrationPostProcess extends PostProcess {
  64950. /**
  64951. * The amount of seperation of rgb channels (default: 30)
  64952. */
  64953. aberrationAmount: number;
  64954. /**
  64955. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64956. */
  64957. radialIntensity: number;
  64958. /**
  64959. * 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))
  64960. */
  64961. direction: Vector2;
  64962. /**
  64963. * 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))
  64964. */
  64965. centerPosition: Vector2;
  64966. /**
  64967. * Creates a new instance ChromaticAberrationPostProcess
  64968. * @param name The name of the effect.
  64969. * @param screenWidth The width of the screen to apply the effect on.
  64970. * @param screenHeight The height of the screen to apply the effect on.
  64971. * @param options The required width/height ratio to downsize to before computing the render pass.
  64972. * @param camera The camera to apply the render pass to.
  64973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64974. * @param engine The engine which the post process will be applied. (default: current engine)
  64975. * @param reusable If the post process can be reused on the same frame. (default: false)
  64976. * @param textureType Type of textures used when performing the post process. (default: 0)
  64977. * @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)
  64978. */
  64979. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64980. }
  64981. }
  64982. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64983. /** @hidden */
  64984. export var circleOfConfusionPixelShader: {
  64985. name: string;
  64986. shader: string;
  64987. };
  64988. }
  64989. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64990. import { Nullable } from "babylonjs/types";
  64991. import { Engine } from "babylonjs/Engines/engine";
  64992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64994. import { Camera } from "babylonjs/Cameras/camera";
  64995. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64996. /**
  64997. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64998. */
  64999. export class CircleOfConfusionPostProcess extends PostProcess {
  65000. /**
  65001. * 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.
  65002. */
  65003. lensSize: number;
  65004. /**
  65005. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65006. */
  65007. fStop: number;
  65008. /**
  65009. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65010. */
  65011. focusDistance: number;
  65012. /**
  65013. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65014. */
  65015. focalLength: number;
  65016. private _depthTexture;
  65017. /**
  65018. * Creates a new instance CircleOfConfusionPostProcess
  65019. * @param name The name of the effect.
  65020. * @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.
  65021. * @param options The required width/height ratio to downsize to before computing the render pass.
  65022. * @param camera The camera to apply the render pass to.
  65023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65024. * @param engine The engine which the post process will be applied. (default: current engine)
  65025. * @param reusable If the post process can be reused on the same frame. (default: false)
  65026. * @param textureType Type of textures used when performing the post process. (default: 0)
  65027. * @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)
  65028. */
  65029. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65030. /**
  65031. * 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.
  65032. */
  65033. depthTexture: RenderTargetTexture;
  65034. }
  65035. }
  65036. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65037. /** @hidden */
  65038. export var colorCorrectionPixelShader: {
  65039. name: string;
  65040. shader: string;
  65041. };
  65042. }
  65043. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65045. import { Engine } from "babylonjs/Engines/engine";
  65046. import { Camera } from "babylonjs/Cameras/camera";
  65047. import "babylonjs/Shaders/colorCorrection.fragment";
  65048. /**
  65049. *
  65050. * This post-process allows the modification of rendered colors by using
  65051. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65052. *
  65053. * The object needs to be provided an url to a texture containing the color
  65054. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65055. * Use an image editing software to tweak the LUT to match your needs.
  65056. *
  65057. * For an example of a color LUT, see here:
  65058. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65059. * For explanations on color grading, see here:
  65060. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65061. *
  65062. */
  65063. export class ColorCorrectionPostProcess extends PostProcess {
  65064. private _colorTableTexture;
  65065. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65066. }
  65067. }
  65068. declare module "babylonjs/Shaders/convolution.fragment" {
  65069. /** @hidden */
  65070. export var convolutionPixelShader: {
  65071. name: string;
  65072. shader: string;
  65073. };
  65074. }
  65075. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65077. import { Nullable } from "babylonjs/types";
  65078. import { Camera } from "babylonjs/Cameras/camera";
  65079. import { Engine } from "babylonjs/Engines/engine";
  65080. import "babylonjs/Shaders/convolution.fragment";
  65081. /**
  65082. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65083. * input texture to perform effects such as edge detection or sharpening
  65084. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65085. */
  65086. export class ConvolutionPostProcess extends PostProcess {
  65087. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65088. kernel: number[];
  65089. /**
  65090. * Creates a new instance ConvolutionPostProcess
  65091. * @param name The name of the effect.
  65092. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65093. * @param options The required width/height ratio to downsize to before computing the render pass.
  65094. * @param camera The camera to apply the render pass to.
  65095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65096. * @param engine The engine which the post process will be applied. (default: current engine)
  65097. * @param reusable If the post process can be reused on the same frame. (default: false)
  65098. * @param textureType Type of textures used when performing the post process. (default: 0)
  65099. */
  65100. constructor(name: string,
  65101. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65102. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65103. /**
  65104. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65105. */
  65106. static EdgeDetect0Kernel: number[];
  65107. /**
  65108. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65109. */
  65110. static EdgeDetect1Kernel: number[];
  65111. /**
  65112. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65113. */
  65114. static EdgeDetect2Kernel: number[];
  65115. /**
  65116. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65117. */
  65118. static SharpenKernel: number[];
  65119. /**
  65120. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65121. */
  65122. static EmbossKernel: number[];
  65123. /**
  65124. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65125. */
  65126. static GaussianKernel: number[];
  65127. }
  65128. }
  65129. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65130. import { Nullable } from "babylonjs/types";
  65131. import { Vector2 } from "babylonjs/Maths/math.vector";
  65132. import { Camera } from "babylonjs/Cameras/camera";
  65133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65134. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65135. import { Engine } from "babylonjs/Engines/engine";
  65136. import { Scene } from "babylonjs/scene";
  65137. /**
  65138. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65139. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65140. * based on samples that have a large difference in distance than the center pixel.
  65141. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65142. */
  65143. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65144. direction: Vector2;
  65145. /**
  65146. * Creates a new instance CircleOfConfusionPostProcess
  65147. * @param name The name of the effect.
  65148. * @param scene The scene the effect belongs to.
  65149. * @param direction The direction the blur should be applied.
  65150. * @param kernel The size of the kernel used to blur.
  65151. * @param options The required width/height ratio to downsize to before computing the render pass.
  65152. * @param camera The camera to apply the render pass to.
  65153. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65154. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65156. * @param engine The engine which the post process will be applied. (default: current engine)
  65157. * @param reusable If the post process can be reused on the same frame. (default: false)
  65158. * @param textureType Type of textures used when performing the post process. (default: 0)
  65159. * @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)
  65160. */
  65161. 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);
  65162. }
  65163. }
  65164. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65165. /** @hidden */
  65166. export var depthOfFieldMergePixelShader: {
  65167. name: string;
  65168. shader: string;
  65169. };
  65170. }
  65171. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65172. import { Nullable } from "babylonjs/types";
  65173. import { Camera } from "babylonjs/Cameras/camera";
  65174. import { Effect } from "babylonjs/Materials/effect";
  65175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65176. import { Engine } from "babylonjs/Engines/engine";
  65177. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65178. /**
  65179. * Options to be set when merging outputs from the default pipeline.
  65180. */
  65181. export class DepthOfFieldMergePostProcessOptions {
  65182. /**
  65183. * The original image to merge on top of
  65184. */
  65185. originalFromInput: PostProcess;
  65186. /**
  65187. * Parameters to perform the merge of the depth of field effect
  65188. */
  65189. depthOfField?: {
  65190. circleOfConfusion: PostProcess;
  65191. blurSteps: Array<PostProcess>;
  65192. };
  65193. /**
  65194. * Parameters to perform the merge of bloom effect
  65195. */
  65196. bloom?: {
  65197. blurred: PostProcess;
  65198. weight: number;
  65199. };
  65200. }
  65201. /**
  65202. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65203. */
  65204. export class DepthOfFieldMergePostProcess extends PostProcess {
  65205. private blurSteps;
  65206. /**
  65207. * Creates a new instance of DepthOfFieldMergePostProcess
  65208. * @param name The name of the effect.
  65209. * @param originalFromInput Post process which's input will be used for the merge.
  65210. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65211. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65212. * @param options The required width/height ratio to downsize to before computing the render pass.
  65213. * @param camera The camera to apply the render pass to.
  65214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65215. * @param engine The engine which the post process will be applied. (default: current engine)
  65216. * @param reusable If the post process can be reused on the same frame. (default: false)
  65217. * @param textureType Type of textures used when performing the post process. (default: 0)
  65218. * @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)
  65219. */
  65220. 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);
  65221. /**
  65222. * Updates the effect with the current post process compile time values and recompiles the shader.
  65223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65226. * @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
  65227. * @param onCompiled Called when the shader has been compiled.
  65228. * @param onError Called if there is an error when compiling a shader.
  65229. */
  65230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65231. }
  65232. }
  65233. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65234. import { Nullable } from "babylonjs/types";
  65235. import { Camera } from "babylonjs/Cameras/camera";
  65236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65238. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65239. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65240. import { Scene } from "babylonjs/scene";
  65241. /**
  65242. * Specifies the level of max blur that should be applied when using the depth of field effect
  65243. */
  65244. export enum DepthOfFieldEffectBlurLevel {
  65245. /**
  65246. * Subtle blur
  65247. */
  65248. Low = 0,
  65249. /**
  65250. * Medium blur
  65251. */
  65252. Medium = 1,
  65253. /**
  65254. * Large blur
  65255. */
  65256. High = 2
  65257. }
  65258. /**
  65259. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65260. */
  65261. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65262. private _circleOfConfusion;
  65263. /**
  65264. * @hidden Internal, blurs from high to low
  65265. */
  65266. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65267. private _depthOfFieldBlurY;
  65268. private _dofMerge;
  65269. /**
  65270. * @hidden Internal post processes in depth of field effect
  65271. */
  65272. _effects: Array<PostProcess>;
  65273. /**
  65274. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65275. */
  65276. focalLength: number;
  65277. /**
  65278. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65279. */
  65280. fStop: number;
  65281. /**
  65282. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65283. */
  65284. focusDistance: number;
  65285. /**
  65286. * 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.
  65287. */
  65288. lensSize: number;
  65289. /**
  65290. * Creates a new instance DepthOfFieldEffect
  65291. * @param scene The scene the effect belongs to.
  65292. * @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.
  65293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65294. * @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)
  65295. */
  65296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65297. /**
  65298. * Get the current class name of the current effet
  65299. * @returns "DepthOfFieldEffect"
  65300. */
  65301. getClassName(): string;
  65302. /**
  65303. * 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.
  65304. */
  65305. depthTexture: RenderTargetTexture;
  65306. /**
  65307. * Disposes each of the internal effects for a given camera.
  65308. * @param camera The camera to dispose the effect on.
  65309. */
  65310. disposeEffects(camera: Camera): void;
  65311. /**
  65312. * @hidden Internal
  65313. */
  65314. _updateEffects(): void;
  65315. /**
  65316. * Internal
  65317. * @returns if all the contained post processes are ready.
  65318. * @hidden
  65319. */
  65320. _isReady(): boolean;
  65321. }
  65322. }
  65323. declare module "babylonjs/Shaders/displayPass.fragment" {
  65324. /** @hidden */
  65325. export var displayPassPixelShader: {
  65326. name: string;
  65327. shader: string;
  65328. };
  65329. }
  65330. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65331. import { Nullable } from "babylonjs/types";
  65332. import { Camera } from "babylonjs/Cameras/camera";
  65333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65334. import { Engine } from "babylonjs/Engines/engine";
  65335. import "babylonjs/Shaders/displayPass.fragment";
  65336. /**
  65337. * DisplayPassPostProcess which produces an output the same as it's input
  65338. */
  65339. export class DisplayPassPostProcess extends PostProcess {
  65340. /**
  65341. * Creates the DisplayPassPostProcess
  65342. * @param name The name of the effect.
  65343. * @param options The required width/height ratio to downsize to before computing the render pass.
  65344. * @param camera The camera to apply the render pass to.
  65345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65346. * @param engine The engine which the post process will be applied. (default: current engine)
  65347. * @param reusable If the post process can be reused on the same frame. (default: false)
  65348. */
  65349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65350. }
  65351. }
  65352. declare module "babylonjs/Shaders/filter.fragment" {
  65353. /** @hidden */
  65354. export var filterPixelShader: {
  65355. name: string;
  65356. shader: string;
  65357. };
  65358. }
  65359. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65360. import { Nullable } from "babylonjs/types";
  65361. import { Matrix } from "babylonjs/Maths/math.vector";
  65362. import { Camera } from "babylonjs/Cameras/camera";
  65363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65364. import { Engine } from "babylonjs/Engines/engine";
  65365. import "babylonjs/Shaders/filter.fragment";
  65366. /**
  65367. * Applies a kernel filter to the image
  65368. */
  65369. export class FilterPostProcess extends PostProcess {
  65370. /** The matrix to be applied to the image */
  65371. kernelMatrix: Matrix;
  65372. /**
  65373. *
  65374. * @param name The name of the effect.
  65375. * @param kernelMatrix The matrix to be applied to the image
  65376. * @param options The required width/height ratio to downsize to before computing the render pass.
  65377. * @param camera The camera to apply the render pass to.
  65378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65379. * @param engine The engine which the post process will be applied. (default: current engine)
  65380. * @param reusable If the post process can be reused on the same frame. (default: false)
  65381. */
  65382. constructor(name: string,
  65383. /** The matrix to be applied to the image */
  65384. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65385. }
  65386. }
  65387. declare module "babylonjs/Shaders/fxaa.fragment" {
  65388. /** @hidden */
  65389. export var fxaaPixelShader: {
  65390. name: string;
  65391. shader: string;
  65392. };
  65393. }
  65394. declare module "babylonjs/Shaders/fxaa.vertex" {
  65395. /** @hidden */
  65396. export var fxaaVertexShader: {
  65397. name: string;
  65398. shader: string;
  65399. };
  65400. }
  65401. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  65402. import { Nullable } from "babylonjs/types";
  65403. import { Camera } from "babylonjs/Cameras/camera";
  65404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65405. import { Engine } from "babylonjs/Engines/engine";
  65406. import "babylonjs/Shaders/fxaa.fragment";
  65407. import "babylonjs/Shaders/fxaa.vertex";
  65408. /**
  65409. * Fxaa post process
  65410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65411. */
  65412. export class FxaaPostProcess extends PostProcess {
  65413. /** @hidden */
  65414. texelWidth: number;
  65415. /** @hidden */
  65416. texelHeight: number;
  65417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65418. private _getDefines;
  65419. }
  65420. }
  65421. declare module "babylonjs/Shaders/grain.fragment" {
  65422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65423. /** @hidden */
  65424. export var grainPixelShader: {
  65425. name: string;
  65426. shader: string;
  65427. };
  65428. }
  65429. declare module "babylonjs/PostProcesses/grainPostProcess" {
  65430. import { Nullable } from "babylonjs/types";
  65431. import { Camera } from "babylonjs/Cameras/camera";
  65432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65433. import { Engine } from "babylonjs/Engines/engine";
  65434. import "babylonjs/Shaders/grain.fragment";
  65435. /**
  65436. * The GrainPostProcess adds noise to the image at mid luminance levels
  65437. */
  65438. export class GrainPostProcess extends PostProcess {
  65439. /**
  65440. * The intensity of the grain added (default: 30)
  65441. */
  65442. intensity: number;
  65443. /**
  65444. * If the grain should be randomized on every frame
  65445. */
  65446. animated: boolean;
  65447. /**
  65448. * Creates a new instance of @see GrainPostProcess
  65449. * @param name The name of the effect.
  65450. * @param options The required width/height ratio to downsize to before computing the render pass.
  65451. * @param camera The camera to apply the render pass to.
  65452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65453. * @param engine The engine which the post process will be applied. (default: current engine)
  65454. * @param reusable If the post process can be reused on the same frame. (default: false)
  65455. * @param textureType Type of textures used when performing the post process. (default: 0)
  65456. * @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)
  65457. */
  65458. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65459. }
  65460. }
  65461. declare module "babylonjs/Shaders/highlights.fragment" {
  65462. /** @hidden */
  65463. export var highlightsPixelShader: {
  65464. name: string;
  65465. shader: string;
  65466. };
  65467. }
  65468. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  65469. import { Nullable } from "babylonjs/types";
  65470. import { Camera } from "babylonjs/Cameras/camera";
  65471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65472. import { Engine } from "babylonjs/Engines/engine";
  65473. import "babylonjs/Shaders/highlights.fragment";
  65474. /**
  65475. * Extracts highlights from the image
  65476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65477. */
  65478. export class HighlightsPostProcess extends PostProcess {
  65479. /**
  65480. * Extracts highlights from the image
  65481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65482. * @param name The name of the effect.
  65483. * @param options The required width/height ratio to downsize to before computing the render pass.
  65484. * @param camera The camera to apply the render pass to.
  65485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65486. * @param engine The engine which the post process will be applied. (default: current engine)
  65487. * @param reusable If the post process can be reused on the same frame. (default: false)
  65488. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65489. */
  65490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65491. }
  65492. }
  65493. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  65494. /** @hidden */
  65495. export var mrtFragmentDeclaration: {
  65496. name: string;
  65497. shader: string;
  65498. };
  65499. }
  65500. declare module "babylonjs/Shaders/geometry.fragment" {
  65501. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  65502. /** @hidden */
  65503. export var geometryPixelShader: {
  65504. name: string;
  65505. shader: string;
  65506. };
  65507. }
  65508. declare module "babylonjs/Shaders/geometry.vertex" {
  65509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65516. /** @hidden */
  65517. export var geometryVertexShader: {
  65518. name: string;
  65519. shader: string;
  65520. };
  65521. }
  65522. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  65523. import { Matrix } from "babylonjs/Maths/math.vector";
  65524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65525. import { Mesh } from "babylonjs/Meshes/mesh";
  65526. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  65527. import { Effect } from "babylonjs/Materials/effect";
  65528. import { Scene } from "babylonjs/scene";
  65529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65530. import "babylonjs/Shaders/geometry.fragment";
  65531. import "babylonjs/Shaders/geometry.vertex";
  65532. /** @hidden */
  65533. interface ISavedTransformationMatrix {
  65534. world: Matrix;
  65535. viewProjection: Matrix;
  65536. }
  65537. /**
  65538. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65539. */
  65540. export class GeometryBufferRenderer {
  65541. /**
  65542. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65543. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65544. */
  65545. static readonly POSITION_TEXTURE_TYPE: number;
  65546. /**
  65547. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65548. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65549. */
  65550. static readonly VELOCITY_TEXTURE_TYPE: number;
  65551. /**
  65552. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65553. * in order to compute objects velocities when enableVelocity is set to "true"
  65554. * @hidden
  65555. */
  65556. _previousTransformationMatrices: {
  65557. [index: number]: ISavedTransformationMatrix;
  65558. };
  65559. /**
  65560. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65561. * in order to compute objects velocities when enableVelocity is set to "true"
  65562. * @hidden
  65563. */
  65564. _previousBonesTransformationMatrices: {
  65565. [index: number]: Float32Array;
  65566. };
  65567. /**
  65568. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65569. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65570. */
  65571. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65572. private _scene;
  65573. private _multiRenderTarget;
  65574. private _ratio;
  65575. private _enablePosition;
  65576. private _enableVelocity;
  65577. private _positionIndex;
  65578. private _velocityIndex;
  65579. protected _effect: Effect;
  65580. protected _cachedDefines: string;
  65581. /**
  65582. * Set the render list (meshes to be rendered) used in the G buffer.
  65583. */
  65584. renderList: Mesh[];
  65585. /**
  65586. * Gets wether or not G buffer are supported by the running hardware.
  65587. * This requires draw buffer supports
  65588. */
  65589. readonly isSupported: boolean;
  65590. /**
  65591. * Returns the index of the given texture type in the G-Buffer textures array
  65592. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65593. * @returns the index of the given texture type in the G-Buffer textures array
  65594. */
  65595. getTextureIndex(textureType: number): number;
  65596. /**
  65597. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65598. */
  65599. /**
  65600. * Sets whether or not objects positions are enabled for the G buffer.
  65601. */
  65602. enablePosition: boolean;
  65603. /**
  65604. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65605. */
  65606. /**
  65607. * Sets wether or not objects velocities are enabled for the G buffer.
  65608. */
  65609. enableVelocity: boolean;
  65610. /**
  65611. * Gets the scene associated with the buffer.
  65612. */
  65613. readonly scene: Scene;
  65614. /**
  65615. * Gets the ratio used by the buffer during its creation.
  65616. * How big is the buffer related to the main canvas.
  65617. */
  65618. readonly ratio: number;
  65619. /** @hidden */
  65620. static _SceneComponentInitialization: (scene: Scene) => void;
  65621. /**
  65622. * Creates a new G Buffer for the scene
  65623. * @param scene The scene the buffer belongs to
  65624. * @param ratio How big is the buffer related to the main canvas.
  65625. */
  65626. constructor(scene: Scene, ratio?: number);
  65627. /**
  65628. * Checks wether everything is ready to render a submesh to the G buffer.
  65629. * @param subMesh the submesh to check readiness for
  65630. * @param useInstances is the mesh drawn using instance or not
  65631. * @returns true if ready otherwise false
  65632. */
  65633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65634. /**
  65635. * Gets the current underlying G Buffer.
  65636. * @returns the buffer
  65637. */
  65638. getGBuffer(): MultiRenderTarget;
  65639. /**
  65640. * Gets the number of samples used to render the buffer (anti aliasing).
  65641. */
  65642. /**
  65643. * Sets the number of samples used to render the buffer (anti aliasing).
  65644. */
  65645. samples: number;
  65646. /**
  65647. * Disposes the renderer and frees up associated resources.
  65648. */
  65649. dispose(): void;
  65650. protected _createRenderTargets(): void;
  65651. private _copyBonesTransformationMatrices;
  65652. }
  65653. }
  65654. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  65655. import { Nullable } from "babylonjs/types";
  65656. import { Scene } from "babylonjs/scene";
  65657. import { ISceneComponent } from "babylonjs/sceneComponent";
  65658. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  65659. module "babylonjs/scene" {
  65660. interface Scene {
  65661. /** @hidden (Backing field) */
  65662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65663. /**
  65664. * Gets or Sets the current geometry buffer associated to the scene.
  65665. */
  65666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65667. /**
  65668. * Enables a GeometryBufferRender and associates it with the scene
  65669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65670. * @returns the GeometryBufferRenderer
  65671. */
  65672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65673. /**
  65674. * Disables the GeometryBufferRender associated with the scene
  65675. */
  65676. disableGeometryBufferRenderer(): void;
  65677. }
  65678. }
  65679. /**
  65680. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65681. * in several rendering techniques.
  65682. */
  65683. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65684. /**
  65685. * The component name helpful to identify the component in the list of scene components.
  65686. */
  65687. readonly name: string;
  65688. /**
  65689. * The scene the component belongs to.
  65690. */
  65691. scene: Scene;
  65692. /**
  65693. * Creates a new instance of the component for the given scene
  65694. * @param scene Defines the scene to register the component in
  65695. */
  65696. constructor(scene: Scene);
  65697. /**
  65698. * Registers the component in a given scene
  65699. */
  65700. register(): void;
  65701. /**
  65702. * Rebuilds the elements related to this component in case of
  65703. * context lost for instance.
  65704. */
  65705. rebuild(): void;
  65706. /**
  65707. * Disposes the component and the associated ressources
  65708. */
  65709. dispose(): void;
  65710. private _gatherRenderTargets;
  65711. }
  65712. }
  65713. declare module "babylonjs/Shaders/motionBlur.fragment" {
  65714. /** @hidden */
  65715. export var motionBlurPixelShader: {
  65716. name: string;
  65717. shader: string;
  65718. };
  65719. }
  65720. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  65721. import { Nullable } from "babylonjs/types";
  65722. import { Camera } from "babylonjs/Cameras/camera";
  65723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65724. import { Scene } from "babylonjs/scene";
  65725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65726. import "babylonjs/Animations/animatable";
  65727. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65728. import "babylonjs/Shaders/motionBlur.fragment";
  65729. import { Engine } from "babylonjs/Engines/engine";
  65730. /**
  65731. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65732. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65733. * As an example, all you have to do is to create the post-process:
  65734. * var mb = new BABYLON.MotionBlurPostProcess(
  65735. * 'mb', // The name of the effect.
  65736. * scene, // The scene containing the objects to blur according to their velocity.
  65737. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65738. * camera // The camera to apply the render pass to.
  65739. * );
  65740. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65741. */
  65742. export class MotionBlurPostProcess extends PostProcess {
  65743. /**
  65744. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65745. */
  65746. motionStrength: number;
  65747. /**
  65748. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65749. */
  65750. /**
  65751. * Sets the number of iterations to be used for motion blur quality
  65752. */
  65753. motionBlurSamples: number;
  65754. private _motionBlurSamples;
  65755. private _geometryBufferRenderer;
  65756. /**
  65757. * Creates a new instance MotionBlurPostProcess
  65758. * @param name The name of the effect.
  65759. * @param scene The scene containing the objects to blur according to their velocity.
  65760. * @param options The required width/height ratio to downsize to before computing the render pass.
  65761. * @param camera The camera to apply the render pass to.
  65762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65763. * @param engine The engine which the post process will be applied. (default: current engine)
  65764. * @param reusable If the post process can be reused on the same frame. (default: false)
  65765. * @param textureType Type of textures used when performing the post process. (default: 0)
  65766. * @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)
  65767. */
  65768. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65769. /**
  65770. * Excludes the given skinned mesh from computing bones velocities.
  65771. * 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.
  65772. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65773. */
  65774. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65775. /**
  65776. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65777. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65778. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65779. */
  65780. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65781. /**
  65782. * Disposes the post process.
  65783. * @param camera The camera to dispose the post process on.
  65784. */
  65785. dispose(camera?: Camera): void;
  65786. }
  65787. }
  65788. declare module "babylonjs/Shaders/refraction.fragment" {
  65789. /** @hidden */
  65790. export var refractionPixelShader: {
  65791. name: string;
  65792. shader: string;
  65793. };
  65794. }
  65795. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65796. import { Color3 } from "babylonjs/Maths/math.color";
  65797. import { Camera } from "babylonjs/Cameras/camera";
  65798. import { Texture } from "babylonjs/Materials/Textures/texture";
  65799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65800. import { Engine } from "babylonjs/Engines/engine";
  65801. import "babylonjs/Shaders/refraction.fragment";
  65802. /**
  65803. * Post process which applies a refractin texture
  65804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65805. */
  65806. export class RefractionPostProcess extends PostProcess {
  65807. /** the base color of the refraction (used to taint the rendering) */
  65808. color: Color3;
  65809. /** simulated refraction depth */
  65810. depth: number;
  65811. /** the coefficient of the base color (0 to remove base color tainting) */
  65812. colorLevel: number;
  65813. private _refTexture;
  65814. private _ownRefractionTexture;
  65815. /**
  65816. * Gets or sets the refraction texture
  65817. * Please note that you are responsible for disposing the texture if you set it manually
  65818. */
  65819. refractionTexture: Texture;
  65820. /**
  65821. * Initializes the RefractionPostProcess
  65822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65823. * @param name The name of the effect.
  65824. * @param refractionTextureUrl Url of the refraction texture to use
  65825. * @param color the base color of the refraction (used to taint the rendering)
  65826. * @param depth simulated refraction depth
  65827. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65828. * @param camera The camera to apply the render pass to.
  65829. * @param options The required width/height ratio to downsize to before computing the render pass.
  65830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65831. * @param engine The engine which the post process will be applied. (default: current engine)
  65832. * @param reusable If the post process can be reused on the same frame. (default: false)
  65833. */
  65834. constructor(name: string, refractionTextureUrl: string,
  65835. /** the base color of the refraction (used to taint the rendering) */
  65836. color: Color3,
  65837. /** simulated refraction depth */
  65838. depth: number,
  65839. /** the coefficient of the base color (0 to remove base color tainting) */
  65840. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65841. /**
  65842. * Disposes of the post process
  65843. * @param camera Camera to dispose post process on
  65844. */
  65845. dispose(camera: Camera): void;
  65846. }
  65847. }
  65848. declare module "babylonjs/Shaders/sharpen.fragment" {
  65849. /** @hidden */
  65850. export var sharpenPixelShader: {
  65851. name: string;
  65852. shader: string;
  65853. };
  65854. }
  65855. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65856. import { Nullable } from "babylonjs/types";
  65857. import { Camera } from "babylonjs/Cameras/camera";
  65858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65859. import "babylonjs/Shaders/sharpen.fragment";
  65860. import { Engine } from "babylonjs/Engines/engine";
  65861. /**
  65862. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65863. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65864. */
  65865. export class SharpenPostProcess extends PostProcess {
  65866. /**
  65867. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65868. */
  65869. colorAmount: number;
  65870. /**
  65871. * How much sharpness should be applied (default: 0.3)
  65872. */
  65873. edgeAmount: number;
  65874. /**
  65875. * Creates a new instance ConvolutionPostProcess
  65876. * @param name The name of the effect.
  65877. * @param options The required width/height ratio to downsize to before computing the render pass.
  65878. * @param camera The camera to apply the render pass to.
  65879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65880. * @param engine The engine which the post process will be applied. (default: current engine)
  65881. * @param reusable If the post process can be reused on the same frame. (default: false)
  65882. * @param textureType Type of textures used when performing the post process. (default: 0)
  65883. * @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)
  65884. */
  65885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65886. }
  65887. }
  65888. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65889. import { Nullable } from "babylonjs/types";
  65890. import { Camera } from "babylonjs/Cameras/camera";
  65891. import { Engine } from "babylonjs/Engines/engine";
  65892. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65893. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65894. /**
  65895. * PostProcessRenderPipeline
  65896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65897. */
  65898. export class PostProcessRenderPipeline {
  65899. private engine;
  65900. private _renderEffects;
  65901. private _renderEffectsForIsolatedPass;
  65902. /**
  65903. * List of inspectable custom properties (used by the Inspector)
  65904. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65905. */
  65906. inspectableCustomProperties: IInspectable[];
  65907. /**
  65908. * @hidden
  65909. */
  65910. protected _cameras: Camera[];
  65911. /** @hidden */
  65912. _name: string;
  65913. /**
  65914. * Gets pipeline name
  65915. */
  65916. readonly name: string;
  65917. /** Gets the list of attached cameras */
  65918. readonly cameras: Camera[];
  65919. /**
  65920. * Initializes a PostProcessRenderPipeline
  65921. * @param engine engine to add the pipeline to
  65922. * @param name name of the pipeline
  65923. */
  65924. constructor(engine: Engine, name: string);
  65925. /**
  65926. * Gets the class name
  65927. * @returns "PostProcessRenderPipeline"
  65928. */
  65929. getClassName(): string;
  65930. /**
  65931. * If all the render effects in the pipeline are supported
  65932. */
  65933. readonly isSupported: boolean;
  65934. /**
  65935. * Adds an effect to the pipeline
  65936. * @param renderEffect the effect to add
  65937. */
  65938. addEffect(renderEffect: PostProcessRenderEffect): void;
  65939. /** @hidden */
  65940. _rebuild(): void;
  65941. /** @hidden */
  65942. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65943. /** @hidden */
  65944. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65945. /** @hidden */
  65946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65947. /** @hidden */
  65948. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65949. /** @hidden */
  65950. _attachCameras(cameras: Camera, unique: boolean): void;
  65951. /** @hidden */
  65952. _attachCameras(cameras: Camera[], unique: boolean): void;
  65953. /** @hidden */
  65954. _detachCameras(cameras: Camera): void;
  65955. /** @hidden */
  65956. _detachCameras(cameras: Nullable<Camera[]>): void;
  65957. /** @hidden */
  65958. _update(): void;
  65959. /** @hidden */
  65960. _reset(): void;
  65961. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65962. /**
  65963. * Disposes of the pipeline
  65964. */
  65965. dispose(): void;
  65966. }
  65967. }
  65968. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65969. import { Camera } from "babylonjs/Cameras/camera";
  65970. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65971. /**
  65972. * PostProcessRenderPipelineManager class
  65973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65974. */
  65975. export class PostProcessRenderPipelineManager {
  65976. private _renderPipelines;
  65977. /**
  65978. * Initializes a PostProcessRenderPipelineManager
  65979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65980. */
  65981. constructor();
  65982. /**
  65983. * Gets the list of supported render pipelines
  65984. */
  65985. readonly supportedPipelines: PostProcessRenderPipeline[];
  65986. /**
  65987. * Adds a pipeline to the manager
  65988. * @param renderPipeline The pipeline to add
  65989. */
  65990. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65991. /**
  65992. * Attaches a camera to the pipeline
  65993. * @param renderPipelineName The name of the pipeline to attach to
  65994. * @param cameras the camera to attach
  65995. * @param unique if the camera can be attached multiple times to the pipeline
  65996. */
  65997. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65998. /**
  65999. * Detaches a camera from the pipeline
  66000. * @param renderPipelineName The name of the pipeline to detach from
  66001. * @param cameras the camera to detach
  66002. */
  66003. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66004. /**
  66005. * Enables an effect by name on a pipeline
  66006. * @param renderPipelineName the name of the pipeline to enable the effect in
  66007. * @param renderEffectName the name of the effect to enable
  66008. * @param cameras the cameras that the effect should be enabled on
  66009. */
  66010. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66011. /**
  66012. * Disables an effect by name on a pipeline
  66013. * @param renderPipelineName the name of the pipeline to disable the effect in
  66014. * @param renderEffectName the name of the effect to disable
  66015. * @param cameras the cameras that the effect should be disabled on
  66016. */
  66017. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66018. /**
  66019. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66020. */
  66021. update(): void;
  66022. /** @hidden */
  66023. _rebuild(): void;
  66024. /**
  66025. * Disposes of the manager and pipelines
  66026. */
  66027. dispose(): void;
  66028. }
  66029. }
  66030. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66031. import { ISceneComponent } from "babylonjs/sceneComponent";
  66032. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66033. import { Scene } from "babylonjs/scene";
  66034. module "babylonjs/scene" {
  66035. interface Scene {
  66036. /** @hidden (Backing field) */
  66037. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66038. /**
  66039. * Gets the postprocess render pipeline manager
  66040. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66041. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66042. */
  66043. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66044. }
  66045. }
  66046. /**
  66047. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66048. */
  66049. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66050. /**
  66051. * The component name helpfull to identify the component in the list of scene components.
  66052. */
  66053. readonly name: string;
  66054. /**
  66055. * The scene the component belongs to.
  66056. */
  66057. scene: Scene;
  66058. /**
  66059. * Creates a new instance of the component for the given scene
  66060. * @param scene Defines the scene to register the component in
  66061. */
  66062. constructor(scene: Scene);
  66063. /**
  66064. * Registers the component in a given scene
  66065. */
  66066. register(): void;
  66067. /**
  66068. * Rebuilds the elements related to this component in case of
  66069. * context lost for instance.
  66070. */
  66071. rebuild(): void;
  66072. /**
  66073. * Disposes the component and the associated ressources
  66074. */
  66075. dispose(): void;
  66076. private _gatherRenderTargets;
  66077. }
  66078. }
  66079. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66080. import { Nullable } from "babylonjs/types";
  66081. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66082. import { Camera } from "babylonjs/Cameras/camera";
  66083. import { IDisposable } from "babylonjs/scene";
  66084. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66085. import { Scene } from "babylonjs/scene";
  66086. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66087. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66088. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66089. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66090. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66091. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66092. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66093. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66094. import { Animation } from "babylonjs/Animations/animation";
  66095. /**
  66096. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66097. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66098. */
  66099. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66100. private _scene;
  66101. private _camerasToBeAttached;
  66102. /**
  66103. * ID of the sharpen post process,
  66104. */
  66105. private readonly SharpenPostProcessId;
  66106. /**
  66107. * @ignore
  66108. * ID of the image processing post process;
  66109. */
  66110. readonly ImageProcessingPostProcessId: string;
  66111. /**
  66112. * @ignore
  66113. * ID of the Fast Approximate Anti-Aliasing post process;
  66114. */
  66115. readonly FxaaPostProcessId: string;
  66116. /**
  66117. * ID of the chromatic aberration post process,
  66118. */
  66119. private readonly ChromaticAberrationPostProcessId;
  66120. /**
  66121. * ID of the grain post process
  66122. */
  66123. private readonly GrainPostProcessId;
  66124. /**
  66125. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66126. */
  66127. sharpen: SharpenPostProcess;
  66128. private _sharpenEffect;
  66129. private bloom;
  66130. /**
  66131. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66132. */
  66133. depthOfField: DepthOfFieldEffect;
  66134. /**
  66135. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66136. */
  66137. fxaa: FxaaPostProcess;
  66138. /**
  66139. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66140. */
  66141. imageProcessing: ImageProcessingPostProcess;
  66142. /**
  66143. * Chromatic aberration post process which will shift rgb colors in the image
  66144. */
  66145. chromaticAberration: ChromaticAberrationPostProcess;
  66146. private _chromaticAberrationEffect;
  66147. /**
  66148. * Grain post process which add noise to the image
  66149. */
  66150. grain: GrainPostProcess;
  66151. private _grainEffect;
  66152. /**
  66153. * Glow post process which adds a glow to emissive areas of the image
  66154. */
  66155. private _glowLayer;
  66156. /**
  66157. * Animations which can be used to tweak settings over a period of time
  66158. */
  66159. animations: Animation[];
  66160. private _imageProcessingConfigurationObserver;
  66161. private _sharpenEnabled;
  66162. private _bloomEnabled;
  66163. private _depthOfFieldEnabled;
  66164. private _depthOfFieldBlurLevel;
  66165. private _fxaaEnabled;
  66166. private _imageProcessingEnabled;
  66167. private _defaultPipelineTextureType;
  66168. private _bloomScale;
  66169. private _chromaticAberrationEnabled;
  66170. private _grainEnabled;
  66171. private _buildAllowed;
  66172. /**
  66173. * Gets active scene
  66174. */
  66175. readonly scene: Scene;
  66176. /**
  66177. * Enable or disable the sharpen process from the pipeline
  66178. */
  66179. sharpenEnabled: boolean;
  66180. private _resizeObserver;
  66181. private _hardwareScaleLevel;
  66182. private _bloomKernel;
  66183. /**
  66184. * Specifies the size of the bloom blur kernel, relative to the final output size
  66185. */
  66186. bloomKernel: number;
  66187. /**
  66188. * Specifies the weight of the bloom in the final rendering
  66189. */
  66190. private _bloomWeight;
  66191. /**
  66192. * Specifies the luma threshold for the area that will be blurred by the bloom
  66193. */
  66194. private _bloomThreshold;
  66195. private _hdr;
  66196. /**
  66197. * The strength of the bloom.
  66198. */
  66199. bloomWeight: number;
  66200. /**
  66201. * The strength of the bloom.
  66202. */
  66203. bloomThreshold: number;
  66204. /**
  66205. * The scale of the bloom, lower value will provide better performance.
  66206. */
  66207. bloomScale: number;
  66208. /**
  66209. * Enable or disable the bloom from the pipeline
  66210. */
  66211. bloomEnabled: boolean;
  66212. private _rebuildBloom;
  66213. /**
  66214. * If the depth of field is enabled.
  66215. */
  66216. depthOfFieldEnabled: boolean;
  66217. /**
  66218. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66219. */
  66220. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  66221. /**
  66222. * If the anti aliasing is enabled.
  66223. */
  66224. fxaaEnabled: boolean;
  66225. private _samples;
  66226. /**
  66227. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66228. */
  66229. samples: number;
  66230. /**
  66231. * If image processing is enabled.
  66232. */
  66233. imageProcessingEnabled: boolean;
  66234. /**
  66235. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66236. */
  66237. glowLayerEnabled: boolean;
  66238. /**
  66239. * Gets the glow layer (or null if not defined)
  66240. */
  66241. readonly glowLayer: Nullable<GlowLayer>;
  66242. /**
  66243. * Enable or disable the chromaticAberration process from the pipeline
  66244. */
  66245. chromaticAberrationEnabled: boolean;
  66246. /**
  66247. * Enable or disable the grain process from the pipeline
  66248. */
  66249. grainEnabled: boolean;
  66250. /**
  66251. * @constructor
  66252. * @param name - The rendering pipeline name (default: "")
  66253. * @param hdr - If high dynamic range textures should be used (default: true)
  66254. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66255. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66256. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66257. */
  66258. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66259. /**
  66260. * Get the class name
  66261. * @returns "DefaultRenderingPipeline"
  66262. */
  66263. getClassName(): string;
  66264. /**
  66265. * Force the compilation of the entire pipeline.
  66266. */
  66267. prepare(): void;
  66268. private _hasCleared;
  66269. private _prevPostProcess;
  66270. private _prevPrevPostProcess;
  66271. private _setAutoClearAndTextureSharing;
  66272. private _depthOfFieldSceneObserver;
  66273. private _buildPipeline;
  66274. private _disposePostProcesses;
  66275. /**
  66276. * Adds a camera to the pipeline
  66277. * @param camera the camera to be added
  66278. */
  66279. addCamera(camera: Camera): void;
  66280. /**
  66281. * Removes a camera from the pipeline
  66282. * @param camera the camera to remove
  66283. */
  66284. removeCamera(camera: Camera): void;
  66285. /**
  66286. * Dispose of the pipeline and stop all post processes
  66287. */
  66288. dispose(): void;
  66289. /**
  66290. * Serialize the rendering pipeline (Used when exporting)
  66291. * @returns the serialized object
  66292. */
  66293. serialize(): any;
  66294. /**
  66295. * Parse the serialized pipeline
  66296. * @param source Source pipeline.
  66297. * @param scene The scene to load the pipeline to.
  66298. * @param rootUrl The URL of the serialized pipeline.
  66299. * @returns An instantiated pipeline from the serialized object.
  66300. */
  66301. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66302. }
  66303. }
  66304. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66305. /** @hidden */
  66306. export var lensHighlightsPixelShader: {
  66307. name: string;
  66308. shader: string;
  66309. };
  66310. }
  66311. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66312. /** @hidden */
  66313. export var depthOfFieldPixelShader: {
  66314. name: string;
  66315. shader: string;
  66316. };
  66317. }
  66318. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66319. import { Camera } from "babylonjs/Cameras/camera";
  66320. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66321. import { Scene } from "babylonjs/scene";
  66322. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66323. import "babylonjs/Shaders/chromaticAberration.fragment";
  66324. import "babylonjs/Shaders/lensHighlights.fragment";
  66325. import "babylonjs/Shaders/depthOfField.fragment";
  66326. /**
  66327. * BABYLON.JS Chromatic Aberration GLSL Shader
  66328. * Author: Olivier Guyot
  66329. * Separates very slightly R, G and B colors on the edges of the screen
  66330. * Inspired by Francois Tarlier & Martins Upitis
  66331. */
  66332. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66333. /**
  66334. * @ignore
  66335. * The chromatic aberration PostProcess id in the pipeline
  66336. */
  66337. LensChromaticAberrationEffect: string;
  66338. /**
  66339. * @ignore
  66340. * The highlights enhancing PostProcess id in the pipeline
  66341. */
  66342. HighlightsEnhancingEffect: string;
  66343. /**
  66344. * @ignore
  66345. * The depth-of-field PostProcess id in the pipeline
  66346. */
  66347. LensDepthOfFieldEffect: string;
  66348. private _scene;
  66349. private _depthTexture;
  66350. private _grainTexture;
  66351. private _chromaticAberrationPostProcess;
  66352. private _highlightsPostProcess;
  66353. private _depthOfFieldPostProcess;
  66354. private _edgeBlur;
  66355. private _grainAmount;
  66356. private _chromaticAberration;
  66357. private _distortion;
  66358. private _highlightsGain;
  66359. private _highlightsThreshold;
  66360. private _dofDistance;
  66361. private _dofAperture;
  66362. private _dofDarken;
  66363. private _dofPentagon;
  66364. private _blurNoise;
  66365. /**
  66366. * @constructor
  66367. *
  66368. * Effect parameters are as follow:
  66369. * {
  66370. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66371. * edge_blur: number; // from 0 to x (1 for realism)
  66372. * distortion: number; // from 0 to x (1 for realism)
  66373. * grain_amount: number; // from 0 to 1
  66374. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66375. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66376. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66377. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66378. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66379. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66380. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66381. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66382. * }
  66383. * Note: if an effect parameter is unset, effect is disabled
  66384. *
  66385. * @param name The rendering pipeline name
  66386. * @param parameters - An object containing all parameters (see above)
  66387. * @param scene The scene linked to this pipeline
  66388. * @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)
  66389. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66390. */
  66391. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66392. /**
  66393. * Get the class name
  66394. * @returns "LensRenderingPipeline"
  66395. */
  66396. getClassName(): string;
  66397. /**
  66398. * Gets associated scene
  66399. */
  66400. readonly scene: Scene;
  66401. /**
  66402. * Gets or sets the edge blur
  66403. */
  66404. edgeBlur: number;
  66405. /**
  66406. * Gets or sets the grain amount
  66407. */
  66408. grainAmount: number;
  66409. /**
  66410. * Gets or sets the chromatic aberration amount
  66411. */
  66412. chromaticAberration: number;
  66413. /**
  66414. * Gets or sets the depth of field aperture
  66415. */
  66416. dofAperture: number;
  66417. /**
  66418. * Gets or sets the edge distortion
  66419. */
  66420. edgeDistortion: number;
  66421. /**
  66422. * Gets or sets the depth of field distortion
  66423. */
  66424. dofDistortion: number;
  66425. /**
  66426. * Gets or sets the darken out of focus amount
  66427. */
  66428. darkenOutOfFocus: number;
  66429. /**
  66430. * Gets or sets a boolean indicating if blur noise is enabled
  66431. */
  66432. blurNoise: boolean;
  66433. /**
  66434. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66435. */
  66436. pentagonBokeh: boolean;
  66437. /**
  66438. * Gets or sets the highlight grain amount
  66439. */
  66440. highlightsGain: number;
  66441. /**
  66442. * Gets or sets the highlight threshold
  66443. */
  66444. highlightsThreshold: number;
  66445. /**
  66446. * Sets the amount of blur at the edges
  66447. * @param amount blur amount
  66448. */
  66449. setEdgeBlur(amount: number): void;
  66450. /**
  66451. * Sets edge blur to 0
  66452. */
  66453. disableEdgeBlur(): void;
  66454. /**
  66455. * Sets the amout of grain
  66456. * @param amount Amount of grain
  66457. */
  66458. setGrainAmount(amount: number): void;
  66459. /**
  66460. * Set grain amount to 0
  66461. */
  66462. disableGrain(): void;
  66463. /**
  66464. * Sets the chromatic aberration amount
  66465. * @param amount amount of chromatic aberration
  66466. */
  66467. setChromaticAberration(amount: number): void;
  66468. /**
  66469. * Sets chromatic aberration amount to 0
  66470. */
  66471. disableChromaticAberration(): void;
  66472. /**
  66473. * Sets the EdgeDistortion amount
  66474. * @param amount amount of EdgeDistortion
  66475. */
  66476. setEdgeDistortion(amount: number): void;
  66477. /**
  66478. * Sets edge distortion to 0
  66479. */
  66480. disableEdgeDistortion(): void;
  66481. /**
  66482. * Sets the FocusDistance amount
  66483. * @param amount amount of FocusDistance
  66484. */
  66485. setFocusDistance(amount: number): void;
  66486. /**
  66487. * Disables depth of field
  66488. */
  66489. disableDepthOfField(): void;
  66490. /**
  66491. * Sets the Aperture amount
  66492. * @param amount amount of Aperture
  66493. */
  66494. setAperture(amount: number): void;
  66495. /**
  66496. * Sets the DarkenOutOfFocus amount
  66497. * @param amount amount of DarkenOutOfFocus
  66498. */
  66499. setDarkenOutOfFocus(amount: number): void;
  66500. private _pentagonBokehIsEnabled;
  66501. /**
  66502. * Creates a pentagon bokeh effect
  66503. */
  66504. enablePentagonBokeh(): void;
  66505. /**
  66506. * Disables the pentagon bokeh effect
  66507. */
  66508. disablePentagonBokeh(): void;
  66509. /**
  66510. * Enables noise blur
  66511. */
  66512. enableNoiseBlur(): void;
  66513. /**
  66514. * Disables noise blur
  66515. */
  66516. disableNoiseBlur(): void;
  66517. /**
  66518. * Sets the HighlightsGain amount
  66519. * @param amount amount of HighlightsGain
  66520. */
  66521. setHighlightsGain(amount: number): void;
  66522. /**
  66523. * Sets the HighlightsThreshold amount
  66524. * @param amount amount of HighlightsThreshold
  66525. */
  66526. setHighlightsThreshold(amount: number): void;
  66527. /**
  66528. * Disables highlights
  66529. */
  66530. disableHighlights(): void;
  66531. /**
  66532. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66533. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66534. */
  66535. dispose(disableDepthRender?: boolean): void;
  66536. private _createChromaticAberrationPostProcess;
  66537. private _createHighlightsPostProcess;
  66538. private _createDepthOfFieldPostProcess;
  66539. private _createGrainTexture;
  66540. }
  66541. }
  66542. declare module "babylonjs/Shaders/ssao2.fragment" {
  66543. /** @hidden */
  66544. export var ssao2PixelShader: {
  66545. name: string;
  66546. shader: string;
  66547. };
  66548. }
  66549. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  66550. /** @hidden */
  66551. export var ssaoCombinePixelShader: {
  66552. name: string;
  66553. shader: string;
  66554. };
  66555. }
  66556. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  66557. import { Camera } from "babylonjs/Cameras/camera";
  66558. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66559. import { Scene } from "babylonjs/scene";
  66560. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66561. import "babylonjs/Shaders/ssao2.fragment";
  66562. import "babylonjs/Shaders/ssaoCombine.fragment";
  66563. /**
  66564. * Render pipeline to produce ssao effect
  66565. */
  66566. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66567. /**
  66568. * @ignore
  66569. * The PassPostProcess id in the pipeline that contains the original scene color
  66570. */
  66571. SSAOOriginalSceneColorEffect: string;
  66572. /**
  66573. * @ignore
  66574. * The SSAO PostProcess id in the pipeline
  66575. */
  66576. SSAORenderEffect: string;
  66577. /**
  66578. * @ignore
  66579. * The horizontal blur PostProcess id in the pipeline
  66580. */
  66581. SSAOBlurHRenderEffect: string;
  66582. /**
  66583. * @ignore
  66584. * The vertical blur PostProcess id in the pipeline
  66585. */
  66586. SSAOBlurVRenderEffect: string;
  66587. /**
  66588. * @ignore
  66589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66590. */
  66591. SSAOCombineRenderEffect: string;
  66592. /**
  66593. * The output strength of the SSAO post-process. Default value is 1.0.
  66594. */
  66595. totalStrength: number;
  66596. /**
  66597. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66598. */
  66599. maxZ: number;
  66600. /**
  66601. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66602. */
  66603. minZAspect: number;
  66604. private _samples;
  66605. /**
  66606. * Number of samples used for the SSAO calculations. Default value is 8
  66607. */
  66608. samples: number;
  66609. private _textureSamples;
  66610. /**
  66611. * Number of samples to use for antialiasing
  66612. */
  66613. textureSamples: number;
  66614. /**
  66615. * Ratio object used for SSAO ratio and blur ratio
  66616. */
  66617. private _ratio;
  66618. /**
  66619. * Dynamically generated sphere sampler.
  66620. */
  66621. private _sampleSphere;
  66622. /**
  66623. * Blur filter offsets
  66624. */
  66625. private _samplerOffsets;
  66626. private _expensiveBlur;
  66627. /**
  66628. * If bilateral blur should be used
  66629. */
  66630. expensiveBlur: boolean;
  66631. /**
  66632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66633. */
  66634. radius: number;
  66635. /**
  66636. * The base color of the SSAO post-process
  66637. * The final result is "base + ssao" between [0, 1]
  66638. */
  66639. base: number;
  66640. /**
  66641. * Support test.
  66642. */
  66643. static readonly IsSupported: boolean;
  66644. private _scene;
  66645. private _depthTexture;
  66646. private _normalTexture;
  66647. private _randomTexture;
  66648. private _originalColorPostProcess;
  66649. private _ssaoPostProcess;
  66650. private _blurHPostProcess;
  66651. private _blurVPostProcess;
  66652. private _ssaoCombinePostProcess;
  66653. /**
  66654. * Gets active scene
  66655. */
  66656. readonly scene: Scene;
  66657. /**
  66658. * @constructor
  66659. * @param name The rendering pipeline name
  66660. * @param scene The scene linked to this pipeline
  66661. * @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 }
  66662. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66663. */
  66664. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66665. /**
  66666. * Get the class name
  66667. * @returns "SSAO2RenderingPipeline"
  66668. */
  66669. getClassName(): string;
  66670. /**
  66671. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66672. */
  66673. dispose(disableGeometryBufferRenderer?: boolean): void;
  66674. private _createBlurPostProcess;
  66675. /** @hidden */
  66676. _rebuild(): void;
  66677. private _bits;
  66678. private _radicalInverse_VdC;
  66679. private _hammersley;
  66680. private _hemisphereSample_uniform;
  66681. private _generateHemisphere;
  66682. private _createSSAOPostProcess;
  66683. private _createSSAOCombinePostProcess;
  66684. private _createRandomTexture;
  66685. /**
  66686. * Serialize the rendering pipeline (Used when exporting)
  66687. * @returns the serialized object
  66688. */
  66689. serialize(): any;
  66690. /**
  66691. * Parse the serialized pipeline
  66692. * @param source Source pipeline.
  66693. * @param scene The scene to load the pipeline to.
  66694. * @param rootUrl The URL of the serialized pipeline.
  66695. * @returns An instantiated pipeline from the serialized object.
  66696. */
  66697. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66698. }
  66699. }
  66700. declare module "babylonjs/Shaders/ssao.fragment" {
  66701. /** @hidden */
  66702. export var ssaoPixelShader: {
  66703. name: string;
  66704. shader: string;
  66705. };
  66706. }
  66707. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  66708. import { Camera } from "babylonjs/Cameras/camera";
  66709. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66710. import { Scene } from "babylonjs/scene";
  66711. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66712. import "babylonjs/Shaders/ssao.fragment";
  66713. import "babylonjs/Shaders/ssaoCombine.fragment";
  66714. /**
  66715. * Render pipeline to produce ssao effect
  66716. */
  66717. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66718. /**
  66719. * @ignore
  66720. * The PassPostProcess id in the pipeline that contains the original scene color
  66721. */
  66722. SSAOOriginalSceneColorEffect: string;
  66723. /**
  66724. * @ignore
  66725. * The SSAO PostProcess id in the pipeline
  66726. */
  66727. SSAORenderEffect: string;
  66728. /**
  66729. * @ignore
  66730. * The horizontal blur PostProcess id in the pipeline
  66731. */
  66732. SSAOBlurHRenderEffect: string;
  66733. /**
  66734. * @ignore
  66735. * The vertical blur PostProcess id in the pipeline
  66736. */
  66737. SSAOBlurVRenderEffect: string;
  66738. /**
  66739. * @ignore
  66740. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66741. */
  66742. SSAOCombineRenderEffect: string;
  66743. /**
  66744. * The output strength of the SSAO post-process. Default value is 1.0.
  66745. */
  66746. totalStrength: number;
  66747. /**
  66748. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66749. */
  66750. radius: number;
  66751. /**
  66752. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66753. * Must not be equal to fallOff and superior to fallOff.
  66754. * Default value is 0.0075
  66755. */
  66756. area: number;
  66757. /**
  66758. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66759. * Must not be equal to area and inferior to area.
  66760. * Default value is 0.000001
  66761. */
  66762. fallOff: number;
  66763. /**
  66764. * The base color of the SSAO post-process
  66765. * The final result is "base + ssao" between [0, 1]
  66766. */
  66767. base: number;
  66768. private _scene;
  66769. private _depthTexture;
  66770. private _randomTexture;
  66771. private _originalColorPostProcess;
  66772. private _ssaoPostProcess;
  66773. private _blurHPostProcess;
  66774. private _blurVPostProcess;
  66775. private _ssaoCombinePostProcess;
  66776. private _firstUpdate;
  66777. /**
  66778. * Gets active scene
  66779. */
  66780. readonly scene: Scene;
  66781. /**
  66782. * @constructor
  66783. * @param name - The rendering pipeline name
  66784. * @param scene - The scene linked to this pipeline
  66785. * @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 }
  66786. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66787. */
  66788. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66789. /**
  66790. * Get the class name
  66791. * @returns "SSAORenderingPipeline"
  66792. */
  66793. getClassName(): string;
  66794. /**
  66795. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66796. */
  66797. dispose(disableDepthRender?: boolean): void;
  66798. private _createBlurPostProcess;
  66799. /** @hidden */
  66800. _rebuild(): void;
  66801. private _createSSAOPostProcess;
  66802. private _createSSAOCombinePostProcess;
  66803. private _createRandomTexture;
  66804. }
  66805. }
  66806. declare module "babylonjs/Shaders/standard.fragment" {
  66807. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66808. /** @hidden */
  66809. export var standardPixelShader: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66815. import { Nullable } from "babylonjs/types";
  66816. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66817. import { Camera } from "babylonjs/Cameras/camera";
  66818. import { Texture } from "babylonjs/Materials/Textures/texture";
  66819. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66820. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66821. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66822. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66823. import { IDisposable } from "babylonjs/scene";
  66824. import { SpotLight } from "babylonjs/Lights/spotLight";
  66825. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66826. import { Scene } from "babylonjs/scene";
  66827. import { Animation } from "babylonjs/Animations/animation";
  66828. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66829. import "babylonjs/Shaders/standard.fragment";
  66830. /**
  66831. * Standard rendering pipeline
  66832. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66833. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66834. */
  66835. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66836. /**
  66837. * Public members
  66838. */
  66839. /**
  66840. * Post-process which contains the original scene color before the pipeline applies all the effects
  66841. */
  66842. originalPostProcess: Nullable<PostProcess>;
  66843. /**
  66844. * Post-process used to down scale an image x4
  66845. */
  66846. downSampleX4PostProcess: Nullable<PostProcess>;
  66847. /**
  66848. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66849. */
  66850. brightPassPostProcess: Nullable<PostProcess>;
  66851. /**
  66852. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66853. */
  66854. blurHPostProcesses: PostProcess[];
  66855. /**
  66856. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66857. */
  66858. blurVPostProcesses: PostProcess[];
  66859. /**
  66860. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66861. */
  66862. textureAdderPostProcess: Nullable<PostProcess>;
  66863. /**
  66864. * Post-process used to create volumetric lighting effect
  66865. */
  66866. volumetricLightPostProcess: Nullable<PostProcess>;
  66867. /**
  66868. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66869. */
  66870. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66871. /**
  66872. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66873. */
  66874. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66875. /**
  66876. * Post-process used to merge the volumetric light effect and the real scene color
  66877. */
  66878. volumetricLightMergePostProces: Nullable<PostProcess>;
  66879. /**
  66880. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66881. */
  66882. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66883. /**
  66884. * Base post-process used to calculate the average luminance of the final image for HDR
  66885. */
  66886. luminancePostProcess: Nullable<PostProcess>;
  66887. /**
  66888. * Post-processes used to create down sample post-processes in order to get
  66889. * the average luminance of the final image for HDR
  66890. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66891. */
  66892. luminanceDownSamplePostProcesses: PostProcess[];
  66893. /**
  66894. * Post-process used to create a HDR effect (light adaptation)
  66895. */
  66896. hdrPostProcess: Nullable<PostProcess>;
  66897. /**
  66898. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66899. */
  66900. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66901. /**
  66902. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66903. */
  66904. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66905. /**
  66906. * Post-process used to merge the final HDR post-process and the real scene color
  66907. */
  66908. hdrFinalPostProcess: Nullable<PostProcess>;
  66909. /**
  66910. * Post-process used to create a lens flare effect
  66911. */
  66912. lensFlarePostProcess: Nullable<PostProcess>;
  66913. /**
  66914. * Post-process that merges the result of the lens flare post-process and the real scene color
  66915. */
  66916. lensFlareComposePostProcess: Nullable<PostProcess>;
  66917. /**
  66918. * Post-process used to create a motion blur effect
  66919. */
  66920. motionBlurPostProcess: Nullable<PostProcess>;
  66921. /**
  66922. * Post-process used to create a depth of field effect
  66923. */
  66924. depthOfFieldPostProcess: Nullable<PostProcess>;
  66925. /**
  66926. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66927. */
  66928. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66929. /**
  66930. * Represents the brightness threshold in order to configure the illuminated surfaces
  66931. */
  66932. brightThreshold: number;
  66933. /**
  66934. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66935. */
  66936. blurWidth: number;
  66937. /**
  66938. * Sets if the blur for highlighted surfaces must be only horizontal
  66939. */
  66940. horizontalBlur: boolean;
  66941. /**
  66942. * Gets the overall exposure used by the pipeline
  66943. */
  66944. /**
  66945. * Sets the overall exposure used by the pipeline
  66946. */
  66947. exposure: number;
  66948. /**
  66949. * Texture used typically to simulate "dirty" on camera lens
  66950. */
  66951. lensTexture: Nullable<Texture>;
  66952. /**
  66953. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66954. */
  66955. volumetricLightCoefficient: number;
  66956. /**
  66957. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66958. */
  66959. volumetricLightPower: number;
  66960. /**
  66961. * Used the set the blur intensity to smooth the volumetric lights
  66962. */
  66963. volumetricLightBlurScale: number;
  66964. /**
  66965. * Light (spot or directional) used to generate the volumetric lights rays
  66966. * The source light must have a shadow generate so the pipeline can get its
  66967. * depth map
  66968. */
  66969. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66970. /**
  66971. * For eye adaptation, represents the minimum luminance the eye can see
  66972. */
  66973. hdrMinimumLuminance: number;
  66974. /**
  66975. * For eye adaptation, represents the decrease luminance speed
  66976. */
  66977. hdrDecreaseRate: number;
  66978. /**
  66979. * For eye adaptation, represents the increase luminance speed
  66980. */
  66981. hdrIncreaseRate: number;
  66982. /**
  66983. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66984. */
  66985. /**
  66986. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66987. */
  66988. hdrAutoExposure: boolean;
  66989. /**
  66990. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66991. */
  66992. lensColorTexture: Nullable<Texture>;
  66993. /**
  66994. * The overall strengh for the lens flare effect
  66995. */
  66996. lensFlareStrength: number;
  66997. /**
  66998. * Dispersion coefficient for lens flare ghosts
  66999. */
  67000. lensFlareGhostDispersal: number;
  67001. /**
  67002. * Main lens flare halo width
  67003. */
  67004. lensFlareHaloWidth: number;
  67005. /**
  67006. * Based on the lens distortion effect, defines how much the lens flare result
  67007. * is distorted
  67008. */
  67009. lensFlareDistortionStrength: number;
  67010. /**
  67011. * Configures the blur intensity used for for lens flare (halo)
  67012. */
  67013. lensFlareBlurWidth: number;
  67014. /**
  67015. * Lens star texture must be used to simulate rays on the flares and is available
  67016. * in the documentation
  67017. */
  67018. lensStarTexture: Nullable<Texture>;
  67019. /**
  67020. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67021. * flare effect by taking account of the dirt texture
  67022. */
  67023. lensFlareDirtTexture: Nullable<Texture>;
  67024. /**
  67025. * Represents the focal length for the depth of field effect
  67026. */
  67027. depthOfFieldDistance: number;
  67028. /**
  67029. * Represents the blur intensity for the blurred part of the depth of field effect
  67030. */
  67031. depthOfFieldBlurWidth: number;
  67032. /**
  67033. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67034. */
  67035. /**
  67036. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67037. */
  67038. motionStrength: number;
  67039. /**
  67040. * Gets wether or not the motion blur post-process is object based or screen based.
  67041. */
  67042. /**
  67043. * Sets wether or not the motion blur post-process should be object based or screen based
  67044. */
  67045. objectBasedMotionBlur: boolean;
  67046. /**
  67047. * List of animations for the pipeline (IAnimatable implementation)
  67048. */
  67049. animations: Animation[];
  67050. /**
  67051. * Private members
  67052. */
  67053. private _scene;
  67054. private _currentDepthOfFieldSource;
  67055. private _basePostProcess;
  67056. private _fixedExposure;
  67057. private _currentExposure;
  67058. private _hdrAutoExposure;
  67059. private _hdrCurrentLuminance;
  67060. private _motionStrength;
  67061. private _isObjectBasedMotionBlur;
  67062. private _floatTextureType;
  67063. private _camerasToBeAttached;
  67064. private _ratio;
  67065. private _bloomEnabled;
  67066. private _depthOfFieldEnabled;
  67067. private _vlsEnabled;
  67068. private _lensFlareEnabled;
  67069. private _hdrEnabled;
  67070. private _motionBlurEnabled;
  67071. private _fxaaEnabled;
  67072. private _motionBlurSamples;
  67073. private _volumetricLightStepsCount;
  67074. private _samples;
  67075. /**
  67076. * @ignore
  67077. * Specifies if the bloom pipeline is enabled
  67078. */
  67079. BloomEnabled: boolean;
  67080. /**
  67081. * @ignore
  67082. * Specifies if the depth of field pipeline is enabed
  67083. */
  67084. DepthOfFieldEnabled: boolean;
  67085. /**
  67086. * @ignore
  67087. * Specifies if the lens flare pipeline is enabed
  67088. */
  67089. LensFlareEnabled: boolean;
  67090. /**
  67091. * @ignore
  67092. * Specifies if the HDR pipeline is enabled
  67093. */
  67094. HDREnabled: boolean;
  67095. /**
  67096. * @ignore
  67097. * Specifies if the volumetric lights scattering effect is enabled
  67098. */
  67099. VLSEnabled: boolean;
  67100. /**
  67101. * @ignore
  67102. * Specifies if the motion blur effect is enabled
  67103. */
  67104. MotionBlurEnabled: boolean;
  67105. /**
  67106. * Specifies if anti-aliasing is enabled
  67107. */
  67108. fxaaEnabled: boolean;
  67109. /**
  67110. * Specifies the number of steps used to calculate the volumetric lights
  67111. * Typically in interval [50, 200]
  67112. */
  67113. volumetricLightStepsCount: number;
  67114. /**
  67115. * Specifies the number of samples used for the motion blur effect
  67116. * Typically in interval [16, 64]
  67117. */
  67118. motionBlurSamples: number;
  67119. /**
  67120. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67121. */
  67122. samples: number;
  67123. /**
  67124. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67125. * @constructor
  67126. * @param name The rendering pipeline name
  67127. * @param scene The scene linked to this pipeline
  67128. * @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)
  67129. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67130. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67131. */
  67132. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67133. private _buildPipeline;
  67134. private _createDownSampleX4PostProcess;
  67135. private _createBrightPassPostProcess;
  67136. private _createBlurPostProcesses;
  67137. private _createTextureAdderPostProcess;
  67138. private _createVolumetricLightPostProcess;
  67139. private _createLuminancePostProcesses;
  67140. private _createHdrPostProcess;
  67141. private _createLensFlarePostProcess;
  67142. private _createDepthOfFieldPostProcess;
  67143. private _createMotionBlurPostProcess;
  67144. private _getDepthTexture;
  67145. private _disposePostProcesses;
  67146. /**
  67147. * Dispose of the pipeline and stop all post processes
  67148. */
  67149. dispose(): void;
  67150. /**
  67151. * Serialize the rendering pipeline (Used when exporting)
  67152. * @returns the serialized object
  67153. */
  67154. serialize(): any;
  67155. /**
  67156. * Parse the serialized pipeline
  67157. * @param source Source pipeline.
  67158. * @param scene The scene to load the pipeline to.
  67159. * @param rootUrl The URL of the serialized pipeline.
  67160. * @returns An instantiated pipeline from the serialized object.
  67161. */
  67162. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67163. /**
  67164. * Luminance steps
  67165. */
  67166. static LuminanceSteps: number;
  67167. }
  67168. }
  67169. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67170. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67171. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67172. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67173. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67174. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67175. }
  67176. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67177. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67178. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67179. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67180. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67181. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67182. }
  67183. declare module "babylonjs/Shaders/tonemap.fragment" {
  67184. /** @hidden */
  67185. export var tonemapPixelShader: {
  67186. name: string;
  67187. shader: string;
  67188. };
  67189. }
  67190. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67191. import { Camera } from "babylonjs/Cameras/camera";
  67192. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67193. import "babylonjs/Shaders/tonemap.fragment";
  67194. import { Engine } from "babylonjs/Engines/engine";
  67195. /** Defines operator used for tonemapping */
  67196. export enum TonemappingOperator {
  67197. /** Hable */
  67198. Hable = 0,
  67199. /** Reinhard */
  67200. Reinhard = 1,
  67201. /** HejiDawson */
  67202. HejiDawson = 2,
  67203. /** Photographic */
  67204. Photographic = 3
  67205. }
  67206. /**
  67207. * Defines a post process to apply tone mapping
  67208. */
  67209. export class TonemapPostProcess extends PostProcess {
  67210. private _operator;
  67211. /** Defines the required exposure adjustement */
  67212. exposureAdjustment: number;
  67213. /**
  67214. * Creates a new TonemapPostProcess
  67215. * @param name defines the name of the postprocess
  67216. * @param _operator defines the operator to use
  67217. * @param exposureAdjustment defines the required exposure adjustement
  67218. * @param camera defines the camera to use (can be null)
  67219. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67220. * @param engine defines the hosting engine (can be ignore if camera is set)
  67221. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67222. */
  67223. constructor(name: string, _operator: TonemappingOperator,
  67224. /** Defines the required exposure adjustement */
  67225. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67226. }
  67227. }
  67228. declare module "babylonjs/Shaders/depth.vertex" {
  67229. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67231. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67232. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67233. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67234. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67235. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67236. /** @hidden */
  67237. export var depthVertexShader: {
  67238. name: string;
  67239. shader: string;
  67240. };
  67241. }
  67242. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67243. /** @hidden */
  67244. export var volumetricLightScatteringPixelShader: {
  67245. name: string;
  67246. shader: string;
  67247. };
  67248. }
  67249. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67253. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67257. /** @hidden */
  67258. export var volumetricLightScatteringPassVertexShader: {
  67259. name: string;
  67260. shader: string;
  67261. };
  67262. }
  67263. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67264. /** @hidden */
  67265. export var volumetricLightScatteringPassPixelShader: {
  67266. name: string;
  67267. shader: string;
  67268. };
  67269. }
  67270. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67271. import { Vector3 } from "babylonjs/Maths/math.vector";
  67272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67273. import { Mesh } from "babylonjs/Meshes/mesh";
  67274. import { Camera } from "babylonjs/Cameras/camera";
  67275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67276. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67277. import { Scene } from "babylonjs/scene";
  67278. import "babylonjs/Meshes/Builders/planeBuilder";
  67279. import "babylonjs/Shaders/depth.vertex";
  67280. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67281. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67282. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67283. import { Engine } from "babylonjs/Engines/engine";
  67284. /**
  67285. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67286. */
  67287. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67288. private _volumetricLightScatteringPass;
  67289. private _volumetricLightScatteringRTT;
  67290. private _viewPort;
  67291. private _screenCoordinates;
  67292. private _cachedDefines;
  67293. /**
  67294. * If not undefined, the mesh position is computed from the attached node position
  67295. */
  67296. attachedNode: {
  67297. position: Vector3;
  67298. };
  67299. /**
  67300. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67301. */
  67302. customMeshPosition: Vector3;
  67303. /**
  67304. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67305. */
  67306. useCustomMeshPosition: boolean;
  67307. /**
  67308. * If the post-process should inverse the light scattering direction
  67309. */
  67310. invert: boolean;
  67311. /**
  67312. * The internal mesh used by the post-process
  67313. */
  67314. mesh: Mesh;
  67315. /**
  67316. * @hidden
  67317. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67318. */
  67319. useDiffuseColor: boolean;
  67320. /**
  67321. * Array containing the excluded meshes not rendered in the internal pass
  67322. */
  67323. excludedMeshes: AbstractMesh[];
  67324. /**
  67325. * Controls the overall intensity of the post-process
  67326. */
  67327. exposure: number;
  67328. /**
  67329. * Dissipates each sample's contribution in range [0, 1]
  67330. */
  67331. decay: number;
  67332. /**
  67333. * Controls the overall intensity of each sample
  67334. */
  67335. weight: number;
  67336. /**
  67337. * Controls the density of each sample
  67338. */
  67339. density: number;
  67340. /**
  67341. * @constructor
  67342. * @param name The post-process name
  67343. * @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)
  67344. * @param camera The camera that the post-process will be attached to
  67345. * @param mesh The mesh used to create the light scattering
  67346. * @param samples The post-process quality, default 100
  67347. * @param samplingModeThe post-process filtering mode
  67348. * @param engine The babylon engine
  67349. * @param reusable If the post-process is reusable
  67350. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67351. */
  67352. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67353. /**
  67354. * Returns the string "VolumetricLightScatteringPostProcess"
  67355. * @returns "VolumetricLightScatteringPostProcess"
  67356. */
  67357. getClassName(): string;
  67358. private _isReady;
  67359. /**
  67360. * Sets the new light position for light scattering effect
  67361. * @param position The new custom light position
  67362. */
  67363. setCustomMeshPosition(position: Vector3): void;
  67364. /**
  67365. * Returns the light position for light scattering effect
  67366. * @return Vector3 The custom light position
  67367. */
  67368. getCustomMeshPosition(): Vector3;
  67369. /**
  67370. * Disposes the internal assets and detaches the post-process from the camera
  67371. */
  67372. dispose(camera: Camera): void;
  67373. /**
  67374. * Returns the render target texture used by the post-process
  67375. * @return the render target texture used by the post-process
  67376. */
  67377. getPass(): RenderTargetTexture;
  67378. private _meshExcluded;
  67379. private _createPass;
  67380. private _updateMeshScreenCoordinates;
  67381. /**
  67382. * Creates a default mesh for the Volumeric Light Scattering post-process
  67383. * @param name The mesh name
  67384. * @param scene The scene where to create the mesh
  67385. * @return the default mesh
  67386. */
  67387. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67388. }
  67389. }
  67390. declare module "babylonjs/PostProcesses/index" {
  67391. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  67392. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  67393. export * from "babylonjs/PostProcesses/bloomEffect";
  67394. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  67395. export * from "babylonjs/PostProcesses/blurPostProcess";
  67396. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67397. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  67398. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  67399. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  67400. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67401. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  67402. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  67403. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  67404. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67405. export * from "babylonjs/PostProcesses/filterPostProcess";
  67406. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  67407. export * from "babylonjs/PostProcesses/grainPostProcess";
  67408. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  67409. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67410. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  67411. export * from "babylonjs/PostProcesses/passPostProcess";
  67412. export * from "babylonjs/PostProcesses/postProcess";
  67413. export * from "babylonjs/PostProcesses/postProcessManager";
  67414. export * from "babylonjs/PostProcesses/refractionPostProcess";
  67415. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  67416. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  67417. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  67418. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  67419. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  67420. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  67421. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  67422. }
  67423. declare module "babylonjs/Probes/index" {
  67424. export * from "babylonjs/Probes/reflectionProbe";
  67425. }
  67426. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  67427. import { Scene } from "babylonjs/scene";
  67428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67429. import { SmartArray } from "babylonjs/Misc/smartArray";
  67430. import { ISceneComponent } from "babylonjs/sceneComponent";
  67431. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  67432. import "babylonjs/Meshes/Builders/boxBuilder";
  67433. import "babylonjs/Shaders/color.fragment";
  67434. import "babylonjs/Shaders/color.vertex";
  67435. import { Color3 } from "babylonjs/Maths/math.color";
  67436. module "babylonjs/scene" {
  67437. interface Scene {
  67438. /** @hidden (Backing field) */
  67439. _boundingBoxRenderer: BoundingBoxRenderer;
  67440. /** @hidden (Backing field) */
  67441. _forceShowBoundingBoxes: boolean;
  67442. /**
  67443. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67444. */
  67445. forceShowBoundingBoxes: boolean;
  67446. /**
  67447. * Gets the bounding box renderer associated with the scene
  67448. * @returns a BoundingBoxRenderer
  67449. */
  67450. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67451. }
  67452. }
  67453. module "babylonjs/Meshes/abstractMesh" {
  67454. interface AbstractMesh {
  67455. /** @hidden (Backing field) */
  67456. _showBoundingBox: boolean;
  67457. /**
  67458. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67459. */
  67460. showBoundingBox: boolean;
  67461. }
  67462. }
  67463. /**
  67464. * Component responsible of rendering the bounding box of the meshes in a scene.
  67465. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67466. */
  67467. export class BoundingBoxRenderer implements ISceneComponent {
  67468. /**
  67469. * The component name helpfull to identify the component in the list of scene components.
  67470. */
  67471. readonly name: string;
  67472. /**
  67473. * The scene the component belongs to.
  67474. */
  67475. scene: Scene;
  67476. /**
  67477. * Color of the bounding box lines placed in front of an object
  67478. */
  67479. frontColor: Color3;
  67480. /**
  67481. * Color of the bounding box lines placed behind an object
  67482. */
  67483. backColor: Color3;
  67484. /**
  67485. * Defines if the renderer should show the back lines or not
  67486. */
  67487. showBackLines: boolean;
  67488. /**
  67489. * @hidden
  67490. */
  67491. renderList: SmartArray<BoundingBox>;
  67492. private _colorShader;
  67493. private _vertexBuffers;
  67494. private _indexBuffer;
  67495. private _fillIndexBuffer;
  67496. private _fillIndexData;
  67497. /**
  67498. * Instantiates a new bounding box renderer in a scene.
  67499. * @param scene the scene the renderer renders in
  67500. */
  67501. constructor(scene: Scene);
  67502. /**
  67503. * Registers the component in a given scene
  67504. */
  67505. register(): void;
  67506. private _evaluateSubMesh;
  67507. private _activeMesh;
  67508. private _prepareRessources;
  67509. private _createIndexBuffer;
  67510. /**
  67511. * Rebuilds the elements related to this component in case of
  67512. * context lost for instance.
  67513. */
  67514. rebuild(): void;
  67515. /**
  67516. * @hidden
  67517. */
  67518. reset(): void;
  67519. /**
  67520. * Render the bounding boxes of a specific rendering group
  67521. * @param renderingGroupId defines the rendering group to render
  67522. */
  67523. render(renderingGroupId: number): void;
  67524. /**
  67525. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67526. * @param mesh Define the mesh to render the occlusion bounding box for
  67527. */
  67528. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67529. /**
  67530. * Dispose and release the resources attached to this renderer.
  67531. */
  67532. dispose(): void;
  67533. }
  67534. }
  67535. declare module "babylonjs/Shaders/depth.fragment" {
  67536. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67537. /** @hidden */
  67538. export var depthPixelShader: {
  67539. name: string;
  67540. shader: string;
  67541. };
  67542. }
  67543. declare module "babylonjs/Rendering/depthRenderer" {
  67544. import { Nullable } from "babylonjs/types";
  67545. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67546. import { Scene } from "babylonjs/scene";
  67547. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67548. import { Camera } from "babylonjs/Cameras/camera";
  67549. import "babylonjs/Shaders/depth.fragment";
  67550. import "babylonjs/Shaders/depth.vertex";
  67551. /**
  67552. * This represents a depth renderer in Babylon.
  67553. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  67554. */
  67555. export class DepthRenderer {
  67556. private _scene;
  67557. private _depthMap;
  67558. private _effect;
  67559. private readonly _storeNonLinearDepth;
  67560. private readonly _clearColor;
  67561. /** Get if the depth renderer is using packed depth or not */
  67562. readonly isPacked: boolean;
  67563. private _cachedDefines;
  67564. private _camera;
  67565. /**
  67566. * Specifiess that the depth renderer will only be used within
  67567. * the camera it is created for.
  67568. * This can help forcing its rendering during the camera processing.
  67569. */
  67570. useOnlyInActiveCamera: boolean;
  67571. /** @hidden */
  67572. static _SceneComponentInitialization: (scene: Scene) => void;
  67573. /**
  67574. * Instantiates a depth renderer
  67575. * @param scene The scene the renderer belongs to
  67576. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  67577. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  67578. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67579. */
  67580. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  67581. /**
  67582. * Creates the depth rendering effect and checks if the effect is ready.
  67583. * @param subMesh The submesh to be used to render the depth map of
  67584. * @param useInstances If multiple world instances should be used
  67585. * @returns if the depth renderer is ready to render the depth map
  67586. */
  67587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67588. /**
  67589. * Gets the texture which the depth map will be written to.
  67590. * @returns The depth map texture
  67591. */
  67592. getDepthMap(): RenderTargetTexture;
  67593. /**
  67594. * Disposes of the depth renderer.
  67595. */
  67596. dispose(): void;
  67597. }
  67598. }
  67599. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  67600. import { Nullable } from "babylonjs/types";
  67601. import { Scene } from "babylonjs/scene";
  67602. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67603. import { Camera } from "babylonjs/Cameras/camera";
  67604. import { ISceneComponent } from "babylonjs/sceneComponent";
  67605. module "babylonjs/scene" {
  67606. interface Scene {
  67607. /** @hidden (Backing field) */
  67608. _depthRenderer: {
  67609. [id: string]: DepthRenderer;
  67610. };
  67611. /**
  67612. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67613. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67614. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67615. * @returns the created depth renderer
  67616. */
  67617. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67618. /**
  67619. * Disables a depth renderer for a given camera
  67620. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67621. */
  67622. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67623. }
  67624. }
  67625. /**
  67626. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67627. * in several rendering techniques.
  67628. */
  67629. export class DepthRendererSceneComponent implements ISceneComponent {
  67630. /**
  67631. * The component name helpfull to identify the component in the list of scene components.
  67632. */
  67633. readonly name: string;
  67634. /**
  67635. * The scene the component belongs to.
  67636. */
  67637. scene: Scene;
  67638. /**
  67639. * Creates a new instance of the component for the given scene
  67640. * @param scene Defines the scene to register the component in
  67641. */
  67642. constructor(scene: Scene);
  67643. /**
  67644. * Registers the component in a given scene
  67645. */
  67646. register(): void;
  67647. /**
  67648. * Rebuilds the elements related to this component in case of
  67649. * context lost for instance.
  67650. */
  67651. rebuild(): void;
  67652. /**
  67653. * Disposes the component and the associated ressources
  67654. */
  67655. dispose(): void;
  67656. private _gatherRenderTargets;
  67657. private _gatherActiveCameraRenderTargets;
  67658. }
  67659. }
  67660. declare module "babylonjs/Shaders/outline.fragment" {
  67661. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67662. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  67663. /** @hidden */
  67664. export var outlinePixelShader: {
  67665. name: string;
  67666. shader: string;
  67667. };
  67668. }
  67669. declare module "babylonjs/Shaders/outline.vertex" {
  67670. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67671. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67672. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67673. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67674. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67675. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67676. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67677. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67678. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  67679. /** @hidden */
  67680. export var outlineVertexShader: {
  67681. name: string;
  67682. shader: string;
  67683. };
  67684. }
  67685. declare module "babylonjs/Rendering/outlineRenderer" {
  67686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67687. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  67688. import { Scene } from "babylonjs/scene";
  67689. import { ISceneComponent } from "babylonjs/sceneComponent";
  67690. import "babylonjs/Shaders/outline.fragment";
  67691. import "babylonjs/Shaders/outline.vertex";
  67692. module "babylonjs/scene" {
  67693. interface Scene {
  67694. /** @hidden */
  67695. _outlineRenderer: OutlineRenderer;
  67696. /**
  67697. * Gets the outline renderer associated with the scene
  67698. * @returns a OutlineRenderer
  67699. */
  67700. getOutlineRenderer(): OutlineRenderer;
  67701. }
  67702. }
  67703. module "babylonjs/Meshes/abstractMesh" {
  67704. interface AbstractMesh {
  67705. /** @hidden (Backing field) */
  67706. _renderOutline: boolean;
  67707. /**
  67708. * Gets or sets a boolean indicating if the outline must be rendered as well
  67709. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67710. */
  67711. renderOutline: boolean;
  67712. /** @hidden (Backing field) */
  67713. _renderOverlay: boolean;
  67714. /**
  67715. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67716. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67717. */
  67718. renderOverlay: boolean;
  67719. }
  67720. }
  67721. /**
  67722. * This class is responsible to draw bothe outline/overlay of meshes.
  67723. * It should not be used directly but through the available method on mesh.
  67724. */
  67725. export class OutlineRenderer implements ISceneComponent {
  67726. /**
  67727. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67728. */
  67729. private static _StencilReference;
  67730. /**
  67731. * The name of the component. Each component must have a unique name.
  67732. */
  67733. name: string;
  67734. /**
  67735. * The scene the component belongs to.
  67736. */
  67737. scene: Scene;
  67738. /**
  67739. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67740. */
  67741. zOffset: number;
  67742. private _engine;
  67743. private _effect;
  67744. private _cachedDefines;
  67745. private _savedDepthWrite;
  67746. /**
  67747. * Instantiates a new outline renderer. (There could be only one per scene).
  67748. * @param scene Defines the scene it belongs to
  67749. */
  67750. constructor(scene: Scene);
  67751. /**
  67752. * Register the component to one instance of a scene.
  67753. */
  67754. register(): void;
  67755. /**
  67756. * Rebuilds the elements related to this component in case of
  67757. * context lost for instance.
  67758. */
  67759. rebuild(): void;
  67760. /**
  67761. * Disposes the component and the associated ressources.
  67762. */
  67763. dispose(): void;
  67764. /**
  67765. * Renders the outline in the canvas.
  67766. * @param subMesh Defines the sumesh to render
  67767. * @param batch Defines the batch of meshes in case of instances
  67768. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67769. */
  67770. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67771. /**
  67772. * Returns whether or not the outline renderer is ready for a given submesh.
  67773. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67774. * @param subMesh Defines the submesh to check readyness for
  67775. * @param useInstances Defines wheter wee are trying to render instances or not
  67776. * @returns true if ready otherwise false
  67777. */
  67778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67779. private _beforeRenderingMesh;
  67780. private _afterRenderingMesh;
  67781. }
  67782. }
  67783. declare module "babylonjs/Rendering/index" {
  67784. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67785. export * from "babylonjs/Rendering/depthRenderer";
  67786. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67787. export * from "babylonjs/Rendering/edgesRenderer";
  67788. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67789. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67790. export * from "babylonjs/Rendering/outlineRenderer";
  67791. export * from "babylonjs/Rendering/renderingGroup";
  67792. export * from "babylonjs/Rendering/renderingManager";
  67793. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67794. }
  67795. declare module "babylonjs/Sprites/ISprites" {
  67796. /**
  67797. * Defines the basic options interface of a Sprite Frame Source Size.
  67798. */
  67799. export interface ISpriteJSONSpriteSourceSize {
  67800. /**
  67801. * number of the original width of the Frame
  67802. */
  67803. w: number;
  67804. /**
  67805. * number of the original height of the Frame
  67806. */
  67807. h: number;
  67808. }
  67809. /**
  67810. * Defines the basic options interface of a Sprite Frame Data.
  67811. */
  67812. export interface ISpriteJSONSpriteFrameData {
  67813. /**
  67814. * number of the x offset of the Frame
  67815. */
  67816. x: number;
  67817. /**
  67818. * number of the y offset of the Frame
  67819. */
  67820. y: number;
  67821. /**
  67822. * number of the width of the Frame
  67823. */
  67824. w: number;
  67825. /**
  67826. * number of the height of the Frame
  67827. */
  67828. h: number;
  67829. }
  67830. /**
  67831. * Defines the basic options interface of a JSON Sprite.
  67832. */
  67833. export interface ISpriteJSONSprite {
  67834. /**
  67835. * string name of the Frame
  67836. */
  67837. filename: string;
  67838. /**
  67839. * ISpriteJSONSpriteFrame basic object of the frame data
  67840. */
  67841. frame: ISpriteJSONSpriteFrameData;
  67842. /**
  67843. * boolean to flag is the frame was rotated.
  67844. */
  67845. rotated: boolean;
  67846. /**
  67847. * boolean to flag is the frame was trimmed.
  67848. */
  67849. trimmed: boolean;
  67850. /**
  67851. * ISpriteJSONSpriteFrame basic object of the source data
  67852. */
  67853. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67854. /**
  67855. * ISpriteJSONSpriteFrame basic object of the source data
  67856. */
  67857. sourceSize: ISpriteJSONSpriteSourceSize;
  67858. }
  67859. /**
  67860. * Defines the basic options interface of a JSON atlas.
  67861. */
  67862. export interface ISpriteJSONAtlas {
  67863. /**
  67864. * Array of objects that contain the frame data.
  67865. */
  67866. frames: Array<ISpriteJSONSprite>;
  67867. /**
  67868. * object basic object containing the sprite meta data.
  67869. */
  67870. meta?: object;
  67871. }
  67872. }
  67873. declare module "babylonjs/Shaders/spriteMap.fragment" {
  67874. /** @hidden */
  67875. export var spriteMapPixelShader: {
  67876. name: string;
  67877. shader: string;
  67878. };
  67879. }
  67880. declare module "babylonjs/Shaders/spriteMap.vertex" {
  67881. /** @hidden */
  67882. export var spriteMapVertexShader: {
  67883. name: string;
  67884. shader: string;
  67885. };
  67886. }
  67887. declare module "babylonjs/Sprites/spriteMap" {
  67888. import { IDisposable, Scene } from "babylonjs/scene";
  67889. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  67890. import { Texture } from "babylonjs/Materials/Textures/texture";
  67891. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67892. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  67893. import "babylonjs/Meshes/Builders/planeBuilder";
  67894. import "babylonjs/Shaders/spriteMap.fragment";
  67895. import "babylonjs/Shaders/spriteMap.vertex";
  67896. /**
  67897. * Defines the basic options interface of a SpriteMap
  67898. */
  67899. export interface ISpriteMapOptions {
  67900. /**
  67901. * Vector2 of the number of cells in the grid.
  67902. */
  67903. stageSize?: Vector2;
  67904. /**
  67905. * Vector2 of the size of the output plane in World Units.
  67906. */
  67907. outputSize?: Vector2;
  67908. /**
  67909. * Vector3 of the position of the output plane in World Units.
  67910. */
  67911. outputPosition?: Vector3;
  67912. /**
  67913. * Vector3 of the rotation of the output plane.
  67914. */
  67915. outputRotation?: Vector3;
  67916. /**
  67917. * number of layers that the system will reserve in resources.
  67918. */
  67919. layerCount?: number;
  67920. /**
  67921. * number of max animation frames a single cell will reserve in resources.
  67922. */
  67923. maxAnimationFrames?: number;
  67924. /**
  67925. * number cell index of the base tile when the system compiles.
  67926. */
  67927. baseTile?: number;
  67928. /**
  67929. * boolean flip the sprite after its been repositioned by the framing data.
  67930. */
  67931. flipU?: boolean;
  67932. /**
  67933. * Vector3 scalar of the global RGB values of the SpriteMap.
  67934. */
  67935. colorMultiply?: Vector3;
  67936. }
  67937. /**
  67938. * Defines the IDisposable interface in order to be cleanable from resources.
  67939. */
  67940. export interface ISpriteMap extends IDisposable {
  67941. /**
  67942. * String name of the SpriteMap.
  67943. */
  67944. name: string;
  67945. /**
  67946. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67947. */
  67948. atlasJSON: ISpriteJSONAtlas;
  67949. /**
  67950. * Texture of the SpriteMap.
  67951. */
  67952. spriteSheet: Texture;
  67953. /**
  67954. * The parameters to initialize the SpriteMap with.
  67955. */
  67956. options: ISpriteMapOptions;
  67957. }
  67958. /**
  67959. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67960. */
  67961. export class SpriteMap implements ISpriteMap {
  67962. /** The Name of the spriteMap */
  67963. name: string;
  67964. /** The JSON file with the frame and meta data */
  67965. atlasJSON: ISpriteJSONAtlas;
  67966. /** The systems Sprite Sheet Texture */
  67967. spriteSheet: Texture;
  67968. /** Arguments passed with the Constructor */
  67969. options: ISpriteMapOptions;
  67970. /** Public Sprite Storage array, parsed from atlasJSON */
  67971. sprites: Array<ISpriteJSONSprite>;
  67972. /** Returns the Number of Sprites in the System */
  67973. readonly spriteCount: number;
  67974. /** Returns the Position of Output Plane*/
  67975. /** Returns the Position of Output Plane*/
  67976. position: Vector3;
  67977. /** Returns the Rotation of Output Plane*/
  67978. /** Returns the Rotation of Output Plane*/
  67979. rotation: Vector3;
  67980. /** Sets the AnimationMap*/
  67981. /** Sets the AnimationMap*/
  67982. animationMap: RawTexture;
  67983. /** Scene that the SpriteMap was created in */
  67984. private _scene;
  67985. /** Texture Buffer of Float32 that holds tile frame data*/
  67986. private _frameMap;
  67987. /** Texture Buffers of Float32 that holds tileMap data*/
  67988. private _tileMaps;
  67989. /** Texture Buffer of Float32 that holds Animation Data*/
  67990. private _animationMap;
  67991. /** Custom ShaderMaterial Central to the System*/
  67992. private _material;
  67993. /** Custom ShaderMaterial Central to the System*/
  67994. private _output;
  67995. /** Systems Time Ticker*/
  67996. private _time;
  67997. /**
  67998. * Creates a new SpriteMap
  67999. * @param name defines the SpriteMaps Name
  68000. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68001. * @param spriteSheet is the Texture that the Sprites are on.
  68002. * @param options a basic deployment configuration
  68003. * @param scene The Scene that the map is deployed on
  68004. */
  68005. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68006. /**
  68007. * Returns tileID location
  68008. * @returns Vector2 the cell position ID
  68009. */
  68010. getTileID(): Vector2;
  68011. /**
  68012. * Gets the UV location of the mouse over the SpriteMap.
  68013. * @returns Vector2 the UV position of the mouse interaction
  68014. */
  68015. getMousePosition(): Vector2;
  68016. /**
  68017. * Creates the "frame" texture Buffer
  68018. * -------------------------------------
  68019. * Structure of frames
  68020. * "filename": "Falling-Water-2.png",
  68021. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68022. * "rotated": true,
  68023. * "trimmed": true,
  68024. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68025. * "sourceSize": {"w":32,"h":32}
  68026. * @returns RawTexture of the frameMap
  68027. */
  68028. private _createFrameBuffer;
  68029. /**
  68030. * Creates the tileMap texture Buffer
  68031. * @param buffer normally and array of numbers, or a false to generate from scratch
  68032. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68033. * @returns RawTexture of the tileMap
  68034. */
  68035. private _createTileBuffer;
  68036. /**
  68037. * Modifies the data of the tileMaps
  68038. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68039. * @param pos is the iVector2 Coordinates of the Tile
  68040. * @param tile The SpriteIndex of the new Tile
  68041. */
  68042. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68043. /**
  68044. * Creates the animationMap texture Buffer
  68045. * @param buffer normally and array of numbers, or a false to generate from scratch
  68046. * @returns RawTexture of the animationMap
  68047. */
  68048. private _createTileAnimationBuffer;
  68049. /**
  68050. * Modifies the data of the animationMap
  68051. * @param cellID is the Index of the Sprite
  68052. * @param _frame is the target Animation frame
  68053. * @param toCell is the Target Index of the next frame of the animation
  68054. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68055. * @param speed is a global scalar of the time variable on the map.
  68056. */
  68057. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68058. /**
  68059. * Exports the .tilemaps file
  68060. */
  68061. saveTileMaps(): void;
  68062. /**
  68063. * Imports the .tilemaps file
  68064. * @param url of the .tilemaps file
  68065. */
  68066. loadTileMaps(url: string): void;
  68067. /**
  68068. * Release associated resources
  68069. */
  68070. dispose(): void;
  68071. }
  68072. }
  68073. declare module "babylonjs/Sprites/spritePackedManager" {
  68074. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68075. import { Scene } from "babylonjs/scene";
  68076. /**
  68077. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68078. * @see http://doc.babylonjs.com/babylon101/sprites
  68079. */
  68080. export class SpritePackedManager extends SpriteManager {
  68081. /** defines the packed manager's name */
  68082. name: string;
  68083. /**
  68084. * Creates a new sprite manager from a packed sprite sheet
  68085. * @param name defines the manager's name
  68086. * @param imgUrl defines the sprite sheet url
  68087. * @param capacity defines the maximum allowed number of sprites
  68088. * @param scene defines the hosting scene
  68089. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68091. * @param samplingMode defines the smapling mode to use with spritesheet
  68092. * @param fromPacked set to true; do not alter
  68093. */
  68094. constructor(
  68095. /** defines the packed manager's name */
  68096. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68097. }
  68098. }
  68099. declare module "babylonjs/Sprites/index" {
  68100. export * from "babylonjs/Sprites/sprite";
  68101. export * from "babylonjs/Sprites/ISprites";
  68102. export * from "babylonjs/Sprites/spriteManager";
  68103. export * from "babylonjs/Sprites/spriteMap";
  68104. export * from "babylonjs/Sprites/spritePackedManager";
  68105. export * from "babylonjs/Sprites/spriteSceneComponent";
  68106. }
  68107. declare module "babylonjs/States/index" {
  68108. export * from "babylonjs/States/alphaCullingState";
  68109. export * from "babylonjs/States/depthCullingState";
  68110. export * from "babylonjs/States/stencilState";
  68111. }
  68112. declare module "babylonjs/Misc/assetsManager" {
  68113. import { Scene } from "babylonjs/scene";
  68114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68116. import { Skeleton } from "babylonjs/Bones/skeleton";
  68117. import { Observable } from "babylonjs/Misc/observable";
  68118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68119. import { Texture } from "babylonjs/Materials/Textures/texture";
  68120. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68121. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68122. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68123. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68124. /**
  68125. * Defines the list of states available for a task inside a AssetsManager
  68126. */
  68127. export enum AssetTaskState {
  68128. /**
  68129. * Initialization
  68130. */
  68131. INIT = 0,
  68132. /**
  68133. * Running
  68134. */
  68135. RUNNING = 1,
  68136. /**
  68137. * Done
  68138. */
  68139. DONE = 2,
  68140. /**
  68141. * Error
  68142. */
  68143. ERROR = 3
  68144. }
  68145. /**
  68146. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68147. */
  68148. export abstract class AbstractAssetTask {
  68149. /**
  68150. * Task name
  68151. */ name: string;
  68152. /**
  68153. * Callback called when the task is successful
  68154. */
  68155. onSuccess: (task: any) => void;
  68156. /**
  68157. * Callback called when the task is not successful
  68158. */
  68159. onError: (task: any, message?: string, exception?: any) => void;
  68160. /**
  68161. * Creates a new AssetsManager
  68162. * @param name defines the name of the task
  68163. */
  68164. constructor(
  68165. /**
  68166. * Task name
  68167. */ name: string);
  68168. private _isCompleted;
  68169. private _taskState;
  68170. private _errorObject;
  68171. /**
  68172. * Get if the task is completed
  68173. */
  68174. readonly isCompleted: boolean;
  68175. /**
  68176. * Gets the current state of the task
  68177. */
  68178. readonly taskState: AssetTaskState;
  68179. /**
  68180. * Gets the current error object (if task is in error)
  68181. */
  68182. readonly errorObject: {
  68183. message?: string;
  68184. exception?: any;
  68185. };
  68186. /**
  68187. * Internal only
  68188. * @hidden
  68189. */
  68190. _setErrorObject(message?: string, exception?: any): void;
  68191. /**
  68192. * Execute the current task
  68193. * @param scene defines the scene where you want your assets to be loaded
  68194. * @param onSuccess is a callback called when the task is successfully executed
  68195. * @param onError is a callback called if an error occurs
  68196. */
  68197. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68198. /**
  68199. * Execute the current task
  68200. * @param scene defines the scene where you want your assets to be loaded
  68201. * @param onSuccess is a callback called when the task is successfully executed
  68202. * @param onError is a callback called if an error occurs
  68203. */
  68204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68205. /**
  68206. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68207. * This can be used with failed tasks that have the reason for failure fixed.
  68208. */
  68209. reset(): void;
  68210. private onErrorCallback;
  68211. private onDoneCallback;
  68212. }
  68213. /**
  68214. * Define the interface used by progress events raised during assets loading
  68215. */
  68216. export interface IAssetsProgressEvent {
  68217. /**
  68218. * Defines the number of remaining tasks to process
  68219. */
  68220. remainingCount: number;
  68221. /**
  68222. * Defines the total number of tasks
  68223. */
  68224. totalCount: number;
  68225. /**
  68226. * Defines the task that was just processed
  68227. */
  68228. task: AbstractAssetTask;
  68229. }
  68230. /**
  68231. * Class used to share progress information about assets loading
  68232. */
  68233. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68234. /**
  68235. * Defines the number of remaining tasks to process
  68236. */
  68237. remainingCount: number;
  68238. /**
  68239. * Defines the total number of tasks
  68240. */
  68241. totalCount: number;
  68242. /**
  68243. * Defines the task that was just processed
  68244. */
  68245. task: AbstractAssetTask;
  68246. /**
  68247. * Creates a AssetsProgressEvent
  68248. * @param remainingCount defines the number of remaining tasks to process
  68249. * @param totalCount defines the total number of tasks
  68250. * @param task defines the task that was just processed
  68251. */
  68252. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68253. }
  68254. /**
  68255. * Define a task used by AssetsManager to load meshes
  68256. */
  68257. export class MeshAssetTask extends AbstractAssetTask {
  68258. /**
  68259. * Defines the name of the task
  68260. */
  68261. name: string;
  68262. /**
  68263. * Defines the list of mesh's names you want to load
  68264. */
  68265. meshesNames: any;
  68266. /**
  68267. * Defines the root url to use as a base to load your meshes and associated resources
  68268. */
  68269. rootUrl: string;
  68270. /**
  68271. * Defines the filename of the scene to load from
  68272. */
  68273. sceneFilename: string;
  68274. /**
  68275. * Gets the list of loaded meshes
  68276. */
  68277. loadedMeshes: Array<AbstractMesh>;
  68278. /**
  68279. * Gets the list of loaded particle systems
  68280. */
  68281. loadedParticleSystems: Array<IParticleSystem>;
  68282. /**
  68283. * Gets the list of loaded skeletons
  68284. */
  68285. loadedSkeletons: Array<Skeleton>;
  68286. /**
  68287. * Gets the list of loaded animation groups
  68288. */
  68289. loadedAnimationGroups: Array<AnimationGroup>;
  68290. /**
  68291. * Callback called when the task is successful
  68292. */
  68293. onSuccess: (task: MeshAssetTask) => void;
  68294. /**
  68295. * Callback called when the task is successful
  68296. */
  68297. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68298. /**
  68299. * Creates a new MeshAssetTask
  68300. * @param name defines the name of the task
  68301. * @param meshesNames defines the list of mesh's names you want to load
  68302. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68303. * @param sceneFilename defines the filename of the scene to load from
  68304. */
  68305. constructor(
  68306. /**
  68307. * Defines the name of the task
  68308. */
  68309. name: string,
  68310. /**
  68311. * Defines the list of mesh's names you want to load
  68312. */
  68313. meshesNames: any,
  68314. /**
  68315. * Defines the root url to use as a base to load your meshes and associated resources
  68316. */
  68317. rootUrl: string,
  68318. /**
  68319. * Defines the filename of the scene to load from
  68320. */
  68321. sceneFilename: string);
  68322. /**
  68323. * Execute the current task
  68324. * @param scene defines the scene where you want your assets to be loaded
  68325. * @param onSuccess is a callback called when the task is successfully executed
  68326. * @param onError is a callback called if an error occurs
  68327. */
  68328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68329. }
  68330. /**
  68331. * Define a task used by AssetsManager to load text content
  68332. */
  68333. export class TextFileAssetTask extends AbstractAssetTask {
  68334. /**
  68335. * Defines the name of the task
  68336. */
  68337. name: string;
  68338. /**
  68339. * Defines the location of the file to load
  68340. */
  68341. url: string;
  68342. /**
  68343. * Gets the loaded text string
  68344. */
  68345. text: string;
  68346. /**
  68347. * Callback called when the task is successful
  68348. */
  68349. onSuccess: (task: TextFileAssetTask) => void;
  68350. /**
  68351. * Callback called when the task is successful
  68352. */
  68353. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68354. /**
  68355. * Creates a new TextFileAssetTask object
  68356. * @param name defines the name of the task
  68357. * @param url defines the location of the file to load
  68358. */
  68359. constructor(
  68360. /**
  68361. * Defines the name of the task
  68362. */
  68363. name: string,
  68364. /**
  68365. * Defines the location of the file to load
  68366. */
  68367. url: string);
  68368. /**
  68369. * Execute the current task
  68370. * @param scene defines the scene where you want your assets to be loaded
  68371. * @param onSuccess is a callback called when the task is successfully executed
  68372. * @param onError is a callback called if an error occurs
  68373. */
  68374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68375. }
  68376. /**
  68377. * Define a task used by AssetsManager to load binary data
  68378. */
  68379. export class BinaryFileAssetTask extends AbstractAssetTask {
  68380. /**
  68381. * Defines the name of the task
  68382. */
  68383. name: string;
  68384. /**
  68385. * Defines the location of the file to load
  68386. */
  68387. url: string;
  68388. /**
  68389. * Gets the lodaded data (as an array buffer)
  68390. */
  68391. data: ArrayBuffer;
  68392. /**
  68393. * Callback called when the task is successful
  68394. */
  68395. onSuccess: (task: BinaryFileAssetTask) => void;
  68396. /**
  68397. * Callback called when the task is successful
  68398. */
  68399. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68400. /**
  68401. * Creates a new BinaryFileAssetTask object
  68402. * @param name defines the name of the new task
  68403. * @param url defines the location of the file to load
  68404. */
  68405. constructor(
  68406. /**
  68407. * Defines the name of the task
  68408. */
  68409. name: string,
  68410. /**
  68411. * Defines the location of the file to load
  68412. */
  68413. url: string);
  68414. /**
  68415. * Execute the current task
  68416. * @param scene defines the scene where you want your assets to be loaded
  68417. * @param onSuccess is a callback called when the task is successfully executed
  68418. * @param onError is a callback called if an error occurs
  68419. */
  68420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68421. }
  68422. /**
  68423. * Define a task used by AssetsManager to load images
  68424. */
  68425. export class ImageAssetTask extends AbstractAssetTask {
  68426. /**
  68427. * Defines the name of the task
  68428. */
  68429. name: string;
  68430. /**
  68431. * Defines the location of the image to load
  68432. */
  68433. url: string;
  68434. /**
  68435. * Gets the loaded images
  68436. */
  68437. image: HTMLImageElement;
  68438. /**
  68439. * Callback called when the task is successful
  68440. */
  68441. onSuccess: (task: ImageAssetTask) => void;
  68442. /**
  68443. * Callback called when the task is successful
  68444. */
  68445. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68446. /**
  68447. * Creates a new ImageAssetTask
  68448. * @param name defines the name of the task
  68449. * @param url defines the location of the image to load
  68450. */
  68451. constructor(
  68452. /**
  68453. * Defines the name of the task
  68454. */
  68455. name: string,
  68456. /**
  68457. * Defines the location of the image to load
  68458. */
  68459. url: string);
  68460. /**
  68461. * Execute the current task
  68462. * @param scene defines the scene where you want your assets to be loaded
  68463. * @param onSuccess is a callback called when the task is successfully executed
  68464. * @param onError is a callback called if an error occurs
  68465. */
  68466. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68467. }
  68468. /**
  68469. * Defines the interface used by texture loading tasks
  68470. */
  68471. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68472. /**
  68473. * Gets the loaded texture
  68474. */
  68475. texture: TEX;
  68476. }
  68477. /**
  68478. * Define a task used by AssetsManager to load 2D textures
  68479. */
  68480. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68481. /**
  68482. * Defines the name of the task
  68483. */
  68484. name: string;
  68485. /**
  68486. * Defines the location of the file to load
  68487. */
  68488. url: string;
  68489. /**
  68490. * Defines if mipmap should not be generated (default is false)
  68491. */
  68492. noMipmap?: boolean | undefined;
  68493. /**
  68494. * Defines if texture must be inverted on Y axis (default is false)
  68495. */
  68496. invertY?: boolean | undefined;
  68497. /**
  68498. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68499. */
  68500. samplingMode: number;
  68501. /**
  68502. * Gets the loaded texture
  68503. */
  68504. texture: Texture;
  68505. /**
  68506. * Callback called when the task is successful
  68507. */
  68508. onSuccess: (task: TextureAssetTask) => void;
  68509. /**
  68510. * Callback called when the task is successful
  68511. */
  68512. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68513. /**
  68514. * Creates a new TextureAssetTask object
  68515. * @param name defines the name of the task
  68516. * @param url defines the location of the file to load
  68517. * @param noMipmap defines if mipmap should not be generated (default is false)
  68518. * @param invertY defines if texture must be inverted on Y axis (default is false)
  68519. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68520. */
  68521. constructor(
  68522. /**
  68523. * Defines the name of the task
  68524. */
  68525. name: string,
  68526. /**
  68527. * Defines the location of the file to load
  68528. */
  68529. url: string,
  68530. /**
  68531. * Defines if mipmap should not be generated (default is false)
  68532. */
  68533. noMipmap?: boolean | undefined,
  68534. /**
  68535. * Defines if texture must be inverted on Y axis (default is false)
  68536. */
  68537. invertY?: boolean | undefined,
  68538. /**
  68539. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68540. */
  68541. samplingMode?: number);
  68542. /**
  68543. * Execute the current task
  68544. * @param scene defines the scene where you want your assets to be loaded
  68545. * @param onSuccess is a callback called when the task is successfully executed
  68546. * @param onError is a callback called if an error occurs
  68547. */
  68548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68549. }
  68550. /**
  68551. * Define a task used by AssetsManager to load cube textures
  68552. */
  68553. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68554. /**
  68555. * Defines the name of the task
  68556. */
  68557. name: string;
  68558. /**
  68559. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68560. */
  68561. url: string;
  68562. /**
  68563. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68564. */
  68565. extensions?: string[] | undefined;
  68566. /**
  68567. * Defines if mipmaps should not be generated (default is false)
  68568. */
  68569. noMipmap?: boolean | undefined;
  68570. /**
  68571. * Defines the explicit list of files (undefined by default)
  68572. */
  68573. files?: string[] | undefined;
  68574. /**
  68575. * Gets the loaded texture
  68576. */
  68577. texture: CubeTexture;
  68578. /**
  68579. * Callback called when the task is successful
  68580. */
  68581. onSuccess: (task: CubeTextureAssetTask) => void;
  68582. /**
  68583. * Callback called when the task is successful
  68584. */
  68585. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68586. /**
  68587. * Creates a new CubeTextureAssetTask
  68588. * @param name defines the name of the task
  68589. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68590. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68592. * @param files defines the explicit list of files (undefined by default)
  68593. */
  68594. constructor(
  68595. /**
  68596. * Defines the name of the task
  68597. */
  68598. name: string,
  68599. /**
  68600. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68601. */
  68602. url: string,
  68603. /**
  68604. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68605. */
  68606. extensions?: string[] | undefined,
  68607. /**
  68608. * Defines if mipmaps should not be generated (default is false)
  68609. */
  68610. noMipmap?: boolean | undefined,
  68611. /**
  68612. * Defines the explicit list of files (undefined by default)
  68613. */
  68614. files?: string[] | undefined);
  68615. /**
  68616. * Execute the current task
  68617. * @param scene defines the scene where you want your assets to be loaded
  68618. * @param onSuccess is a callback called when the task is successfully executed
  68619. * @param onError is a callback called if an error occurs
  68620. */
  68621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68622. }
  68623. /**
  68624. * Define a task used by AssetsManager to load HDR cube textures
  68625. */
  68626. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68627. /**
  68628. * Defines the name of the task
  68629. */
  68630. name: string;
  68631. /**
  68632. * Defines the location of the file to load
  68633. */
  68634. url: string;
  68635. /**
  68636. * Defines the desired size (the more it increases the longer the generation will be)
  68637. */
  68638. size: number;
  68639. /**
  68640. * Defines if mipmaps should not be generated (default is false)
  68641. */
  68642. noMipmap: boolean;
  68643. /**
  68644. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68645. */
  68646. generateHarmonics: boolean;
  68647. /**
  68648. * 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)
  68649. */
  68650. gammaSpace: boolean;
  68651. /**
  68652. * Internal Use Only
  68653. */
  68654. reserved: boolean;
  68655. /**
  68656. * Gets the loaded texture
  68657. */
  68658. texture: HDRCubeTexture;
  68659. /**
  68660. * Callback called when the task is successful
  68661. */
  68662. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68663. /**
  68664. * Callback called when the task is successful
  68665. */
  68666. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68667. /**
  68668. * Creates a new HDRCubeTextureAssetTask object
  68669. * @param name defines the name of the task
  68670. * @param url defines the location of the file to load
  68671. * @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.
  68672. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68673. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68674. * @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)
  68675. * @param reserved Internal use only
  68676. */
  68677. constructor(
  68678. /**
  68679. * Defines the name of the task
  68680. */
  68681. name: string,
  68682. /**
  68683. * Defines the location of the file to load
  68684. */
  68685. url: string,
  68686. /**
  68687. * Defines the desired size (the more it increases the longer the generation will be)
  68688. */
  68689. size: number,
  68690. /**
  68691. * Defines if mipmaps should not be generated (default is false)
  68692. */
  68693. noMipmap?: boolean,
  68694. /**
  68695. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68696. */
  68697. generateHarmonics?: boolean,
  68698. /**
  68699. * 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)
  68700. */
  68701. gammaSpace?: boolean,
  68702. /**
  68703. * Internal Use Only
  68704. */
  68705. reserved?: boolean);
  68706. /**
  68707. * Execute the current task
  68708. * @param scene defines the scene where you want your assets to be loaded
  68709. * @param onSuccess is a callback called when the task is successfully executed
  68710. * @param onError is a callback called if an error occurs
  68711. */
  68712. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68713. }
  68714. /**
  68715. * Define a task used by AssetsManager to load Equirectangular cube textures
  68716. */
  68717. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68718. /**
  68719. * Defines the name of the task
  68720. */
  68721. name: string;
  68722. /**
  68723. * Defines the location of the file to load
  68724. */
  68725. url: string;
  68726. /**
  68727. * Defines the desired size (the more it increases the longer the generation will be)
  68728. */
  68729. size: number;
  68730. /**
  68731. * Defines if mipmaps should not be generated (default is false)
  68732. */
  68733. noMipmap: boolean;
  68734. /**
  68735. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68736. * but the standard material would require them in Gamma space) (default is true)
  68737. */
  68738. gammaSpace: boolean;
  68739. /**
  68740. * Gets the loaded texture
  68741. */
  68742. texture: EquiRectangularCubeTexture;
  68743. /**
  68744. * Callback called when the task is successful
  68745. */
  68746. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68747. /**
  68748. * Callback called when the task is successful
  68749. */
  68750. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68751. /**
  68752. * Creates a new EquiRectangularCubeTextureAssetTask object
  68753. * @param name defines the name of the task
  68754. * @param url defines the location of the file to load
  68755. * @param size defines the desired size (the more it increases the longer the generation will be)
  68756. * If the size is omitted this implies you are using a preprocessed cubemap.
  68757. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68758. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68759. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68760. * (default is true)
  68761. */
  68762. constructor(
  68763. /**
  68764. * Defines the name of the task
  68765. */
  68766. name: string,
  68767. /**
  68768. * Defines the location of the file to load
  68769. */
  68770. url: string,
  68771. /**
  68772. * Defines the desired size (the more it increases the longer the generation will be)
  68773. */
  68774. size: number,
  68775. /**
  68776. * Defines if mipmaps should not be generated (default is false)
  68777. */
  68778. noMipmap?: boolean,
  68779. /**
  68780. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68781. * but the standard material would require them in Gamma space) (default is true)
  68782. */
  68783. gammaSpace?: boolean);
  68784. /**
  68785. * Execute the current task
  68786. * @param scene defines the scene where you want your assets to be loaded
  68787. * @param onSuccess is a callback called when the task is successfully executed
  68788. * @param onError is a callback called if an error occurs
  68789. */
  68790. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68791. }
  68792. /**
  68793. * This class can be used to easily import assets into a scene
  68794. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68795. */
  68796. export class AssetsManager {
  68797. private _scene;
  68798. private _isLoading;
  68799. protected _tasks: AbstractAssetTask[];
  68800. protected _waitingTasksCount: number;
  68801. protected _totalTasksCount: number;
  68802. /**
  68803. * Callback called when all tasks are processed
  68804. */
  68805. onFinish: (tasks: AbstractAssetTask[]) => void;
  68806. /**
  68807. * Callback called when a task is successful
  68808. */
  68809. onTaskSuccess: (task: AbstractAssetTask) => void;
  68810. /**
  68811. * Callback called when a task had an error
  68812. */
  68813. onTaskError: (task: AbstractAssetTask) => void;
  68814. /**
  68815. * Callback called when a task is done (whatever the result is)
  68816. */
  68817. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68818. /**
  68819. * Observable called when all tasks are processed
  68820. */
  68821. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68822. /**
  68823. * Observable called when a task had an error
  68824. */
  68825. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68826. /**
  68827. * Observable called when all tasks were executed
  68828. */
  68829. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68830. /**
  68831. * Observable called when a task is done (whatever the result is)
  68832. */
  68833. onProgressObservable: Observable<IAssetsProgressEvent>;
  68834. /**
  68835. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68837. */
  68838. useDefaultLoadingScreen: boolean;
  68839. /**
  68840. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68841. * when all assets have been downloaded.
  68842. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68843. */
  68844. autoHideLoadingUI: boolean;
  68845. /**
  68846. * Creates a new AssetsManager
  68847. * @param scene defines the scene to work on
  68848. */
  68849. constructor(scene: Scene);
  68850. /**
  68851. * Add a MeshAssetTask to the list of active tasks
  68852. * @param taskName defines the name of the new task
  68853. * @param meshesNames defines the name of meshes to load
  68854. * @param rootUrl defines the root url to use to locate files
  68855. * @param sceneFilename defines the filename of the scene file
  68856. * @returns a new MeshAssetTask object
  68857. */
  68858. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68859. /**
  68860. * Add a TextFileAssetTask to the list of active tasks
  68861. * @param taskName defines the name of the new task
  68862. * @param url defines the url of the file to load
  68863. * @returns a new TextFileAssetTask object
  68864. */
  68865. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68866. /**
  68867. * Add a BinaryFileAssetTask to the list of active tasks
  68868. * @param taskName defines the name of the new task
  68869. * @param url defines the url of the file to load
  68870. * @returns a new BinaryFileAssetTask object
  68871. */
  68872. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68873. /**
  68874. * Add a ImageAssetTask to the list of active tasks
  68875. * @param taskName defines the name of the new task
  68876. * @param url defines the url of the file to load
  68877. * @returns a new ImageAssetTask object
  68878. */
  68879. addImageTask(taskName: string, url: string): ImageAssetTask;
  68880. /**
  68881. * Add a TextureAssetTask to the list of active tasks
  68882. * @param taskName defines the name of the new task
  68883. * @param url defines the url of the file to load
  68884. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68885. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68886. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68887. * @returns a new TextureAssetTask object
  68888. */
  68889. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68890. /**
  68891. * Add a CubeTextureAssetTask to the list of active tasks
  68892. * @param taskName defines the name of the new task
  68893. * @param url defines the url of the file to load
  68894. * @param extensions defines the extension to use to load the cube map (can be null)
  68895. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68896. * @param files defines the list of files to load (can be null)
  68897. * @returns a new CubeTextureAssetTask object
  68898. */
  68899. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68900. /**
  68901. *
  68902. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68903. * @param taskName defines the name of the new task
  68904. * @param url defines the url of the file to load
  68905. * @param size defines the size you want for the cubemap (can be null)
  68906. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68907. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68908. * @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)
  68909. * @param reserved Internal use only
  68910. * @returns a new HDRCubeTextureAssetTask object
  68911. */
  68912. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68913. /**
  68914. *
  68915. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68916. * @param taskName defines the name of the new task
  68917. * @param url defines the url of the file to load
  68918. * @param size defines the size you want for the cubemap (can be null)
  68919. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68920. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68921. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68922. * @returns a new EquiRectangularCubeTextureAssetTask object
  68923. */
  68924. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68925. /**
  68926. * Remove a task from the assets manager.
  68927. * @param task the task to remove
  68928. */
  68929. removeTask(task: AbstractAssetTask): void;
  68930. private _decreaseWaitingTasksCount;
  68931. private _runTask;
  68932. /**
  68933. * Reset the AssetsManager and remove all tasks
  68934. * @return the current instance of the AssetsManager
  68935. */
  68936. reset(): AssetsManager;
  68937. /**
  68938. * Start the loading process
  68939. * @return the current instance of the AssetsManager
  68940. */
  68941. load(): AssetsManager;
  68942. /**
  68943. * Start the loading process as an async operation
  68944. * @return a promise returning the list of failed tasks
  68945. */
  68946. loadAsync(): Promise<void>;
  68947. }
  68948. }
  68949. declare module "babylonjs/Misc/deferred" {
  68950. /**
  68951. * Wrapper class for promise with external resolve and reject.
  68952. */
  68953. export class Deferred<T> {
  68954. /**
  68955. * The promise associated with this deferred object.
  68956. */
  68957. readonly promise: Promise<T>;
  68958. private _resolve;
  68959. private _reject;
  68960. /**
  68961. * The resolve method of the promise associated with this deferred object.
  68962. */
  68963. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  68964. /**
  68965. * The reject method of the promise associated with this deferred object.
  68966. */
  68967. readonly reject: (reason?: any) => void;
  68968. /**
  68969. * Constructor for this deferred object.
  68970. */
  68971. constructor();
  68972. }
  68973. }
  68974. declare module "babylonjs/Misc/meshExploder" {
  68975. import { Mesh } from "babylonjs/Meshes/mesh";
  68976. /**
  68977. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68978. */
  68979. export class MeshExploder {
  68980. private _centerMesh;
  68981. private _meshes;
  68982. private _meshesOrigins;
  68983. private _toCenterVectors;
  68984. private _scaledDirection;
  68985. private _newPosition;
  68986. private _centerPosition;
  68987. /**
  68988. * Explodes meshes from a center mesh.
  68989. * @param meshes The meshes to explode.
  68990. * @param centerMesh The mesh to be center of explosion.
  68991. */
  68992. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68993. private _setCenterMesh;
  68994. /**
  68995. * Get class name
  68996. * @returns "MeshExploder"
  68997. */
  68998. getClassName(): string;
  68999. /**
  69000. * "Exploded meshes"
  69001. * @returns Array of meshes with the centerMesh at index 0.
  69002. */
  69003. getMeshes(): Array<Mesh>;
  69004. /**
  69005. * Explodes meshes giving a specific direction
  69006. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69007. */
  69008. explode(direction?: number): void;
  69009. }
  69010. }
  69011. declare module "babylonjs/Misc/filesInput" {
  69012. import { Engine } from "babylonjs/Engines/engine";
  69013. import { Scene } from "babylonjs/scene";
  69014. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69015. /**
  69016. * Class used to help managing file picking and drag'n'drop
  69017. */
  69018. export class FilesInput {
  69019. /**
  69020. * List of files ready to be loaded
  69021. */
  69022. static readonly FilesToLoad: {
  69023. [key: string]: File;
  69024. };
  69025. /**
  69026. * Callback called when a file is processed
  69027. */
  69028. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69029. private _engine;
  69030. private _currentScene;
  69031. private _sceneLoadedCallback;
  69032. private _progressCallback;
  69033. private _additionalRenderLoopLogicCallback;
  69034. private _textureLoadingCallback;
  69035. private _startingProcessingFilesCallback;
  69036. private _onReloadCallback;
  69037. private _errorCallback;
  69038. private _elementToMonitor;
  69039. private _sceneFileToLoad;
  69040. private _filesToLoad;
  69041. /**
  69042. * Creates a new FilesInput
  69043. * @param engine defines the rendering engine
  69044. * @param scene defines the hosting scene
  69045. * @param sceneLoadedCallback callback called when scene is loaded
  69046. * @param progressCallback callback called to track progress
  69047. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69048. * @param textureLoadingCallback callback called when a texture is loading
  69049. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69050. * @param onReloadCallback callback called when a reload is requested
  69051. * @param errorCallback callback call if an error occurs
  69052. */
  69053. 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);
  69054. private _dragEnterHandler;
  69055. private _dragOverHandler;
  69056. private _dropHandler;
  69057. /**
  69058. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69059. * @param elementToMonitor defines the DOM element to track
  69060. */
  69061. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69062. /**
  69063. * Release all associated resources
  69064. */
  69065. dispose(): void;
  69066. private renderFunction;
  69067. private drag;
  69068. private drop;
  69069. private _traverseFolder;
  69070. private _processFiles;
  69071. /**
  69072. * Load files from a drop event
  69073. * @param event defines the drop event to use as source
  69074. */
  69075. loadFiles(event: any): void;
  69076. private _processReload;
  69077. /**
  69078. * Reload the current scene from the loaded files
  69079. */
  69080. reload(): void;
  69081. }
  69082. }
  69083. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69084. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69085. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69086. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69087. }
  69088. declare module "babylonjs/Misc/sceneOptimizer" {
  69089. import { Scene, IDisposable } from "babylonjs/scene";
  69090. import { Observable } from "babylonjs/Misc/observable";
  69091. /**
  69092. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69094. */
  69095. export class SceneOptimization {
  69096. /**
  69097. * Defines the priority of this optimization (0 by default which means first in the list)
  69098. */
  69099. priority: number;
  69100. /**
  69101. * Gets a string describing the action executed by the current optimization
  69102. * @returns description string
  69103. */
  69104. getDescription(): string;
  69105. /**
  69106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69107. * @param scene defines the current scene where to apply this optimization
  69108. * @param optimizer defines the current optimizer
  69109. * @returns true if everything that can be done was applied
  69110. */
  69111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69112. /**
  69113. * Creates the SceneOptimization object
  69114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69115. * @param desc defines the description associated with the optimization
  69116. */
  69117. constructor(
  69118. /**
  69119. * Defines the priority of this optimization (0 by default which means first in the list)
  69120. */
  69121. priority?: number);
  69122. }
  69123. /**
  69124. * Defines an optimization used to reduce the size of render target textures
  69125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69126. */
  69127. export class TextureOptimization extends SceneOptimization {
  69128. /**
  69129. * Defines the priority of this optimization (0 by default which means first in the list)
  69130. */
  69131. priority: number;
  69132. /**
  69133. * 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
  69134. */
  69135. maximumSize: number;
  69136. /**
  69137. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69138. */
  69139. step: number;
  69140. /**
  69141. * Gets a string describing the action executed by the current optimization
  69142. * @returns description string
  69143. */
  69144. getDescription(): string;
  69145. /**
  69146. * Creates the TextureOptimization object
  69147. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69148. * @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
  69149. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69150. */
  69151. constructor(
  69152. /**
  69153. * Defines the priority of this optimization (0 by default which means first in the list)
  69154. */
  69155. priority?: number,
  69156. /**
  69157. * 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
  69158. */
  69159. maximumSize?: number,
  69160. /**
  69161. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69162. */
  69163. step?: number);
  69164. /**
  69165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69166. * @param scene defines the current scene where to apply this optimization
  69167. * @param optimizer defines the current optimizer
  69168. * @returns true if everything that can be done was applied
  69169. */
  69170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69171. }
  69172. /**
  69173. * Defines an optimization used to increase or decrease the rendering resolution
  69174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69175. */
  69176. export class HardwareScalingOptimization extends SceneOptimization {
  69177. /**
  69178. * Defines the priority of this optimization (0 by default which means first in the list)
  69179. */
  69180. priority: number;
  69181. /**
  69182. * Defines the maximum scale to use (2 by default)
  69183. */
  69184. maximumScale: number;
  69185. /**
  69186. * Defines the step to use between two passes (0.5 by default)
  69187. */
  69188. step: number;
  69189. private _currentScale;
  69190. private _directionOffset;
  69191. /**
  69192. * Gets a string describing the action executed by the current optimization
  69193. * @return description string
  69194. */
  69195. getDescription(): string;
  69196. /**
  69197. * Creates the HardwareScalingOptimization object
  69198. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69199. * @param maximumScale defines the maximum scale to use (2 by default)
  69200. * @param step defines the step to use between two passes (0.5 by default)
  69201. */
  69202. constructor(
  69203. /**
  69204. * Defines the priority of this optimization (0 by default which means first in the list)
  69205. */
  69206. priority?: number,
  69207. /**
  69208. * Defines the maximum scale to use (2 by default)
  69209. */
  69210. maximumScale?: number,
  69211. /**
  69212. * Defines the step to use between two passes (0.5 by default)
  69213. */
  69214. step?: number);
  69215. /**
  69216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69217. * @param scene defines the current scene where to apply this optimization
  69218. * @param optimizer defines the current optimizer
  69219. * @returns true if everything that can be done was applied
  69220. */
  69221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69222. }
  69223. /**
  69224. * Defines an optimization used to remove shadows
  69225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69226. */
  69227. export class ShadowsOptimization extends SceneOptimization {
  69228. /**
  69229. * Gets a string describing the action executed by the current optimization
  69230. * @return description string
  69231. */
  69232. getDescription(): string;
  69233. /**
  69234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69235. * @param scene defines the current scene where to apply this optimization
  69236. * @param optimizer defines the current optimizer
  69237. * @returns true if everything that can be done was applied
  69238. */
  69239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69240. }
  69241. /**
  69242. * Defines an optimization used to turn post-processes off
  69243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69244. */
  69245. export class PostProcessesOptimization extends SceneOptimization {
  69246. /**
  69247. * Gets a string describing the action executed by the current optimization
  69248. * @return description string
  69249. */
  69250. getDescription(): string;
  69251. /**
  69252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69253. * @param scene defines the current scene where to apply this optimization
  69254. * @param optimizer defines the current optimizer
  69255. * @returns true if everything that can be done was applied
  69256. */
  69257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69258. }
  69259. /**
  69260. * Defines an optimization used to turn lens flares off
  69261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69262. */
  69263. export class LensFlaresOptimization extends SceneOptimization {
  69264. /**
  69265. * Gets a string describing the action executed by the current optimization
  69266. * @return description string
  69267. */
  69268. getDescription(): string;
  69269. /**
  69270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69271. * @param scene defines the current scene where to apply this optimization
  69272. * @param optimizer defines the current optimizer
  69273. * @returns true if everything that can be done was applied
  69274. */
  69275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69276. }
  69277. /**
  69278. * Defines an optimization based on user defined callback.
  69279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69280. */
  69281. export class CustomOptimization extends SceneOptimization {
  69282. /**
  69283. * Callback called to apply the custom optimization.
  69284. */
  69285. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69286. /**
  69287. * Callback called to get custom description
  69288. */
  69289. onGetDescription: () => string;
  69290. /**
  69291. * Gets a string describing the action executed by the current optimization
  69292. * @returns description string
  69293. */
  69294. getDescription(): string;
  69295. /**
  69296. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69297. * @param scene defines the current scene where to apply this optimization
  69298. * @param optimizer defines the current optimizer
  69299. * @returns true if everything that can be done was applied
  69300. */
  69301. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69302. }
  69303. /**
  69304. * Defines an optimization used to turn particles off
  69305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69306. */
  69307. export class ParticlesOptimization extends SceneOptimization {
  69308. /**
  69309. * Gets a string describing the action executed by the current optimization
  69310. * @return description string
  69311. */
  69312. getDescription(): string;
  69313. /**
  69314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69315. * @param scene defines the current scene where to apply this optimization
  69316. * @param optimizer defines the current optimizer
  69317. * @returns true if everything that can be done was applied
  69318. */
  69319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69320. }
  69321. /**
  69322. * Defines an optimization used to turn render targets off
  69323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69324. */
  69325. export class RenderTargetsOptimization extends SceneOptimization {
  69326. /**
  69327. * Gets a string describing the action executed by the current optimization
  69328. * @return description string
  69329. */
  69330. getDescription(): string;
  69331. /**
  69332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69333. * @param scene defines the current scene where to apply this optimization
  69334. * @param optimizer defines the current optimizer
  69335. * @returns true if everything that can be done was applied
  69336. */
  69337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69338. }
  69339. /**
  69340. * Defines an optimization used to merge meshes with compatible materials
  69341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69342. */
  69343. export class MergeMeshesOptimization extends SceneOptimization {
  69344. private static _UpdateSelectionTree;
  69345. /**
  69346. * Gets or sets a boolean which defines if optimization octree has to be updated
  69347. */
  69348. /**
  69349. * Gets or sets a boolean which defines if optimization octree has to be updated
  69350. */
  69351. static UpdateSelectionTree: boolean;
  69352. /**
  69353. * Gets a string describing the action executed by the current optimization
  69354. * @return description string
  69355. */
  69356. getDescription(): string;
  69357. private _canBeMerged;
  69358. /**
  69359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69360. * @param scene defines the current scene where to apply this optimization
  69361. * @param optimizer defines the current optimizer
  69362. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69363. * @returns true if everything that can be done was applied
  69364. */
  69365. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69366. }
  69367. /**
  69368. * Defines a list of options used by SceneOptimizer
  69369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69370. */
  69371. export class SceneOptimizerOptions {
  69372. /**
  69373. * Defines the target frame rate to reach (60 by default)
  69374. */
  69375. targetFrameRate: number;
  69376. /**
  69377. * Defines the interval between two checkes (2000ms by default)
  69378. */
  69379. trackerDuration: number;
  69380. /**
  69381. * Gets the list of optimizations to apply
  69382. */
  69383. optimizations: SceneOptimization[];
  69384. /**
  69385. * Creates a new list of options used by SceneOptimizer
  69386. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69387. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69388. */
  69389. constructor(
  69390. /**
  69391. * Defines the target frame rate to reach (60 by default)
  69392. */
  69393. targetFrameRate?: number,
  69394. /**
  69395. * Defines the interval between two checkes (2000ms by default)
  69396. */
  69397. trackerDuration?: number);
  69398. /**
  69399. * Add a new optimization
  69400. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69401. * @returns the current SceneOptimizerOptions
  69402. */
  69403. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69404. /**
  69405. * Add a new custom optimization
  69406. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69407. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69408. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69409. * @returns the current SceneOptimizerOptions
  69410. */
  69411. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69412. /**
  69413. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69414. * @param targetFrameRate defines the target frame rate (60 by default)
  69415. * @returns a SceneOptimizerOptions object
  69416. */
  69417. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69418. /**
  69419. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69420. * @param targetFrameRate defines the target frame rate (60 by default)
  69421. * @returns a SceneOptimizerOptions object
  69422. */
  69423. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69424. /**
  69425. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69426. * @param targetFrameRate defines the target frame rate (60 by default)
  69427. * @returns a SceneOptimizerOptions object
  69428. */
  69429. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69430. }
  69431. /**
  69432. * Class used to run optimizations in order to reach a target frame rate
  69433. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69434. */
  69435. export class SceneOptimizer implements IDisposable {
  69436. private _isRunning;
  69437. private _options;
  69438. private _scene;
  69439. private _currentPriorityLevel;
  69440. private _targetFrameRate;
  69441. private _trackerDuration;
  69442. private _currentFrameRate;
  69443. private _sceneDisposeObserver;
  69444. private _improvementMode;
  69445. /**
  69446. * Defines an observable called when the optimizer reaches the target frame rate
  69447. */
  69448. onSuccessObservable: Observable<SceneOptimizer>;
  69449. /**
  69450. * Defines an observable called when the optimizer enables an optimization
  69451. */
  69452. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69453. /**
  69454. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69455. */
  69456. onFailureObservable: Observable<SceneOptimizer>;
  69457. /**
  69458. * Gets a boolean indicating if the optimizer is in improvement mode
  69459. */
  69460. readonly isInImprovementMode: boolean;
  69461. /**
  69462. * Gets the current priority level (0 at start)
  69463. */
  69464. readonly currentPriorityLevel: number;
  69465. /**
  69466. * Gets the current frame rate checked by the SceneOptimizer
  69467. */
  69468. readonly currentFrameRate: number;
  69469. /**
  69470. * Gets or sets the current target frame rate (60 by default)
  69471. */
  69472. /**
  69473. * Gets or sets the current target frame rate (60 by default)
  69474. */
  69475. targetFrameRate: number;
  69476. /**
  69477. * Gets or sets the current interval between two checks (every 2000ms by default)
  69478. */
  69479. /**
  69480. * Gets or sets the current interval between two checks (every 2000ms by default)
  69481. */
  69482. trackerDuration: number;
  69483. /**
  69484. * Gets the list of active optimizations
  69485. */
  69486. readonly optimizations: SceneOptimization[];
  69487. /**
  69488. * Creates a new SceneOptimizer
  69489. * @param scene defines the scene to work on
  69490. * @param options defines the options to use with the SceneOptimizer
  69491. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69492. * @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)
  69493. */
  69494. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69495. /**
  69496. * Stops the current optimizer
  69497. */
  69498. stop(): void;
  69499. /**
  69500. * Reset the optimizer to initial step (current priority level = 0)
  69501. */
  69502. reset(): void;
  69503. /**
  69504. * Start the optimizer. By default it will try to reach a specific framerate
  69505. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69506. */
  69507. start(): void;
  69508. private _checkCurrentState;
  69509. /**
  69510. * Release all resources
  69511. */
  69512. dispose(): void;
  69513. /**
  69514. * Helper function to create a SceneOptimizer with one single line of code
  69515. * @param scene defines the scene to work on
  69516. * @param options defines the options to use with the SceneOptimizer
  69517. * @param onSuccess defines a callback to call on success
  69518. * @param onFailure defines a callback to call on failure
  69519. * @returns the new SceneOptimizer object
  69520. */
  69521. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69522. }
  69523. }
  69524. declare module "babylonjs/Misc/sceneSerializer" {
  69525. import { Scene } from "babylonjs/scene";
  69526. /**
  69527. * Class used to serialize a scene into a string
  69528. */
  69529. export class SceneSerializer {
  69530. /**
  69531. * Clear cache used by a previous serialization
  69532. */
  69533. static ClearCache(): void;
  69534. /**
  69535. * Serialize a scene into a JSON compatible object
  69536. * @param scene defines the scene to serialize
  69537. * @returns a JSON compatible object
  69538. */
  69539. static Serialize(scene: Scene): any;
  69540. /**
  69541. * Serialize a mesh into a JSON compatible object
  69542. * @param toSerialize defines the mesh to serialize
  69543. * @param withParents defines if parents must be serialized as well
  69544. * @param withChildren defines if children must be serialized as well
  69545. * @returns a JSON compatible object
  69546. */
  69547. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69548. }
  69549. }
  69550. declare module "babylonjs/Misc/textureTools" {
  69551. import { Texture } from "babylonjs/Materials/Textures/texture";
  69552. /**
  69553. * Class used to host texture specific utilities
  69554. */
  69555. export class TextureTools {
  69556. /**
  69557. * Uses the GPU to create a copy texture rescaled at a given size
  69558. * @param texture Texture to copy from
  69559. * @param width defines the desired width
  69560. * @param height defines the desired height
  69561. * @param useBilinearMode defines if bilinear mode has to be used
  69562. * @return the generated texture
  69563. */
  69564. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69565. }
  69566. }
  69567. declare module "babylonjs/Misc/videoRecorder" {
  69568. import { Nullable } from "babylonjs/types";
  69569. import { Engine } from "babylonjs/Engines/engine";
  69570. /**
  69571. * This represents the different options available for the video capture.
  69572. */
  69573. export interface VideoRecorderOptions {
  69574. /** Defines the mime type of the video. */
  69575. mimeType: string;
  69576. /** Defines the FPS the video should be recorded at. */
  69577. fps: number;
  69578. /** Defines the chunk size for the recording data. */
  69579. recordChunckSize: number;
  69580. /** The audio tracks to attach to the recording. */
  69581. audioTracks?: MediaStreamTrack[];
  69582. }
  69583. /**
  69584. * This can help with recording videos from BabylonJS.
  69585. * This is based on the available WebRTC functionalities of the browser.
  69586. *
  69587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69588. */
  69589. export class VideoRecorder {
  69590. private static readonly _defaultOptions;
  69591. /**
  69592. * Returns whether or not the VideoRecorder is available in your browser.
  69593. * @param engine Defines the Babylon Engine.
  69594. * @returns true if supported otherwise false.
  69595. */
  69596. static IsSupported(engine: Engine): boolean;
  69597. private readonly _options;
  69598. private _canvas;
  69599. private _mediaRecorder;
  69600. private _recordedChunks;
  69601. private _fileName;
  69602. private _resolve;
  69603. private _reject;
  69604. /**
  69605. * True when a recording is already in progress.
  69606. */
  69607. readonly isRecording: boolean;
  69608. /**
  69609. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69610. * @param engine Defines the BabylonJS Engine you wish to record.
  69611. * @param options Defines options that can be used to customize the capture.
  69612. */
  69613. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69614. /**
  69615. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69616. */
  69617. stopRecording(): void;
  69618. /**
  69619. * Starts recording the canvas for a max duration specified in parameters.
  69620. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69621. * If null no automatic download will start and you can rely on the promise to get the data back.
  69622. * @param maxDuration Defines the maximum recording time in seconds.
  69623. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69624. * @return A promise callback at the end of the recording with the video data in Blob.
  69625. */
  69626. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69627. /**
  69628. * Releases internal resources used during the recording.
  69629. */
  69630. dispose(): void;
  69631. private _handleDataAvailable;
  69632. private _handleError;
  69633. private _handleStop;
  69634. }
  69635. }
  69636. declare module "babylonjs/Misc/screenshotTools" {
  69637. import { Camera } from "babylonjs/Cameras/camera";
  69638. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  69639. import { Engine } from "babylonjs/Engines/engine";
  69640. /**
  69641. * Class containing a set of static utilities functions for screenshots
  69642. */
  69643. export class ScreenshotTools {
  69644. /**
  69645. * Captures a screenshot of the current rendering
  69646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69647. * @param engine defines the rendering engine
  69648. * @param camera defines the source camera
  69649. * @param size This parameter can be set to a single number or to an object with the
  69650. * following (optional) properties: precision, width, height. If a single number is passed,
  69651. * it will be used for both width and height. If an object is passed, the screenshot size
  69652. * will be derived from the parameters. The precision property is a multiplier allowing
  69653. * rendering at a higher or lower resolution
  69654. * @param successCallback defines the callback receives a single parameter which contains the
  69655. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69656. * src parameter of an <img> to display it
  69657. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69658. * Check your browser for supported MIME types
  69659. */
  69660. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69661. /**
  69662. * Captures a screenshot of the current rendering
  69663. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69664. * @param engine defines the rendering engine
  69665. * @param camera defines the source camera
  69666. * @param size This parameter can be set to a single number or to an object with the
  69667. * following (optional) properties: precision, width, height. If a single number is passed,
  69668. * it will be used for both width and height. If an object is passed, the screenshot size
  69669. * will be derived from the parameters. The precision property is a multiplier allowing
  69670. * rendering at a higher or lower resolution
  69671. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69672. * Check your browser for supported MIME types
  69673. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69674. * to the src parameter of an <img> to display it
  69675. */
  69676. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69677. /**
  69678. * Generates an image screenshot from the specified camera.
  69679. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69680. * @param engine The engine to use for rendering
  69681. * @param camera The camera to use for rendering
  69682. * @param size This parameter can be set to a single number or to an object with the
  69683. * following (optional) properties: precision, width, height. If a single number is passed,
  69684. * it will be used for both width and height. If an object is passed, the screenshot size
  69685. * will be derived from the parameters. The precision property is a multiplier allowing
  69686. * rendering at a higher or lower resolution
  69687. * @param successCallback The callback receives a single parameter which contains the
  69688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69689. * src parameter of an <img> to display it
  69690. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69691. * Check your browser for supported MIME types
  69692. * @param samples Texture samples (default: 1)
  69693. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69694. * @param fileName A name for for the downloaded file.
  69695. */
  69696. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  69697. /**
  69698. * Generates an image screenshot from the specified camera.
  69699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69700. * @param engine The engine to use for rendering
  69701. * @param camera The camera to use for rendering
  69702. * @param size This parameter can be set to a single number or to an object with the
  69703. * following (optional) properties: precision, width, height. If a single number is passed,
  69704. * it will be used for both width and height. If an object is passed, the screenshot size
  69705. * will be derived from the parameters. The precision property is a multiplier allowing
  69706. * rendering at a higher or lower resolution
  69707. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69708. * Check your browser for supported MIME types
  69709. * @param samples Texture samples (default: 1)
  69710. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69711. * @param fileName A name for for the downloaded file.
  69712. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69713. * to the src parameter of an <img> to display it
  69714. */
  69715. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  69716. /**
  69717. * Gets height and width for screenshot size
  69718. * @private
  69719. */
  69720. private static _getScreenshotSize;
  69721. }
  69722. }
  69723. declare module "babylonjs/Misc/dataReader" {
  69724. /**
  69725. * Interface for a data buffer
  69726. */
  69727. export interface IDataBuffer {
  69728. /**
  69729. * Reads bytes from the data buffer.
  69730. * @param byteOffset The byte offset to read
  69731. * @param byteLength The byte length to read
  69732. * @returns A promise that resolves when the bytes are read
  69733. */
  69734. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69735. /**
  69736. * The byte length of the buffer.
  69737. */
  69738. readonly byteLength: number;
  69739. }
  69740. /**
  69741. * Utility class for reading from a data buffer
  69742. */
  69743. export class DataReader {
  69744. /**
  69745. * The data buffer associated with this data reader.
  69746. */
  69747. readonly buffer: IDataBuffer;
  69748. /**
  69749. * The current byte offset from the beginning of the data buffer.
  69750. */
  69751. byteOffset: number;
  69752. private _dataView;
  69753. private _dataByteOffset;
  69754. /**
  69755. * Constructor
  69756. * @param buffer The buffer to read
  69757. */
  69758. constructor(buffer: IDataBuffer);
  69759. /**
  69760. * Loads the given byte length.
  69761. * @param byteLength The byte length to load
  69762. * @returns A promise that resolves when the load is complete
  69763. */
  69764. loadAsync(byteLength: number): Promise<void>;
  69765. /**
  69766. * Read a unsigned 32-bit integer from the currently loaded data range.
  69767. * @returns The 32-bit integer read
  69768. */
  69769. readUint32(): number;
  69770. /**
  69771. * Read a byte array from the currently loaded data range.
  69772. * @param byteLength The byte length to read
  69773. * @returns The byte array read
  69774. */
  69775. readUint8Array(byteLength: number): Uint8Array;
  69776. /**
  69777. * Read a string from the currently loaded data range.
  69778. * @param byteLength The byte length to read
  69779. * @returns The string read
  69780. */
  69781. readString(byteLength: number): string;
  69782. /**
  69783. * Skips the given byte length the currently loaded data range.
  69784. * @param byteLength The byte length to skip
  69785. */
  69786. skipBytes(byteLength: number): void;
  69787. }
  69788. }
  69789. declare module "babylonjs/Misc/index" {
  69790. export * from "babylonjs/Misc/andOrNotEvaluator";
  69791. export * from "babylonjs/Misc/assetsManager";
  69792. export * from "babylonjs/Misc/basis";
  69793. export * from "babylonjs/Misc/dds";
  69794. export * from "babylonjs/Misc/decorators";
  69795. export * from "babylonjs/Misc/deferred";
  69796. export * from "babylonjs/Misc/environmentTextureTools";
  69797. export * from "babylonjs/Misc/meshExploder";
  69798. export * from "babylonjs/Misc/filesInput";
  69799. export * from "babylonjs/Misc/HighDynamicRange/index";
  69800. export * from "babylonjs/Misc/khronosTextureContainer";
  69801. export * from "babylonjs/Misc/observable";
  69802. export * from "babylonjs/Misc/performanceMonitor";
  69803. export * from "babylonjs/Misc/promise";
  69804. export * from "babylonjs/Misc/sceneOptimizer";
  69805. export * from "babylonjs/Misc/sceneSerializer";
  69806. export * from "babylonjs/Misc/smartArray";
  69807. export * from "babylonjs/Misc/stringDictionary";
  69808. export * from "babylonjs/Misc/tags";
  69809. export * from "babylonjs/Misc/textureTools";
  69810. export * from "babylonjs/Misc/tga";
  69811. export * from "babylonjs/Misc/tools";
  69812. export * from "babylonjs/Misc/videoRecorder";
  69813. export * from "babylonjs/Misc/virtualJoystick";
  69814. export * from "babylonjs/Misc/workerPool";
  69815. export * from "babylonjs/Misc/logger";
  69816. export * from "babylonjs/Misc/typeStore";
  69817. export * from "babylonjs/Misc/filesInputStore";
  69818. export * from "babylonjs/Misc/deepCopier";
  69819. export * from "babylonjs/Misc/pivotTools";
  69820. export * from "babylonjs/Misc/precisionDate";
  69821. export * from "babylonjs/Misc/screenshotTools";
  69822. export * from "babylonjs/Misc/typeStore";
  69823. export * from "babylonjs/Misc/webRequest";
  69824. export * from "babylonjs/Misc/iInspectable";
  69825. export * from "babylonjs/Misc/brdfTextureTools";
  69826. export * from "babylonjs/Misc/rgbdTextureTools";
  69827. export * from "babylonjs/Misc/gradients";
  69828. export * from "babylonjs/Misc/perfCounter";
  69829. export * from "babylonjs/Misc/fileRequest";
  69830. export * from "babylonjs/Misc/customAnimationFrameRequester";
  69831. export * from "babylonjs/Misc/retryStrategy";
  69832. export * from "babylonjs/Misc/interfaces/screenshotSize";
  69833. export * from "babylonjs/Misc/canvasGenerator";
  69834. export * from "babylonjs/Misc/fileTools";
  69835. export * from "babylonjs/Misc/stringTools";
  69836. export * from "babylonjs/Misc/dataReader";
  69837. }
  69838. declare module "babylonjs/index" {
  69839. export * from "babylonjs/abstractScene";
  69840. export * from "babylonjs/Actions/index";
  69841. export * from "babylonjs/Animations/index";
  69842. export * from "babylonjs/assetContainer";
  69843. export * from "babylonjs/Audio/index";
  69844. export * from "babylonjs/Behaviors/index";
  69845. export * from "babylonjs/Bones/index";
  69846. export * from "babylonjs/Cameras/index";
  69847. export * from "babylonjs/Collisions/index";
  69848. export * from "babylonjs/Culling/index";
  69849. export * from "babylonjs/Debug/index";
  69850. export * from "babylonjs/Engines/index";
  69851. export * from "babylonjs/Events/index";
  69852. export * from "babylonjs/Gamepads/index";
  69853. export * from "babylonjs/Gizmos/index";
  69854. export * from "babylonjs/Helpers/index";
  69855. export * from "babylonjs/Instrumentation/index";
  69856. export * from "babylonjs/Layers/index";
  69857. export * from "babylonjs/LensFlares/index";
  69858. export * from "babylonjs/Lights/index";
  69859. export * from "babylonjs/Loading/index";
  69860. export * from "babylonjs/Materials/index";
  69861. export * from "babylonjs/Maths/index";
  69862. export * from "babylonjs/Meshes/index";
  69863. export * from "babylonjs/Morph/index";
  69864. export * from "babylonjs/Navigation/index";
  69865. export * from "babylonjs/node";
  69866. export * from "babylonjs/Offline/index";
  69867. export * from "babylonjs/Particles/index";
  69868. export * from "babylonjs/Physics/index";
  69869. export * from "babylonjs/PostProcesses/index";
  69870. export * from "babylonjs/Probes/index";
  69871. export * from "babylonjs/Rendering/index";
  69872. export * from "babylonjs/scene";
  69873. export * from "babylonjs/sceneComponent";
  69874. export * from "babylonjs/Sprites/index";
  69875. export * from "babylonjs/States/index";
  69876. export * from "babylonjs/Misc/index";
  69877. export * from "babylonjs/types";
  69878. }
  69879. declare module "babylonjs/Animations/pathCursor" {
  69880. import { Vector3 } from "babylonjs/Maths/math.vector";
  69881. import { Path2 } from "babylonjs/Maths/math.path";
  69882. /**
  69883. * A cursor which tracks a point on a path
  69884. */
  69885. export class PathCursor {
  69886. private path;
  69887. /**
  69888. * Stores path cursor callbacks for when an onchange event is triggered
  69889. */
  69890. private _onchange;
  69891. /**
  69892. * The value of the path cursor
  69893. */
  69894. value: number;
  69895. /**
  69896. * The animation array of the path cursor
  69897. */
  69898. animations: Animation[];
  69899. /**
  69900. * Initializes the path cursor
  69901. * @param path The path to track
  69902. */
  69903. constructor(path: Path2);
  69904. /**
  69905. * Gets the cursor point on the path
  69906. * @returns A point on the path cursor at the cursor location
  69907. */
  69908. getPoint(): Vector3;
  69909. /**
  69910. * Moves the cursor ahead by the step amount
  69911. * @param step The amount to move the cursor forward
  69912. * @returns This path cursor
  69913. */
  69914. moveAhead(step?: number): PathCursor;
  69915. /**
  69916. * Moves the cursor behind by the step amount
  69917. * @param step The amount to move the cursor back
  69918. * @returns This path cursor
  69919. */
  69920. moveBack(step?: number): PathCursor;
  69921. /**
  69922. * Moves the cursor by the step amount
  69923. * If the step amount is greater than one, an exception is thrown
  69924. * @param step The amount to move the cursor
  69925. * @returns This path cursor
  69926. */
  69927. move(step: number): PathCursor;
  69928. /**
  69929. * Ensures that the value is limited between zero and one
  69930. * @returns This path cursor
  69931. */
  69932. private ensureLimits;
  69933. /**
  69934. * Runs onchange callbacks on change (used by the animation engine)
  69935. * @returns This path cursor
  69936. */
  69937. private raiseOnChange;
  69938. /**
  69939. * Executes a function on change
  69940. * @param f A path cursor onchange callback
  69941. * @returns This path cursor
  69942. */
  69943. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69944. }
  69945. }
  69946. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  69947. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  69948. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  69949. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  69950. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  69951. }
  69952. declare module "babylonjs/Engines/Processors/Expressions/index" {
  69953. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  69954. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  69955. }
  69956. declare module "babylonjs/Engines/Processors/index" {
  69957. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  69958. export * from "babylonjs/Engines/Processors/Expressions/index";
  69959. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  69960. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  69961. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  69962. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  69963. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  69964. export * from "babylonjs/Engines/Processors/shaderProcessor";
  69965. }
  69966. declare module "babylonjs/Legacy/legacy" {
  69967. import * as Babylon from "babylonjs/index";
  69968. export * from "babylonjs/index";
  69969. }
  69970. declare module "babylonjs/Shaders/blur.fragment" {
  69971. /** @hidden */
  69972. export var blurPixelShader: {
  69973. name: string;
  69974. shader: string;
  69975. };
  69976. }
  69977. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  69978. /** @hidden */
  69979. export var pointCloudVertexDeclaration: {
  69980. name: string;
  69981. shader: string;
  69982. };
  69983. }
  69984. declare module "babylonjs" {
  69985. export * from "babylonjs/Legacy/legacy";
  69986. }
  69987. declare module BABYLON {
  69988. /** Alias type for value that can be null */
  69989. export type Nullable<T> = T | null;
  69990. /**
  69991. * Alias type for number that are floats
  69992. * @ignorenaming
  69993. */
  69994. export type float = number;
  69995. /**
  69996. * Alias type for number that are doubles.
  69997. * @ignorenaming
  69998. */
  69999. export type double = number;
  70000. /**
  70001. * Alias type for number that are integer
  70002. * @ignorenaming
  70003. */
  70004. export type int = number;
  70005. /** Alias type for number array or Float32Array */
  70006. export type FloatArray = number[] | Float32Array;
  70007. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70008. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70009. /**
  70010. * Alias for types that can be used by a Buffer or VertexBuffer.
  70011. */
  70012. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70013. /**
  70014. * Alias type for primitive types
  70015. * @ignorenaming
  70016. */
  70017. type Primitive = undefined | null | boolean | string | number | Function;
  70018. /**
  70019. * Type modifier to make all the properties of an object Readonly
  70020. */
  70021. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70022. /**
  70023. * Type modifier to make all the properties of an object Readonly recursively
  70024. */
  70025. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70026. /**
  70027. * Type modifier to make object properties readonly.
  70028. */
  70029. export type DeepImmutableObject<T> = {
  70030. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70031. };
  70032. /** @hidden */
  70033. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70034. }
  70035. }
  70036. declare module BABYLON {
  70037. /**
  70038. * A class serves as a medium between the observable and its observers
  70039. */
  70040. export class EventState {
  70041. /**
  70042. * Create a new EventState
  70043. * @param mask defines the mask associated with this state
  70044. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70045. * @param target defines the original target of the state
  70046. * @param currentTarget defines the current target of the state
  70047. */
  70048. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70049. /**
  70050. * Initialize the current event state
  70051. * @param mask defines the mask associated with this state
  70052. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70053. * @param target defines the original target of the state
  70054. * @param currentTarget defines the current target of the state
  70055. * @returns the current event state
  70056. */
  70057. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70058. /**
  70059. * An Observer can set this property to true to prevent subsequent observers of being notified
  70060. */
  70061. skipNextObservers: boolean;
  70062. /**
  70063. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70064. */
  70065. mask: number;
  70066. /**
  70067. * The object that originally notified the event
  70068. */
  70069. target?: any;
  70070. /**
  70071. * The current object in the bubbling phase
  70072. */
  70073. currentTarget?: any;
  70074. /**
  70075. * This will be populated with the return value of the last function that was executed.
  70076. * If it is the first function in the callback chain it will be the event data.
  70077. */
  70078. lastReturnValue?: any;
  70079. }
  70080. /**
  70081. * Represent an Observer registered to a given Observable object.
  70082. */
  70083. export class Observer<T> {
  70084. /**
  70085. * Defines the callback to call when the observer is notified
  70086. */
  70087. callback: (eventData: T, eventState: EventState) => void;
  70088. /**
  70089. * Defines the mask of the observer (used to filter notifications)
  70090. */
  70091. mask: number;
  70092. /**
  70093. * Defines the current scope used to restore the JS context
  70094. */
  70095. scope: any;
  70096. /** @hidden */
  70097. _willBeUnregistered: boolean;
  70098. /**
  70099. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70100. */
  70101. unregisterOnNextCall: boolean;
  70102. /**
  70103. * Creates a new observer
  70104. * @param callback defines the callback to call when the observer is notified
  70105. * @param mask defines the mask of the observer (used to filter notifications)
  70106. * @param scope defines the current scope used to restore the JS context
  70107. */
  70108. constructor(
  70109. /**
  70110. * Defines the callback to call when the observer is notified
  70111. */
  70112. callback: (eventData: T, eventState: EventState) => void,
  70113. /**
  70114. * Defines the mask of the observer (used to filter notifications)
  70115. */
  70116. mask: number,
  70117. /**
  70118. * Defines the current scope used to restore the JS context
  70119. */
  70120. scope?: any);
  70121. }
  70122. /**
  70123. * Represent a list of observers registered to multiple Observables object.
  70124. */
  70125. export class MultiObserver<T> {
  70126. private _observers;
  70127. private _observables;
  70128. /**
  70129. * Release associated resources
  70130. */
  70131. dispose(): void;
  70132. /**
  70133. * Raise a callback when one of the observable will notify
  70134. * @param observables defines a list of observables to watch
  70135. * @param callback defines the callback to call on notification
  70136. * @param mask defines the mask used to filter notifications
  70137. * @param scope defines the current scope used to restore the JS context
  70138. * @returns the new MultiObserver
  70139. */
  70140. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70141. }
  70142. /**
  70143. * The Observable class is a simple implementation of the Observable pattern.
  70144. *
  70145. * 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.
  70146. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70147. * 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).
  70148. * 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.
  70149. */
  70150. export class Observable<T> {
  70151. private _observers;
  70152. private _eventState;
  70153. private _onObserverAdded;
  70154. /**
  70155. * Gets the list of observers
  70156. */
  70157. readonly observers: Array<Observer<T>>;
  70158. /**
  70159. * Creates a new observable
  70160. * @param onObserverAdded defines a callback to call when a new observer is added
  70161. */
  70162. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70163. /**
  70164. * Create a new Observer with the specified callback
  70165. * @param callback the callback that will be executed for that Observer
  70166. * @param mask the mask used to filter observers
  70167. * @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.
  70168. * @param scope optional scope for the callback to be called from
  70169. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70170. * @returns the new observer created for the callback
  70171. */
  70172. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70173. /**
  70174. * Create a new Observer with the specified callback and unregisters after the next notification
  70175. * @param callback the callback that will be executed for that Observer
  70176. * @returns the new observer created for the callback
  70177. */
  70178. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70179. /**
  70180. * Remove an Observer from the Observable object
  70181. * @param observer the instance of the Observer to remove
  70182. * @returns false if it doesn't belong to this Observable
  70183. */
  70184. remove(observer: Nullable<Observer<T>>): boolean;
  70185. /**
  70186. * Remove a callback from the Observable object
  70187. * @param callback the callback to remove
  70188. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70189. * @returns false if it doesn't belong to this Observable
  70190. */
  70191. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70192. private _deferUnregister;
  70193. private _remove;
  70194. /**
  70195. * Moves the observable to the top of the observer list making it get called first when notified
  70196. * @param observer the observer to move
  70197. */
  70198. makeObserverTopPriority(observer: Observer<T>): void;
  70199. /**
  70200. * Moves the observable to the bottom of the observer list making it get called last when notified
  70201. * @param observer the observer to move
  70202. */
  70203. makeObserverBottomPriority(observer: Observer<T>): void;
  70204. /**
  70205. * Notify all Observers by calling their respective callback with the given data
  70206. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70207. * @param eventData defines the data to send to all observers
  70208. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70209. * @param target defines the original target of the state
  70210. * @param currentTarget defines the current target of the state
  70211. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70212. */
  70213. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70214. /**
  70215. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70216. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70217. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70218. * and it is crucial that all callbacks will be executed.
  70219. * The order of the callbacks is kept, callbacks are not executed parallel.
  70220. *
  70221. * @param eventData The data to be sent to each callback
  70222. * @param mask is used to filter observers defaults to -1
  70223. * @param target defines the callback target (see EventState)
  70224. * @param currentTarget defines he current object in the bubbling phase
  70225. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70226. */
  70227. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70228. /**
  70229. * Notify a specific observer
  70230. * @param observer defines the observer to notify
  70231. * @param eventData defines the data to be sent to each callback
  70232. * @param mask is used to filter observers defaults to -1
  70233. */
  70234. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70235. /**
  70236. * Gets a boolean indicating if the observable has at least one observer
  70237. * @returns true is the Observable has at least one Observer registered
  70238. */
  70239. hasObservers(): boolean;
  70240. /**
  70241. * Clear the list of observers
  70242. */
  70243. clear(): void;
  70244. /**
  70245. * Clone the current observable
  70246. * @returns a new observable
  70247. */
  70248. clone(): Observable<T>;
  70249. /**
  70250. * Does this observable handles observer registered with a given mask
  70251. * @param mask defines the mask to be tested
  70252. * @return whether or not one observer registered with the given mask is handeled
  70253. **/
  70254. hasSpecificMask(mask?: number): boolean;
  70255. }
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70260. * Babylon.js
  70261. */
  70262. export class DomManagement {
  70263. /**
  70264. * Checks if the window object exists
  70265. * @returns true if the window object exists
  70266. */
  70267. static IsWindowObjectExist(): boolean;
  70268. /**
  70269. * Checks if the navigator object exists
  70270. * @returns true if the navigator object exists
  70271. */
  70272. static IsNavigatorAvailable(): boolean;
  70273. /**
  70274. * Extracts text content from a DOM element hierarchy
  70275. * @param element defines the root element
  70276. * @returns a string
  70277. */
  70278. static GetDOMTextContent(element: HTMLElement): string;
  70279. }
  70280. }
  70281. declare module BABYLON {
  70282. /**
  70283. * Logger used througouht the application to allow configuration of
  70284. * the log level required for the messages.
  70285. */
  70286. export class Logger {
  70287. /**
  70288. * No log
  70289. */
  70290. static readonly NoneLogLevel: number;
  70291. /**
  70292. * Only message logs
  70293. */
  70294. static readonly MessageLogLevel: number;
  70295. /**
  70296. * Only warning logs
  70297. */
  70298. static readonly WarningLogLevel: number;
  70299. /**
  70300. * Only error logs
  70301. */
  70302. static readonly ErrorLogLevel: number;
  70303. /**
  70304. * All logs
  70305. */
  70306. static readonly AllLogLevel: number;
  70307. private static _LogCache;
  70308. /**
  70309. * Gets a value indicating the number of loading errors
  70310. * @ignorenaming
  70311. */
  70312. static errorsCount: number;
  70313. /**
  70314. * Callback called when a new log is added
  70315. */
  70316. static OnNewCacheEntry: (entry: string) => void;
  70317. private static _AddLogEntry;
  70318. private static _FormatMessage;
  70319. private static _LogDisabled;
  70320. private static _LogEnabled;
  70321. private static _WarnDisabled;
  70322. private static _WarnEnabled;
  70323. private static _ErrorDisabled;
  70324. private static _ErrorEnabled;
  70325. /**
  70326. * Log a message to the console
  70327. */
  70328. static Log: (message: string) => void;
  70329. /**
  70330. * Write a warning message to the console
  70331. */
  70332. static Warn: (message: string) => void;
  70333. /**
  70334. * Write an error message to the console
  70335. */
  70336. static Error: (message: string) => void;
  70337. /**
  70338. * Gets current log cache (list of logs)
  70339. */
  70340. static readonly LogCache: string;
  70341. /**
  70342. * Clears the log cache
  70343. */
  70344. static ClearLogCache(): void;
  70345. /**
  70346. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  70347. */
  70348. static LogLevels: number;
  70349. }
  70350. }
  70351. declare module BABYLON {
  70352. /** @hidden */
  70353. export class _TypeStore {
  70354. /** @hidden */
  70355. static RegisteredTypes: {
  70356. [key: string]: Object;
  70357. };
  70358. /** @hidden */
  70359. static GetClass(fqdn: string): any;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /**
  70364. * Helper to manipulate strings
  70365. */
  70366. export class StringTools {
  70367. /**
  70368. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70369. * @param str Source string
  70370. * @param suffix Suffix to search for in the source string
  70371. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70372. */
  70373. static EndsWith(str: string, suffix: string): boolean;
  70374. /**
  70375. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70376. * @param str Source string
  70377. * @param suffix Suffix to search for in the source string
  70378. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70379. */
  70380. static StartsWith(str: string, suffix: string): boolean;
  70381. /**
  70382. * Decodes a buffer into a string
  70383. * @param buffer The buffer to decode
  70384. * @returns The decoded string
  70385. */
  70386. static Decode(buffer: Uint8Array | Uint16Array): string;
  70387. /**
  70388. * Encode a buffer to a base64 string
  70389. * @param buffer defines the buffer to encode
  70390. * @returns the encoded string
  70391. */
  70392. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  70393. }
  70394. }
  70395. declare module BABYLON {
  70396. /**
  70397. * Class containing a set of static utilities functions for deep copy.
  70398. */
  70399. export class DeepCopier {
  70400. /**
  70401. * Tries to copy an object by duplicating every property
  70402. * @param source defines the source object
  70403. * @param destination defines the target object
  70404. * @param doNotCopyList defines a list of properties to avoid
  70405. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  70406. */
  70407. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  70408. }
  70409. }
  70410. declare module BABYLON {
  70411. /**
  70412. * Class containing a set of static utilities functions for precision date
  70413. */
  70414. export class PrecisionDate {
  70415. /**
  70416. * Gets either window.performance.now() if supported or Date.now() else
  70417. */
  70418. static readonly Now: number;
  70419. }
  70420. }
  70421. declare module BABYLON {
  70422. /** @hidden */
  70423. export class _DevTools {
  70424. static WarnImport(name: string): string;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /**
  70429. * Interface used to define the mechanism to get data from the network
  70430. */
  70431. export interface IWebRequest {
  70432. /**
  70433. * Returns client's response url
  70434. */
  70435. responseURL: string;
  70436. /**
  70437. * Returns client's status
  70438. */
  70439. status: number;
  70440. /**
  70441. * Returns client's status as a text
  70442. */
  70443. statusText: string;
  70444. }
  70445. }
  70446. declare module BABYLON {
  70447. /**
  70448. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  70449. */
  70450. export class WebRequest implements IWebRequest {
  70451. private _xhr;
  70452. /**
  70453. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  70454. * i.e. when loading files, where the server/service expects an Authorization header
  70455. */
  70456. static CustomRequestHeaders: {
  70457. [key: string]: string;
  70458. };
  70459. /**
  70460. * Add callback functions in this array to update all the requests before they get sent to the network
  70461. */
  70462. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  70463. private _injectCustomRequestHeaders;
  70464. /**
  70465. * Gets or sets a function to be called when loading progress changes
  70466. */
  70467. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  70468. /**
  70469. * Returns client's state
  70470. */
  70471. readonly readyState: number;
  70472. /**
  70473. * Returns client's status
  70474. */
  70475. readonly status: number;
  70476. /**
  70477. * Returns client's status as a text
  70478. */
  70479. readonly statusText: string;
  70480. /**
  70481. * Returns client's response
  70482. */
  70483. readonly response: any;
  70484. /**
  70485. * Returns client's response url
  70486. */
  70487. readonly responseURL: string;
  70488. /**
  70489. * Returns client's response as text
  70490. */
  70491. readonly responseText: string;
  70492. /**
  70493. * Gets or sets the expected response type
  70494. */
  70495. responseType: XMLHttpRequestResponseType;
  70496. /** @hidden */
  70497. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  70498. /** @hidden */
  70499. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  70500. /**
  70501. * Cancels any network activity
  70502. */
  70503. abort(): void;
  70504. /**
  70505. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  70506. * @param body defines an optional request body
  70507. */
  70508. send(body?: Document | BodyInit | null): void;
  70509. /**
  70510. * Sets the request method, request URL
  70511. * @param method defines the method to use (GET, POST, etc..)
  70512. * @param url defines the url to connect with
  70513. */
  70514. open(method: string, url: string): void;
  70515. /**
  70516. * Sets the value of a request header.
  70517. * @param name The name of the header whose value is to be set
  70518. * @param value The value to set as the body of the header
  70519. */
  70520. setRequestHeader(name: string, value: string): void;
  70521. /**
  70522. * Get the string containing the text of a particular header's value.
  70523. * @param name The name of the header
  70524. * @returns The string containing the text of the given header name
  70525. */
  70526. getResponseHeader(name: string): Nullable<string>;
  70527. }
  70528. }
  70529. declare module BABYLON {
  70530. /**
  70531. * File request interface
  70532. */
  70533. export interface IFileRequest {
  70534. /**
  70535. * Raised when the request is complete (success or error).
  70536. */
  70537. onCompleteObservable: Observable<IFileRequest>;
  70538. /**
  70539. * Aborts the request for a file.
  70540. */
  70541. abort: () => void;
  70542. }
  70543. }
  70544. declare module BABYLON {
  70545. /**
  70546. * Define options used to create a render target texture
  70547. */
  70548. export class RenderTargetCreationOptions {
  70549. /**
  70550. * Specifies is mipmaps must be generated
  70551. */
  70552. generateMipMaps?: boolean;
  70553. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70554. generateDepthBuffer?: boolean;
  70555. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70556. generateStencilBuffer?: boolean;
  70557. /** Defines texture type (int by default) */
  70558. type?: number;
  70559. /** Defines sampling mode (trilinear by default) */
  70560. samplingMode?: number;
  70561. /** Defines format (RGBA by default) */
  70562. format?: number;
  70563. }
  70564. }
  70565. declare module BABYLON {
  70566. /**
  70567. * @hidden
  70568. **/
  70569. export class _TimeToken {
  70570. _startTimeQuery: Nullable<WebGLQuery>;
  70571. _endTimeQuery: Nullable<WebGLQuery>;
  70572. _timeElapsedQuery: Nullable<WebGLQuery>;
  70573. _timeElapsedQueryEnded: boolean;
  70574. }
  70575. }
  70576. declare module BABYLON {
  70577. /** Defines the cross module used constants to avoid circular dependncies */
  70578. export class Constants {
  70579. /** Defines that alpha blending is disabled */
  70580. static readonly ALPHA_DISABLE: number;
  70581. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  70582. static readonly ALPHA_ADD: number;
  70583. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70584. static readonly ALPHA_COMBINE: number;
  70585. /** Defines that alpha blending is DEST - SRC * DEST */
  70586. static readonly ALPHA_SUBTRACT: number;
  70587. /** Defines that alpha blending is SRC * DEST */
  70588. static readonly ALPHA_MULTIPLY: number;
  70589. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  70590. static readonly ALPHA_MAXIMIZED: number;
  70591. /** Defines that alpha blending is SRC + DEST */
  70592. static readonly ALPHA_ONEONE: number;
  70593. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  70594. static readonly ALPHA_PREMULTIPLIED: number;
  70595. /**
  70596. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  70597. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70598. */
  70599. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70600. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  70601. static readonly ALPHA_INTERPOLATE: number;
  70602. /**
  70603. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  70604. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70605. */
  70606. static readonly ALPHA_SCREENMODE: number;
  70607. /**
  70608. * Defines that alpha blending is SRC + DST
  70609. * Alpha will be set to SRC ALPHA + DST ALPHA
  70610. */
  70611. static readonly ALPHA_ONEONE_ONEONE: number;
  70612. /**
  70613. * Defines that alpha blending is SRC * DST ALPHA + DST
  70614. * Alpha will be set to 0
  70615. */
  70616. static readonly ALPHA_ALPHATOCOLOR: number;
  70617. /**
  70618. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70619. */
  70620. static readonly ALPHA_REVERSEONEMINUS: number;
  70621. /**
  70622. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  70623. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70624. */
  70625. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70626. /**
  70627. * Defines that alpha blending is SRC + DST
  70628. * Alpha will be set to SRC ALPHA
  70629. */
  70630. static readonly ALPHA_ONEONE_ONEZERO: number;
  70631. /**
  70632. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70633. * Alpha will be set to DST ALPHA
  70634. */
  70635. static readonly ALPHA_EXCLUSION: number;
  70636. /** Defines that alpha blending equation a SUM */
  70637. static readonly ALPHA_EQUATION_ADD: number;
  70638. /** Defines that alpha blending equation a SUBSTRACTION */
  70639. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70640. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70641. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70642. /** Defines that alpha blending equation a MAX operation */
  70643. static readonly ALPHA_EQUATION_MAX: number;
  70644. /** Defines that alpha blending equation a MIN operation */
  70645. static readonly ALPHA_EQUATION_MIN: number;
  70646. /**
  70647. * Defines that alpha blending equation a DARKEN operation:
  70648. * It takes the min of the src and sums the alpha channels.
  70649. */
  70650. static readonly ALPHA_EQUATION_DARKEN: number;
  70651. /** Defines that the ressource is not delayed*/
  70652. static readonly DELAYLOADSTATE_NONE: number;
  70653. /** Defines that the ressource was successfully delay loaded */
  70654. static readonly DELAYLOADSTATE_LOADED: number;
  70655. /** Defines that the ressource is currently delay loading */
  70656. static readonly DELAYLOADSTATE_LOADING: number;
  70657. /** Defines that the ressource is delayed and has not started loading */
  70658. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70660. static readonly NEVER: number;
  70661. /** 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 */
  70662. static readonly ALWAYS: number;
  70663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70664. static readonly LESS: number;
  70665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70666. static readonly EQUAL: number;
  70667. /** 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 */
  70668. static readonly LEQUAL: number;
  70669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70670. static readonly GREATER: number;
  70671. /** 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 */
  70672. static readonly GEQUAL: number;
  70673. /** 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 */
  70674. static readonly NOTEQUAL: number;
  70675. /** Passed to stencilOperation to specify that stencil value must be kept */
  70676. static readonly KEEP: number;
  70677. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70678. static readonly REPLACE: number;
  70679. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70680. static readonly INCR: number;
  70681. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70682. static readonly DECR: number;
  70683. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70684. static readonly INVERT: number;
  70685. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70686. static readonly INCR_WRAP: number;
  70687. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70688. static readonly DECR_WRAP: number;
  70689. /** Texture is not repeating outside of 0..1 UVs */
  70690. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70691. /** Texture is repeating outside of 0..1 UVs */
  70692. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70693. /** Texture is repeating and mirrored */
  70694. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70695. /** ALPHA */
  70696. static readonly TEXTUREFORMAT_ALPHA: number;
  70697. /** LUMINANCE */
  70698. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70699. /** LUMINANCE_ALPHA */
  70700. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70701. /** RGB */
  70702. static readonly TEXTUREFORMAT_RGB: number;
  70703. /** RGBA */
  70704. static readonly TEXTUREFORMAT_RGBA: number;
  70705. /** RED */
  70706. static readonly TEXTUREFORMAT_RED: number;
  70707. /** RED (2nd reference) */
  70708. static readonly TEXTUREFORMAT_R: number;
  70709. /** RG */
  70710. static readonly TEXTUREFORMAT_RG: number;
  70711. /** RED_INTEGER */
  70712. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70713. /** RED_INTEGER (2nd reference) */
  70714. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70715. /** RG_INTEGER */
  70716. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70717. /** RGB_INTEGER */
  70718. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70719. /** RGBA_INTEGER */
  70720. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70721. /** UNSIGNED_BYTE */
  70722. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70723. /** UNSIGNED_BYTE (2nd reference) */
  70724. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70725. /** FLOAT */
  70726. static readonly TEXTURETYPE_FLOAT: number;
  70727. /** HALF_FLOAT */
  70728. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70729. /** BYTE */
  70730. static readonly TEXTURETYPE_BYTE: number;
  70731. /** SHORT */
  70732. static readonly TEXTURETYPE_SHORT: number;
  70733. /** UNSIGNED_SHORT */
  70734. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70735. /** INT */
  70736. static readonly TEXTURETYPE_INT: number;
  70737. /** UNSIGNED_INT */
  70738. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70739. /** UNSIGNED_SHORT_4_4_4_4 */
  70740. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70741. /** UNSIGNED_SHORT_5_5_5_1 */
  70742. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70743. /** UNSIGNED_SHORT_5_6_5 */
  70744. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70745. /** UNSIGNED_INT_2_10_10_10_REV */
  70746. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70747. /** UNSIGNED_INT_24_8 */
  70748. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70749. /** UNSIGNED_INT_10F_11F_11F_REV */
  70750. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70751. /** UNSIGNED_INT_5_9_9_9_REV */
  70752. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70753. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70754. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70755. /** nearest is mag = nearest and min = nearest and mip = nearest */
  70756. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70757. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70758. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70759. /** Trilinear is mag = linear and min = linear and mip = linear */
  70760. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70761. /** nearest is mag = nearest and min = nearest and mip = linear */
  70762. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70763. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70764. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70765. /** Trilinear is mag = linear and min = linear and mip = linear */
  70766. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70767. /** mag = nearest and min = nearest and mip = nearest */
  70768. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70769. /** mag = nearest and min = linear and mip = nearest */
  70770. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70771. /** mag = nearest and min = linear and mip = linear */
  70772. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70773. /** mag = nearest and min = linear and mip = none */
  70774. static readonly TEXTURE_NEAREST_LINEAR: number;
  70775. /** mag = nearest and min = nearest and mip = none */
  70776. static readonly TEXTURE_NEAREST_NEAREST: number;
  70777. /** mag = linear and min = nearest and mip = nearest */
  70778. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70779. /** mag = linear and min = nearest and mip = linear */
  70780. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70781. /** mag = linear and min = linear and mip = none */
  70782. static readonly TEXTURE_LINEAR_LINEAR: number;
  70783. /** mag = linear and min = nearest and mip = none */
  70784. static readonly TEXTURE_LINEAR_NEAREST: number;
  70785. /** Explicit coordinates mode */
  70786. static readonly TEXTURE_EXPLICIT_MODE: number;
  70787. /** Spherical coordinates mode */
  70788. static readonly TEXTURE_SPHERICAL_MODE: number;
  70789. /** Planar coordinates mode */
  70790. static readonly TEXTURE_PLANAR_MODE: number;
  70791. /** Cubic coordinates mode */
  70792. static readonly TEXTURE_CUBIC_MODE: number;
  70793. /** Projection coordinates mode */
  70794. static readonly TEXTURE_PROJECTION_MODE: number;
  70795. /** Skybox coordinates mode */
  70796. static readonly TEXTURE_SKYBOX_MODE: number;
  70797. /** Inverse Cubic coordinates mode */
  70798. static readonly TEXTURE_INVCUBIC_MODE: number;
  70799. /** Equirectangular coordinates mode */
  70800. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70801. /** Equirectangular Fixed coordinates mode */
  70802. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70803. /** Equirectangular Fixed Mirrored coordinates mode */
  70804. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70805. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70806. static readonly SCALEMODE_FLOOR: number;
  70807. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70808. static readonly SCALEMODE_NEAREST: number;
  70809. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70810. static readonly SCALEMODE_CEILING: number;
  70811. /**
  70812. * The dirty texture flag value
  70813. */
  70814. static readonly MATERIAL_TextureDirtyFlag: number;
  70815. /**
  70816. * The dirty light flag value
  70817. */
  70818. static readonly MATERIAL_LightDirtyFlag: number;
  70819. /**
  70820. * The dirty fresnel flag value
  70821. */
  70822. static readonly MATERIAL_FresnelDirtyFlag: number;
  70823. /**
  70824. * The dirty attribute flag value
  70825. */
  70826. static readonly MATERIAL_AttributesDirtyFlag: number;
  70827. /**
  70828. * The dirty misc flag value
  70829. */
  70830. static readonly MATERIAL_MiscDirtyFlag: number;
  70831. /**
  70832. * The all dirty flag value
  70833. */
  70834. static readonly MATERIAL_AllDirtyFlag: number;
  70835. /**
  70836. * Returns the triangle fill mode
  70837. */
  70838. static readonly MATERIAL_TriangleFillMode: number;
  70839. /**
  70840. * Returns the wireframe mode
  70841. */
  70842. static readonly MATERIAL_WireFrameFillMode: number;
  70843. /**
  70844. * Returns the point fill mode
  70845. */
  70846. static readonly MATERIAL_PointFillMode: number;
  70847. /**
  70848. * Returns the point list draw mode
  70849. */
  70850. static readonly MATERIAL_PointListDrawMode: number;
  70851. /**
  70852. * Returns the line list draw mode
  70853. */
  70854. static readonly MATERIAL_LineListDrawMode: number;
  70855. /**
  70856. * Returns the line loop draw mode
  70857. */
  70858. static readonly MATERIAL_LineLoopDrawMode: number;
  70859. /**
  70860. * Returns the line strip draw mode
  70861. */
  70862. static readonly MATERIAL_LineStripDrawMode: number;
  70863. /**
  70864. * Returns the triangle strip draw mode
  70865. */
  70866. static readonly MATERIAL_TriangleStripDrawMode: number;
  70867. /**
  70868. * Returns the triangle fan draw mode
  70869. */
  70870. static readonly MATERIAL_TriangleFanDrawMode: number;
  70871. /**
  70872. * Stores the clock-wise side orientation
  70873. */
  70874. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70875. /**
  70876. * Stores the counter clock-wise side orientation
  70877. */
  70878. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70879. /**
  70880. * Nothing
  70881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70882. */
  70883. static readonly ACTION_NothingTrigger: number;
  70884. /**
  70885. * On pick
  70886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70887. */
  70888. static readonly ACTION_OnPickTrigger: number;
  70889. /**
  70890. * On left pick
  70891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70892. */
  70893. static readonly ACTION_OnLeftPickTrigger: number;
  70894. /**
  70895. * On right pick
  70896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70897. */
  70898. static readonly ACTION_OnRightPickTrigger: number;
  70899. /**
  70900. * On center pick
  70901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70902. */
  70903. static readonly ACTION_OnCenterPickTrigger: number;
  70904. /**
  70905. * On pick down
  70906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70907. */
  70908. static readonly ACTION_OnPickDownTrigger: number;
  70909. /**
  70910. * On double pick
  70911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70912. */
  70913. static readonly ACTION_OnDoublePickTrigger: number;
  70914. /**
  70915. * On pick up
  70916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70917. */
  70918. static readonly ACTION_OnPickUpTrigger: number;
  70919. /**
  70920. * On pick out.
  70921. * This trigger will only be raised if you also declared a OnPickDown
  70922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70923. */
  70924. static readonly ACTION_OnPickOutTrigger: number;
  70925. /**
  70926. * On long press
  70927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70928. */
  70929. static readonly ACTION_OnLongPressTrigger: number;
  70930. /**
  70931. * On pointer over
  70932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70933. */
  70934. static readonly ACTION_OnPointerOverTrigger: number;
  70935. /**
  70936. * On pointer out
  70937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70938. */
  70939. static readonly ACTION_OnPointerOutTrigger: number;
  70940. /**
  70941. * On every frame
  70942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70943. */
  70944. static readonly ACTION_OnEveryFrameTrigger: number;
  70945. /**
  70946. * On intersection enter
  70947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70948. */
  70949. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70950. /**
  70951. * On intersection exit
  70952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70953. */
  70954. static readonly ACTION_OnIntersectionExitTrigger: number;
  70955. /**
  70956. * On key down
  70957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70958. */
  70959. static readonly ACTION_OnKeyDownTrigger: number;
  70960. /**
  70961. * On key up
  70962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70963. */
  70964. static readonly ACTION_OnKeyUpTrigger: number;
  70965. /**
  70966. * Billboard mode will only apply to Y axis
  70967. */
  70968. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70969. /**
  70970. * Billboard mode will apply to all axes
  70971. */
  70972. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70973. /**
  70974. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70975. */
  70976. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70977. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70978. * Test order :
  70979. * Is the bounding sphere outside the frustum ?
  70980. * If not, are the bounding box vertices outside the frustum ?
  70981. * It not, then the cullable object is in the frustum.
  70982. */
  70983. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70984. /** Culling strategy : Bounding Sphere Only.
  70985. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70986. * It's also less accurate than the standard because some not visible objects can still be selected.
  70987. * Test : is the bounding sphere outside the frustum ?
  70988. * If not, then the cullable object is in the frustum.
  70989. */
  70990. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70991. /** Culling strategy : Optimistic Inclusion.
  70992. * This in an inclusion test first, then the standard exclusion test.
  70993. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70994. * 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.
  70995. * Anyway, it's as accurate as the standard strategy.
  70996. * Test :
  70997. * Is the cullable object bounding sphere center in the frustum ?
  70998. * If not, apply the default culling strategy.
  70999. */
  71000. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71001. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71002. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71003. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71004. * 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.
  71005. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71006. * Test :
  71007. * Is the cullable object bounding sphere center in the frustum ?
  71008. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71009. */
  71010. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71011. /**
  71012. * No logging while loading
  71013. */
  71014. static readonly SCENELOADER_NO_LOGGING: number;
  71015. /**
  71016. * Minimal logging while loading
  71017. */
  71018. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71019. /**
  71020. * Summary logging while loading
  71021. */
  71022. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71023. /**
  71024. * Detailled logging while loading
  71025. */
  71026. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. /**
  71031. * This represents the required contract to create a new type of texture loader.
  71032. */
  71033. export interface IInternalTextureLoader {
  71034. /**
  71035. * Defines wether the loader supports cascade loading the different faces.
  71036. */
  71037. supportCascades: boolean;
  71038. /**
  71039. * This returns if the loader support the current file information.
  71040. * @param extension defines the file extension of the file being loaded
  71041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71042. * @param fallback defines the fallback internal texture if any
  71043. * @param isBase64 defines whether the texture is encoded as a base64
  71044. * @param isBuffer defines whether the texture data are stored as a buffer
  71045. * @returns true if the loader can load the specified file
  71046. */
  71047. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71048. /**
  71049. * Transform the url before loading if required.
  71050. * @param rootUrl the url of the texture
  71051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71052. * @returns the transformed texture
  71053. */
  71054. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71055. /**
  71056. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71057. * @param rootUrl the url of the texture
  71058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71059. * @returns the fallback texture
  71060. */
  71061. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71062. /**
  71063. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71064. * @param data contains the texture data
  71065. * @param texture defines the BabylonJS internal texture
  71066. * @param createPolynomials will be true if polynomials have been requested
  71067. * @param onLoad defines the callback to trigger once the texture is ready
  71068. * @param onError defines the callback to trigger in case of error
  71069. */
  71070. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71071. /**
  71072. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71073. * @param data contains the texture data
  71074. * @param texture defines the BabylonJS internal texture
  71075. * @param callback defines the method to call once ready to upload
  71076. */
  71077. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71078. }
  71079. }
  71080. declare module BABYLON {
  71081. /**
  71082. * Class used to store and describe the pipeline context associated with an effect
  71083. */
  71084. export interface IPipelineContext {
  71085. /**
  71086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71087. */
  71088. isAsync: boolean;
  71089. /**
  71090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71091. */
  71092. isReady: boolean;
  71093. /** @hidden */
  71094. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71095. }
  71096. }
  71097. declare module BABYLON {
  71098. /**
  71099. * Class used to store gfx data (like WebGLBuffer)
  71100. */
  71101. export class DataBuffer {
  71102. /**
  71103. * Gets or sets the number of objects referencing this buffer
  71104. */
  71105. references: number;
  71106. /** Gets or sets the size of the underlying buffer */
  71107. capacity: number;
  71108. /**
  71109. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71110. */
  71111. is32Bits: boolean;
  71112. /**
  71113. * Gets the underlying buffer
  71114. */
  71115. readonly underlyingResource: any;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /** @hidden */
  71120. export interface IShaderProcessor {
  71121. attributeProcessor?: (attribute: string) => string;
  71122. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71123. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71124. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71125. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71126. lineProcessor?: (line: string, isFragment: boolean) => string;
  71127. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71128. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71129. }
  71130. }
  71131. declare module BABYLON {
  71132. /** @hidden */
  71133. export interface ProcessingOptions {
  71134. defines: string[];
  71135. indexParameters: any;
  71136. isFragment: boolean;
  71137. shouldUseHighPrecisionShader: boolean;
  71138. supportsUniformBuffers: boolean;
  71139. shadersRepository: string;
  71140. includesShadersStore: {
  71141. [key: string]: string;
  71142. };
  71143. processor?: IShaderProcessor;
  71144. version: string;
  71145. platformName: string;
  71146. lookForClosingBracketForUniformBuffer?: boolean;
  71147. }
  71148. }
  71149. declare module BABYLON {
  71150. /** @hidden */
  71151. export class ShaderCodeNode {
  71152. line: string;
  71153. children: ShaderCodeNode[];
  71154. additionalDefineKey?: string;
  71155. additionalDefineValue?: string;
  71156. isValid(preprocessors: {
  71157. [key: string]: string;
  71158. }): boolean;
  71159. process(preprocessors: {
  71160. [key: string]: string;
  71161. }, options: ProcessingOptions): string;
  71162. }
  71163. }
  71164. declare module BABYLON {
  71165. /** @hidden */
  71166. export class ShaderCodeCursor {
  71167. private _lines;
  71168. lineIndex: number;
  71169. readonly currentLine: string;
  71170. readonly canRead: boolean;
  71171. lines: string[];
  71172. }
  71173. }
  71174. declare module BABYLON {
  71175. /** @hidden */
  71176. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71177. process(preprocessors: {
  71178. [key: string]: string;
  71179. }, options: ProcessingOptions): string;
  71180. }
  71181. }
  71182. declare module BABYLON {
  71183. /** @hidden */
  71184. export class ShaderDefineExpression {
  71185. isTrue(preprocessors: {
  71186. [key: string]: string;
  71187. }): boolean;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. /** @hidden */
  71192. export class ShaderCodeTestNode extends ShaderCodeNode {
  71193. testExpression: ShaderDefineExpression;
  71194. isValid(preprocessors: {
  71195. [key: string]: string;
  71196. }): boolean;
  71197. }
  71198. }
  71199. declare module BABYLON {
  71200. /** @hidden */
  71201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71202. define: string;
  71203. not: boolean;
  71204. constructor(define: string, not?: boolean);
  71205. isTrue(preprocessors: {
  71206. [key: string]: string;
  71207. }): boolean;
  71208. }
  71209. }
  71210. declare module BABYLON {
  71211. /** @hidden */
  71212. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71213. leftOperand: ShaderDefineExpression;
  71214. rightOperand: ShaderDefineExpression;
  71215. isTrue(preprocessors: {
  71216. [key: string]: string;
  71217. }): boolean;
  71218. }
  71219. }
  71220. declare module BABYLON {
  71221. /** @hidden */
  71222. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71223. leftOperand: ShaderDefineExpression;
  71224. rightOperand: ShaderDefineExpression;
  71225. isTrue(preprocessors: {
  71226. [key: string]: string;
  71227. }): boolean;
  71228. }
  71229. }
  71230. declare module BABYLON {
  71231. /** @hidden */
  71232. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71233. define: string;
  71234. operand: string;
  71235. testValue: string;
  71236. constructor(define: string, operand: string, testValue: string);
  71237. isTrue(preprocessors: {
  71238. [key: string]: string;
  71239. }): boolean;
  71240. }
  71241. }
  71242. declare module BABYLON {
  71243. /**
  71244. * Class used to enable access to offline support
  71245. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71246. */
  71247. export interface IOfflineProvider {
  71248. /**
  71249. * Gets a boolean indicating if scene must be saved in the database
  71250. */
  71251. enableSceneOffline: boolean;
  71252. /**
  71253. * Gets a boolean indicating if textures must be saved in the database
  71254. */
  71255. enableTexturesOffline: boolean;
  71256. /**
  71257. * Open the offline support and make it available
  71258. * @param successCallback defines the callback to call on success
  71259. * @param errorCallback defines the callback to call on error
  71260. */
  71261. open(successCallback: () => void, errorCallback: () => void): void;
  71262. /**
  71263. * Loads an image from the offline support
  71264. * @param url defines the url to load from
  71265. * @param image defines the target DOM image
  71266. */
  71267. loadImage(url: string, image: HTMLImageElement): void;
  71268. /**
  71269. * Loads a file from offline support
  71270. * @param url defines the URL to load from
  71271. * @param sceneLoaded defines a callback to call on success
  71272. * @param progressCallBack defines a callback to call when progress changed
  71273. * @param errorCallback defines a callback to call on error
  71274. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71275. */
  71276. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71277. }
  71278. }
  71279. declare module BABYLON {
  71280. /**
  71281. * Class used to help managing file picking and drag'n'drop
  71282. * File Storage
  71283. */
  71284. export class FilesInputStore {
  71285. /**
  71286. * List of files ready to be loaded
  71287. */
  71288. static FilesToLoad: {
  71289. [key: string]: File;
  71290. };
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /**
  71295. * Class used to define a retry strategy when error happens while loading assets
  71296. */
  71297. export class RetryStrategy {
  71298. /**
  71299. * Function used to defines an exponential back off strategy
  71300. * @param maxRetries defines the maximum number of retries (3 by default)
  71301. * @param baseInterval defines the interval between retries
  71302. * @returns the strategy function to use
  71303. */
  71304. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71305. }
  71306. }
  71307. declare module BABYLON {
  71308. /**
  71309. * @ignore
  71310. * Application error to support additional information when loading a file
  71311. */
  71312. export abstract class BaseError extends Error {
  71313. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71314. }
  71315. }
  71316. declare module BABYLON {
  71317. /** @ignore */
  71318. export class LoadFileError extends BaseError {
  71319. request?: WebRequest;
  71320. file?: File;
  71321. /**
  71322. * Creates a new LoadFileError
  71323. * @param message defines the message of the error
  71324. * @param request defines the optional web request
  71325. * @param file defines the optional file
  71326. */
  71327. constructor(message: string, object?: WebRequest | File);
  71328. }
  71329. /** @ignore */
  71330. export class RequestFileError extends BaseError {
  71331. request: WebRequest;
  71332. /**
  71333. * Creates a new LoadFileError
  71334. * @param message defines the message of the error
  71335. * @param request defines the optional web request
  71336. */
  71337. constructor(message: string, request: WebRequest);
  71338. }
  71339. /** @ignore */
  71340. export class ReadFileError extends BaseError {
  71341. file: File;
  71342. /**
  71343. * Creates a new ReadFileError
  71344. * @param message defines the message of the error
  71345. * @param file defines the optional file
  71346. */
  71347. constructor(message: string, file: File);
  71348. }
  71349. /**
  71350. * @hidden
  71351. */
  71352. export class FileTools {
  71353. /**
  71354. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71355. */
  71356. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71357. /**
  71358. * Gets or sets the base URL to use to load assets
  71359. */
  71360. static BaseUrl: string;
  71361. /**
  71362. * Default behaviour for cors in the application.
  71363. * It can be a string if the expected behavior is identical in the entire app.
  71364. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71365. */
  71366. static CorsBehavior: string | ((url: string | string[]) => string);
  71367. /**
  71368. * Gets or sets a function used to pre-process url before using them to load assets
  71369. */
  71370. static PreprocessUrl: (url: string) => string;
  71371. /**
  71372. * Removes unwanted characters from an url
  71373. * @param url defines the url to clean
  71374. * @returns the cleaned url
  71375. */
  71376. private static _CleanUrl;
  71377. /**
  71378. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71379. * @param url define the url we are trying
  71380. * @param element define the dom element where to configure the cors policy
  71381. */
  71382. static SetCorsBehavior(url: string | string[], element: {
  71383. crossOrigin: string | null;
  71384. }): void;
  71385. /**
  71386. * Loads an image as an HTMLImageElement.
  71387. * @param input url string, ArrayBuffer, or Blob to load
  71388. * @param onLoad callback called when the image successfully loads
  71389. * @param onError callback called when the image fails to load
  71390. * @param offlineProvider offline provider for caching
  71391. * @param mimeType optional mime type
  71392. * @returns the HTMLImageElement of the loaded image
  71393. */
  71394. 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>;
  71395. /**
  71396. * Reads a file from a File object
  71397. * @param file defines the file to load
  71398. * @param onSuccess defines the callback to call when data is loaded
  71399. * @param onProgress defines the callback to call during loading process
  71400. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71401. * @param onError defines the callback to call when an error occurs
  71402. * @returns a file request object
  71403. */
  71404. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  71405. /**
  71406. * Loads a file from a url
  71407. * @param url url to load
  71408. * @param onSuccess callback called when the file successfully loads
  71409. * @param onProgress callback called while file is loading (if the server supports this mode)
  71410. * @param offlineProvider defines the offline provider for caching
  71411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71412. * @param onError callback called when the file fails to load
  71413. * @returns a file request object
  71414. */
  71415. 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;
  71416. /**
  71417. * Loads a file
  71418. * @param url url to load
  71419. * @param onSuccess callback called when the file successfully loads
  71420. * @param onProgress callback called while file is loading (if the server supports this mode)
  71421. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71422. * @param onError callback called when the file fails to load
  71423. * @param onOpened callback called when the web request is opened
  71424. * @returns a file request object
  71425. */
  71426. 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;
  71427. /**
  71428. * Checks if the loaded document was accessed via `file:`-Protocol.
  71429. * @returns boolean
  71430. */
  71431. static IsFileURL(): boolean;
  71432. }
  71433. }
  71434. declare module BABYLON {
  71435. /** @hidden */
  71436. export class ShaderProcessor {
  71437. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71438. private static _ProcessPrecision;
  71439. private static _ExtractOperation;
  71440. private static _BuildSubExpression;
  71441. private static _BuildExpression;
  71442. private static _MoveCursorWithinIf;
  71443. private static _MoveCursor;
  71444. private static _EvaluatePreProcessors;
  71445. private static _PreparePreProcessors;
  71446. private static _ProcessShaderConversion;
  71447. private static _ProcessIncludes;
  71448. }
  71449. }
  71450. declare module BABYLON {
  71451. /**
  71452. * @hidden
  71453. */
  71454. export interface IColor4Like {
  71455. r: float;
  71456. g: float;
  71457. b: float;
  71458. a: float;
  71459. }
  71460. /**
  71461. * @hidden
  71462. */
  71463. export interface IColor3Like {
  71464. r: float;
  71465. g: float;
  71466. b: float;
  71467. }
  71468. /**
  71469. * @hidden
  71470. */
  71471. export interface IVector4Like {
  71472. x: float;
  71473. y: float;
  71474. z: float;
  71475. w: float;
  71476. }
  71477. /**
  71478. * @hidden
  71479. */
  71480. export interface IVector3Like {
  71481. x: float;
  71482. y: float;
  71483. z: float;
  71484. }
  71485. /**
  71486. * @hidden
  71487. */
  71488. export interface IVector2Like {
  71489. x: float;
  71490. y: float;
  71491. }
  71492. /**
  71493. * @hidden
  71494. */
  71495. export interface IMatrixLike {
  71496. toArray(): DeepImmutable<Float32Array>;
  71497. updateFlag: int;
  71498. }
  71499. /**
  71500. * @hidden
  71501. */
  71502. export interface IViewportLike {
  71503. x: float;
  71504. y: float;
  71505. width: float;
  71506. height: float;
  71507. }
  71508. /**
  71509. * @hidden
  71510. */
  71511. export interface IPlaneLike {
  71512. normal: IVector3Like;
  71513. d: float;
  71514. normalize(): void;
  71515. }
  71516. }
  71517. declare module BABYLON {
  71518. /**
  71519. * Interface used to define common properties for effect fallbacks
  71520. */
  71521. export interface IEffectFallbacks {
  71522. /**
  71523. * Removes the defines that should be removed when falling back.
  71524. * @param currentDefines defines the current define statements for the shader.
  71525. * @param effect defines the current effect we try to compile
  71526. * @returns The resulting defines with defines of the current rank removed.
  71527. */
  71528. reduce(currentDefines: string, effect: Effect): string;
  71529. /**
  71530. * Removes the fallback from the bound mesh.
  71531. */
  71532. unBindMesh(): void;
  71533. /**
  71534. * Checks to see if more fallbacks are still availible.
  71535. */
  71536. hasMoreFallbacks: boolean;
  71537. }
  71538. }
  71539. declare module BABYLON {
  71540. /**
  71541. * Class used to evalaute queries containing `and` and `or` operators
  71542. */
  71543. export class AndOrNotEvaluator {
  71544. /**
  71545. * Evaluate a query
  71546. * @param query defines the query to evaluate
  71547. * @param evaluateCallback defines the callback used to filter result
  71548. * @returns true if the query matches
  71549. */
  71550. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71551. private static _HandleParenthesisContent;
  71552. private static _SimplifyNegation;
  71553. }
  71554. }
  71555. declare module BABYLON {
  71556. /**
  71557. * Class used to store custom tags
  71558. */
  71559. export class Tags {
  71560. /**
  71561. * Adds support for tags on the given object
  71562. * @param obj defines the object to use
  71563. */
  71564. static EnableFor(obj: any): void;
  71565. /**
  71566. * Removes tags support
  71567. * @param obj defines the object to use
  71568. */
  71569. static DisableFor(obj: any): void;
  71570. /**
  71571. * Gets a boolean indicating if the given object has tags
  71572. * @param obj defines the object to use
  71573. * @returns a boolean
  71574. */
  71575. static HasTags(obj: any): boolean;
  71576. /**
  71577. * Gets the tags available on a given object
  71578. * @param obj defines the object to use
  71579. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71580. * @returns the tags
  71581. */
  71582. static GetTags(obj: any, asString?: boolean): any;
  71583. /**
  71584. * Adds tags to an object
  71585. * @param obj defines the object to use
  71586. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71587. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71588. */
  71589. static AddTagsTo(obj: any, tagsString: string): void;
  71590. /**
  71591. * @hidden
  71592. */
  71593. static _AddTagTo(obj: any, tag: string): void;
  71594. /**
  71595. * Removes specific tags from a specific object
  71596. * @param obj defines the object to use
  71597. * @param tagsString defines the tags to remove
  71598. */
  71599. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71600. /**
  71601. * @hidden
  71602. */
  71603. static _RemoveTagFrom(obj: any, tag: string): void;
  71604. /**
  71605. * Defines if tags hosted on an object match a given query
  71606. * @param obj defines the object to use
  71607. * @param tagsQuery defines the tag query
  71608. * @returns a boolean
  71609. */
  71610. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71611. }
  71612. }
  71613. declare module BABYLON {
  71614. /**
  71615. * Scalar computation library
  71616. */
  71617. export class Scalar {
  71618. /**
  71619. * Two pi constants convenient for computation.
  71620. */
  71621. static TwoPi: number;
  71622. /**
  71623. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71624. * @param a number
  71625. * @param b number
  71626. * @param epsilon (default = 1.401298E-45)
  71627. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71628. */
  71629. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  71630. /**
  71631. * Returns a string : the upper case translation of the number i to hexadecimal.
  71632. * @param i number
  71633. * @returns the upper case translation of the number i to hexadecimal.
  71634. */
  71635. static ToHex(i: number): string;
  71636. /**
  71637. * Returns -1 if value is negative and +1 is value is positive.
  71638. * @param value the value
  71639. * @returns the value itself if it's equal to zero.
  71640. */
  71641. static Sign(value: number): number;
  71642. /**
  71643. * Returns the value itself if it's between min and max.
  71644. * Returns min if the value is lower than min.
  71645. * Returns max if the value is greater than max.
  71646. * @param value the value to clmap
  71647. * @param min the min value to clamp to (default: 0)
  71648. * @param max the max value to clamp to (default: 1)
  71649. * @returns the clamped value
  71650. */
  71651. static Clamp(value: number, min?: number, max?: number): number;
  71652. /**
  71653. * the log2 of value.
  71654. * @param value the value to compute log2 of
  71655. * @returns the log2 of value.
  71656. */
  71657. static Log2(value: number): number;
  71658. /**
  71659. * Loops the value, so that it is never larger than length and never smaller than 0.
  71660. *
  71661. * This is similar to the modulo operator but it works with floating point numbers.
  71662. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  71663. * With t = 5 and length = 2.5, the result would be 0.0.
  71664. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  71665. * @param value the value
  71666. * @param length the length
  71667. * @returns the looped value
  71668. */
  71669. static Repeat(value: number, length: number): number;
  71670. /**
  71671. * Normalize the value between 0.0 and 1.0 using min and max values
  71672. * @param value value to normalize
  71673. * @param min max to normalize between
  71674. * @param max min to normalize between
  71675. * @returns the normalized value
  71676. */
  71677. static Normalize(value: number, min: number, max: number): number;
  71678. /**
  71679. * Denormalize the value from 0.0 and 1.0 using min and max values
  71680. * @param normalized value to denormalize
  71681. * @param min max to denormalize between
  71682. * @param max min to denormalize between
  71683. * @returns the denormalized value
  71684. */
  71685. static Denormalize(normalized: number, min: number, max: number): number;
  71686. /**
  71687. * Calculates the shortest difference between two given angles given in degrees.
  71688. * @param current current angle in degrees
  71689. * @param target target angle in degrees
  71690. * @returns the delta
  71691. */
  71692. static DeltaAngle(current: number, target: number): number;
  71693. /**
  71694. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  71695. * @param tx value
  71696. * @param length length
  71697. * @returns The returned value will move back and forth between 0 and length
  71698. */
  71699. static PingPong(tx: number, length: number): number;
  71700. /**
  71701. * Interpolates between min and max with smoothing at the limits.
  71702. *
  71703. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  71704. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  71705. * @param from from
  71706. * @param to to
  71707. * @param tx value
  71708. * @returns the smooth stepped value
  71709. */
  71710. static SmoothStep(from: number, to: number, tx: number): number;
  71711. /**
  71712. * Moves a value current towards target.
  71713. *
  71714. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  71715. * Negative values of maxDelta pushes the value away from target.
  71716. * @param current current value
  71717. * @param target target value
  71718. * @param maxDelta max distance to move
  71719. * @returns resulting value
  71720. */
  71721. static MoveTowards(current: number, target: number, maxDelta: number): number;
  71722. /**
  71723. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71724. *
  71725. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  71726. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  71727. * @param current current value
  71728. * @param target target value
  71729. * @param maxDelta max distance to move
  71730. * @returns resulting angle
  71731. */
  71732. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  71733. /**
  71734. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  71735. * @param start start value
  71736. * @param end target value
  71737. * @param amount amount to lerp between
  71738. * @returns the lerped value
  71739. */
  71740. static Lerp(start: number, end: number, amount: number): number;
  71741. /**
  71742. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71743. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  71744. * @param start start value
  71745. * @param end target value
  71746. * @param amount amount to lerp between
  71747. * @returns the lerped value
  71748. */
  71749. static LerpAngle(start: number, end: number, amount: number): number;
  71750. /**
  71751. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  71752. * @param a start value
  71753. * @param b target value
  71754. * @param value value between a and b
  71755. * @returns the inverseLerp value
  71756. */
  71757. static InverseLerp(a: number, b: number, value: number): number;
  71758. /**
  71759. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  71760. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  71761. * @param value1 spline value
  71762. * @param tangent1 spline value
  71763. * @param value2 spline value
  71764. * @param tangent2 spline value
  71765. * @param amount input value
  71766. * @returns hermite result
  71767. */
  71768. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  71769. /**
  71770. * Returns a random float number between and min and max values
  71771. * @param min min value of random
  71772. * @param max max value of random
  71773. * @returns random value
  71774. */
  71775. static RandomRange(min: number, max: number): number;
  71776. /**
  71777. * This function returns percentage of a number in a given range.
  71778. *
  71779. * RangeToPercent(40,20,60) will return 0.5 (50%)
  71780. * RangeToPercent(34,0,100) will return 0.34 (34%)
  71781. * @param number to convert to percentage
  71782. * @param min min range
  71783. * @param max max range
  71784. * @returns the percentage
  71785. */
  71786. static RangeToPercent(number: number, min: number, max: number): number;
  71787. /**
  71788. * This function returns number that corresponds to the percentage in a given range.
  71789. *
  71790. * PercentToRange(0.34,0,100) will return 34.
  71791. * @param percent to convert to number
  71792. * @param min min range
  71793. * @param max max range
  71794. * @returns the number
  71795. */
  71796. static PercentToRange(percent: number, min: number, max: number): number;
  71797. /**
  71798. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71799. * @param angle The angle to normalize in radian.
  71800. * @return The converted angle.
  71801. */
  71802. static NormalizeRadians(angle: number): number;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /**
  71807. * Constant used to convert a value to gamma space
  71808. * @ignorenaming
  71809. */
  71810. export const ToGammaSpace: number;
  71811. /**
  71812. * Constant used to convert a value to linear space
  71813. * @ignorenaming
  71814. */
  71815. export const ToLinearSpace = 2.2;
  71816. /**
  71817. * Constant used to define the minimal number value in Babylon.js
  71818. * @ignorenaming
  71819. */
  71820. let Epsilon: number;
  71821. }
  71822. declare module BABYLON {
  71823. /**
  71824. * Class used to represent a viewport on screen
  71825. */
  71826. export class Viewport {
  71827. /** viewport left coordinate */
  71828. x: number;
  71829. /** viewport top coordinate */
  71830. y: number;
  71831. /**viewport width */
  71832. width: number;
  71833. /** viewport height */
  71834. height: number;
  71835. /**
  71836. * Creates a Viewport object located at (x, y) and sized (width, height)
  71837. * @param x defines viewport left coordinate
  71838. * @param y defines viewport top coordinate
  71839. * @param width defines the viewport width
  71840. * @param height defines the viewport height
  71841. */
  71842. constructor(
  71843. /** viewport left coordinate */
  71844. x: number,
  71845. /** viewport top coordinate */
  71846. y: number,
  71847. /**viewport width */
  71848. width: number,
  71849. /** viewport height */
  71850. height: number);
  71851. /**
  71852. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  71853. * @param renderWidth defines the rendering width
  71854. * @param renderHeight defines the rendering height
  71855. * @returns a new Viewport
  71856. */
  71857. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  71858. /**
  71859. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  71860. * @param renderWidth defines the rendering width
  71861. * @param renderHeight defines the rendering height
  71862. * @param ref defines the target viewport
  71863. * @returns the current viewport
  71864. */
  71865. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  71866. /**
  71867. * Returns a new Viewport copied from the current one
  71868. * @returns a new Viewport
  71869. */
  71870. clone(): Viewport;
  71871. }
  71872. }
  71873. declare module BABYLON {
  71874. /**
  71875. * Class containing a set of static utilities functions for arrays.
  71876. */
  71877. export class ArrayTools {
  71878. /**
  71879. * Returns an array of the given size filled with element built from the given constructor and the paramters
  71880. * @param size the number of element to construct and put in the array
  71881. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  71882. * @returns a new array filled with new objects
  71883. */
  71884. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  71885. }
  71886. }
  71887. declare module BABYLON {
  71888. /**
  71889. * Class representing a vector containing 2 coordinates
  71890. */
  71891. export class Vector2 {
  71892. /** defines the first coordinate */
  71893. x: number;
  71894. /** defines the second coordinate */
  71895. y: number;
  71896. /**
  71897. * Creates a new Vector2 from the given x and y coordinates
  71898. * @param x defines the first coordinate
  71899. * @param y defines the second coordinate
  71900. */
  71901. constructor(
  71902. /** defines the first coordinate */
  71903. x?: number,
  71904. /** defines the second coordinate */
  71905. y?: number);
  71906. /**
  71907. * Gets a string with the Vector2 coordinates
  71908. * @returns a string with the Vector2 coordinates
  71909. */
  71910. toString(): string;
  71911. /**
  71912. * Gets class name
  71913. * @returns the string "Vector2"
  71914. */
  71915. getClassName(): string;
  71916. /**
  71917. * Gets current vector hash code
  71918. * @returns the Vector2 hash code as a number
  71919. */
  71920. getHashCode(): number;
  71921. /**
  71922. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71923. * @param array defines the source array
  71924. * @param index defines the offset in source array
  71925. * @returns the current Vector2
  71926. */
  71927. toArray(array: FloatArray, index?: number): Vector2;
  71928. /**
  71929. * Copy the current vector to an array
  71930. * @returns a new array with 2 elements: the Vector2 coordinates.
  71931. */
  71932. asArray(): number[];
  71933. /**
  71934. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71935. * @param source defines the source Vector2
  71936. * @returns the current updated Vector2
  71937. */
  71938. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  71939. /**
  71940. * Sets the Vector2 coordinates with the given floats
  71941. * @param x defines the first coordinate
  71942. * @param y defines the second coordinate
  71943. * @returns the current updated Vector2
  71944. */
  71945. copyFromFloats(x: number, y: number): Vector2;
  71946. /**
  71947. * Sets the Vector2 coordinates with the given floats
  71948. * @param x defines the first coordinate
  71949. * @param y defines the second coordinate
  71950. * @returns the current updated Vector2
  71951. */
  71952. set(x: number, y: number): Vector2;
  71953. /**
  71954. * Add another vector with the current one
  71955. * @param otherVector defines the other vector
  71956. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71957. */
  71958. add(otherVector: DeepImmutable<Vector2>): Vector2;
  71959. /**
  71960. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71961. * @param otherVector defines the other vector
  71962. * @param result defines the target vector
  71963. * @returns the unmodified current Vector2
  71964. */
  71965. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71966. /**
  71967. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71968. * @param otherVector defines the other vector
  71969. * @returns the current updated Vector2
  71970. */
  71971. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71972. /**
  71973. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71974. * @param otherVector defines the other vector
  71975. * @returns a new Vector2
  71976. */
  71977. addVector3(otherVector: Vector3): Vector2;
  71978. /**
  71979. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71980. * @param otherVector defines the other vector
  71981. * @returns a new Vector2
  71982. */
  71983. subtract(otherVector: Vector2): Vector2;
  71984. /**
  71985. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71986. * @param otherVector defines the other vector
  71987. * @param result defines the target vector
  71988. * @returns the unmodified current Vector2
  71989. */
  71990. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71991. /**
  71992. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71993. * @param otherVector defines the other vector
  71994. * @returns the current updated Vector2
  71995. */
  71996. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71997. /**
  71998. * Multiplies in place the current Vector2 coordinates by the given ones
  71999. * @param otherVector defines the other vector
  72000. * @returns the current updated Vector2
  72001. */
  72002. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72003. /**
  72004. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72005. * @param otherVector defines the other vector
  72006. * @returns a new Vector2
  72007. */
  72008. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72009. /**
  72010. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72011. * @param otherVector defines the other vector
  72012. * @param result defines the target vector
  72013. * @returns the unmodified current Vector2
  72014. */
  72015. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72016. /**
  72017. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72018. * @param x defines the first coordinate
  72019. * @param y defines the second coordinate
  72020. * @returns a new Vector2
  72021. */
  72022. multiplyByFloats(x: number, y: number): Vector2;
  72023. /**
  72024. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72025. * @param otherVector defines the other vector
  72026. * @returns a new Vector2
  72027. */
  72028. divide(otherVector: Vector2): Vector2;
  72029. /**
  72030. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72031. * @param otherVector defines the other vector
  72032. * @param result defines the target vector
  72033. * @returns the unmodified current Vector2
  72034. */
  72035. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72036. /**
  72037. * Divides the current Vector2 coordinates by the given ones
  72038. * @param otherVector defines the other vector
  72039. * @returns the current updated Vector2
  72040. */
  72041. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72042. /**
  72043. * Gets a new Vector2 with current Vector2 negated coordinates
  72044. * @returns a new Vector2
  72045. */
  72046. negate(): Vector2;
  72047. /**
  72048. * Multiply the Vector2 coordinates by scale
  72049. * @param scale defines the scaling factor
  72050. * @returns the current updated Vector2
  72051. */
  72052. scaleInPlace(scale: number): Vector2;
  72053. /**
  72054. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72055. * @param scale defines the scaling factor
  72056. * @returns a new Vector2
  72057. */
  72058. scale(scale: number): Vector2;
  72059. /**
  72060. * Scale the current Vector2 values by a factor to a given Vector2
  72061. * @param scale defines the scale factor
  72062. * @param result defines the Vector2 object where to store the result
  72063. * @returns the unmodified current Vector2
  72064. */
  72065. scaleToRef(scale: number, result: Vector2): Vector2;
  72066. /**
  72067. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72068. * @param scale defines the scale factor
  72069. * @param result defines the Vector2 object where to store the result
  72070. * @returns the unmodified current Vector2
  72071. */
  72072. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72073. /**
  72074. * Gets a boolean if two vectors are equals
  72075. * @param otherVector defines the other vector
  72076. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72077. */
  72078. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72079. /**
  72080. * Gets a boolean if two vectors are equals (using an epsilon value)
  72081. * @param otherVector defines the other vector
  72082. * @param epsilon defines the minimal distance to consider equality
  72083. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72084. */
  72085. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72086. /**
  72087. * Gets a new Vector2 from current Vector2 floored values
  72088. * @returns a new Vector2
  72089. */
  72090. floor(): Vector2;
  72091. /**
  72092. * Gets a new Vector2 from current Vector2 floored values
  72093. * @returns a new Vector2
  72094. */
  72095. fract(): Vector2;
  72096. /**
  72097. * Gets the length of the vector
  72098. * @returns the vector length (float)
  72099. */
  72100. length(): number;
  72101. /**
  72102. * Gets the vector squared length
  72103. * @returns the vector squared length (float)
  72104. */
  72105. lengthSquared(): number;
  72106. /**
  72107. * Normalize the vector
  72108. * @returns the current updated Vector2
  72109. */
  72110. normalize(): Vector2;
  72111. /**
  72112. * Gets a new Vector2 copied from the Vector2
  72113. * @returns a new Vector2
  72114. */
  72115. clone(): Vector2;
  72116. /**
  72117. * Gets a new Vector2(0, 0)
  72118. * @returns a new Vector2
  72119. */
  72120. static Zero(): Vector2;
  72121. /**
  72122. * Gets a new Vector2(1, 1)
  72123. * @returns a new Vector2
  72124. */
  72125. static One(): Vector2;
  72126. /**
  72127. * Gets a new Vector2 set from the given index element of the given array
  72128. * @param array defines the data source
  72129. * @param offset defines the offset in the data source
  72130. * @returns a new Vector2
  72131. */
  72132. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72133. /**
  72134. * Sets "result" from the given index element of the given array
  72135. * @param array defines the data source
  72136. * @param offset defines the offset in the data source
  72137. * @param result defines the target vector
  72138. */
  72139. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72140. /**
  72141. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72142. * @param value1 defines 1st point of control
  72143. * @param value2 defines 2nd point of control
  72144. * @param value3 defines 3rd point of control
  72145. * @param value4 defines 4th point of control
  72146. * @param amount defines the interpolation factor
  72147. * @returns a new Vector2
  72148. */
  72149. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72150. /**
  72151. * 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".
  72152. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72153. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72154. * @param value defines the value to clamp
  72155. * @param min defines the lower limit
  72156. * @param max defines the upper limit
  72157. * @returns a new Vector2
  72158. */
  72159. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72160. /**
  72161. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72162. * @param value1 defines the 1st control point
  72163. * @param tangent1 defines the outgoing tangent
  72164. * @param value2 defines the 2nd control point
  72165. * @param tangent2 defines the incoming tangent
  72166. * @param amount defines the interpolation factor
  72167. * @returns a new Vector2
  72168. */
  72169. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72170. /**
  72171. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72172. * @param start defines the start vector
  72173. * @param end defines the end vector
  72174. * @param amount defines the interpolation factor
  72175. * @returns a new Vector2
  72176. */
  72177. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72178. /**
  72179. * Gets the dot product of the vector "left" and the vector "right"
  72180. * @param left defines first vector
  72181. * @param right defines second vector
  72182. * @returns the dot product (float)
  72183. */
  72184. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72185. /**
  72186. * Returns a new Vector2 equal to the normalized given vector
  72187. * @param vector defines the vector to normalize
  72188. * @returns a new Vector2
  72189. */
  72190. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72191. /**
  72192. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72193. * @param left defines 1st vector
  72194. * @param right defines 2nd vector
  72195. * @returns a new Vector2
  72196. */
  72197. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72198. /**
  72199. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72200. * @param left defines 1st vector
  72201. * @param right defines 2nd vector
  72202. * @returns a new Vector2
  72203. */
  72204. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72205. /**
  72206. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72207. * @param vector defines the vector to transform
  72208. * @param transformation defines the matrix to apply
  72209. * @returns a new Vector2
  72210. */
  72211. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72212. /**
  72213. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72214. * @param vector defines the vector to transform
  72215. * @param transformation defines the matrix to apply
  72216. * @param result defines the target vector
  72217. */
  72218. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72219. /**
  72220. * Determines if a given vector is included in a triangle
  72221. * @param p defines the vector to test
  72222. * @param p0 defines 1st triangle point
  72223. * @param p1 defines 2nd triangle point
  72224. * @param p2 defines 3rd triangle point
  72225. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72226. */
  72227. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72228. /**
  72229. * Gets the distance between the vectors "value1" and "value2"
  72230. * @param value1 defines first vector
  72231. * @param value2 defines second vector
  72232. * @returns the distance between vectors
  72233. */
  72234. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72235. /**
  72236. * Returns the squared distance between the vectors "value1" and "value2"
  72237. * @param value1 defines first vector
  72238. * @param value2 defines second vector
  72239. * @returns the squared distance between vectors
  72240. */
  72241. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72242. /**
  72243. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72244. * @param value1 defines first vector
  72245. * @param value2 defines second vector
  72246. * @returns a new Vector2
  72247. */
  72248. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72249. /**
  72250. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72251. * @param p defines the middle point
  72252. * @param segA defines one point of the segment
  72253. * @param segB defines the other point of the segment
  72254. * @returns the shortest distance
  72255. */
  72256. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72257. }
  72258. /**
  72259. * Class used to store (x,y,z) vector representation
  72260. * A Vector3 is the main object used in 3D geometry
  72261. * It can represent etiher the coordinates of a point the space, either a direction
  72262. * Reminder: js uses a left handed forward facing system
  72263. */
  72264. export class Vector3 {
  72265. /**
  72266. * Defines the first coordinates (on X axis)
  72267. */
  72268. x: number;
  72269. /**
  72270. * Defines the second coordinates (on Y axis)
  72271. */
  72272. y: number;
  72273. /**
  72274. * Defines the third coordinates (on Z axis)
  72275. */
  72276. z: number;
  72277. private static _UpReadOnly;
  72278. private static _ZeroReadOnly;
  72279. /**
  72280. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72281. * @param x defines the first coordinates (on X axis)
  72282. * @param y defines the second coordinates (on Y axis)
  72283. * @param z defines the third coordinates (on Z axis)
  72284. */
  72285. constructor(
  72286. /**
  72287. * Defines the first coordinates (on X axis)
  72288. */
  72289. x?: number,
  72290. /**
  72291. * Defines the second coordinates (on Y axis)
  72292. */
  72293. y?: number,
  72294. /**
  72295. * Defines the third coordinates (on Z axis)
  72296. */
  72297. z?: number);
  72298. /**
  72299. * Creates a string representation of the Vector3
  72300. * @returns a string with the Vector3 coordinates.
  72301. */
  72302. toString(): string;
  72303. /**
  72304. * Gets the class name
  72305. * @returns the string "Vector3"
  72306. */
  72307. getClassName(): string;
  72308. /**
  72309. * Creates the Vector3 hash code
  72310. * @returns a number which tends to be unique between Vector3 instances
  72311. */
  72312. getHashCode(): number;
  72313. /**
  72314. * Creates an array containing three elements : the coordinates of the Vector3
  72315. * @returns a new array of numbers
  72316. */
  72317. asArray(): number[];
  72318. /**
  72319. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72320. * @param array defines the destination array
  72321. * @param index defines the offset in the destination array
  72322. * @returns the current Vector3
  72323. */
  72324. toArray(array: FloatArray, index?: number): Vector3;
  72325. /**
  72326. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72327. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72328. */
  72329. toQuaternion(): Quaternion;
  72330. /**
  72331. * Adds the given vector to the current Vector3
  72332. * @param otherVector defines the second operand
  72333. * @returns the current updated Vector3
  72334. */
  72335. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72336. /**
  72337. * Adds the given coordinates to the current Vector3
  72338. * @param x defines the x coordinate of the operand
  72339. * @param y defines the y coordinate of the operand
  72340. * @param z defines the z coordinate of the operand
  72341. * @returns the current updated Vector3
  72342. */
  72343. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72344. /**
  72345. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72346. * @param otherVector defines the second operand
  72347. * @returns the resulting Vector3
  72348. */
  72349. add(otherVector: DeepImmutable<Vector3>): Vector3;
  72350. /**
  72351. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72352. * @param otherVector defines the second operand
  72353. * @param result defines the Vector3 object where to store the result
  72354. * @returns the current Vector3
  72355. */
  72356. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72357. /**
  72358. * Subtract the given vector from the current Vector3
  72359. * @param otherVector defines the second operand
  72360. * @returns the current updated Vector3
  72361. */
  72362. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72363. /**
  72364. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72365. * @param otherVector defines the second operand
  72366. * @returns the resulting Vector3
  72367. */
  72368. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  72369. /**
  72370. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72371. * @param otherVector defines the second operand
  72372. * @param result defines the Vector3 object where to store the result
  72373. * @returns the current Vector3
  72374. */
  72375. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72376. /**
  72377. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72378. * @param x defines the x coordinate of the operand
  72379. * @param y defines the y coordinate of the operand
  72380. * @param z defines the z coordinate of the operand
  72381. * @returns the resulting Vector3
  72382. */
  72383. subtractFromFloats(x: number, y: number, z: number): Vector3;
  72384. /**
  72385. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72386. * @param x defines the x coordinate of the operand
  72387. * @param y defines the y coordinate of the operand
  72388. * @param z defines the z coordinate of the operand
  72389. * @param result defines the Vector3 object where to store the result
  72390. * @returns the current Vector3
  72391. */
  72392. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  72393. /**
  72394. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72395. * @returns a new Vector3
  72396. */
  72397. negate(): Vector3;
  72398. /**
  72399. * Multiplies the Vector3 coordinates by the float "scale"
  72400. * @param scale defines the multiplier factor
  72401. * @returns the current updated Vector3
  72402. */
  72403. scaleInPlace(scale: number): Vector3;
  72404. /**
  72405. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72406. * @param scale defines the multiplier factor
  72407. * @returns a new Vector3
  72408. */
  72409. scale(scale: number): Vector3;
  72410. /**
  72411. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  72412. * @param scale defines the multiplier factor
  72413. * @param result defines the Vector3 object where to store the result
  72414. * @returns the current Vector3
  72415. */
  72416. scaleToRef(scale: number, result: Vector3): Vector3;
  72417. /**
  72418. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  72419. * @param scale defines the scale factor
  72420. * @param result defines the Vector3 object where to store the result
  72421. * @returns the unmodified current Vector3
  72422. */
  72423. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  72424. /**
  72425. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  72426. * @param otherVector defines the second operand
  72427. * @returns true if both vectors are equals
  72428. */
  72429. equals(otherVector: DeepImmutable<Vector3>): boolean;
  72430. /**
  72431. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  72432. * @param otherVector defines the second operand
  72433. * @param epsilon defines the minimal distance to define values as equals
  72434. * @returns true if both vectors are distant less than epsilon
  72435. */
  72436. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  72437. /**
  72438. * Returns true if the current Vector3 coordinates equals the given floats
  72439. * @param x defines the x coordinate of the operand
  72440. * @param y defines the y coordinate of the operand
  72441. * @param z defines the z coordinate of the operand
  72442. * @returns true if both vectors are equals
  72443. */
  72444. equalsToFloats(x: number, y: number, z: number): boolean;
  72445. /**
  72446. * Multiplies the current Vector3 coordinates by the given ones
  72447. * @param otherVector defines the second operand
  72448. * @returns the current updated Vector3
  72449. */
  72450. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72451. /**
  72452. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  72453. * @param otherVector defines the second operand
  72454. * @returns the new Vector3
  72455. */
  72456. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  72457. /**
  72458. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  72459. * @param otherVector defines the second operand
  72460. * @param result defines the Vector3 object where to store the result
  72461. * @returns the current Vector3
  72462. */
  72463. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72464. /**
  72465. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  72466. * @param x defines the x coordinate of the operand
  72467. * @param y defines the y coordinate of the operand
  72468. * @param z defines the z coordinate of the operand
  72469. * @returns the new Vector3
  72470. */
  72471. multiplyByFloats(x: number, y: number, z: number): Vector3;
  72472. /**
  72473. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  72474. * @param otherVector defines the second operand
  72475. * @returns the new Vector3
  72476. */
  72477. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  72478. /**
  72479. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  72480. * @param otherVector defines the second operand
  72481. * @param result defines the Vector3 object where to store the result
  72482. * @returns the current Vector3
  72483. */
  72484. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72485. /**
  72486. * Divides the current Vector3 coordinates by the given ones.
  72487. * @param otherVector defines the second operand
  72488. * @returns the current updated Vector3
  72489. */
  72490. divideInPlace(otherVector: Vector3): Vector3;
  72491. /**
  72492. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  72493. * @param other defines the second operand
  72494. * @returns the current updated Vector3
  72495. */
  72496. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  72497. /**
  72498. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  72499. * @param other defines the second operand
  72500. * @returns the current updated Vector3
  72501. */
  72502. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  72503. /**
  72504. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  72505. * @param x defines the x coordinate of the operand
  72506. * @param y defines the y coordinate of the operand
  72507. * @param z defines the z coordinate of the operand
  72508. * @returns the current updated Vector3
  72509. */
  72510. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72511. /**
  72512. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  72513. * @param x defines the x coordinate of the operand
  72514. * @param y defines the y coordinate of the operand
  72515. * @param z defines the z coordinate of the operand
  72516. * @returns the current updated Vector3
  72517. */
  72518. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72519. /**
  72520. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  72521. * Check if is non uniform within a certain amount of decimal places to account for this
  72522. * @param epsilon the amount the values can differ
  72523. * @returns if the the vector is non uniform to a certain number of decimal places
  72524. */
  72525. isNonUniformWithinEpsilon(epsilon: number): boolean;
  72526. /**
  72527. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  72528. */
  72529. readonly isNonUniform: boolean;
  72530. /**
  72531. * Gets a new Vector3 from current Vector3 floored values
  72532. * @returns a new Vector3
  72533. */
  72534. floor(): Vector3;
  72535. /**
  72536. * Gets a new Vector3 from current Vector3 floored values
  72537. * @returns a new Vector3
  72538. */
  72539. fract(): Vector3;
  72540. /**
  72541. * Gets the length of the Vector3
  72542. * @returns the length of the Vector3
  72543. */
  72544. length(): number;
  72545. /**
  72546. * Gets the squared length of the Vector3
  72547. * @returns squared length of the Vector3
  72548. */
  72549. lengthSquared(): number;
  72550. /**
  72551. * Normalize the current Vector3.
  72552. * Please note that this is an in place operation.
  72553. * @returns the current updated Vector3
  72554. */
  72555. normalize(): Vector3;
  72556. /**
  72557. * Reorders the x y z properties of the vector in place
  72558. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  72559. * @returns the current updated vector
  72560. */
  72561. reorderInPlace(order: string): this;
  72562. /**
  72563. * Rotates the vector around 0,0,0 by a quaternion
  72564. * @param quaternion the rotation quaternion
  72565. * @param result vector to store the result
  72566. * @returns the resulting vector
  72567. */
  72568. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  72569. /**
  72570. * Rotates a vector around a given point
  72571. * @param quaternion the rotation quaternion
  72572. * @param point the point to rotate around
  72573. * @param result vector to store the result
  72574. * @returns the resulting vector
  72575. */
  72576. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  72577. /**
  72578. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  72579. * The cross product is then orthogonal to both current and "other"
  72580. * @param other defines the right operand
  72581. * @returns the cross product
  72582. */
  72583. cross(other: Vector3): Vector3;
  72584. /**
  72585. * Normalize the current Vector3 with the given input length.
  72586. * Please note that this is an in place operation.
  72587. * @param len the length of the vector
  72588. * @returns the current updated Vector3
  72589. */
  72590. normalizeFromLength(len: number): Vector3;
  72591. /**
  72592. * Normalize the current Vector3 to a new vector
  72593. * @returns the new Vector3
  72594. */
  72595. normalizeToNew(): Vector3;
  72596. /**
  72597. * Normalize the current Vector3 to the reference
  72598. * @param reference define the Vector3 to update
  72599. * @returns the updated Vector3
  72600. */
  72601. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  72602. /**
  72603. * Creates a new Vector3 copied from the current Vector3
  72604. * @returns the new Vector3
  72605. */
  72606. clone(): Vector3;
  72607. /**
  72608. * Copies the given vector coordinates to the current Vector3 ones
  72609. * @param source defines the source Vector3
  72610. * @returns the current updated Vector3
  72611. */
  72612. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  72613. /**
  72614. * Copies the given floats to the current Vector3 coordinates
  72615. * @param x defines the x coordinate of the operand
  72616. * @param y defines the y coordinate of the operand
  72617. * @param z defines the z coordinate of the operand
  72618. * @returns the current updated Vector3
  72619. */
  72620. copyFromFloats(x: number, y: number, z: number): Vector3;
  72621. /**
  72622. * Copies the given floats to the current Vector3 coordinates
  72623. * @param x defines the x coordinate of the operand
  72624. * @param y defines the y coordinate of the operand
  72625. * @param z defines the z coordinate of the operand
  72626. * @returns the current updated Vector3
  72627. */
  72628. set(x: number, y: number, z: number): Vector3;
  72629. /**
  72630. * Copies the given float to the current Vector3 coordinates
  72631. * @param v defines the x, y and z coordinates of the operand
  72632. * @returns the current updated Vector3
  72633. */
  72634. setAll(v: number): Vector3;
  72635. /**
  72636. * Get the clip factor between two vectors
  72637. * @param vector0 defines the first operand
  72638. * @param vector1 defines the second operand
  72639. * @param axis defines the axis to use
  72640. * @param size defines the size along the axis
  72641. * @returns the clip factor
  72642. */
  72643. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  72644. /**
  72645. * Get angle between two vectors
  72646. * @param vector0 angle between vector0 and vector1
  72647. * @param vector1 angle between vector0 and vector1
  72648. * @param normal direction of the normal
  72649. * @return the angle between vector0 and vector1
  72650. */
  72651. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  72652. /**
  72653. * Returns a new Vector3 set from the index "offset" of the given array
  72654. * @param array defines the source array
  72655. * @param offset defines the offset in the source array
  72656. * @returns the new Vector3
  72657. */
  72658. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  72659. /**
  72660. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  72661. * @param array defines the source array
  72662. * @param offset defines the offset in the source array
  72663. * @returns the new Vector3
  72664. * @deprecated Please use FromArray instead.
  72665. */
  72666. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  72667. /**
  72668. * Sets the given vector "result" with the element values from the index "offset" of the given array
  72669. * @param array defines the source array
  72670. * @param offset defines the offset in the source array
  72671. * @param result defines the Vector3 where to store the result
  72672. */
  72673. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  72674. /**
  72675. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  72676. * @param array defines the source array
  72677. * @param offset defines the offset in the source array
  72678. * @param result defines the Vector3 where to store the result
  72679. * @deprecated Please use FromArrayToRef instead.
  72680. */
  72681. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  72682. /**
  72683. * Sets the given vector "result" with the given floats.
  72684. * @param x defines the x coordinate of the source
  72685. * @param y defines the y coordinate of the source
  72686. * @param z defines the z coordinate of the source
  72687. * @param result defines the Vector3 where to store the result
  72688. */
  72689. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  72690. /**
  72691. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  72692. * @returns a new empty Vector3
  72693. */
  72694. static Zero(): Vector3;
  72695. /**
  72696. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  72697. * @returns a new unit Vector3
  72698. */
  72699. static One(): Vector3;
  72700. /**
  72701. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  72702. * @returns a new up Vector3
  72703. */
  72704. static Up(): Vector3;
  72705. /**
  72706. * Gets a up Vector3 that must not be updated
  72707. */
  72708. static readonly UpReadOnly: DeepImmutable<Vector3>;
  72709. /**
  72710. * Gets a zero Vector3 that must not be updated
  72711. */
  72712. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  72713. /**
  72714. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72715. * @returns a new down Vector3
  72716. */
  72717. static Down(): Vector3;
  72718. /**
  72719. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72720. * @returns a new forward Vector3
  72721. */
  72722. static Forward(): Vector3;
  72723. /**
  72724. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72725. * @returns a new forward Vector3
  72726. */
  72727. static Backward(): Vector3;
  72728. /**
  72729. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72730. * @returns a new right Vector3
  72731. */
  72732. static Right(): Vector3;
  72733. /**
  72734. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72735. * @returns a new left Vector3
  72736. */
  72737. static Left(): Vector3;
  72738. /**
  72739. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72740. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72741. * @param vector defines the Vector3 to transform
  72742. * @param transformation defines the transformation matrix
  72743. * @returns the transformed Vector3
  72744. */
  72745. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72746. /**
  72747. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72748. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72749. * @param vector defines the Vector3 to transform
  72750. * @param transformation defines the transformation matrix
  72751. * @param result defines the Vector3 where to store the result
  72752. */
  72753. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72754. /**
  72755. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72756. * This method computes tranformed coordinates only, not transformed direction vectors
  72757. * @param x define the x coordinate of the source vector
  72758. * @param y define the y coordinate of the source vector
  72759. * @param z define the z coordinate of the source vector
  72760. * @param transformation defines the transformation matrix
  72761. * @param result defines the Vector3 where to store the result
  72762. */
  72763. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72764. /**
  72765. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72766. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72767. * @param vector defines the Vector3 to transform
  72768. * @param transformation defines the transformation matrix
  72769. * @returns the new Vector3
  72770. */
  72771. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72772. /**
  72773. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72774. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72775. * @param vector defines the Vector3 to transform
  72776. * @param transformation defines the transformation matrix
  72777. * @param result defines the Vector3 where to store the result
  72778. */
  72779. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72780. /**
  72781. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72782. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72783. * @param x define the x coordinate of the source vector
  72784. * @param y define the y coordinate of the source vector
  72785. * @param z define the z coordinate of the source vector
  72786. * @param transformation defines the transformation matrix
  72787. * @param result defines the Vector3 where to store the result
  72788. */
  72789. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72790. /**
  72791. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72792. * @param value1 defines the first control point
  72793. * @param value2 defines the second control point
  72794. * @param value3 defines the third control point
  72795. * @param value4 defines the fourth control point
  72796. * @param amount defines the amount on the spline to use
  72797. * @returns the new Vector3
  72798. */
  72799. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  72800. /**
  72801. * 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"
  72802. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72803. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72804. * @param value defines the current value
  72805. * @param min defines the lower range value
  72806. * @param max defines the upper range value
  72807. * @returns the new Vector3
  72808. */
  72809. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  72810. /**
  72811. * 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"
  72812. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72813. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72814. * @param value defines the current value
  72815. * @param min defines the lower range value
  72816. * @param max defines the upper range value
  72817. * @param result defines the Vector3 where to store the result
  72818. */
  72819. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  72820. /**
  72821. * Checks if a given vector is inside a specific range
  72822. * @param v defines the vector to test
  72823. * @param min defines the minimum range
  72824. * @param max defines the maximum range
  72825. */
  72826. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  72827. /**
  72828. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72829. * @param value1 defines the first control point
  72830. * @param tangent1 defines the first tangent vector
  72831. * @param value2 defines the second control point
  72832. * @param tangent2 defines the second tangent vector
  72833. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72834. * @returns the new Vector3
  72835. */
  72836. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  72837. /**
  72838. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72839. * @param start defines the start value
  72840. * @param end defines the end value
  72841. * @param amount max defines amount between both (between 0 and 1)
  72842. * @returns the new Vector3
  72843. */
  72844. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  72845. /**
  72846. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72847. * @param start defines the start value
  72848. * @param end defines the end value
  72849. * @param amount max defines amount between both (between 0 and 1)
  72850. * @param result defines the Vector3 where to store the result
  72851. */
  72852. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  72853. /**
  72854. * Returns the dot product (float) between the vectors "left" and "right"
  72855. * @param left defines the left operand
  72856. * @param right defines the right operand
  72857. * @returns the dot product
  72858. */
  72859. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  72860. /**
  72861. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72862. * The cross product is then orthogonal to both "left" and "right"
  72863. * @param left defines the left operand
  72864. * @param right defines the right operand
  72865. * @returns the cross product
  72866. */
  72867. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72868. /**
  72869. * Sets the given vector "result" with the cross product of "left" and "right"
  72870. * The cross product is then orthogonal to both "left" and "right"
  72871. * @param left defines the left operand
  72872. * @param right defines the right operand
  72873. * @param result defines the Vector3 where to store the result
  72874. */
  72875. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  72876. /**
  72877. * Returns a new Vector3 as the normalization of the given vector
  72878. * @param vector defines the Vector3 to normalize
  72879. * @returns the new Vector3
  72880. */
  72881. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  72882. /**
  72883. * Sets the given vector "result" with the normalization of the given first vector
  72884. * @param vector defines the Vector3 to normalize
  72885. * @param result defines the Vector3 where to store the result
  72886. */
  72887. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  72888. /**
  72889. * Project a Vector3 onto screen space
  72890. * @param vector defines the Vector3 to project
  72891. * @param world defines the world matrix to use
  72892. * @param transform defines the transform (view x projection) matrix to use
  72893. * @param viewport defines the screen viewport to use
  72894. * @returns the new Vector3
  72895. */
  72896. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  72897. /** @hidden */
  72898. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  72899. /**
  72900. * Unproject from screen space to object space
  72901. * @param source defines the screen space Vector3 to use
  72902. * @param viewportWidth defines the current width of the viewport
  72903. * @param viewportHeight defines the current height of the viewport
  72904. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72905. * @param transform defines the transform (view x projection) matrix to use
  72906. * @returns the new Vector3
  72907. */
  72908. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  72909. /**
  72910. * Unproject from screen space to object space
  72911. * @param source defines the screen space Vector3 to use
  72912. * @param viewportWidth defines the current width of the viewport
  72913. * @param viewportHeight defines the current height of the viewport
  72914. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72915. * @param view defines the view matrix to use
  72916. * @param projection defines the projection matrix to use
  72917. * @returns the new Vector3
  72918. */
  72919. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  72920. /**
  72921. * Unproject from screen space to object space
  72922. * @param source defines the screen space Vector3 to use
  72923. * @param viewportWidth defines the current width of the viewport
  72924. * @param viewportHeight defines the current height of the viewport
  72925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72926. * @param view defines the view matrix to use
  72927. * @param projection defines the projection matrix to use
  72928. * @param result defines the Vector3 where to store the result
  72929. */
  72930. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72931. /**
  72932. * Unproject from screen space to object space
  72933. * @param sourceX defines the screen space x coordinate to use
  72934. * @param sourceY defines the screen space y coordinate to use
  72935. * @param sourceZ defines the screen space z coordinate to use
  72936. * @param viewportWidth defines the current width of the viewport
  72937. * @param viewportHeight defines the current height of the viewport
  72938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72939. * @param view defines the view matrix to use
  72940. * @param projection defines the projection matrix to use
  72941. * @param result defines the Vector3 where to store the result
  72942. */
  72943. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72944. /**
  72945. * Gets the minimal coordinate values between two Vector3
  72946. * @param left defines the first operand
  72947. * @param right defines the second operand
  72948. * @returns the new Vector3
  72949. */
  72950. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72951. /**
  72952. * Gets the maximal coordinate values between two Vector3
  72953. * @param left defines the first operand
  72954. * @param right defines the second operand
  72955. * @returns the new Vector3
  72956. */
  72957. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72958. /**
  72959. * Returns the distance between the vectors "value1" and "value2"
  72960. * @param value1 defines the first operand
  72961. * @param value2 defines the second operand
  72962. * @returns the distance
  72963. */
  72964. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72965. /**
  72966. * Returns the squared distance between the vectors "value1" and "value2"
  72967. * @param value1 defines the first operand
  72968. * @param value2 defines the second operand
  72969. * @returns the squared distance
  72970. */
  72971. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72972. /**
  72973. * Returns a new Vector3 located at the center between "value1" and "value2"
  72974. * @param value1 defines the first operand
  72975. * @param value2 defines the second operand
  72976. * @returns the new Vector3
  72977. */
  72978. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  72979. /**
  72980. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72981. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72982. * to something in order to rotate it from its local system to the given target system
  72983. * Note: axis1, axis2 and axis3 are normalized during this operation
  72984. * @param axis1 defines the first axis
  72985. * @param axis2 defines the second axis
  72986. * @param axis3 defines the third axis
  72987. * @returns a new Vector3
  72988. */
  72989. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  72990. /**
  72991. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72992. * @param axis1 defines the first axis
  72993. * @param axis2 defines the second axis
  72994. * @param axis3 defines the third axis
  72995. * @param ref defines the Vector3 where to store the result
  72996. */
  72997. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  72998. }
  72999. /**
  73000. * Vector4 class created for EulerAngle class conversion to Quaternion
  73001. */
  73002. export class Vector4 {
  73003. /** x value of the vector */
  73004. x: number;
  73005. /** y value of the vector */
  73006. y: number;
  73007. /** z value of the vector */
  73008. z: number;
  73009. /** w value of the vector */
  73010. w: number;
  73011. /**
  73012. * Creates a Vector4 object from the given floats.
  73013. * @param x x value of the vector
  73014. * @param y y value of the vector
  73015. * @param z z value of the vector
  73016. * @param w w value of the vector
  73017. */
  73018. constructor(
  73019. /** x value of the vector */
  73020. x: number,
  73021. /** y value of the vector */
  73022. y: number,
  73023. /** z value of the vector */
  73024. z: number,
  73025. /** w value of the vector */
  73026. w: number);
  73027. /**
  73028. * Returns the string with the Vector4 coordinates.
  73029. * @returns a string containing all the vector values
  73030. */
  73031. toString(): string;
  73032. /**
  73033. * Returns the string "Vector4".
  73034. * @returns "Vector4"
  73035. */
  73036. getClassName(): string;
  73037. /**
  73038. * Returns the Vector4 hash code.
  73039. * @returns a unique hash code
  73040. */
  73041. getHashCode(): number;
  73042. /**
  73043. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73044. * @returns the resulting array
  73045. */
  73046. asArray(): number[];
  73047. /**
  73048. * Populates the given array from the given index with the Vector4 coordinates.
  73049. * @param array array to populate
  73050. * @param index index of the array to start at (default: 0)
  73051. * @returns the Vector4.
  73052. */
  73053. toArray(array: FloatArray, index?: number): Vector4;
  73054. /**
  73055. * Adds the given vector to the current Vector4.
  73056. * @param otherVector the vector to add
  73057. * @returns the updated Vector4.
  73058. */
  73059. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73060. /**
  73061. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73062. * @param otherVector the vector to add
  73063. * @returns the resulting vector
  73064. */
  73065. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73066. /**
  73067. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73068. * @param otherVector the vector to add
  73069. * @param result the vector to store the result
  73070. * @returns the current Vector4.
  73071. */
  73072. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73073. /**
  73074. * Subtract in place the given vector from the current Vector4.
  73075. * @param otherVector the vector to subtract
  73076. * @returns the updated Vector4.
  73077. */
  73078. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73079. /**
  73080. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73081. * @param otherVector the vector to add
  73082. * @returns the new vector with the result
  73083. */
  73084. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73085. /**
  73086. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73087. * @param otherVector the vector to subtract
  73088. * @param result the vector to store the result
  73089. * @returns the current Vector4.
  73090. */
  73091. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73092. /**
  73093. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73094. */
  73095. /**
  73096. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73097. * @param x value to subtract
  73098. * @param y value to subtract
  73099. * @param z value to subtract
  73100. * @param w value to subtract
  73101. * @returns new vector containing the result
  73102. */
  73103. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73104. /**
  73105. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73106. * @param x value to subtract
  73107. * @param y value to subtract
  73108. * @param z value to subtract
  73109. * @param w value to subtract
  73110. * @param result the vector to store the result in
  73111. * @returns the current Vector4.
  73112. */
  73113. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73114. /**
  73115. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73116. * @returns a new vector with the negated values
  73117. */
  73118. negate(): Vector4;
  73119. /**
  73120. * Multiplies the current Vector4 coordinates by scale (float).
  73121. * @param scale the number to scale with
  73122. * @returns the updated Vector4.
  73123. */
  73124. scaleInPlace(scale: number): Vector4;
  73125. /**
  73126. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73127. * @param scale the number to scale with
  73128. * @returns a new vector with the result
  73129. */
  73130. scale(scale: number): Vector4;
  73131. /**
  73132. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73133. * @param scale the number to scale with
  73134. * @param result a vector to store the result in
  73135. * @returns the current Vector4.
  73136. */
  73137. scaleToRef(scale: number, result: Vector4): Vector4;
  73138. /**
  73139. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73140. * @param scale defines the scale factor
  73141. * @param result defines the Vector4 object where to store the result
  73142. * @returns the unmodified current Vector4
  73143. */
  73144. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73145. /**
  73146. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73147. * @param otherVector the vector to compare against
  73148. * @returns true if they are equal
  73149. */
  73150. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73151. /**
  73152. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73153. * @param otherVector vector to compare against
  73154. * @param epsilon (Default: very small number)
  73155. * @returns true if they are equal
  73156. */
  73157. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73158. /**
  73159. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73160. * @param x x value to compare against
  73161. * @param y y value to compare against
  73162. * @param z z value to compare against
  73163. * @param w w value to compare against
  73164. * @returns true if equal
  73165. */
  73166. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73167. /**
  73168. * Multiplies in place the current Vector4 by the given one.
  73169. * @param otherVector vector to multiple with
  73170. * @returns the updated Vector4.
  73171. */
  73172. multiplyInPlace(otherVector: Vector4): Vector4;
  73173. /**
  73174. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73175. * @param otherVector vector to multiple with
  73176. * @returns resulting new vector
  73177. */
  73178. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73179. /**
  73180. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73181. * @param otherVector vector to multiple with
  73182. * @param result vector to store the result
  73183. * @returns the current Vector4.
  73184. */
  73185. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73186. /**
  73187. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73188. * @param x x value multiply with
  73189. * @param y y value multiply with
  73190. * @param z z value multiply with
  73191. * @param w w value multiply with
  73192. * @returns resulting new vector
  73193. */
  73194. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73195. /**
  73196. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73197. * @param otherVector vector to devide with
  73198. * @returns resulting new vector
  73199. */
  73200. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73201. /**
  73202. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73203. * @param otherVector vector to devide with
  73204. * @param result vector to store the result
  73205. * @returns the current Vector4.
  73206. */
  73207. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73208. /**
  73209. * Divides the current Vector3 coordinates by the given ones.
  73210. * @param otherVector vector to devide with
  73211. * @returns the updated Vector3.
  73212. */
  73213. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73214. /**
  73215. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73216. * @param other defines the second operand
  73217. * @returns the current updated Vector4
  73218. */
  73219. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73220. /**
  73221. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73222. * @param other defines the second operand
  73223. * @returns the current updated Vector4
  73224. */
  73225. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73226. /**
  73227. * Gets a new Vector4 from current Vector4 floored values
  73228. * @returns a new Vector4
  73229. */
  73230. floor(): Vector4;
  73231. /**
  73232. * Gets a new Vector4 from current Vector3 floored values
  73233. * @returns a new Vector4
  73234. */
  73235. fract(): Vector4;
  73236. /**
  73237. * Returns the Vector4 length (float).
  73238. * @returns the length
  73239. */
  73240. length(): number;
  73241. /**
  73242. * Returns the Vector4 squared length (float).
  73243. * @returns the length squared
  73244. */
  73245. lengthSquared(): number;
  73246. /**
  73247. * Normalizes in place the Vector4.
  73248. * @returns the updated Vector4.
  73249. */
  73250. normalize(): Vector4;
  73251. /**
  73252. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73253. * @returns this converted to a new vector3
  73254. */
  73255. toVector3(): Vector3;
  73256. /**
  73257. * Returns a new Vector4 copied from the current one.
  73258. * @returns the new cloned vector
  73259. */
  73260. clone(): Vector4;
  73261. /**
  73262. * Updates the current Vector4 with the given one coordinates.
  73263. * @param source the source vector to copy from
  73264. * @returns the updated Vector4.
  73265. */
  73266. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73267. /**
  73268. * Updates the current Vector4 coordinates with the given floats.
  73269. * @param x float to copy from
  73270. * @param y float to copy from
  73271. * @param z float to copy from
  73272. * @param w float to copy from
  73273. * @returns the updated Vector4.
  73274. */
  73275. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73276. /**
  73277. * Updates the current Vector4 coordinates with the given floats.
  73278. * @param x float to set from
  73279. * @param y float to set from
  73280. * @param z float to set from
  73281. * @param w float to set from
  73282. * @returns the updated Vector4.
  73283. */
  73284. set(x: number, y: number, z: number, w: number): Vector4;
  73285. /**
  73286. * Copies the given float to the current Vector3 coordinates
  73287. * @param v defines the x, y, z and w coordinates of the operand
  73288. * @returns the current updated Vector3
  73289. */
  73290. setAll(v: number): Vector4;
  73291. /**
  73292. * Returns a new Vector4 set from the starting index of the given array.
  73293. * @param array the array to pull values from
  73294. * @param offset the offset into the array to start at
  73295. * @returns the new vector
  73296. */
  73297. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73298. /**
  73299. * Updates the given vector "result" from the starting index of the given array.
  73300. * @param array the array to pull values from
  73301. * @param offset the offset into the array to start at
  73302. * @param result the vector to store the result in
  73303. */
  73304. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73305. /**
  73306. * Updates the given vector "result" from the starting index of the given Float32Array.
  73307. * @param array the array to pull values from
  73308. * @param offset the offset into the array to start at
  73309. * @param result the vector to store the result in
  73310. */
  73311. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73312. /**
  73313. * Updates the given vector "result" coordinates from the given floats.
  73314. * @param x float to set from
  73315. * @param y float to set from
  73316. * @param z float to set from
  73317. * @param w float to set from
  73318. * @param result the vector to the floats in
  73319. */
  73320. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  73321. /**
  73322. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73323. * @returns the new vector
  73324. */
  73325. static Zero(): Vector4;
  73326. /**
  73327. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73328. * @returns the new vector
  73329. */
  73330. static One(): Vector4;
  73331. /**
  73332. * Returns a new normalized Vector4 from the given one.
  73333. * @param vector the vector to normalize
  73334. * @returns the vector
  73335. */
  73336. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  73337. /**
  73338. * Updates the given vector "result" from the normalization of the given one.
  73339. * @param vector the vector to normalize
  73340. * @param result the vector to store the result in
  73341. */
  73342. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  73343. /**
  73344. * Returns a vector with the minimum values from the left and right vectors
  73345. * @param left left vector to minimize
  73346. * @param right right vector to minimize
  73347. * @returns a new vector with the minimum of the left and right vector values
  73348. */
  73349. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73350. /**
  73351. * Returns a vector with the maximum values from the left and right vectors
  73352. * @param left left vector to maximize
  73353. * @param right right vector to maximize
  73354. * @returns a new vector with the maximum of the left and right vector values
  73355. */
  73356. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73357. /**
  73358. * Returns the distance (float) between the vectors "value1" and "value2".
  73359. * @param value1 value to calulate the distance between
  73360. * @param value2 value to calulate the distance between
  73361. * @return the distance between the two vectors
  73362. */
  73363. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73364. /**
  73365. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73366. * @param value1 value to calulate the distance between
  73367. * @param value2 value to calulate the distance between
  73368. * @return the distance between the two vectors squared
  73369. */
  73370. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73371. /**
  73372. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73373. * @param value1 value to calulate the center between
  73374. * @param value2 value to calulate the center between
  73375. * @return the center between the two vectors
  73376. */
  73377. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  73378. /**
  73379. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73380. * This methods computes transformed normalized direction vectors only.
  73381. * @param vector the vector to transform
  73382. * @param transformation the transformation matrix to apply
  73383. * @returns the new vector
  73384. */
  73385. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  73386. /**
  73387. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73388. * This methods computes transformed normalized direction vectors only.
  73389. * @param vector the vector to transform
  73390. * @param transformation the transformation matrix to apply
  73391. * @param result the vector to store the result in
  73392. */
  73393. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73394. /**
  73395. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73396. * This methods computes transformed normalized direction vectors only.
  73397. * @param x value to transform
  73398. * @param y value to transform
  73399. * @param z value to transform
  73400. * @param w value to transform
  73401. * @param transformation the transformation matrix to apply
  73402. * @param result the vector to store the results in
  73403. */
  73404. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73405. /**
  73406. * Creates a new Vector4 from a Vector3
  73407. * @param source defines the source data
  73408. * @param w defines the 4th component (default is 0)
  73409. * @returns a new Vector4
  73410. */
  73411. static FromVector3(source: Vector3, w?: number): Vector4;
  73412. }
  73413. /**
  73414. * Class used to store quaternion data
  73415. * @see https://en.wikipedia.org/wiki/Quaternion
  73416. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  73417. */
  73418. export class Quaternion {
  73419. /** defines the first component (0 by default) */
  73420. x: number;
  73421. /** defines the second component (0 by default) */
  73422. y: number;
  73423. /** defines the third component (0 by default) */
  73424. z: number;
  73425. /** defines the fourth component (1.0 by default) */
  73426. w: number;
  73427. /**
  73428. * Creates a new Quaternion from the given floats
  73429. * @param x defines the first component (0 by default)
  73430. * @param y defines the second component (0 by default)
  73431. * @param z defines the third component (0 by default)
  73432. * @param w defines the fourth component (1.0 by default)
  73433. */
  73434. constructor(
  73435. /** defines the first component (0 by default) */
  73436. x?: number,
  73437. /** defines the second component (0 by default) */
  73438. y?: number,
  73439. /** defines the third component (0 by default) */
  73440. z?: number,
  73441. /** defines the fourth component (1.0 by default) */
  73442. w?: number);
  73443. /**
  73444. * Gets a string representation for the current quaternion
  73445. * @returns a string with the Quaternion coordinates
  73446. */
  73447. toString(): string;
  73448. /**
  73449. * Gets the class name of the quaternion
  73450. * @returns the string "Quaternion"
  73451. */
  73452. getClassName(): string;
  73453. /**
  73454. * Gets a hash code for this quaternion
  73455. * @returns the quaternion hash code
  73456. */
  73457. getHashCode(): number;
  73458. /**
  73459. * Copy the quaternion to an array
  73460. * @returns a new array populated with 4 elements from the quaternion coordinates
  73461. */
  73462. asArray(): number[];
  73463. /**
  73464. * Check if two quaternions are equals
  73465. * @param otherQuaternion defines the second operand
  73466. * @return true if the current quaternion and the given one coordinates are strictly equals
  73467. */
  73468. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  73469. /**
  73470. * Clone the current quaternion
  73471. * @returns a new quaternion copied from the current one
  73472. */
  73473. clone(): Quaternion;
  73474. /**
  73475. * Copy a quaternion to the current one
  73476. * @param other defines the other quaternion
  73477. * @returns the updated current quaternion
  73478. */
  73479. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  73480. /**
  73481. * Updates the current quaternion with the given float coordinates
  73482. * @param x defines the x coordinate
  73483. * @param y defines the y coordinate
  73484. * @param z defines the z coordinate
  73485. * @param w defines the w coordinate
  73486. * @returns the updated current quaternion
  73487. */
  73488. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  73489. /**
  73490. * Updates the current quaternion from the given float coordinates
  73491. * @param x defines the x coordinate
  73492. * @param y defines the y coordinate
  73493. * @param z defines the z coordinate
  73494. * @param w defines the w coordinate
  73495. * @returns the updated current quaternion
  73496. */
  73497. set(x: number, y: number, z: number, w: number): Quaternion;
  73498. /**
  73499. * Adds two quaternions
  73500. * @param other defines the second operand
  73501. * @returns a new quaternion as the addition result of the given one and the current quaternion
  73502. */
  73503. add(other: DeepImmutable<Quaternion>): Quaternion;
  73504. /**
  73505. * Add a quaternion to the current one
  73506. * @param other defines the quaternion to add
  73507. * @returns the current quaternion
  73508. */
  73509. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  73510. /**
  73511. * Subtract two quaternions
  73512. * @param other defines the second operand
  73513. * @returns a new quaternion as the subtraction result of the given one from the current one
  73514. */
  73515. subtract(other: Quaternion): Quaternion;
  73516. /**
  73517. * Multiplies the current quaternion by a scale factor
  73518. * @param value defines the scale factor
  73519. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  73520. */
  73521. scale(value: number): Quaternion;
  73522. /**
  73523. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  73524. * @param scale defines the scale factor
  73525. * @param result defines the Quaternion object where to store the result
  73526. * @returns the unmodified current quaternion
  73527. */
  73528. scaleToRef(scale: number, result: Quaternion): Quaternion;
  73529. /**
  73530. * Multiplies in place the current quaternion by a scale factor
  73531. * @param value defines the scale factor
  73532. * @returns the current modified quaternion
  73533. */
  73534. scaleInPlace(value: number): Quaternion;
  73535. /**
  73536. * Scale the current quaternion values by a factor and add the result to a given quaternion
  73537. * @param scale defines the scale factor
  73538. * @param result defines the Quaternion object where to store the result
  73539. * @returns the unmodified current quaternion
  73540. */
  73541. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  73542. /**
  73543. * Multiplies two quaternions
  73544. * @param q1 defines the second operand
  73545. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  73546. */
  73547. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  73548. /**
  73549. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  73550. * @param q1 defines the second operand
  73551. * @param result defines the target quaternion
  73552. * @returns the current quaternion
  73553. */
  73554. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  73555. /**
  73556. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  73557. * @param q1 defines the second operand
  73558. * @returns the currentupdated quaternion
  73559. */
  73560. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  73561. /**
  73562. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  73563. * @param ref defines the target quaternion
  73564. * @returns the current quaternion
  73565. */
  73566. conjugateToRef(ref: Quaternion): Quaternion;
  73567. /**
  73568. * Conjugates in place (1-q) the current quaternion
  73569. * @returns the current updated quaternion
  73570. */
  73571. conjugateInPlace(): Quaternion;
  73572. /**
  73573. * Conjugates in place (1-q) the current quaternion
  73574. * @returns a new quaternion
  73575. */
  73576. conjugate(): Quaternion;
  73577. /**
  73578. * Gets length of current quaternion
  73579. * @returns the quaternion length (float)
  73580. */
  73581. length(): number;
  73582. /**
  73583. * Normalize in place the current quaternion
  73584. * @returns the current updated quaternion
  73585. */
  73586. normalize(): Quaternion;
  73587. /**
  73588. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  73589. * @param order is a reserved parameter and is ignore for now
  73590. * @returns a new Vector3 containing the Euler angles
  73591. */
  73592. toEulerAngles(order?: string): Vector3;
  73593. /**
  73594. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  73595. * @param result defines the vector which will be filled with the Euler angles
  73596. * @param order is a reserved parameter and is ignore for now
  73597. * @returns the current unchanged quaternion
  73598. */
  73599. toEulerAnglesToRef(result: Vector3): Quaternion;
  73600. /**
  73601. * Updates the given rotation matrix with the current quaternion values
  73602. * @param result defines the target matrix
  73603. * @returns the current unchanged quaternion
  73604. */
  73605. toRotationMatrix(result: Matrix): Quaternion;
  73606. /**
  73607. * Updates the current quaternion from the given rotation matrix values
  73608. * @param matrix defines the source matrix
  73609. * @returns the current updated quaternion
  73610. */
  73611. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73612. /**
  73613. * Creates a new quaternion from a rotation matrix
  73614. * @param matrix defines the source matrix
  73615. * @returns a new quaternion created from the given rotation matrix values
  73616. */
  73617. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73618. /**
  73619. * Updates the given quaternion with the given rotation matrix values
  73620. * @param matrix defines the source matrix
  73621. * @param result defines the target quaternion
  73622. */
  73623. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  73624. /**
  73625. * Returns the dot product (float) between the quaternions "left" and "right"
  73626. * @param left defines the left operand
  73627. * @param right defines the right operand
  73628. * @returns the dot product
  73629. */
  73630. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  73631. /**
  73632. * Checks if the two quaternions are close to each other
  73633. * @param quat0 defines the first quaternion to check
  73634. * @param quat1 defines the second quaternion to check
  73635. * @returns true if the two quaternions are close to each other
  73636. */
  73637. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  73638. /**
  73639. * Creates an empty quaternion
  73640. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73641. */
  73642. static Zero(): Quaternion;
  73643. /**
  73644. * Inverse a given quaternion
  73645. * @param q defines the source quaternion
  73646. * @returns a new quaternion as the inverted current quaternion
  73647. */
  73648. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  73649. /**
  73650. * Inverse a given quaternion
  73651. * @param q defines the source quaternion
  73652. * @param result the quaternion the result will be stored in
  73653. * @returns the result quaternion
  73654. */
  73655. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  73656. /**
  73657. * Creates an identity quaternion
  73658. * @returns the identity quaternion
  73659. */
  73660. static Identity(): Quaternion;
  73661. /**
  73662. * Gets a boolean indicating if the given quaternion is identity
  73663. * @param quaternion defines the quaternion to check
  73664. * @returns true if the quaternion is identity
  73665. */
  73666. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  73667. /**
  73668. * Creates a quaternion from a rotation around an axis
  73669. * @param axis defines the axis to use
  73670. * @param angle defines the angle to use
  73671. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  73672. */
  73673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  73674. /**
  73675. * Creates a rotation around an axis and stores it into the given quaternion
  73676. * @param axis defines the axis to use
  73677. * @param angle defines the angle to use
  73678. * @param result defines the target quaternion
  73679. * @returns the target quaternion
  73680. */
  73681. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  73682. /**
  73683. * Creates a new quaternion from data stored into an array
  73684. * @param array defines the data source
  73685. * @param offset defines the offset in the source array where the data starts
  73686. * @returns a new quaternion
  73687. */
  73688. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  73689. /**
  73690. * Create a quaternion from Euler rotation angles
  73691. * @param x Pitch
  73692. * @param y Yaw
  73693. * @param z Roll
  73694. * @returns the new Quaternion
  73695. */
  73696. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  73697. /**
  73698. * Updates a quaternion from Euler rotation angles
  73699. * @param x Pitch
  73700. * @param y Yaw
  73701. * @param z Roll
  73702. * @param result the quaternion to store the result
  73703. * @returns the updated quaternion
  73704. */
  73705. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  73706. /**
  73707. * Create a quaternion from Euler rotation vector
  73708. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73709. * @returns the new Quaternion
  73710. */
  73711. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  73712. /**
  73713. * Updates a quaternion from Euler rotation vector
  73714. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73715. * @param result the quaternion to store the result
  73716. * @returns the updated quaternion
  73717. */
  73718. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  73719. /**
  73720. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73721. * @param yaw defines the rotation around Y axis
  73722. * @param pitch defines the rotation around X axis
  73723. * @param roll defines the rotation around Z axis
  73724. * @returns the new quaternion
  73725. */
  73726. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  73727. /**
  73728. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73729. * @param yaw defines the rotation around Y axis
  73730. * @param pitch defines the rotation around X axis
  73731. * @param roll defines the rotation around Z axis
  73732. * @param result defines the target quaternion
  73733. */
  73734. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  73735. /**
  73736. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73737. * @param alpha defines the rotation around first axis
  73738. * @param beta defines the rotation around second axis
  73739. * @param gamma defines the rotation around third axis
  73740. * @returns the new quaternion
  73741. */
  73742. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  73743. /**
  73744. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73745. * @param alpha defines the rotation around first axis
  73746. * @param beta defines the rotation around second axis
  73747. * @param gamma defines the rotation around third axis
  73748. * @param result defines the target quaternion
  73749. */
  73750. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  73751. /**
  73752. * 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)
  73753. * @param axis1 defines the first axis
  73754. * @param axis2 defines the second axis
  73755. * @param axis3 defines the third axis
  73756. * @returns the new quaternion
  73757. */
  73758. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  73759. /**
  73760. * 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
  73761. * @param axis1 defines the first axis
  73762. * @param axis2 defines the second axis
  73763. * @param axis3 defines the third axis
  73764. * @param ref defines the target quaternion
  73765. */
  73766. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  73767. /**
  73768. * Interpolates between two quaternions
  73769. * @param left defines first quaternion
  73770. * @param right defines second quaternion
  73771. * @param amount defines the gradient to use
  73772. * @returns the new interpolated quaternion
  73773. */
  73774. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73775. /**
  73776. * Interpolates between two quaternions and stores it into a target quaternion
  73777. * @param left defines first quaternion
  73778. * @param right defines second quaternion
  73779. * @param amount defines the gradient to use
  73780. * @param result defines the target quaternion
  73781. */
  73782. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  73783. /**
  73784. * Interpolate between two quaternions using Hermite interpolation
  73785. * @param value1 defines first quaternion
  73786. * @param tangent1 defines the incoming tangent
  73787. * @param value2 defines second quaternion
  73788. * @param tangent2 defines the outgoing tangent
  73789. * @param amount defines the target quaternion
  73790. * @returns the new interpolated quaternion
  73791. */
  73792. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73793. }
  73794. /**
  73795. * Class used to store matrix data (4x4)
  73796. */
  73797. export class Matrix {
  73798. private static _updateFlagSeed;
  73799. private static _identityReadOnly;
  73800. private _isIdentity;
  73801. private _isIdentityDirty;
  73802. private _isIdentity3x2;
  73803. private _isIdentity3x2Dirty;
  73804. /**
  73805. * Gets the update flag of the matrix which is an unique number for the matrix.
  73806. * It will be incremented every time the matrix data change.
  73807. * You can use it to speed the comparison between two versions of the same matrix.
  73808. */
  73809. updateFlag: number;
  73810. private readonly _m;
  73811. /**
  73812. * Gets the internal data of the matrix
  73813. */
  73814. readonly m: DeepImmutable<Float32Array>;
  73815. /** @hidden */
  73816. _markAsUpdated(): void;
  73817. /** @hidden */
  73818. private _updateIdentityStatus;
  73819. /**
  73820. * Creates an empty matrix (filled with zeros)
  73821. */
  73822. constructor();
  73823. /**
  73824. * Check if the current matrix is identity
  73825. * @returns true is the matrix is the identity matrix
  73826. */
  73827. isIdentity(): boolean;
  73828. /**
  73829. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73830. * @returns true is the matrix is the identity matrix
  73831. */
  73832. isIdentityAs3x2(): boolean;
  73833. /**
  73834. * Gets the determinant of the matrix
  73835. * @returns the matrix determinant
  73836. */
  73837. determinant(): number;
  73838. /**
  73839. * Returns the matrix as a Float32Array
  73840. * @returns the matrix underlying array
  73841. */
  73842. toArray(): DeepImmutable<Float32Array>;
  73843. /**
  73844. * Returns the matrix as a Float32Array
  73845. * @returns the matrix underlying array.
  73846. */
  73847. asArray(): DeepImmutable<Float32Array>;
  73848. /**
  73849. * Inverts the current matrix in place
  73850. * @returns the current inverted matrix
  73851. */
  73852. invert(): Matrix;
  73853. /**
  73854. * Sets all the matrix elements to zero
  73855. * @returns the current matrix
  73856. */
  73857. reset(): Matrix;
  73858. /**
  73859. * Adds the current matrix with a second one
  73860. * @param other defines the matrix to add
  73861. * @returns a new matrix as the addition of the current matrix and the given one
  73862. */
  73863. add(other: DeepImmutable<Matrix>): Matrix;
  73864. /**
  73865. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73866. * @param other defines the matrix to add
  73867. * @param result defines the target matrix
  73868. * @returns the current matrix
  73869. */
  73870. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73871. /**
  73872. * Adds in place the given matrix to the current matrix
  73873. * @param other defines the second operand
  73874. * @returns the current updated matrix
  73875. */
  73876. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  73877. /**
  73878. * Sets the given matrix to the current inverted Matrix
  73879. * @param other defines the target matrix
  73880. * @returns the unmodified current matrix
  73881. */
  73882. invertToRef(other: Matrix): Matrix;
  73883. /**
  73884. * add a value at the specified position in the current Matrix
  73885. * @param index the index of the value within the matrix. between 0 and 15.
  73886. * @param value the value to be added
  73887. * @returns the current updated matrix
  73888. */
  73889. addAtIndex(index: number, value: number): Matrix;
  73890. /**
  73891. * mutiply the specified position in the current Matrix by a value
  73892. * @param index the index of the value within the matrix. between 0 and 15.
  73893. * @param value the value to be added
  73894. * @returns the current updated matrix
  73895. */
  73896. multiplyAtIndex(index: number, value: number): Matrix;
  73897. /**
  73898. * Inserts the translation vector (using 3 floats) in the current matrix
  73899. * @param x defines the 1st component of the translation
  73900. * @param y defines the 2nd component of the translation
  73901. * @param z defines the 3rd component of the translation
  73902. * @returns the current updated matrix
  73903. */
  73904. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73905. /**
  73906. * Adds the translation vector (using 3 floats) in the current matrix
  73907. * @param x defines the 1st component of the translation
  73908. * @param y defines the 2nd component of the translation
  73909. * @param z defines the 3rd component of the translation
  73910. * @returns the current updated matrix
  73911. */
  73912. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73913. /**
  73914. * Inserts the translation vector in the current matrix
  73915. * @param vector3 defines the translation to insert
  73916. * @returns the current updated matrix
  73917. */
  73918. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  73919. /**
  73920. * Gets the translation value of the current matrix
  73921. * @returns a new Vector3 as the extracted translation from the matrix
  73922. */
  73923. getTranslation(): Vector3;
  73924. /**
  73925. * Fill a Vector3 with the extracted translation from the matrix
  73926. * @param result defines the Vector3 where to store the translation
  73927. * @returns the current matrix
  73928. */
  73929. getTranslationToRef(result: Vector3): Matrix;
  73930. /**
  73931. * Remove rotation and scaling part from the matrix
  73932. * @returns the updated matrix
  73933. */
  73934. removeRotationAndScaling(): Matrix;
  73935. /**
  73936. * Multiply two matrices
  73937. * @param other defines the second operand
  73938. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  73939. */
  73940. multiply(other: DeepImmutable<Matrix>): Matrix;
  73941. /**
  73942. * Copy the current matrix from the given one
  73943. * @param other defines the source matrix
  73944. * @returns the current updated matrix
  73945. */
  73946. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  73947. /**
  73948. * Populates the given array from the starting index with the current matrix values
  73949. * @param array defines the target array
  73950. * @param offset defines the offset in the target array where to start storing values
  73951. * @returns the current matrix
  73952. */
  73953. copyToArray(array: Float32Array, offset?: number): Matrix;
  73954. /**
  73955. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  73956. * @param other defines the second operand
  73957. * @param result defines the matrix where to store the multiplication
  73958. * @returns the current matrix
  73959. */
  73960. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73961. /**
  73962. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  73963. * @param other defines the second operand
  73964. * @param result defines the array where to store the multiplication
  73965. * @param offset defines the offset in the target array where to start storing values
  73966. * @returns the current matrix
  73967. */
  73968. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  73969. /**
  73970. * Check equality between this matrix and a second one
  73971. * @param value defines the second matrix to compare
  73972. * @returns true is the current matrix and the given one values are strictly equal
  73973. */
  73974. equals(value: DeepImmutable<Matrix>): boolean;
  73975. /**
  73976. * Clone the current matrix
  73977. * @returns a new matrix from the current matrix
  73978. */
  73979. clone(): Matrix;
  73980. /**
  73981. * Returns the name of the current matrix class
  73982. * @returns the string "Matrix"
  73983. */
  73984. getClassName(): string;
  73985. /**
  73986. * Gets the hash code of the current matrix
  73987. * @returns the hash code
  73988. */
  73989. getHashCode(): number;
  73990. /**
  73991. * Decomposes the current Matrix into a translation, rotation and scaling components
  73992. * @param scale defines the scale vector3 given as a reference to update
  73993. * @param rotation defines the rotation quaternion given as a reference to update
  73994. * @param translation defines the translation vector3 given as a reference to update
  73995. * @returns true if operation was successful
  73996. */
  73997. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  73998. /**
  73999. * Gets specific row of the matrix
  74000. * @param index defines the number of the row to get
  74001. * @returns the index-th row of the current matrix as a new Vector4
  74002. */
  74003. getRow(index: number): Nullable<Vector4>;
  74004. /**
  74005. * Sets the index-th row of the current matrix to the vector4 values
  74006. * @param index defines the number of the row to set
  74007. * @param row defines the target vector4
  74008. * @returns the updated current matrix
  74009. */
  74010. setRow(index: number, row: Vector4): Matrix;
  74011. /**
  74012. * Compute the transpose of the matrix
  74013. * @returns the new transposed matrix
  74014. */
  74015. transpose(): Matrix;
  74016. /**
  74017. * Compute the transpose of the matrix and store it in a given matrix
  74018. * @param result defines the target matrix
  74019. * @returns the current matrix
  74020. */
  74021. transposeToRef(result: Matrix): Matrix;
  74022. /**
  74023. * Sets the index-th row of the current matrix with the given 4 x float values
  74024. * @param index defines the row index
  74025. * @param x defines the x component to set
  74026. * @param y defines the y component to set
  74027. * @param z defines the z component to set
  74028. * @param w defines the w component to set
  74029. * @returns the updated current matrix
  74030. */
  74031. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74032. /**
  74033. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74034. * @param scale defines the scale factor
  74035. * @returns a new matrix
  74036. */
  74037. scale(scale: number): Matrix;
  74038. /**
  74039. * Scale the current matrix values by a factor to a given result matrix
  74040. * @param scale defines the scale factor
  74041. * @param result defines the matrix to store the result
  74042. * @returns the current matrix
  74043. */
  74044. scaleToRef(scale: number, result: Matrix): Matrix;
  74045. /**
  74046. * Scale the current matrix values by a factor and add the result to a given matrix
  74047. * @param scale defines the scale factor
  74048. * @param result defines the Matrix to store the result
  74049. * @returns the current matrix
  74050. */
  74051. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74052. /**
  74053. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74054. * @param ref matrix to store the result
  74055. */
  74056. toNormalMatrix(ref: Matrix): void;
  74057. /**
  74058. * Gets only rotation part of the current matrix
  74059. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74060. */
  74061. getRotationMatrix(): Matrix;
  74062. /**
  74063. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74064. * @param result defines the target matrix to store data to
  74065. * @returns the current matrix
  74066. */
  74067. getRotationMatrixToRef(result: Matrix): Matrix;
  74068. /**
  74069. * Toggles model matrix from being right handed to left handed in place and vice versa
  74070. */
  74071. toggleModelMatrixHandInPlace(): void;
  74072. /**
  74073. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74074. */
  74075. toggleProjectionMatrixHandInPlace(): void;
  74076. /**
  74077. * Creates a matrix from an array
  74078. * @param array defines the source array
  74079. * @param offset defines an offset in the source array
  74080. * @returns a new Matrix set from the starting index of the given array
  74081. */
  74082. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74083. /**
  74084. * Copy the content of an array into a given matrix
  74085. * @param array defines the source array
  74086. * @param offset defines an offset in the source array
  74087. * @param result defines the target matrix
  74088. */
  74089. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74090. /**
  74091. * Stores an array into a matrix after having multiplied each component by a given factor
  74092. * @param array defines the source array
  74093. * @param offset defines the offset in the source array
  74094. * @param scale defines the scaling factor
  74095. * @param result defines the target matrix
  74096. */
  74097. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74098. /**
  74099. * Gets an identity matrix that must not be updated
  74100. */
  74101. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  74102. /**
  74103. * Stores a list of values (16) inside a given matrix
  74104. * @param initialM11 defines 1st value of 1st row
  74105. * @param initialM12 defines 2nd value of 1st row
  74106. * @param initialM13 defines 3rd value of 1st row
  74107. * @param initialM14 defines 4th value of 1st row
  74108. * @param initialM21 defines 1st value of 2nd row
  74109. * @param initialM22 defines 2nd value of 2nd row
  74110. * @param initialM23 defines 3rd value of 2nd row
  74111. * @param initialM24 defines 4th value of 2nd row
  74112. * @param initialM31 defines 1st value of 3rd row
  74113. * @param initialM32 defines 2nd value of 3rd row
  74114. * @param initialM33 defines 3rd value of 3rd row
  74115. * @param initialM34 defines 4th value of 3rd row
  74116. * @param initialM41 defines 1st value of 4th row
  74117. * @param initialM42 defines 2nd value of 4th row
  74118. * @param initialM43 defines 3rd value of 4th row
  74119. * @param initialM44 defines 4th value of 4th row
  74120. * @param result defines the target matrix
  74121. */
  74122. 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;
  74123. /**
  74124. * Creates new matrix from a list of values (16)
  74125. * @param initialM11 defines 1st value of 1st row
  74126. * @param initialM12 defines 2nd value of 1st row
  74127. * @param initialM13 defines 3rd value of 1st row
  74128. * @param initialM14 defines 4th value of 1st row
  74129. * @param initialM21 defines 1st value of 2nd row
  74130. * @param initialM22 defines 2nd value of 2nd row
  74131. * @param initialM23 defines 3rd value of 2nd row
  74132. * @param initialM24 defines 4th value of 2nd row
  74133. * @param initialM31 defines 1st value of 3rd row
  74134. * @param initialM32 defines 2nd value of 3rd row
  74135. * @param initialM33 defines 3rd value of 3rd row
  74136. * @param initialM34 defines 4th value of 3rd row
  74137. * @param initialM41 defines 1st value of 4th row
  74138. * @param initialM42 defines 2nd value of 4th row
  74139. * @param initialM43 defines 3rd value of 4th row
  74140. * @param initialM44 defines 4th value of 4th row
  74141. * @returns the new matrix
  74142. */
  74143. 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;
  74144. /**
  74145. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74146. * @param scale defines the scale vector3
  74147. * @param rotation defines the rotation quaternion
  74148. * @param translation defines the translation vector3
  74149. * @returns a new matrix
  74150. */
  74151. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74152. /**
  74153. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74154. * @param scale defines the scale vector3
  74155. * @param rotation defines the rotation quaternion
  74156. * @param translation defines the translation vector3
  74157. * @param result defines the target matrix
  74158. */
  74159. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74160. /**
  74161. * Creates a new identity matrix
  74162. * @returns a new identity matrix
  74163. */
  74164. static Identity(): Matrix;
  74165. /**
  74166. * Creates a new identity matrix and stores the result in a given matrix
  74167. * @param result defines the target matrix
  74168. */
  74169. static IdentityToRef(result: Matrix): void;
  74170. /**
  74171. * Creates a new zero matrix
  74172. * @returns a new zero matrix
  74173. */
  74174. static Zero(): Matrix;
  74175. /**
  74176. * Creates a new rotation matrix for "angle" radians around the X axis
  74177. * @param angle defines the angle (in radians) to use
  74178. * @return the new matrix
  74179. */
  74180. static RotationX(angle: number): Matrix;
  74181. /**
  74182. * Creates a new matrix as the invert of a given matrix
  74183. * @param source defines the source matrix
  74184. * @returns the new matrix
  74185. */
  74186. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74187. /**
  74188. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74189. * @param angle defines the angle (in radians) to use
  74190. * @param result defines the target matrix
  74191. */
  74192. static RotationXToRef(angle: number, result: Matrix): void;
  74193. /**
  74194. * Creates a new rotation matrix for "angle" radians around the Y axis
  74195. * @param angle defines the angle (in radians) to use
  74196. * @return the new matrix
  74197. */
  74198. static RotationY(angle: number): Matrix;
  74199. /**
  74200. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74201. * @param angle defines the angle (in radians) to use
  74202. * @param result defines the target matrix
  74203. */
  74204. static RotationYToRef(angle: number, result: Matrix): void;
  74205. /**
  74206. * Creates a new rotation matrix for "angle" radians around the Z axis
  74207. * @param angle defines the angle (in radians) to use
  74208. * @return the new matrix
  74209. */
  74210. static RotationZ(angle: number): Matrix;
  74211. /**
  74212. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74213. * @param angle defines the angle (in radians) to use
  74214. * @param result defines the target matrix
  74215. */
  74216. static RotationZToRef(angle: number, result: Matrix): void;
  74217. /**
  74218. * Creates a new rotation matrix for "angle" radians around the given axis
  74219. * @param axis defines the axis to use
  74220. * @param angle defines the angle (in radians) to use
  74221. * @return the new matrix
  74222. */
  74223. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74224. /**
  74225. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74226. * @param axis defines the axis to use
  74227. * @param angle defines the angle (in radians) to use
  74228. * @param result defines the target matrix
  74229. */
  74230. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74231. /**
  74232. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74233. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74234. * @param from defines the vector to align
  74235. * @param to defines the vector to align to
  74236. * @param result defines the target matrix
  74237. */
  74238. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74239. /**
  74240. * Creates a rotation matrix
  74241. * @param yaw defines the yaw angle in radians (Y axis)
  74242. * @param pitch defines the pitch angle in radians (X axis)
  74243. * @param roll defines the roll angle in radians (X axis)
  74244. * @returns the new rotation matrix
  74245. */
  74246. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74247. /**
  74248. * Creates a rotation matrix and stores it in a given matrix
  74249. * @param yaw defines the yaw angle in radians (Y axis)
  74250. * @param pitch defines the pitch angle in radians (X axis)
  74251. * @param roll defines the roll angle in radians (X axis)
  74252. * @param result defines the target matrix
  74253. */
  74254. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74255. /**
  74256. * Creates a scaling matrix
  74257. * @param x defines the scale factor on X axis
  74258. * @param y defines the scale factor on Y axis
  74259. * @param z defines the scale factor on Z axis
  74260. * @returns the new matrix
  74261. */
  74262. static Scaling(x: number, y: number, z: number): Matrix;
  74263. /**
  74264. * Creates a scaling matrix and stores it in a given matrix
  74265. * @param x defines the scale factor on X axis
  74266. * @param y defines the scale factor on Y axis
  74267. * @param z defines the scale factor on Z axis
  74268. * @param result defines the target matrix
  74269. */
  74270. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74271. /**
  74272. * Creates a translation matrix
  74273. * @param x defines the translation on X axis
  74274. * @param y defines the translation on Y axis
  74275. * @param z defines the translationon Z axis
  74276. * @returns the new matrix
  74277. */
  74278. static Translation(x: number, y: number, z: number): Matrix;
  74279. /**
  74280. * Creates a translation matrix and stores it in a given matrix
  74281. * @param x defines the translation on X axis
  74282. * @param y defines the translation on Y axis
  74283. * @param z defines the translationon Z axis
  74284. * @param result defines the target matrix
  74285. */
  74286. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74287. /**
  74288. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74289. * @param startValue defines the start value
  74290. * @param endValue defines the end value
  74291. * @param gradient defines the gradient factor
  74292. * @returns the new matrix
  74293. */
  74294. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74295. /**
  74296. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74297. * @param startValue defines the start value
  74298. * @param endValue defines the end value
  74299. * @param gradient defines the gradient factor
  74300. * @param result defines the Matrix object where to store data
  74301. */
  74302. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74303. /**
  74304. * Builds a new matrix whose values are computed by:
  74305. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74306. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74307. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74308. * @param startValue defines the first matrix
  74309. * @param endValue defines the second matrix
  74310. * @param gradient defines the gradient between the two matrices
  74311. * @returns the new matrix
  74312. */
  74313. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74314. /**
  74315. * Update a matrix to values which are computed by:
  74316. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74317. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74318. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74319. * @param startValue defines the first matrix
  74320. * @param endValue defines the second matrix
  74321. * @param gradient defines the gradient between the two matrices
  74322. * @param result defines the target matrix
  74323. */
  74324. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74325. /**
  74326. * 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"
  74327. * This function works in left handed mode
  74328. * @param eye defines the final position of the entity
  74329. * @param target defines where the entity should look at
  74330. * @param up defines the up vector for the entity
  74331. * @returns the new matrix
  74332. */
  74333. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74334. /**
  74335. * 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".
  74336. * This function works in left handed mode
  74337. * @param eye defines the final position of the entity
  74338. * @param target defines where the entity should look at
  74339. * @param up defines the up vector for the entity
  74340. * @param result defines the target matrix
  74341. */
  74342. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74343. /**
  74344. * 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"
  74345. * This function works in right handed mode
  74346. * @param eye defines the final position of the entity
  74347. * @param target defines where the entity should look at
  74348. * @param up defines the up vector for the entity
  74349. * @returns the new matrix
  74350. */
  74351. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74352. /**
  74353. * 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".
  74354. * This function works in right handed mode
  74355. * @param eye defines the final position of the entity
  74356. * @param target defines where the entity should look at
  74357. * @param up defines the up vector for the entity
  74358. * @param result defines the target matrix
  74359. */
  74360. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74361. /**
  74362. * Create a left-handed orthographic projection matrix
  74363. * @param width defines the viewport width
  74364. * @param height defines the viewport height
  74365. * @param znear defines the near clip plane
  74366. * @param zfar defines the far clip plane
  74367. * @returns a new matrix as a left-handed orthographic projection matrix
  74368. */
  74369. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74370. /**
  74371. * Store a left-handed orthographic projection to a given matrix
  74372. * @param width defines the viewport width
  74373. * @param height defines the viewport height
  74374. * @param znear defines the near clip plane
  74375. * @param zfar defines the far clip plane
  74376. * @param result defines the target matrix
  74377. */
  74378. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  74379. /**
  74380. * Create a left-handed orthographic projection matrix
  74381. * @param left defines the viewport left coordinate
  74382. * @param right defines the viewport right coordinate
  74383. * @param bottom defines the viewport bottom coordinate
  74384. * @param top defines the viewport top coordinate
  74385. * @param znear defines the near clip plane
  74386. * @param zfar defines the far clip plane
  74387. * @returns a new matrix as a left-handed orthographic projection matrix
  74388. */
  74389. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  74390. /**
  74391. * Stores a left-handed orthographic projection into a given matrix
  74392. * @param left defines the viewport left coordinate
  74393. * @param right defines the viewport right coordinate
  74394. * @param bottom defines the viewport bottom coordinate
  74395. * @param top defines the viewport top coordinate
  74396. * @param znear defines the near clip plane
  74397. * @param zfar defines the far clip plane
  74398. * @param result defines the target matrix
  74399. */
  74400. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  74401. /**
  74402. * Creates a right-handed orthographic projection matrix
  74403. * @param left defines the viewport left coordinate
  74404. * @param right defines the viewport right coordinate
  74405. * @param bottom defines the viewport bottom coordinate
  74406. * @param top defines the viewport top coordinate
  74407. * @param znear defines the near clip plane
  74408. * @param zfar defines the far clip plane
  74409. * @returns a new matrix as a right-handed orthographic projection matrix
  74410. */
  74411. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  74412. /**
  74413. * Stores a right-handed orthographic projection into a given matrix
  74414. * @param left defines the viewport left coordinate
  74415. * @param right defines the viewport right coordinate
  74416. * @param bottom defines the viewport bottom coordinate
  74417. * @param top defines the viewport top coordinate
  74418. * @param znear defines the near clip plane
  74419. * @param zfar defines the far clip plane
  74420. * @param result defines the target matrix
  74421. */
  74422. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  74423. /**
  74424. * Creates a left-handed perspective projection matrix
  74425. * @param width defines the viewport width
  74426. * @param height defines the viewport height
  74427. * @param znear defines the near clip plane
  74428. * @param zfar defines the far clip plane
  74429. * @returns a new matrix as a left-handed perspective projection matrix
  74430. */
  74431. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74432. /**
  74433. * Creates a left-handed perspective projection matrix
  74434. * @param fov defines the horizontal field of view
  74435. * @param aspect defines the aspect ratio
  74436. * @param znear defines the near clip plane
  74437. * @param zfar defines the far clip plane
  74438. * @returns a new matrix as a left-handed perspective projection matrix
  74439. */
  74440. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  74441. /**
  74442. * Stores a left-handed perspective projection into a given matrix
  74443. * @param fov defines the horizontal field of view
  74444. * @param aspect defines the aspect ratio
  74445. * @param znear defines the near clip plane
  74446. * @param zfar defines the far clip plane
  74447. * @param result defines the target matrix
  74448. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74449. */
  74450. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  74451. /**
  74452. * Stores a left-handed perspective projection into a given matrix with depth reversed
  74453. * @param fov defines the horizontal field of view
  74454. * @param aspect defines the aspect ratio
  74455. * @param znear defines the near clip plane
  74456. * @param zfar not used as infinity is used as far clip
  74457. * @param result defines the target matrix
  74458. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74459. */
  74460. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  74461. /**
  74462. * Creates a right-handed perspective projection matrix
  74463. * @param fov defines the horizontal field of view
  74464. * @param aspect defines the aspect ratio
  74465. * @param znear defines the near clip plane
  74466. * @param zfar defines the far clip plane
  74467. * @returns a new matrix as a right-handed perspective projection matrix
  74468. */
  74469. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  74470. /**
  74471. * Stores a right-handed perspective projection into a given matrix
  74472. * @param fov defines the horizontal field of view
  74473. * @param aspect defines the aspect ratio
  74474. * @param znear defines the near clip plane
  74475. * @param zfar defines the far clip plane
  74476. * @param result defines the target matrix
  74477. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74478. */
  74479. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  74480. /**
  74481. * Stores a right-handed perspective projection into a given matrix
  74482. * @param fov defines the horizontal field of view
  74483. * @param aspect defines the aspect ratio
  74484. * @param znear defines the near clip plane
  74485. * @param zfar not used as infinity is used as far clip
  74486. * @param result defines the target matrix
  74487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74488. */
  74489. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  74490. /**
  74491. * Stores a perspective projection for WebVR info a given matrix
  74492. * @param fov defines the field of view
  74493. * @param znear defines the near clip plane
  74494. * @param zfar defines the far clip plane
  74495. * @param result defines the target matrix
  74496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  74497. */
  74498. static PerspectiveFovWebVRToRef(fov: {
  74499. upDegrees: number;
  74500. downDegrees: number;
  74501. leftDegrees: number;
  74502. rightDegrees: number;
  74503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  74504. /**
  74505. * Computes a complete transformation matrix
  74506. * @param viewport defines the viewport to use
  74507. * @param world defines the world matrix
  74508. * @param view defines the view matrix
  74509. * @param projection defines the projection matrix
  74510. * @param zmin defines the near clip plane
  74511. * @param zmax defines the far clip plane
  74512. * @returns the transformation matrix
  74513. */
  74514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  74515. /**
  74516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  74517. * @param matrix defines the matrix to use
  74518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  74519. */
  74520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  74521. /**
  74522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  74523. * @param matrix defines the matrix to use
  74524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  74525. */
  74526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  74527. /**
  74528. * Compute the transpose of a given matrix
  74529. * @param matrix defines the matrix to transpose
  74530. * @returns the new matrix
  74531. */
  74532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  74533. /**
  74534. * Compute the transpose of a matrix and store it in a target matrix
  74535. * @param matrix defines the matrix to transpose
  74536. * @param result defines the target matrix
  74537. */
  74538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  74539. /**
  74540. * Computes a reflection matrix from a plane
  74541. * @param plane defines the reflection plane
  74542. * @returns a new matrix
  74543. */
  74544. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  74545. /**
  74546. * Computes a reflection matrix from a plane
  74547. * @param plane defines the reflection plane
  74548. * @param result defines the target matrix
  74549. */
  74550. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  74551. /**
  74552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  74553. * @param xaxis defines the value of the 1st axis
  74554. * @param yaxis defines the value of the 2nd axis
  74555. * @param zaxis defines the value of the 3rd axis
  74556. * @param result defines the target matrix
  74557. */
  74558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  74559. /**
  74560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  74561. * @param quat defines the quaternion to use
  74562. * @param result defines the target matrix
  74563. */
  74564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  74565. }
  74566. /**
  74567. * @hidden
  74568. */
  74569. export class TmpVectors {
  74570. static Vector2: Vector2[];
  74571. static Vector3: Vector3[];
  74572. static Vector4: Vector4[];
  74573. static Quaternion: Quaternion[];
  74574. static Matrix: Matrix[];
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /**
  74579. * Defines potential orientation for back face culling
  74580. */
  74581. export enum Orientation {
  74582. /**
  74583. * Clockwise
  74584. */
  74585. CW = 0,
  74586. /** Counter clockwise */
  74587. CCW = 1
  74588. }
  74589. /** Class used to represent a Bezier curve */
  74590. export class BezierCurve {
  74591. /**
  74592. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  74593. * @param t defines the time
  74594. * @param x1 defines the left coordinate on X axis
  74595. * @param y1 defines the left coordinate on Y axis
  74596. * @param x2 defines the right coordinate on X axis
  74597. * @param y2 defines the right coordinate on Y axis
  74598. * @returns the interpolated value
  74599. */
  74600. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  74601. }
  74602. /**
  74603. * Defines angle representation
  74604. */
  74605. export class Angle {
  74606. private _radians;
  74607. /**
  74608. * Creates an Angle object of "radians" radians (float).
  74609. * @param radians the angle in radians
  74610. */
  74611. constructor(radians: number);
  74612. /**
  74613. * Get value in degrees
  74614. * @returns the Angle value in degrees (float)
  74615. */
  74616. degrees(): number;
  74617. /**
  74618. * Get value in radians
  74619. * @returns the Angle value in radians (float)
  74620. */
  74621. radians(): number;
  74622. /**
  74623. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  74624. * @param a defines first vector
  74625. * @param b defines second vector
  74626. * @returns a new Angle
  74627. */
  74628. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  74629. /**
  74630. * Gets a new Angle object from the given float in radians
  74631. * @param radians defines the angle value in radians
  74632. * @returns a new Angle
  74633. */
  74634. static FromRadians(radians: number): Angle;
  74635. /**
  74636. * Gets a new Angle object from the given float in degrees
  74637. * @param degrees defines the angle value in degrees
  74638. * @returns a new Angle
  74639. */
  74640. static FromDegrees(degrees: number): Angle;
  74641. }
  74642. /**
  74643. * This represents an arc in a 2d space.
  74644. */
  74645. export class Arc2 {
  74646. /** Defines the start point of the arc */
  74647. startPoint: Vector2;
  74648. /** Defines the mid point of the arc */
  74649. midPoint: Vector2;
  74650. /** Defines the end point of the arc */
  74651. endPoint: Vector2;
  74652. /**
  74653. * Defines the center point of the arc.
  74654. */
  74655. centerPoint: Vector2;
  74656. /**
  74657. * Defines the radius of the arc.
  74658. */
  74659. radius: number;
  74660. /**
  74661. * Defines the angle of the arc (from mid point to end point).
  74662. */
  74663. angle: Angle;
  74664. /**
  74665. * Defines the start angle of the arc (from start point to middle point).
  74666. */
  74667. startAngle: Angle;
  74668. /**
  74669. * Defines the orientation of the arc (clock wise/counter clock wise).
  74670. */
  74671. orientation: Orientation;
  74672. /**
  74673. * Creates an Arc object from the three given points : start, middle and end.
  74674. * @param startPoint Defines the start point of the arc
  74675. * @param midPoint Defines the midlle point of the arc
  74676. * @param endPoint Defines the end point of the arc
  74677. */
  74678. constructor(
  74679. /** Defines the start point of the arc */
  74680. startPoint: Vector2,
  74681. /** Defines the mid point of the arc */
  74682. midPoint: Vector2,
  74683. /** Defines the end point of the arc */
  74684. endPoint: Vector2);
  74685. }
  74686. /**
  74687. * Represents a 2D path made up of multiple 2D points
  74688. */
  74689. export class Path2 {
  74690. private _points;
  74691. private _length;
  74692. /**
  74693. * If the path start and end point are the same
  74694. */
  74695. closed: boolean;
  74696. /**
  74697. * Creates a Path2 object from the starting 2D coordinates x and y.
  74698. * @param x the starting points x value
  74699. * @param y the starting points y value
  74700. */
  74701. constructor(x: number, y: number);
  74702. /**
  74703. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  74704. * @param x the added points x value
  74705. * @param y the added points y value
  74706. * @returns the updated Path2.
  74707. */
  74708. addLineTo(x: number, y: number): Path2;
  74709. /**
  74710. * 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.
  74711. * @param midX middle point x value
  74712. * @param midY middle point y value
  74713. * @param endX end point x value
  74714. * @param endY end point y value
  74715. * @param numberOfSegments (default: 36)
  74716. * @returns the updated Path2.
  74717. */
  74718. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  74719. /**
  74720. * Closes the Path2.
  74721. * @returns the Path2.
  74722. */
  74723. close(): Path2;
  74724. /**
  74725. * Gets the sum of the distance between each sequential point in the path
  74726. * @returns the Path2 total length (float).
  74727. */
  74728. length(): number;
  74729. /**
  74730. * Gets the points which construct the path
  74731. * @returns the Path2 internal array of points.
  74732. */
  74733. getPoints(): Vector2[];
  74734. /**
  74735. * Retreives the point at the distance aways from the starting point
  74736. * @param normalizedLengthPosition the length along the path to retreive the point from
  74737. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74738. */
  74739. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  74740. /**
  74741. * Creates a new path starting from an x and y position
  74742. * @param x starting x value
  74743. * @param y starting y value
  74744. * @returns a new Path2 starting at the coordinates (x, y).
  74745. */
  74746. static StartingAt(x: number, y: number): Path2;
  74747. }
  74748. /**
  74749. * Represents a 3D path made up of multiple 3D points
  74750. */
  74751. export class Path3D {
  74752. /**
  74753. * an array of Vector3, the curve axis of the Path3D
  74754. */
  74755. path: Vector3[];
  74756. private _curve;
  74757. private _distances;
  74758. private _tangents;
  74759. private _normals;
  74760. private _binormals;
  74761. private _raw;
  74762. private _alignTangentsWithPath;
  74763. private readonly _pointAtData;
  74764. /**
  74765. * new Path3D(path, normal, raw)
  74766. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74767. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74768. * @param path an array of Vector3, the curve axis of the Path3D
  74769. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74770. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74771. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  74772. */
  74773. constructor(
  74774. /**
  74775. * an array of Vector3, the curve axis of the Path3D
  74776. */
  74777. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  74778. /**
  74779. * Returns the Path3D array of successive Vector3 designing its curve.
  74780. * @returns the Path3D array of successive Vector3 designing its curve.
  74781. */
  74782. getCurve(): Vector3[];
  74783. /**
  74784. * Returns the Path3D array of successive Vector3 designing its curve.
  74785. * @returns the Path3D array of successive Vector3 designing its curve.
  74786. */
  74787. getPoints(): Vector3[];
  74788. /**
  74789. * @returns the computed length (float) of the path.
  74790. */
  74791. length(): number;
  74792. /**
  74793. * Returns an array populated with tangent vectors on each Path3D curve point.
  74794. * @returns an array populated with tangent vectors on each Path3D curve point.
  74795. */
  74796. getTangents(): Vector3[];
  74797. /**
  74798. * Returns an array populated with normal vectors on each Path3D curve point.
  74799. * @returns an array populated with normal vectors on each Path3D curve point.
  74800. */
  74801. getNormals(): Vector3[];
  74802. /**
  74803. * Returns an array populated with binormal vectors on each Path3D curve point.
  74804. * @returns an array populated with binormal vectors on each Path3D curve point.
  74805. */
  74806. getBinormals(): Vector3[];
  74807. /**
  74808. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74809. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74810. */
  74811. getDistances(): number[];
  74812. /**
  74813. * Returns an interpolated point along this path
  74814. * @param position the position of the point along this path, from 0.0 to 1.0
  74815. * @returns a new Vector3 as the point
  74816. */
  74817. getPointAt(position: number): Vector3;
  74818. /**
  74819. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74820. * @param position the position of the point along this path, from 0.0 to 1.0
  74821. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  74822. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  74823. */
  74824. getTangentAt(position: number, interpolated?: boolean): Vector3;
  74825. /**
  74826. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74827. * @param position the position of the point along this path, from 0.0 to 1.0
  74828. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  74829. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  74830. */
  74831. getNormalAt(position: number, interpolated?: boolean): Vector3;
  74832. /**
  74833. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  74834. * @param position the position of the point along this path, from 0.0 to 1.0
  74835. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  74836. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  74837. */
  74838. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  74839. /**
  74840. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  74841. * @param position the position of the point along this path, from 0.0 to 1.0
  74842. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  74843. */
  74844. getDistanceAt(position: number): number;
  74845. /**
  74846. * Returns the array index of the previous point of an interpolated point along this path
  74847. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74848. * @returns the array index
  74849. */
  74850. getPreviousPointIndexAt(position: number): number;
  74851. /**
  74852. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  74853. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74854. * @returns the sub position
  74855. */
  74856. getSubPositionAt(position: number): number;
  74857. /**
  74858. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  74859. * @param target the vector of which to get the closest position to
  74860. * @returns the position of the closest virtual point on this path to the target vector
  74861. */
  74862. getClosestPositionTo(target: Vector3): number;
  74863. /**
  74864. * Returns a sub path (slice) of this path
  74865. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74866. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74867. * @returns a sub path (slice) of this path
  74868. */
  74869. slice(start?: number, end?: number): Path3D;
  74870. /**
  74871. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74872. * @param path path which all values are copied into the curves points
  74873. * @param firstNormal which should be projected onto the curve
  74874. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  74875. * @returns the same object updated.
  74876. */
  74877. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  74878. private _compute;
  74879. private _getFirstNonNullVector;
  74880. private _getLastNonNullVector;
  74881. private _normalVector;
  74882. /**
  74883. * Updates the point at data for an interpolated point along this curve
  74884. * @param position the position of the point along this curve, from 0.0 to 1.0
  74885. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  74886. * @returns the (updated) point at data
  74887. */
  74888. private _updatePointAtData;
  74889. /**
  74890. * Updates the point at data from the specified parameters
  74891. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  74892. * @param point the interpolated point
  74893. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  74894. */
  74895. private _setPointAtData;
  74896. /**
  74897. * Updates the point at interpolation matrix for the tangents, normals and binormals
  74898. */
  74899. private _updateInterpolationMatrix;
  74900. }
  74901. /**
  74902. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74903. * A Curve3 is designed from a series of successive Vector3.
  74904. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74905. */
  74906. export class Curve3 {
  74907. private _points;
  74908. private _length;
  74909. /**
  74910. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74911. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74912. * @param v1 (Vector3) the control point
  74913. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74914. * @param nbPoints (integer) the wanted number of points in the curve
  74915. * @returns the created Curve3
  74916. */
  74917. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74918. /**
  74919. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74920. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74921. * @param v1 (Vector3) the first control point
  74922. * @param v2 (Vector3) the second control point
  74923. * @param v3 (Vector3) the end point of the Cubic Bezier
  74924. * @param nbPoints (integer) the wanted number of points in the curve
  74925. * @returns the created Curve3
  74926. */
  74927. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74928. /**
  74929. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74930. * @param p1 (Vector3) the origin point of the Hermite Spline
  74931. * @param t1 (Vector3) the tangent vector at the origin point
  74932. * @param p2 (Vector3) the end point of the Hermite Spline
  74933. * @param t2 (Vector3) the tangent vector at the end point
  74934. * @param nbPoints (integer) the wanted number of points in the curve
  74935. * @returns the created Curve3
  74936. */
  74937. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74938. /**
  74939. * Returns a Curve3 object along a CatmullRom Spline curve :
  74940. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74941. * @param nbPoints (integer) the wanted number of points between each curve control points
  74942. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74943. * @returns the created Curve3
  74944. */
  74945. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  74946. /**
  74947. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74948. * A Curve3 is designed from a series of successive Vector3.
  74949. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74950. * @param points points which make up the curve
  74951. */
  74952. constructor(points: Vector3[]);
  74953. /**
  74954. * @returns the Curve3 stored array of successive Vector3
  74955. */
  74956. getPoints(): Vector3[];
  74957. /**
  74958. * @returns the computed length (float) of the curve.
  74959. */
  74960. length(): number;
  74961. /**
  74962. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74963. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74964. * curveA and curveB keep unchanged.
  74965. * @param curve the curve to continue from this curve
  74966. * @returns the newly constructed curve
  74967. */
  74968. continue(curve: DeepImmutable<Curve3>): Curve3;
  74969. private _computeLength;
  74970. }
  74971. }
  74972. declare module BABYLON {
  74973. /**
  74974. * This represents the main contract an easing function should follow.
  74975. * Easing functions are used throughout the animation system.
  74976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74977. */
  74978. export interface IEasingFunction {
  74979. /**
  74980. * Given an input gradient between 0 and 1, this returns the corrseponding value
  74981. * of the easing function.
  74982. * The link below provides some of the most common examples of easing functions.
  74983. * @see https://easings.net/
  74984. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74985. * @returns the corresponding value on the curve defined by the easing function
  74986. */
  74987. ease(gradient: number): number;
  74988. }
  74989. /**
  74990. * Base class used for every default easing function.
  74991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74992. */
  74993. export class EasingFunction implements IEasingFunction {
  74994. /**
  74995. * Interpolation follows the mathematical formula associated with the easing function.
  74996. */
  74997. static readonly EASINGMODE_EASEIN: number;
  74998. /**
  74999. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75000. */
  75001. static readonly EASINGMODE_EASEOUT: number;
  75002. /**
  75003. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75004. */
  75005. static readonly EASINGMODE_EASEINOUT: number;
  75006. private _easingMode;
  75007. /**
  75008. * Sets the easing mode of the current function.
  75009. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75010. */
  75011. setEasingMode(easingMode: number): void;
  75012. /**
  75013. * Gets the current easing mode.
  75014. * @returns the easing mode
  75015. */
  75016. getEasingMode(): number;
  75017. /**
  75018. * @hidden
  75019. */
  75020. easeInCore(gradient: number): number;
  75021. /**
  75022. * Given an input gradient between 0 and 1, this returns the corresponding value
  75023. * of the easing function.
  75024. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75025. * @returns the corresponding value on the curve defined by the easing function
  75026. */
  75027. ease(gradient: number): number;
  75028. }
  75029. /**
  75030. * Easing function with a circle shape (see link below).
  75031. * @see https://easings.net/#easeInCirc
  75032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75033. */
  75034. export class CircleEase extends EasingFunction implements IEasingFunction {
  75035. /** @hidden */
  75036. easeInCore(gradient: number): number;
  75037. }
  75038. /**
  75039. * Easing function with a ease back shape (see link below).
  75040. * @see https://easings.net/#easeInBack
  75041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75042. */
  75043. export class BackEase extends EasingFunction implements IEasingFunction {
  75044. /** Defines the amplitude of the function */
  75045. amplitude: number;
  75046. /**
  75047. * Instantiates a back ease easing
  75048. * @see https://easings.net/#easeInBack
  75049. * @param amplitude Defines the amplitude of the function
  75050. */
  75051. constructor(
  75052. /** Defines the amplitude of the function */
  75053. amplitude?: number);
  75054. /** @hidden */
  75055. easeInCore(gradient: number): number;
  75056. }
  75057. /**
  75058. * Easing function with a bouncing shape (see link below).
  75059. * @see https://easings.net/#easeInBounce
  75060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75061. */
  75062. export class BounceEase extends EasingFunction implements IEasingFunction {
  75063. /** Defines the number of bounces */
  75064. bounces: number;
  75065. /** Defines the amplitude of the bounce */
  75066. bounciness: number;
  75067. /**
  75068. * Instantiates a bounce easing
  75069. * @see https://easings.net/#easeInBounce
  75070. * @param bounces Defines the number of bounces
  75071. * @param bounciness Defines the amplitude of the bounce
  75072. */
  75073. constructor(
  75074. /** Defines the number of bounces */
  75075. bounces?: number,
  75076. /** Defines the amplitude of the bounce */
  75077. bounciness?: number);
  75078. /** @hidden */
  75079. easeInCore(gradient: number): number;
  75080. }
  75081. /**
  75082. * Easing function with a power of 3 shape (see link below).
  75083. * @see https://easings.net/#easeInCubic
  75084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75085. */
  75086. export class CubicEase extends EasingFunction implements IEasingFunction {
  75087. /** @hidden */
  75088. easeInCore(gradient: number): number;
  75089. }
  75090. /**
  75091. * Easing function with an elastic shape (see link below).
  75092. * @see https://easings.net/#easeInElastic
  75093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75094. */
  75095. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75096. /** Defines the number of oscillations*/
  75097. oscillations: number;
  75098. /** Defines the amplitude of the oscillations*/
  75099. springiness: number;
  75100. /**
  75101. * Instantiates an elastic easing function
  75102. * @see https://easings.net/#easeInElastic
  75103. * @param oscillations Defines the number of oscillations
  75104. * @param springiness Defines the amplitude of the oscillations
  75105. */
  75106. constructor(
  75107. /** Defines the number of oscillations*/
  75108. oscillations?: number,
  75109. /** Defines the amplitude of the oscillations*/
  75110. springiness?: number);
  75111. /** @hidden */
  75112. easeInCore(gradient: number): number;
  75113. }
  75114. /**
  75115. * Easing function with an exponential shape (see link below).
  75116. * @see https://easings.net/#easeInExpo
  75117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75118. */
  75119. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75120. /** Defines the exponent of the function */
  75121. exponent: number;
  75122. /**
  75123. * Instantiates an exponential easing function
  75124. * @see https://easings.net/#easeInExpo
  75125. * @param exponent Defines the exponent of the function
  75126. */
  75127. constructor(
  75128. /** Defines the exponent of the function */
  75129. exponent?: number);
  75130. /** @hidden */
  75131. easeInCore(gradient: number): number;
  75132. }
  75133. /**
  75134. * Easing function with a power shape (see link below).
  75135. * @see https://easings.net/#easeInQuad
  75136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75137. */
  75138. export class PowerEase extends EasingFunction implements IEasingFunction {
  75139. /** Defines the power of the function */
  75140. power: number;
  75141. /**
  75142. * Instantiates an power base easing function
  75143. * @see https://easings.net/#easeInQuad
  75144. * @param power Defines the power of the function
  75145. */
  75146. constructor(
  75147. /** Defines the power of the function */
  75148. power?: number);
  75149. /** @hidden */
  75150. easeInCore(gradient: number): number;
  75151. }
  75152. /**
  75153. * Easing function with a power of 2 shape (see link below).
  75154. * @see https://easings.net/#easeInQuad
  75155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75156. */
  75157. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75158. /** @hidden */
  75159. easeInCore(gradient: number): number;
  75160. }
  75161. /**
  75162. * Easing function with a power of 4 shape (see link below).
  75163. * @see https://easings.net/#easeInQuart
  75164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75165. */
  75166. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75167. /** @hidden */
  75168. easeInCore(gradient: number): number;
  75169. }
  75170. /**
  75171. * Easing function with a power of 5 shape (see link below).
  75172. * @see https://easings.net/#easeInQuint
  75173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75174. */
  75175. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75176. /** @hidden */
  75177. easeInCore(gradient: number): number;
  75178. }
  75179. /**
  75180. * Easing function with a sin shape (see link below).
  75181. * @see https://easings.net/#easeInSine
  75182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75183. */
  75184. export class SineEase extends EasingFunction implements IEasingFunction {
  75185. /** @hidden */
  75186. easeInCore(gradient: number): number;
  75187. }
  75188. /**
  75189. * Easing function with a bezier shape (see link below).
  75190. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75192. */
  75193. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75194. /** Defines the x component of the start tangent in the bezier curve */
  75195. x1: number;
  75196. /** Defines the y component of the start tangent in the bezier curve */
  75197. y1: number;
  75198. /** Defines the x component of the end tangent in the bezier curve */
  75199. x2: number;
  75200. /** Defines the y component of the end tangent in the bezier curve */
  75201. y2: number;
  75202. /**
  75203. * Instantiates a bezier function
  75204. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75205. * @param x1 Defines the x component of the start tangent in the bezier curve
  75206. * @param y1 Defines the y component of the start tangent in the bezier curve
  75207. * @param x2 Defines the x component of the end tangent in the bezier curve
  75208. * @param y2 Defines the y component of the end tangent in the bezier curve
  75209. */
  75210. constructor(
  75211. /** Defines the x component of the start tangent in the bezier curve */
  75212. x1?: number,
  75213. /** Defines the y component of the start tangent in the bezier curve */
  75214. y1?: number,
  75215. /** Defines the x component of the end tangent in the bezier curve */
  75216. x2?: number,
  75217. /** Defines the y component of the end tangent in the bezier curve */
  75218. y2?: number);
  75219. /** @hidden */
  75220. easeInCore(gradient: number): number;
  75221. }
  75222. }
  75223. declare module BABYLON {
  75224. /**
  75225. * Class used to hold a RBG color
  75226. */
  75227. export class Color3 {
  75228. /**
  75229. * Defines the red component (between 0 and 1, default is 0)
  75230. */
  75231. r: number;
  75232. /**
  75233. * Defines the green component (between 0 and 1, default is 0)
  75234. */
  75235. g: number;
  75236. /**
  75237. * Defines the blue component (between 0 and 1, default is 0)
  75238. */
  75239. b: number;
  75240. /**
  75241. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75242. * @param r defines the red component (between 0 and 1, default is 0)
  75243. * @param g defines the green component (between 0 and 1, default is 0)
  75244. * @param b defines the blue component (between 0 and 1, default is 0)
  75245. */
  75246. constructor(
  75247. /**
  75248. * Defines the red component (between 0 and 1, default is 0)
  75249. */
  75250. r?: number,
  75251. /**
  75252. * Defines the green component (between 0 and 1, default is 0)
  75253. */
  75254. g?: number,
  75255. /**
  75256. * Defines the blue component (between 0 and 1, default is 0)
  75257. */
  75258. b?: number);
  75259. /**
  75260. * Creates a string with the Color3 current values
  75261. * @returns the string representation of the Color3 object
  75262. */
  75263. toString(): string;
  75264. /**
  75265. * Returns the string "Color3"
  75266. * @returns "Color3"
  75267. */
  75268. getClassName(): string;
  75269. /**
  75270. * Compute the Color3 hash code
  75271. * @returns an unique number that can be used to hash Color3 objects
  75272. */
  75273. getHashCode(): number;
  75274. /**
  75275. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75276. * @param array defines the array where to store the r,g,b components
  75277. * @param index defines an optional index in the target array to define where to start storing values
  75278. * @returns the current Color3 object
  75279. */
  75280. toArray(array: FloatArray, index?: number): Color3;
  75281. /**
  75282. * Returns a new Color4 object from the current Color3 and the given alpha
  75283. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75284. * @returns a new Color4 object
  75285. */
  75286. toColor4(alpha?: number): Color4;
  75287. /**
  75288. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75289. * @returns the new array
  75290. */
  75291. asArray(): number[];
  75292. /**
  75293. * Returns the luminance value
  75294. * @returns a float value
  75295. */
  75296. toLuminance(): number;
  75297. /**
  75298. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75299. * @param otherColor defines the second operand
  75300. * @returns the new Color3 object
  75301. */
  75302. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75303. /**
  75304. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75305. * @param otherColor defines the second operand
  75306. * @param result defines the Color3 object where to store the result
  75307. * @returns the current Color3
  75308. */
  75309. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75310. /**
  75311. * Determines equality between Color3 objects
  75312. * @param otherColor defines the second operand
  75313. * @returns true if the rgb values are equal to the given ones
  75314. */
  75315. equals(otherColor: DeepImmutable<Color3>): boolean;
  75316. /**
  75317. * Determines equality between the current Color3 object and a set of r,b,g values
  75318. * @param r defines the red component to check
  75319. * @param g defines the green component to check
  75320. * @param b defines the blue component to check
  75321. * @returns true if the rgb values are equal to the given ones
  75322. */
  75323. equalsFloats(r: number, g: number, b: number): boolean;
  75324. /**
  75325. * Multiplies in place each rgb value by scale
  75326. * @param scale defines the scaling factor
  75327. * @returns the updated Color3
  75328. */
  75329. scale(scale: number): Color3;
  75330. /**
  75331. * Multiplies the rgb values by scale and stores the result into "result"
  75332. * @param scale defines the scaling factor
  75333. * @param result defines the Color3 object where to store the result
  75334. * @returns the unmodified current Color3
  75335. */
  75336. scaleToRef(scale: number, result: Color3): Color3;
  75337. /**
  75338. * Scale the current Color3 values by a factor and add the result to a given Color3
  75339. * @param scale defines the scale factor
  75340. * @param result defines color to store the result into
  75341. * @returns the unmodified current Color3
  75342. */
  75343. scaleAndAddToRef(scale: number, result: Color3): Color3;
  75344. /**
  75345. * Clamps the rgb values by the min and max values and stores the result into "result"
  75346. * @param min defines minimum clamping value (default is 0)
  75347. * @param max defines maximum clamping value (default is 1)
  75348. * @param result defines color to store the result into
  75349. * @returns the original Color3
  75350. */
  75351. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  75352. /**
  75353. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  75354. * @param otherColor defines the second operand
  75355. * @returns the new Color3
  75356. */
  75357. add(otherColor: DeepImmutable<Color3>): Color3;
  75358. /**
  75359. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  75360. * @param otherColor defines the second operand
  75361. * @param result defines Color3 object to store the result into
  75362. * @returns the unmodified current Color3
  75363. */
  75364. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75365. /**
  75366. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  75367. * @param otherColor defines the second operand
  75368. * @returns the new Color3
  75369. */
  75370. subtract(otherColor: DeepImmutable<Color3>): Color3;
  75371. /**
  75372. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  75373. * @param otherColor defines the second operand
  75374. * @param result defines Color3 object to store the result into
  75375. * @returns the unmodified current Color3
  75376. */
  75377. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75378. /**
  75379. * Copy the current object
  75380. * @returns a new Color3 copied the current one
  75381. */
  75382. clone(): Color3;
  75383. /**
  75384. * Copies the rgb values from the source in the current Color3
  75385. * @param source defines the source Color3 object
  75386. * @returns the updated Color3 object
  75387. */
  75388. copyFrom(source: DeepImmutable<Color3>): Color3;
  75389. /**
  75390. * Updates the Color3 rgb values from the given floats
  75391. * @param r defines the red component to read from
  75392. * @param g defines the green component to read from
  75393. * @param b defines the blue component to read from
  75394. * @returns the current Color3 object
  75395. */
  75396. copyFromFloats(r: number, g: number, b: number): Color3;
  75397. /**
  75398. * Updates the Color3 rgb values from the given floats
  75399. * @param r defines the red component to read from
  75400. * @param g defines the green component to read from
  75401. * @param b defines the blue component to read from
  75402. * @returns the current Color3 object
  75403. */
  75404. set(r: number, g: number, b: number): Color3;
  75405. /**
  75406. * Compute the Color3 hexadecimal code as a string
  75407. * @returns a string containing the hexadecimal representation of the Color3 object
  75408. */
  75409. toHexString(): string;
  75410. /**
  75411. * Computes a new Color3 converted from the current one to linear space
  75412. * @returns a new Color3 object
  75413. */
  75414. toLinearSpace(): Color3;
  75415. /**
  75416. * Converts current color in rgb space to HSV values
  75417. * @returns a new color3 representing the HSV values
  75418. */
  75419. toHSV(): Color3;
  75420. /**
  75421. * Converts current color in rgb space to HSV values
  75422. * @param result defines the Color3 where to store the HSV values
  75423. */
  75424. toHSVToRef(result: Color3): void;
  75425. /**
  75426. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  75427. * @param convertedColor defines the Color3 object where to store the linear space version
  75428. * @returns the unmodified Color3
  75429. */
  75430. toLinearSpaceToRef(convertedColor: Color3): Color3;
  75431. /**
  75432. * Computes a new Color3 converted from the current one to gamma space
  75433. * @returns a new Color3 object
  75434. */
  75435. toGammaSpace(): Color3;
  75436. /**
  75437. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  75438. * @param convertedColor defines the Color3 object where to store the gamma space version
  75439. * @returns the unmodified Color3
  75440. */
  75441. toGammaSpaceToRef(convertedColor: Color3): Color3;
  75442. private static _BlackReadOnly;
  75443. /**
  75444. * Convert Hue, saturation and value to a Color3 (RGB)
  75445. * @param hue defines the hue
  75446. * @param saturation defines the saturation
  75447. * @param value defines the value
  75448. * @param result defines the Color3 where to store the RGB values
  75449. */
  75450. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  75451. /**
  75452. * Creates a new Color3 from the string containing valid hexadecimal values
  75453. * @param hex defines a string containing valid hexadecimal values
  75454. * @returns a new Color3 object
  75455. */
  75456. static FromHexString(hex: string): Color3;
  75457. /**
  75458. * Creates a new Color3 from the starting index of the given array
  75459. * @param array defines the source array
  75460. * @param offset defines an offset in the source array
  75461. * @returns a new Color3 object
  75462. */
  75463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  75464. /**
  75465. * Creates a new Color3 from integer values (< 256)
  75466. * @param r defines the red component to read from (value between 0 and 255)
  75467. * @param g defines the green component to read from (value between 0 and 255)
  75468. * @param b defines the blue component to read from (value between 0 and 255)
  75469. * @returns a new Color3 object
  75470. */
  75471. static FromInts(r: number, g: number, b: number): Color3;
  75472. /**
  75473. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  75474. * @param start defines the start Color3 value
  75475. * @param end defines the end Color3 value
  75476. * @param amount defines the gradient value between start and end
  75477. * @returns a new Color3 object
  75478. */
  75479. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  75480. /**
  75481. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  75482. * @param left defines the start value
  75483. * @param right defines the end value
  75484. * @param amount defines the gradient factor
  75485. * @param result defines the Color3 object where to store the result
  75486. */
  75487. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  75488. /**
  75489. * Returns a Color3 value containing a red color
  75490. * @returns a new Color3 object
  75491. */
  75492. static Red(): Color3;
  75493. /**
  75494. * Returns a Color3 value containing a green color
  75495. * @returns a new Color3 object
  75496. */
  75497. static Green(): Color3;
  75498. /**
  75499. * Returns a Color3 value containing a blue color
  75500. * @returns a new Color3 object
  75501. */
  75502. static Blue(): Color3;
  75503. /**
  75504. * Returns a Color3 value containing a black color
  75505. * @returns a new Color3 object
  75506. */
  75507. static Black(): Color3;
  75508. /**
  75509. * Gets a Color3 value containing a black color that must not be updated
  75510. */
  75511. static readonly BlackReadOnly: DeepImmutable<Color3>;
  75512. /**
  75513. * Returns a Color3 value containing a white color
  75514. * @returns a new Color3 object
  75515. */
  75516. static White(): Color3;
  75517. /**
  75518. * Returns a Color3 value containing a purple color
  75519. * @returns a new Color3 object
  75520. */
  75521. static Purple(): Color3;
  75522. /**
  75523. * Returns a Color3 value containing a magenta color
  75524. * @returns a new Color3 object
  75525. */
  75526. static Magenta(): Color3;
  75527. /**
  75528. * Returns a Color3 value containing a yellow color
  75529. * @returns a new Color3 object
  75530. */
  75531. static Yellow(): Color3;
  75532. /**
  75533. * Returns a Color3 value containing a gray color
  75534. * @returns a new Color3 object
  75535. */
  75536. static Gray(): Color3;
  75537. /**
  75538. * Returns a Color3 value containing a teal color
  75539. * @returns a new Color3 object
  75540. */
  75541. static Teal(): Color3;
  75542. /**
  75543. * Returns a Color3 value containing a random color
  75544. * @returns a new Color3 object
  75545. */
  75546. static Random(): Color3;
  75547. }
  75548. /**
  75549. * Class used to hold a RBGA color
  75550. */
  75551. export class Color4 {
  75552. /**
  75553. * Defines the red component (between 0 and 1, default is 0)
  75554. */
  75555. r: number;
  75556. /**
  75557. * Defines the green component (between 0 and 1, default is 0)
  75558. */
  75559. g: number;
  75560. /**
  75561. * Defines the blue component (between 0 and 1, default is 0)
  75562. */
  75563. b: number;
  75564. /**
  75565. * Defines the alpha component (between 0 and 1, default is 1)
  75566. */
  75567. a: number;
  75568. /**
  75569. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  75570. * @param r defines the red component (between 0 and 1, default is 0)
  75571. * @param g defines the green component (between 0 and 1, default is 0)
  75572. * @param b defines the blue component (between 0 and 1, default is 0)
  75573. * @param a defines the alpha component (between 0 and 1, default is 1)
  75574. */
  75575. constructor(
  75576. /**
  75577. * Defines the red component (between 0 and 1, default is 0)
  75578. */
  75579. r?: number,
  75580. /**
  75581. * Defines the green component (between 0 and 1, default is 0)
  75582. */
  75583. g?: number,
  75584. /**
  75585. * Defines the blue component (between 0 and 1, default is 0)
  75586. */
  75587. b?: number,
  75588. /**
  75589. * Defines the alpha component (between 0 and 1, default is 1)
  75590. */
  75591. a?: number);
  75592. /**
  75593. * Adds in place the given Color4 values to the current Color4 object
  75594. * @param right defines the second operand
  75595. * @returns the current updated Color4 object
  75596. */
  75597. addInPlace(right: DeepImmutable<Color4>): Color4;
  75598. /**
  75599. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  75600. * @returns the new array
  75601. */
  75602. asArray(): number[];
  75603. /**
  75604. * Stores from the starting index in the given array the Color4 successive values
  75605. * @param array defines the array where to store the r,g,b components
  75606. * @param index defines an optional index in the target array to define where to start storing values
  75607. * @returns the current Color4 object
  75608. */
  75609. toArray(array: number[], index?: number): Color4;
  75610. /**
  75611. * Determines equality between Color4 objects
  75612. * @param otherColor defines the second operand
  75613. * @returns true if the rgba values are equal to the given ones
  75614. */
  75615. equals(otherColor: DeepImmutable<Color4>): boolean;
  75616. /**
  75617. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  75618. * @param right defines the second operand
  75619. * @returns a new Color4 object
  75620. */
  75621. add(right: DeepImmutable<Color4>): Color4;
  75622. /**
  75623. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  75624. * @param right defines the second operand
  75625. * @returns a new Color4 object
  75626. */
  75627. subtract(right: DeepImmutable<Color4>): Color4;
  75628. /**
  75629. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  75630. * @param right defines the second operand
  75631. * @param result defines the Color4 object where to store the result
  75632. * @returns the current Color4 object
  75633. */
  75634. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  75635. /**
  75636. * Creates a new Color4 with the current Color4 values multiplied by scale
  75637. * @param scale defines the scaling factor to apply
  75638. * @returns a new Color4 object
  75639. */
  75640. scale(scale: number): Color4;
  75641. /**
  75642. * Multiplies the current Color4 values by scale and stores the result in "result"
  75643. * @param scale defines the scaling factor to apply
  75644. * @param result defines the Color4 object where to store the result
  75645. * @returns the current unmodified Color4
  75646. */
  75647. scaleToRef(scale: number, result: Color4): Color4;
  75648. /**
  75649. * Scale the current Color4 values by a factor and add the result to a given Color4
  75650. * @param scale defines the scale factor
  75651. * @param result defines the Color4 object where to store the result
  75652. * @returns the unmodified current Color4
  75653. */
  75654. scaleAndAddToRef(scale: number, result: Color4): Color4;
  75655. /**
  75656. * Clamps the rgb values by the min and max values and stores the result into "result"
  75657. * @param min defines minimum clamping value (default is 0)
  75658. * @param max defines maximum clamping value (default is 1)
  75659. * @param result defines color to store the result into.
  75660. * @returns the cuurent Color4
  75661. */
  75662. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  75663. /**
  75664. * Multipy an Color4 value by another and return a new Color4 object
  75665. * @param color defines the Color4 value to multiply by
  75666. * @returns a new Color4 object
  75667. */
  75668. multiply(color: Color4): Color4;
  75669. /**
  75670. * Multipy a Color4 value by another and push the result in a reference value
  75671. * @param color defines the Color4 value to multiply by
  75672. * @param result defines the Color4 to fill the result in
  75673. * @returns the result Color4
  75674. */
  75675. multiplyToRef(color: Color4, result: Color4): Color4;
  75676. /**
  75677. * Creates a string with the Color4 current values
  75678. * @returns the string representation of the Color4 object
  75679. */
  75680. toString(): string;
  75681. /**
  75682. * Returns the string "Color4"
  75683. * @returns "Color4"
  75684. */
  75685. getClassName(): string;
  75686. /**
  75687. * Compute the Color4 hash code
  75688. * @returns an unique number that can be used to hash Color4 objects
  75689. */
  75690. getHashCode(): number;
  75691. /**
  75692. * Creates a new Color4 copied from the current one
  75693. * @returns a new Color4 object
  75694. */
  75695. clone(): Color4;
  75696. /**
  75697. * Copies the given Color4 values into the current one
  75698. * @param source defines the source Color4 object
  75699. * @returns the current updated Color4 object
  75700. */
  75701. copyFrom(source: Color4): Color4;
  75702. /**
  75703. * Copies the given float values into the current one
  75704. * @param r defines the red component to read from
  75705. * @param g defines the green component to read from
  75706. * @param b defines the blue component to read from
  75707. * @param a defines the alpha component to read from
  75708. * @returns the current updated Color4 object
  75709. */
  75710. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  75711. /**
  75712. * Copies the given float values into the current one
  75713. * @param r defines the red component to read from
  75714. * @param g defines the green component to read from
  75715. * @param b defines the blue component to read from
  75716. * @param a defines the alpha component to read from
  75717. * @returns the current updated Color4 object
  75718. */
  75719. set(r: number, g: number, b: number, a: number): Color4;
  75720. /**
  75721. * Compute the Color4 hexadecimal code as a string
  75722. * @returns a string containing the hexadecimal representation of the Color4 object
  75723. */
  75724. toHexString(): string;
  75725. /**
  75726. * Computes a new Color4 converted from the current one to linear space
  75727. * @returns a new Color4 object
  75728. */
  75729. toLinearSpace(): Color4;
  75730. /**
  75731. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  75732. * @param convertedColor defines the Color4 object where to store the linear space version
  75733. * @returns the unmodified Color4
  75734. */
  75735. toLinearSpaceToRef(convertedColor: Color4): Color4;
  75736. /**
  75737. * Computes a new Color4 converted from the current one to gamma space
  75738. * @returns a new Color4 object
  75739. */
  75740. toGammaSpace(): Color4;
  75741. /**
  75742. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  75743. * @param convertedColor defines the Color4 object where to store the gamma space version
  75744. * @returns the unmodified Color4
  75745. */
  75746. toGammaSpaceToRef(convertedColor: Color4): Color4;
  75747. /**
  75748. * Creates a new Color4 from the string containing valid hexadecimal values
  75749. * @param hex defines a string containing valid hexadecimal values
  75750. * @returns a new Color4 object
  75751. */
  75752. static FromHexString(hex: string): Color4;
  75753. /**
  75754. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75755. * @param left defines the start value
  75756. * @param right defines the end value
  75757. * @param amount defines the gradient factor
  75758. * @returns a new Color4 object
  75759. */
  75760. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  75761. /**
  75762. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75763. * @param left defines the start value
  75764. * @param right defines the end value
  75765. * @param amount defines the gradient factor
  75766. * @param result defines the Color4 object where to store data
  75767. */
  75768. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  75769. /**
  75770. * Creates a new Color4 from a Color3 and an alpha value
  75771. * @param color3 defines the source Color3 to read from
  75772. * @param alpha defines the alpha component (1.0 by default)
  75773. * @returns a new Color4 object
  75774. */
  75775. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  75776. /**
  75777. * Creates a new Color4 from the starting index element of the given array
  75778. * @param array defines the source array to read from
  75779. * @param offset defines the offset in the source array
  75780. * @returns a new Color4 object
  75781. */
  75782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  75783. /**
  75784. * Creates a new Color3 from integer values (< 256)
  75785. * @param r defines the red component to read from (value between 0 and 255)
  75786. * @param g defines the green component to read from (value between 0 and 255)
  75787. * @param b defines the blue component to read from (value between 0 and 255)
  75788. * @param a defines the alpha component to read from (value between 0 and 255)
  75789. * @returns a new Color3 object
  75790. */
  75791. static FromInts(r: number, g: number, b: number, a: number): Color4;
  75792. /**
  75793. * Check the content of a given array and convert it to an array containing RGBA data
  75794. * If the original array was already containing count * 4 values then it is returned directly
  75795. * @param colors defines the array to check
  75796. * @param count defines the number of RGBA data to expect
  75797. * @returns an array containing count * 4 values (RGBA)
  75798. */
  75799. static CheckColors4(colors: number[], count: number): number[];
  75800. }
  75801. /**
  75802. * @hidden
  75803. */
  75804. export class TmpColors {
  75805. static Color3: Color3[];
  75806. static Color4: Color4[];
  75807. }
  75808. }
  75809. declare module BABYLON {
  75810. /**
  75811. * Defines an interface which represents an animation key frame
  75812. */
  75813. export interface IAnimationKey {
  75814. /**
  75815. * Frame of the key frame
  75816. */
  75817. frame: number;
  75818. /**
  75819. * Value at the specifies key frame
  75820. */
  75821. value: any;
  75822. /**
  75823. * The input tangent for the cubic hermite spline
  75824. */
  75825. inTangent?: any;
  75826. /**
  75827. * The output tangent for the cubic hermite spline
  75828. */
  75829. outTangent?: any;
  75830. /**
  75831. * The animation interpolation type
  75832. */
  75833. interpolation?: AnimationKeyInterpolation;
  75834. }
  75835. /**
  75836. * Enum for the animation key frame interpolation type
  75837. */
  75838. export enum AnimationKeyInterpolation {
  75839. /**
  75840. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  75841. */
  75842. STEP = 1
  75843. }
  75844. }
  75845. declare module BABYLON {
  75846. /**
  75847. * Represents the range of an animation
  75848. */
  75849. export class AnimationRange {
  75850. /**The name of the animation range**/
  75851. name: string;
  75852. /**The starting frame of the animation */
  75853. from: number;
  75854. /**The ending frame of the animation*/
  75855. to: number;
  75856. /**
  75857. * Initializes the range of an animation
  75858. * @param name The name of the animation range
  75859. * @param from The starting frame of the animation
  75860. * @param to The ending frame of the animation
  75861. */
  75862. constructor(
  75863. /**The name of the animation range**/
  75864. name: string,
  75865. /**The starting frame of the animation */
  75866. from: number,
  75867. /**The ending frame of the animation*/
  75868. to: number);
  75869. /**
  75870. * Makes a copy of the animation range
  75871. * @returns A copy of the animation range
  75872. */
  75873. clone(): AnimationRange;
  75874. }
  75875. }
  75876. declare module BABYLON {
  75877. /**
  75878. * Composed of a frame, and an action function
  75879. */
  75880. export class AnimationEvent {
  75881. /** The frame for which the event is triggered **/
  75882. frame: number;
  75883. /** The event to perform when triggered **/
  75884. action: (currentFrame: number) => void;
  75885. /** Specifies if the event should be triggered only once**/
  75886. onlyOnce?: boolean | undefined;
  75887. /**
  75888. * Specifies if the animation event is done
  75889. */
  75890. isDone: boolean;
  75891. /**
  75892. * Initializes the animation event
  75893. * @param frame The frame for which the event is triggered
  75894. * @param action The event to perform when triggered
  75895. * @param onlyOnce Specifies if the event should be triggered only once
  75896. */
  75897. constructor(
  75898. /** The frame for which the event is triggered **/
  75899. frame: number,
  75900. /** The event to perform when triggered **/
  75901. action: (currentFrame: number) => void,
  75902. /** Specifies if the event should be triggered only once**/
  75903. onlyOnce?: boolean | undefined);
  75904. /** @hidden */
  75905. _clone(): AnimationEvent;
  75906. }
  75907. }
  75908. declare module BABYLON {
  75909. /**
  75910. * Interface used to define a behavior
  75911. */
  75912. export interface Behavior<T> {
  75913. /** gets or sets behavior's name */
  75914. name: string;
  75915. /**
  75916. * Function called when the behavior needs to be initialized (after attaching it to a target)
  75917. */
  75918. init(): void;
  75919. /**
  75920. * Called when the behavior is attached to a target
  75921. * @param target defines the target where the behavior is attached to
  75922. */
  75923. attach(target: T): void;
  75924. /**
  75925. * Called when the behavior is detached from its target
  75926. */
  75927. detach(): void;
  75928. }
  75929. /**
  75930. * Interface implemented by classes supporting behaviors
  75931. */
  75932. export interface IBehaviorAware<T> {
  75933. /**
  75934. * Attach a behavior
  75935. * @param behavior defines the behavior to attach
  75936. * @returns the current host
  75937. */
  75938. addBehavior(behavior: Behavior<T>): T;
  75939. /**
  75940. * Remove a behavior from the current object
  75941. * @param behavior defines the behavior to detach
  75942. * @returns the current host
  75943. */
  75944. removeBehavior(behavior: Behavior<T>): T;
  75945. /**
  75946. * Gets a behavior using its name to search
  75947. * @param name defines the name to search
  75948. * @returns the behavior or null if not found
  75949. */
  75950. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  75951. }
  75952. }
  75953. declare module BABYLON {
  75954. /**
  75955. * Defines an array and its length.
  75956. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  75957. */
  75958. export interface ISmartArrayLike<T> {
  75959. /**
  75960. * The data of the array.
  75961. */
  75962. data: Array<T>;
  75963. /**
  75964. * The active length of the array.
  75965. */
  75966. length: number;
  75967. }
  75968. /**
  75969. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75970. */
  75971. export class SmartArray<T> implements ISmartArrayLike<T> {
  75972. /**
  75973. * The full set of data from the array.
  75974. */
  75975. data: Array<T>;
  75976. /**
  75977. * The active length of the array.
  75978. */
  75979. length: number;
  75980. protected _id: number;
  75981. /**
  75982. * Instantiates a Smart Array.
  75983. * @param capacity defines the default capacity of the array.
  75984. */
  75985. constructor(capacity: number);
  75986. /**
  75987. * Pushes a value at the end of the active data.
  75988. * @param value defines the object to push in the array.
  75989. */
  75990. push(value: T): void;
  75991. /**
  75992. * Iterates over the active data and apply the lambda to them.
  75993. * @param func defines the action to apply on each value.
  75994. */
  75995. forEach(func: (content: T) => void): void;
  75996. /**
  75997. * Sorts the full sets of data.
  75998. * @param compareFn defines the comparison function to apply.
  75999. */
  76000. sort(compareFn: (a: T, b: T) => number): void;
  76001. /**
  76002. * Resets the active data to an empty array.
  76003. */
  76004. reset(): void;
  76005. /**
  76006. * Releases all the data from the array as well as the array.
  76007. */
  76008. dispose(): void;
  76009. /**
  76010. * Concats the active data with a given array.
  76011. * @param array defines the data to concatenate with.
  76012. */
  76013. concat(array: any): void;
  76014. /**
  76015. * Returns the position of a value in the active data.
  76016. * @param value defines the value to find the index for
  76017. * @returns the index if found in the active data otherwise -1
  76018. */
  76019. indexOf(value: T): number;
  76020. /**
  76021. * Returns whether an element is part of the active data.
  76022. * @param value defines the value to look for
  76023. * @returns true if found in the active data otherwise false
  76024. */
  76025. contains(value: T): boolean;
  76026. private static _GlobalId;
  76027. }
  76028. /**
  76029. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76030. * The data in this array can only be present once
  76031. */
  76032. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76033. private _duplicateId;
  76034. /**
  76035. * Pushes a value at the end of the active data.
  76036. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76037. * @param value defines the object to push in the array.
  76038. */
  76039. push(value: T): void;
  76040. /**
  76041. * Pushes a value at the end of the active data.
  76042. * If the data is already present, it won t be added again
  76043. * @param value defines the object to push in the array.
  76044. * @returns true if added false if it was already present
  76045. */
  76046. pushNoDuplicate(value: T): boolean;
  76047. /**
  76048. * Resets the active data to an empty array.
  76049. */
  76050. reset(): void;
  76051. /**
  76052. * Concats the active data with a given array.
  76053. * This ensures no dupplicate will be present in the result.
  76054. * @param array defines the data to concatenate with.
  76055. */
  76056. concatWithNoDuplicate(array: any): void;
  76057. }
  76058. }
  76059. declare module BABYLON {
  76060. /**
  76061. * @ignore
  76062. * This is a list of all the different input types that are available in the application.
  76063. * Fo instance: ArcRotateCameraGamepadInput...
  76064. */
  76065. export var CameraInputTypes: {};
  76066. /**
  76067. * This is the contract to implement in order to create a new input class.
  76068. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76069. */
  76070. export interface ICameraInput<TCamera extends Camera> {
  76071. /**
  76072. * Defines the camera the input is attached to.
  76073. */
  76074. camera: Nullable<TCamera>;
  76075. /**
  76076. * Gets the class name of the current intput.
  76077. * @returns the class name
  76078. */
  76079. getClassName(): string;
  76080. /**
  76081. * Get the friendly name associated with the input class.
  76082. * @returns the input friendly name
  76083. */
  76084. getSimpleName(): string;
  76085. /**
  76086. * Attach the input controls to a specific dom element to get the input from.
  76087. * @param element Defines the element the controls should be listened from
  76088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76089. */
  76090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76091. /**
  76092. * Detach the current controls from the specified dom element.
  76093. * @param element Defines the element to stop listening the inputs from
  76094. */
  76095. detachControl(element: Nullable<HTMLElement>): void;
  76096. /**
  76097. * Update the current camera state depending on the inputs that have been used this frame.
  76098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76099. */
  76100. checkInputs?: () => void;
  76101. }
  76102. /**
  76103. * Represents a map of input types to input instance or input index to input instance.
  76104. */
  76105. export interface CameraInputsMap<TCamera extends Camera> {
  76106. /**
  76107. * Accessor to the input by input type.
  76108. */
  76109. [name: string]: ICameraInput<TCamera>;
  76110. /**
  76111. * Accessor to the input by input index.
  76112. */
  76113. [idx: number]: ICameraInput<TCamera>;
  76114. }
  76115. /**
  76116. * This represents the input manager used within a camera.
  76117. * It helps dealing with all the different kind of input attached to a camera.
  76118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76119. */
  76120. export class CameraInputsManager<TCamera extends Camera> {
  76121. /**
  76122. * Defines the list of inputs attahed to the camera.
  76123. */
  76124. attached: CameraInputsMap<TCamera>;
  76125. /**
  76126. * Defines the dom element the camera is collecting inputs from.
  76127. * This is null if the controls have not been attached.
  76128. */
  76129. attachedElement: Nullable<HTMLElement>;
  76130. /**
  76131. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76132. */
  76133. noPreventDefault: boolean;
  76134. /**
  76135. * Defined the camera the input manager belongs to.
  76136. */
  76137. camera: TCamera;
  76138. /**
  76139. * Update the current camera state depending on the inputs that have been used this frame.
  76140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76141. */
  76142. checkInputs: () => void;
  76143. /**
  76144. * Instantiate a new Camera Input Manager.
  76145. * @param camera Defines the camera the input manager blongs to
  76146. */
  76147. constructor(camera: TCamera);
  76148. /**
  76149. * Add an input method to a camera
  76150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76151. * @param input camera input method
  76152. */
  76153. add(input: ICameraInput<TCamera>): void;
  76154. /**
  76155. * Remove a specific input method from a camera
  76156. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76157. * @param inputToRemove camera input method
  76158. */
  76159. remove(inputToRemove: ICameraInput<TCamera>): void;
  76160. /**
  76161. * Remove a specific input type from a camera
  76162. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76163. * @param inputType the type of the input to remove
  76164. */
  76165. removeByType(inputType: string): void;
  76166. private _addCheckInputs;
  76167. /**
  76168. * Attach the input controls to the currently attached dom element to listen the events from.
  76169. * @param input Defines the input to attach
  76170. */
  76171. attachInput(input: ICameraInput<TCamera>): void;
  76172. /**
  76173. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76174. * @param element Defines the dom element to collect the events from
  76175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76176. */
  76177. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76178. /**
  76179. * Detach the current manager inputs controls from a specific dom element.
  76180. * @param element Defines the dom element to collect the events from
  76181. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76182. */
  76183. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76184. /**
  76185. * Rebuild the dynamic inputCheck function from the current list of
  76186. * defined inputs in the manager.
  76187. */
  76188. rebuildInputCheck(): void;
  76189. /**
  76190. * Remove all attached input methods from a camera
  76191. */
  76192. clear(): void;
  76193. /**
  76194. * Serialize the current input manager attached to a camera.
  76195. * This ensures than once parsed,
  76196. * the input associated to the camera will be identical to the current ones
  76197. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76198. */
  76199. serialize(serializedCamera: any): void;
  76200. /**
  76201. * Parses an input manager serialized JSON to restore the previous list of inputs
  76202. * and states associated to a camera.
  76203. * @param parsedCamera Defines the JSON to parse
  76204. */
  76205. parse(parsedCamera: any): void;
  76206. }
  76207. }
  76208. declare module BABYLON {
  76209. /**
  76210. * Class used to store data that will be store in GPU memory
  76211. */
  76212. export class Buffer {
  76213. private _engine;
  76214. private _buffer;
  76215. /** @hidden */
  76216. _data: Nullable<DataArray>;
  76217. private _updatable;
  76218. private _instanced;
  76219. private _divisor;
  76220. /**
  76221. * Gets the byte stride.
  76222. */
  76223. readonly byteStride: number;
  76224. /**
  76225. * Constructor
  76226. * @param engine the engine
  76227. * @param data the data to use for this buffer
  76228. * @param updatable whether the data is updatable
  76229. * @param stride the stride (optional)
  76230. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76231. * @param instanced whether the buffer is instanced (optional)
  76232. * @param useBytes set to true if the stride in in bytes (optional)
  76233. * @param divisor sets an optional divisor for instances (1 by default)
  76234. */
  76235. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76236. /**
  76237. * Create a new VertexBuffer based on the current buffer
  76238. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76239. * @param offset defines offset in the buffer (0 by default)
  76240. * @param size defines the size in floats of attributes (position is 3 for instance)
  76241. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76242. * @param instanced defines if the vertex buffer contains indexed data
  76243. * @param useBytes defines if the offset and stride are in bytes *
  76244. * @param divisor sets an optional divisor for instances (1 by default)
  76245. * @returns the new vertex buffer
  76246. */
  76247. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76248. /**
  76249. * Gets a boolean indicating if the Buffer is updatable?
  76250. * @returns true if the buffer is updatable
  76251. */
  76252. isUpdatable(): boolean;
  76253. /**
  76254. * Gets current buffer's data
  76255. * @returns a DataArray or null
  76256. */
  76257. getData(): Nullable<DataArray>;
  76258. /**
  76259. * Gets underlying native buffer
  76260. * @returns underlying native buffer
  76261. */
  76262. getBuffer(): Nullable<DataBuffer>;
  76263. /**
  76264. * Gets the stride in float32 units (i.e. byte stride / 4).
  76265. * May not be an integer if the byte stride is not divisible by 4.
  76266. * @returns the stride in float32 units
  76267. * @deprecated Please use byteStride instead.
  76268. */
  76269. getStrideSize(): number;
  76270. /**
  76271. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76272. * @param data defines the data to store
  76273. */
  76274. create(data?: Nullable<DataArray>): void;
  76275. /** @hidden */
  76276. _rebuild(): void;
  76277. /**
  76278. * Update current buffer data
  76279. * @param data defines the data to store
  76280. */
  76281. update(data: DataArray): void;
  76282. /**
  76283. * Updates the data directly.
  76284. * @param data the new data
  76285. * @param offset the new offset
  76286. * @param vertexCount the vertex count (optional)
  76287. * @param useBytes set to true if the offset is in bytes
  76288. */
  76289. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76290. /**
  76291. * Release all resources
  76292. */
  76293. dispose(): void;
  76294. }
  76295. /**
  76296. * Specialized buffer used to store vertex data
  76297. */
  76298. export class VertexBuffer {
  76299. /** @hidden */
  76300. _buffer: Buffer;
  76301. private _kind;
  76302. private _size;
  76303. private _ownsBuffer;
  76304. private _instanced;
  76305. private _instanceDivisor;
  76306. /**
  76307. * The byte type.
  76308. */
  76309. static readonly BYTE: number;
  76310. /**
  76311. * The unsigned byte type.
  76312. */
  76313. static readonly UNSIGNED_BYTE: number;
  76314. /**
  76315. * The short type.
  76316. */
  76317. static readonly SHORT: number;
  76318. /**
  76319. * The unsigned short type.
  76320. */
  76321. static readonly UNSIGNED_SHORT: number;
  76322. /**
  76323. * The integer type.
  76324. */
  76325. static readonly INT: number;
  76326. /**
  76327. * The unsigned integer type.
  76328. */
  76329. static readonly UNSIGNED_INT: number;
  76330. /**
  76331. * The float type.
  76332. */
  76333. static readonly FLOAT: number;
  76334. /**
  76335. * Gets or sets the instance divisor when in instanced mode
  76336. */
  76337. instanceDivisor: number;
  76338. /**
  76339. * Gets the byte stride.
  76340. */
  76341. readonly byteStride: number;
  76342. /**
  76343. * Gets the byte offset.
  76344. */
  76345. readonly byteOffset: number;
  76346. /**
  76347. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  76348. */
  76349. readonly normalized: boolean;
  76350. /**
  76351. * Gets the data type of each component in the array.
  76352. */
  76353. readonly type: number;
  76354. /**
  76355. * Constructor
  76356. * @param engine the engine
  76357. * @param data the data to use for this vertex buffer
  76358. * @param kind the vertex buffer kind
  76359. * @param updatable whether the data is updatable
  76360. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76361. * @param stride the stride (optional)
  76362. * @param instanced whether the buffer is instanced (optional)
  76363. * @param offset the offset of the data (optional)
  76364. * @param size the number of components (optional)
  76365. * @param type the type of the component (optional)
  76366. * @param normalized whether the data contains normalized data (optional)
  76367. * @param useBytes set to true if stride and offset are in bytes (optional)
  76368. * @param divisor defines the instance divisor to use (1 by default)
  76369. */
  76370. 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);
  76371. /** @hidden */
  76372. _rebuild(): void;
  76373. /**
  76374. * Returns the kind of the VertexBuffer (string)
  76375. * @returns a string
  76376. */
  76377. getKind(): string;
  76378. /**
  76379. * Gets a boolean indicating if the VertexBuffer is updatable?
  76380. * @returns true if the buffer is updatable
  76381. */
  76382. isUpdatable(): boolean;
  76383. /**
  76384. * Gets current buffer's data
  76385. * @returns a DataArray or null
  76386. */
  76387. getData(): Nullable<DataArray>;
  76388. /**
  76389. * Gets underlying native buffer
  76390. * @returns underlying native buffer
  76391. */
  76392. getBuffer(): Nullable<DataBuffer>;
  76393. /**
  76394. * Gets the stride in float32 units (i.e. byte stride / 4).
  76395. * May not be an integer if the byte stride is not divisible by 4.
  76396. * @returns the stride in float32 units
  76397. * @deprecated Please use byteStride instead.
  76398. */
  76399. getStrideSize(): number;
  76400. /**
  76401. * Returns the offset as a multiple of the type byte length.
  76402. * @returns the offset in bytes
  76403. * @deprecated Please use byteOffset instead.
  76404. */
  76405. getOffset(): number;
  76406. /**
  76407. * Returns the number of components per vertex attribute (integer)
  76408. * @returns the size in float
  76409. */
  76410. getSize(): number;
  76411. /**
  76412. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  76413. * @returns true if this buffer is instanced
  76414. */
  76415. getIsInstanced(): boolean;
  76416. /**
  76417. * Returns the instancing divisor, zero for non-instanced (integer).
  76418. * @returns a number
  76419. */
  76420. getInstanceDivisor(): number;
  76421. /**
  76422. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76423. * @param data defines the data to store
  76424. */
  76425. create(data?: DataArray): void;
  76426. /**
  76427. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  76428. * This function will create a new buffer if the current one is not updatable
  76429. * @param data defines the data to store
  76430. */
  76431. update(data: DataArray): void;
  76432. /**
  76433. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  76434. * Returns the directly updated WebGLBuffer.
  76435. * @param data the new data
  76436. * @param offset the new offset
  76437. * @param useBytes set to true if the offset is in bytes
  76438. */
  76439. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  76440. /**
  76441. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  76442. */
  76443. dispose(): void;
  76444. /**
  76445. * Enumerates each value of this vertex buffer as numbers.
  76446. * @param count the number of values to enumerate
  76447. * @param callback the callback function called for each value
  76448. */
  76449. forEach(count: number, callback: (value: number, index: number) => void): void;
  76450. /**
  76451. * Positions
  76452. */
  76453. static readonly PositionKind: string;
  76454. /**
  76455. * Normals
  76456. */
  76457. static readonly NormalKind: string;
  76458. /**
  76459. * Tangents
  76460. */
  76461. static readonly TangentKind: string;
  76462. /**
  76463. * Texture coordinates
  76464. */
  76465. static readonly UVKind: string;
  76466. /**
  76467. * Texture coordinates 2
  76468. */
  76469. static readonly UV2Kind: string;
  76470. /**
  76471. * Texture coordinates 3
  76472. */
  76473. static readonly UV3Kind: string;
  76474. /**
  76475. * Texture coordinates 4
  76476. */
  76477. static readonly UV4Kind: string;
  76478. /**
  76479. * Texture coordinates 5
  76480. */
  76481. static readonly UV5Kind: string;
  76482. /**
  76483. * Texture coordinates 6
  76484. */
  76485. static readonly UV6Kind: string;
  76486. /**
  76487. * Colors
  76488. */
  76489. static readonly ColorKind: string;
  76490. /**
  76491. * Matrix indices (for bones)
  76492. */
  76493. static readonly MatricesIndicesKind: string;
  76494. /**
  76495. * Matrix weights (for bones)
  76496. */
  76497. static readonly MatricesWeightsKind: string;
  76498. /**
  76499. * Additional matrix indices (for bones)
  76500. */
  76501. static readonly MatricesIndicesExtraKind: string;
  76502. /**
  76503. * Additional matrix weights (for bones)
  76504. */
  76505. static readonly MatricesWeightsExtraKind: string;
  76506. /**
  76507. * Deduces the stride given a kind.
  76508. * @param kind The kind string to deduce
  76509. * @returns The deduced stride
  76510. */
  76511. static DeduceStride(kind: string): number;
  76512. /**
  76513. * Gets the byte length of the given type.
  76514. * @param type the type
  76515. * @returns the number of bytes
  76516. */
  76517. static GetTypeByteLength(type: number): number;
  76518. /**
  76519. * Enumerates each value of the given parameters as numbers.
  76520. * @param data the data to enumerate
  76521. * @param byteOffset the byte offset of the data
  76522. * @param byteStride the byte stride of the data
  76523. * @param componentCount the number of components per element
  76524. * @param componentType the type of the component
  76525. * @param count the number of values to enumerate
  76526. * @param normalized whether the data is normalized
  76527. * @param callback the callback function called for each value
  76528. */
  76529. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  76530. private static _GetFloatValue;
  76531. }
  76532. }
  76533. declare module BABYLON {
  76534. /**
  76535. * @hidden
  76536. */
  76537. export class IntersectionInfo {
  76538. bu: Nullable<number>;
  76539. bv: Nullable<number>;
  76540. distance: number;
  76541. faceId: number;
  76542. subMeshId: number;
  76543. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  76544. }
  76545. }
  76546. declare module BABYLON {
  76547. /**
  76548. * Represens a plane by the equation ax + by + cz + d = 0
  76549. */
  76550. export class Plane {
  76551. private static _TmpMatrix;
  76552. /**
  76553. * Normal of the plane (a,b,c)
  76554. */
  76555. normal: Vector3;
  76556. /**
  76557. * d component of the plane
  76558. */
  76559. d: number;
  76560. /**
  76561. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  76562. * @param a a component of the plane
  76563. * @param b b component of the plane
  76564. * @param c c component of the plane
  76565. * @param d d component of the plane
  76566. */
  76567. constructor(a: number, b: number, c: number, d: number);
  76568. /**
  76569. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  76570. */
  76571. asArray(): number[];
  76572. /**
  76573. * @returns a new plane copied from the current Plane.
  76574. */
  76575. clone(): Plane;
  76576. /**
  76577. * @returns the string "Plane".
  76578. */
  76579. getClassName(): string;
  76580. /**
  76581. * @returns the Plane hash code.
  76582. */
  76583. getHashCode(): number;
  76584. /**
  76585. * Normalize the current Plane in place.
  76586. * @returns the updated Plane.
  76587. */
  76588. normalize(): Plane;
  76589. /**
  76590. * Applies a transformation the plane and returns the result
  76591. * @param transformation the transformation matrix to be applied to the plane
  76592. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  76593. */
  76594. transform(transformation: DeepImmutable<Matrix>): Plane;
  76595. /**
  76596. * Calcualtte the dot product between the point and the plane normal
  76597. * @param point point to calculate the dot product with
  76598. * @returns the dot product (float) of the point coordinates and the plane normal.
  76599. */
  76600. dotCoordinate(point: DeepImmutable<Vector3>): number;
  76601. /**
  76602. * Updates the current Plane from the plane defined by the three given points.
  76603. * @param point1 one of the points used to contruct the plane
  76604. * @param point2 one of the points used to contruct the plane
  76605. * @param point3 one of the points used to contruct the plane
  76606. * @returns the updated Plane.
  76607. */
  76608. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76609. /**
  76610. * Checks if the plane is facing a given direction
  76611. * @param direction the direction to check if the plane is facing
  76612. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76613. * @returns True is the vector "direction" is the same side than the plane normal.
  76614. */
  76615. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  76616. /**
  76617. * Calculates the distance to a point
  76618. * @param point point to calculate distance to
  76619. * @returns the signed distance (float) from the given point to the Plane.
  76620. */
  76621. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  76622. /**
  76623. * Creates a plane from an array
  76624. * @param array the array to create a plane from
  76625. * @returns a new Plane from the given array.
  76626. */
  76627. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  76628. /**
  76629. * Creates a plane from three points
  76630. * @param point1 point used to create the plane
  76631. * @param point2 point used to create the plane
  76632. * @param point3 point used to create the plane
  76633. * @returns a new Plane defined by the three given points.
  76634. */
  76635. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76636. /**
  76637. * Creates a plane from an origin point and a normal
  76638. * @param origin origin of the plane to be constructed
  76639. * @param normal normal of the plane to be constructed
  76640. * @returns a new Plane the normal vector to this plane at the given origin point.
  76641. * Note : the vector "normal" is updated because normalized.
  76642. */
  76643. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  76644. /**
  76645. * Calculates the distance from a plane and a point
  76646. * @param origin origin of the plane to be constructed
  76647. * @param normal normal of the plane to be constructed
  76648. * @param point point to calculate distance to
  76649. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76650. */
  76651. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  76652. }
  76653. }
  76654. declare module BABYLON {
  76655. /**
  76656. * Class used to store bounding sphere information
  76657. */
  76658. export class BoundingSphere {
  76659. /**
  76660. * Gets the center of the bounding sphere in local space
  76661. */
  76662. readonly center: Vector3;
  76663. /**
  76664. * Radius of the bounding sphere in local space
  76665. */
  76666. radius: number;
  76667. /**
  76668. * Gets the center of the bounding sphere in world space
  76669. */
  76670. readonly centerWorld: Vector3;
  76671. /**
  76672. * Radius of the bounding sphere in world space
  76673. */
  76674. radiusWorld: number;
  76675. /**
  76676. * Gets the minimum vector in local space
  76677. */
  76678. readonly minimum: Vector3;
  76679. /**
  76680. * Gets the maximum vector in local space
  76681. */
  76682. readonly maximum: Vector3;
  76683. private _worldMatrix;
  76684. private static readonly TmpVector3;
  76685. /**
  76686. * Creates a new bounding sphere
  76687. * @param min defines the minimum vector (in local space)
  76688. * @param max defines the maximum vector (in local space)
  76689. * @param worldMatrix defines the new world matrix
  76690. */
  76691. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76692. /**
  76693. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  76694. * @param min defines the new minimum vector (in local space)
  76695. * @param max defines the new maximum vector (in local space)
  76696. * @param worldMatrix defines the new world matrix
  76697. */
  76698. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76699. /**
  76700. * Scale the current bounding sphere by applying a scale factor
  76701. * @param factor defines the scale factor to apply
  76702. * @returns the current bounding box
  76703. */
  76704. scale(factor: number): BoundingSphere;
  76705. /**
  76706. * Gets the world matrix of the bounding box
  76707. * @returns a matrix
  76708. */
  76709. getWorldMatrix(): DeepImmutable<Matrix>;
  76710. /** @hidden */
  76711. _update(worldMatrix: DeepImmutable<Matrix>): void;
  76712. /**
  76713. * Tests if the bounding sphere is intersecting the frustum planes
  76714. * @param frustumPlanes defines the frustum planes to test
  76715. * @returns true if there is an intersection
  76716. */
  76717. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76718. /**
  76719. * Tests if the bounding sphere center is in between the frustum planes.
  76720. * Used for optimistic fast inclusion.
  76721. * @param frustumPlanes defines the frustum planes to test
  76722. * @returns true if the sphere center is in between the frustum planes
  76723. */
  76724. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76725. /**
  76726. * Tests if a point is inside the bounding sphere
  76727. * @param point defines the point to test
  76728. * @returns true if the point is inside the bounding sphere
  76729. */
  76730. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76731. /**
  76732. * Checks if two sphere intersct
  76733. * @param sphere0 sphere 0
  76734. * @param sphere1 sphere 1
  76735. * @returns true if the speres intersect
  76736. */
  76737. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  76738. }
  76739. }
  76740. declare module BABYLON {
  76741. /**
  76742. * Class used to store bounding box information
  76743. */
  76744. export class BoundingBox implements ICullable {
  76745. /**
  76746. * Gets the 8 vectors representing the bounding box in local space
  76747. */
  76748. readonly vectors: Vector3[];
  76749. /**
  76750. * Gets the center of the bounding box in local space
  76751. */
  76752. readonly center: Vector3;
  76753. /**
  76754. * Gets the center of the bounding box in world space
  76755. */
  76756. readonly centerWorld: Vector3;
  76757. /**
  76758. * Gets the extend size in local space
  76759. */
  76760. readonly extendSize: Vector3;
  76761. /**
  76762. * Gets the extend size in world space
  76763. */
  76764. readonly extendSizeWorld: Vector3;
  76765. /**
  76766. * Gets the OBB (object bounding box) directions
  76767. */
  76768. readonly directions: Vector3[];
  76769. /**
  76770. * Gets the 8 vectors representing the bounding box in world space
  76771. */
  76772. readonly vectorsWorld: Vector3[];
  76773. /**
  76774. * Gets the minimum vector in world space
  76775. */
  76776. readonly minimumWorld: Vector3;
  76777. /**
  76778. * Gets the maximum vector in world space
  76779. */
  76780. readonly maximumWorld: Vector3;
  76781. /**
  76782. * Gets the minimum vector in local space
  76783. */
  76784. readonly minimum: Vector3;
  76785. /**
  76786. * Gets the maximum vector in local space
  76787. */
  76788. readonly maximum: Vector3;
  76789. private _worldMatrix;
  76790. private static readonly TmpVector3;
  76791. /**
  76792. * @hidden
  76793. */
  76794. _tag: number;
  76795. /**
  76796. * Creates a new bounding box
  76797. * @param min defines the minimum vector (in local space)
  76798. * @param max defines the maximum vector (in local space)
  76799. * @param worldMatrix defines the new world matrix
  76800. */
  76801. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76802. /**
  76803. * Recreates the entire bounding box from scratch as if we call the constructor in place
  76804. * @param min defines the new minimum vector (in local space)
  76805. * @param max defines the new maximum vector (in local space)
  76806. * @param worldMatrix defines the new world matrix
  76807. */
  76808. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76809. /**
  76810. * Scale the current bounding box by applying a scale factor
  76811. * @param factor defines the scale factor to apply
  76812. * @returns the current bounding box
  76813. */
  76814. scale(factor: number): BoundingBox;
  76815. /**
  76816. * Gets the world matrix of the bounding box
  76817. * @returns a matrix
  76818. */
  76819. getWorldMatrix(): DeepImmutable<Matrix>;
  76820. /** @hidden */
  76821. _update(world: DeepImmutable<Matrix>): void;
  76822. /**
  76823. * Tests if the bounding box is intersecting the frustum planes
  76824. * @param frustumPlanes defines the frustum planes to test
  76825. * @returns true if there is an intersection
  76826. */
  76827. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76828. /**
  76829. * Tests if the bounding box is entirely inside the frustum planes
  76830. * @param frustumPlanes defines the frustum planes to test
  76831. * @returns true if there is an inclusion
  76832. */
  76833. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76834. /**
  76835. * Tests if a point is inside the bounding box
  76836. * @param point defines the point to test
  76837. * @returns true if the point is inside the bounding box
  76838. */
  76839. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76840. /**
  76841. * Tests if the bounding box intersects with a bounding sphere
  76842. * @param sphere defines the sphere to test
  76843. * @returns true if there is an intersection
  76844. */
  76845. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  76846. /**
  76847. * Tests if the bounding box intersects with a box defined by a min and max vectors
  76848. * @param min defines the min vector to use
  76849. * @param max defines the max vector to use
  76850. * @returns true if there is an intersection
  76851. */
  76852. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  76853. /**
  76854. * Tests if two bounding boxes are intersections
  76855. * @param box0 defines the first box to test
  76856. * @param box1 defines the second box to test
  76857. * @returns true if there is an intersection
  76858. */
  76859. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  76860. /**
  76861. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  76862. * @param minPoint defines the minimum vector of the bounding box
  76863. * @param maxPoint defines the maximum vector of the bounding box
  76864. * @param sphereCenter defines the sphere center
  76865. * @param sphereRadius defines the sphere radius
  76866. * @returns true if there is an intersection
  76867. */
  76868. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  76869. /**
  76870. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  76871. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76872. * @param frustumPlanes defines the frustum planes to test
  76873. * @return true if there is an inclusion
  76874. */
  76875. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76876. /**
  76877. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  76878. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76879. * @param frustumPlanes defines the frustum planes to test
  76880. * @return true if there is an intersection
  76881. */
  76882. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76883. }
  76884. }
  76885. declare module BABYLON {
  76886. /** @hidden */
  76887. export class Collider {
  76888. /** Define if a collision was found */
  76889. collisionFound: boolean;
  76890. /**
  76891. * Define last intersection point in local space
  76892. */
  76893. intersectionPoint: Vector3;
  76894. /**
  76895. * Define last collided mesh
  76896. */
  76897. collidedMesh: Nullable<AbstractMesh>;
  76898. private _collisionPoint;
  76899. private _planeIntersectionPoint;
  76900. private _tempVector;
  76901. private _tempVector2;
  76902. private _tempVector3;
  76903. private _tempVector4;
  76904. private _edge;
  76905. private _baseToVertex;
  76906. private _destinationPoint;
  76907. private _slidePlaneNormal;
  76908. private _displacementVector;
  76909. /** @hidden */
  76910. _radius: Vector3;
  76911. /** @hidden */
  76912. _retry: number;
  76913. private _velocity;
  76914. private _basePoint;
  76915. private _epsilon;
  76916. /** @hidden */
  76917. _velocityWorldLength: number;
  76918. /** @hidden */
  76919. _basePointWorld: Vector3;
  76920. private _velocityWorld;
  76921. private _normalizedVelocity;
  76922. /** @hidden */
  76923. _initialVelocity: Vector3;
  76924. /** @hidden */
  76925. _initialPosition: Vector3;
  76926. private _nearestDistance;
  76927. private _collisionMask;
  76928. collisionMask: number;
  76929. /**
  76930. * Gets the plane normal used to compute the sliding response (in local space)
  76931. */
  76932. readonly slidePlaneNormal: Vector3;
  76933. /** @hidden */
  76934. _initialize(source: Vector3, dir: Vector3, e: number): void;
  76935. /** @hidden */
  76936. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  76937. /** @hidden */
  76938. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  76939. /** @hidden */
  76940. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76941. /** @hidden */
  76942. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76943. /** @hidden */
  76944. _getResponse(pos: Vector3, vel: Vector3): void;
  76945. }
  76946. }
  76947. declare module BABYLON {
  76948. /**
  76949. * Interface for cullable objects
  76950. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  76951. */
  76952. export interface ICullable {
  76953. /**
  76954. * Checks if the object or part of the object is in the frustum
  76955. * @param frustumPlanes Camera near/planes
  76956. * @returns true if the object is in frustum otherwise false
  76957. */
  76958. isInFrustum(frustumPlanes: Plane[]): boolean;
  76959. /**
  76960. * Checks if a cullable object (mesh...) is in the camera frustum
  76961. * Unlike isInFrustum this cheks the full bounding box
  76962. * @param frustumPlanes Camera near/planes
  76963. * @returns true if the object is in frustum otherwise false
  76964. */
  76965. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  76966. }
  76967. /**
  76968. * Info for a bounding data of a mesh
  76969. */
  76970. export class BoundingInfo implements ICullable {
  76971. /**
  76972. * Bounding box for the mesh
  76973. */
  76974. readonly boundingBox: BoundingBox;
  76975. /**
  76976. * Bounding sphere for the mesh
  76977. */
  76978. readonly boundingSphere: BoundingSphere;
  76979. private _isLocked;
  76980. private static readonly TmpVector3;
  76981. /**
  76982. * Constructs bounding info
  76983. * @param minimum min vector of the bounding box/sphere
  76984. * @param maximum max vector of the bounding box/sphere
  76985. * @param worldMatrix defines the new world matrix
  76986. */
  76987. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76988. /**
  76989. * Recreates the entire bounding info from scratch as if we call the constructor in place
  76990. * @param min defines the new minimum vector (in local space)
  76991. * @param max defines the new maximum vector (in local space)
  76992. * @param worldMatrix defines the new world matrix
  76993. */
  76994. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76995. /**
  76996. * min vector of the bounding box/sphere
  76997. */
  76998. readonly minimum: Vector3;
  76999. /**
  77000. * max vector of the bounding box/sphere
  77001. */
  77002. readonly maximum: Vector3;
  77003. /**
  77004. * If the info is locked and won't be updated to avoid perf overhead
  77005. */
  77006. isLocked: boolean;
  77007. /**
  77008. * Updates the bounding sphere and box
  77009. * @param world world matrix to be used to update
  77010. */
  77011. update(world: DeepImmutable<Matrix>): void;
  77012. /**
  77013. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77014. * @param center New center of the bounding info
  77015. * @param extend New extend of the bounding info
  77016. * @returns the current bounding info
  77017. */
  77018. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77019. /**
  77020. * Scale the current bounding info by applying a scale factor
  77021. * @param factor defines the scale factor to apply
  77022. * @returns the current bounding info
  77023. */
  77024. scale(factor: number): BoundingInfo;
  77025. /**
  77026. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77027. * @param frustumPlanes defines the frustum to test
  77028. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77029. * @returns true if the bounding info is in the frustum planes
  77030. */
  77031. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77032. /**
  77033. * Gets the world distance between the min and max points of the bounding box
  77034. */
  77035. readonly diagonalLength: number;
  77036. /**
  77037. * Checks if a cullable object (mesh...) is in the camera frustum
  77038. * Unlike isInFrustum this cheks the full bounding box
  77039. * @param frustumPlanes Camera near/planes
  77040. * @returns true if the object is in frustum otherwise false
  77041. */
  77042. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77043. /** @hidden */
  77044. _checkCollision(collider: Collider): boolean;
  77045. /**
  77046. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77047. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77048. * @param point the point to check intersection with
  77049. * @returns if the point intersects
  77050. */
  77051. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77052. /**
  77053. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77054. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77055. * @param boundingInfo the bounding info to check intersection with
  77056. * @param precise if the intersection should be done using OBB
  77057. * @returns if the bounding info intersects
  77058. */
  77059. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77060. }
  77061. }
  77062. declare module BABYLON {
  77063. /**
  77064. * Extracts minimum and maximum values from a list of indexed positions
  77065. * @param positions defines the positions to use
  77066. * @param indices defines the indices to the positions
  77067. * @param indexStart defines the start index
  77068. * @param indexCount defines the end index
  77069. * @param bias defines bias value to add to the result
  77070. * @return minimum and maximum values
  77071. */
  77072. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77073. minimum: Vector3;
  77074. maximum: Vector3;
  77075. };
  77076. /**
  77077. * Extracts minimum and maximum values from a list of positions
  77078. * @param positions defines the positions to use
  77079. * @param start defines the start index in the positions array
  77080. * @param count defines the number of positions to handle
  77081. * @param bias defines bias value to add to the result
  77082. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77083. * @return minimum and maximum values
  77084. */
  77085. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77086. minimum: Vector3;
  77087. maximum: Vector3;
  77088. };
  77089. }
  77090. declare module BABYLON {
  77091. /** @hidden */
  77092. export class WebGLDataBuffer extends DataBuffer {
  77093. private _buffer;
  77094. constructor(resource: WebGLBuffer);
  77095. readonly underlyingResource: any;
  77096. }
  77097. }
  77098. declare module BABYLON {
  77099. /** @hidden */
  77100. export class WebGLPipelineContext implements IPipelineContext {
  77101. engine: ThinEngine;
  77102. program: Nullable<WebGLProgram>;
  77103. context?: WebGLRenderingContext;
  77104. vertexShader?: WebGLShader;
  77105. fragmentShader?: WebGLShader;
  77106. isParallelCompiled: boolean;
  77107. onCompiled?: () => void;
  77108. transformFeedback?: WebGLTransformFeedback | null;
  77109. vertexCompilationError: Nullable<string>;
  77110. fragmentCompilationError: Nullable<string>;
  77111. programLinkError: Nullable<string>;
  77112. programValidationError: Nullable<string>;
  77113. readonly isAsync: boolean;
  77114. readonly isReady: boolean;
  77115. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77116. }
  77117. }
  77118. declare module BABYLON {
  77119. interface ThinEngine {
  77120. /**
  77121. * Create an uniform buffer
  77122. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77123. * @param elements defines the content of the uniform buffer
  77124. * @returns the webGL uniform buffer
  77125. */
  77126. createUniformBuffer(elements: FloatArray): DataBuffer;
  77127. /**
  77128. * Create a dynamic uniform buffer
  77129. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77130. * @param elements defines the content of the uniform buffer
  77131. * @returns the webGL uniform buffer
  77132. */
  77133. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77134. /**
  77135. * Update an existing uniform buffer
  77136. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77137. * @param uniformBuffer defines the target uniform buffer
  77138. * @param elements defines the content to update
  77139. * @param offset defines the offset in the uniform buffer where update should start
  77140. * @param count defines the size of the data to update
  77141. */
  77142. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77143. /**
  77144. * Bind an uniform buffer to the current webGL context
  77145. * @param buffer defines the buffer to bind
  77146. */
  77147. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77148. /**
  77149. * Bind a buffer to the current webGL context at a given location
  77150. * @param buffer defines the buffer to bind
  77151. * @param location defines the index where to bind the buffer
  77152. */
  77153. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77154. /**
  77155. * Bind a specific block at a given index in a specific shader program
  77156. * @param pipelineContext defines the pipeline context to use
  77157. * @param blockName defines the block name
  77158. * @param index defines the index where to bind the block
  77159. */
  77160. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77161. }
  77162. }
  77163. declare module BABYLON {
  77164. /**
  77165. * Uniform buffer objects.
  77166. *
  77167. * Handles blocks of uniform on the GPU.
  77168. *
  77169. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77170. *
  77171. * For more information, please refer to :
  77172. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77173. */
  77174. export class UniformBuffer {
  77175. private _engine;
  77176. private _buffer;
  77177. private _data;
  77178. private _bufferData;
  77179. private _dynamic?;
  77180. private _uniformLocations;
  77181. private _uniformSizes;
  77182. private _uniformLocationPointer;
  77183. private _needSync;
  77184. private _noUBO;
  77185. private _currentEffect;
  77186. /** @hidden */
  77187. _alreadyBound: boolean;
  77188. private static _MAX_UNIFORM_SIZE;
  77189. private static _tempBuffer;
  77190. /**
  77191. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77192. * This is dynamic to allow compat with webgl 1 and 2.
  77193. * You will need to pass the name of the uniform as well as the value.
  77194. */
  77195. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77196. /**
  77197. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77198. * This is dynamic to allow compat with webgl 1 and 2.
  77199. * You will need to pass the name of the uniform as well as the value.
  77200. */
  77201. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77202. /**
  77203. * Lambda to Update a single float in a uniform buffer.
  77204. * This is dynamic to allow compat with webgl 1 and 2.
  77205. * You will need to pass the name of the uniform as well as the value.
  77206. */
  77207. updateFloat: (name: string, x: number) => void;
  77208. /**
  77209. * Lambda to Update a vec2 of float in a uniform buffer.
  77210. * This is dynamic to allow compat with webgl 1 and 2.
  77211. * You will need to pass the name of the uniform as well as the value.
  77212. */
  77213. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77214. /**
  77215. * Lambda to Update a vec3 of float in a uniform buffer.
  77216. * This is dynamic to allow compat with webgl 1 and 2.
  77217. * You will need to pass the name of the uniform as well as the value.
  77218. */
  77219. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77220. /**
  77221. * Lambda to Update a vec4 of float in a uniform buffer.
  77222. * This is dynamic to allow compat with webgl 1 and 2.
  77223. * You will need to pass the name of the uniform as well as the value.
  77224. */
  77225. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77226. /**
  77227. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77228. * This is dynamic to allow compat with webgl 1 and 2.
  77229. * You will need to pass the name of the uniform as well as the value.
  77230. */
  77231. updateMatrix: (name: string, mat: Matrix) => void;
  77232. /**
  77233. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77234. * This is dynamic to allow compat with webgl 1 and 2.
  77235. * You will need to pass the name of the uniform as well as the value.
  77236. */
  77237. updateVector3: (name: string, vector: Vector3) => void;
  77238. /**
  77239. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77240. * This is dynamic to allow compat with webgl 1 and 2.
  77241. * You will need to pass the name of the uniform as well as the value.
  77242. */
  77243. updateVector4: (name: string, vector: Vector4) => void;
  77244. /**
  77245. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77246. * This is dynamic to allow compat with webgl 1 and 2.
  77247. * You will need to pass the name of the uniform as well as the value.
  77248. */
  77249. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77250. /**
  77251. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77252. * This is dynamic to allow compat with webgl 1 and 2.
  77253. * You will need to pass the name of the uniform as well as the value.
  77254. */
  77255. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77256. /**
  77257. * Instantiates a new Uniform buffer objects.
  77258. *
  77259. * Handles blocks of uniform on the GPU.
  77260. *
  77261. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77262. *
  77263. * For more information, please refer to :
  77264. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77265. * @param engine Define the engine the buffer is associated with
  77266. * @param data Define the data contained in the buffer
  77267. * @param dynamic Define if the buffer is updatable
  77268. */
  77269. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77270. /**
  77271. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77272. * or just falling back on setUniformXXX calls.
  77273. */
  77274. readonly useUbo: boolean;
  77275. /**
  77276. * Indicates if the WebGL underlying uniform buffer is in sync
  77277. * with the javascript cache data.
  77278. */
  77279. readonly isSync: boolean;
  77280. /**
  77281. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77282. * Also, a dynamic UniformBuffer will disable cache verification and always
  77283. * update the underlying WebGL uniform buffer to the GPU.
  77284. * @returns if Dynamic, otherwise false
  77285. */
  77286. isDynamic(): boolean;
  77287. /**
  77288. * The data cache on JS side.
  77289. * @returns the underlying data as a float array
  77290. */
  77291. getData(): Float32Array;
  77292. /**
  77293. * The underlying WebGL Uniform buffer.
  77294. * @returns the webgl buffer
  77295. */
  77296. getBuffer(): Nullable<DataBuffer>;
  77297. /**
  77298. * std140 layout specifies how to align data within an UBO structure.
  77299. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77300. * for specs.
  77301. */
  77302. private _fillAlignment;
  77303. /**
  77304. * Adds an uniform in the buffer.
  77305. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77306. * for the layout to be correct !
  77307. * @param name Name of the uniform, as used in the uniform block in the shader.
  77308. * @param size Data size, or data directly.
  77309. */
  77310. addUniform(name: string, size: number | number[]): void;
  77311. /**
  77312. * Adds a Matrix 4x4 to the uniform buffer.
  77313. * @param name Name of the uniform, as used in the uniform block in the shader.
  77314. * @param mat A 4x4 matrix.
  77315. */
  77316. addMatrix(name: string, mat: Matrix): void;
  77317. /**
  77318. * Adds a vec2 to the uniform buffer.
  77319. * @param name Name of the uniform, as used in the uniform block in the shader.
  77320. * @param x Define the x component value of the vec2
  77321. * @param y Define the y component value of the vec2
  77322. */
  77323. addFloat2(name: string, x: number, y: number): void;
  77324. /**
  77325. * Adds a vec3 to the uniform buffer.
  77326. * @param name Name of the uniform, as used in the uniform block in the shader.
  77327. * @param x Define the x component value of the vec3
  77328. * @param y Define the y component value of the vec3
  77329. * @param z Define the z component value of the vec3
  77330. */
  77331. addFloat3(name: string, x: number, y: number, z: number): void;
  77332. /**
  77333. * Adds a vec3 to the uniform buffer.
  77334. * @param name Name of the uniform, as used in the uniform block in the shader.
  77335. * @param color Define the vec3 from a Color
  77336. */
  77337. addColor3(name: string, color: Color3): void;
  77338. /**
  77339. * Adds a vec4 to the uniform buffer.
  77340. * @param name Name of the uniform, as used in the uniform block in the shader.
  77341. * @param color Define the rgb components from a Color
  77342. * @param alpha Define the a component of the vec4
  77343. */
  77344. addColor4(name: string, color: Color3, alpha: number): void;
  77345. /**
  77346. * Adds a vec3 to the uniform buffer.
  77347. * @param name Name of the uniform, as used in the uniform block in the shader.
  77348. * @param vector Define the vec3 components from a Vector
  77349. */
  77350. addVector3(name: string, vector: Vector3): void;
  77351. /**
  77352. * Adds a Matrix 3x3 to the uniform buffer.
  77353. * @param name Name of the uniform, as used in the uniform block in the shader.
  77354. */
  77355. addMatrix3x3(name: string): void;
  77356. /**
  77357. * Adds a Matrix 2x2 to the uniform buffer.
  77358. * @param name Name of the uniform, as used in the uniform block in the shader.
  77359. */
  77360. addMatrix2x2(name: string): void;
  77361. /**
  77362. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  77363. */
  77364. create(): void;
  77365. /** @hidden */
  77366. _rebuild(): void;
  77367. /**
  77368. * Updates the WebGL Uniform Buffer on the GPU.
  77369. * If the `dynamic` flag is set to true, no cache comparison is done.
  77370. * Otherwise, the buffer will be updated only if the cache differs.
  77371. */
  77372. update(): void;
  77373. /**
  77374. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  77375. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77376. * @param data Define the flattened data
  77377. * @param size Define the size of the data.
  77378. */
  77379. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  77380. private _valueCache;
  77381. private _cacheMatrix;
  77382. private _updateMatrix3x3ForUniform;
  77383. private _updateMatrix3x3ForEffect;
  77384. private _updateMatrix2x2ForEffect;
  77385. private _updateMatrix2x2ForUniform;
  77386. private _updateFloatForEffect;
  77387. private _updateFloatForUniform;
  77388. private _updateFloat2ForEffect;
  77389. private _updateFloat2ForUniform;
  77390. private _updateFloat3ForEffect;
  77391. private _updateFloat3ForUniform;
  77392. private _updateFloat4ForEffect;
  77393. private _updateFloat4ForUniform;
  77394. private _updateMatrixForEffect;
  77395. private _updateMatrixForUniform;
  77396. private _updateVector3ForEffect;
  77397. private _updateVector3ForUniform;
  77398. private _updateVector4ForEffect;
  77399. private _updateVector4ForUniform;
  77400. private _updateColor3ForEffect;
  77401. private _updateColor3ForUniform;
  77402. private _updateColor4ForEffect;
  77403. private _updateColor4ForUniform;
  77404. /**
  77405. * Sets a sampler uniform on the effect.
  77406. * @param name Define the name of the sampler.
  77407. * @param texture Define the texture to set in the sampler
  77408. */
  77409. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  77410. /**
  77411. * Directly updates the value of the uniform in the cache AND on the GPU.
  77412. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77413. * @param data Define the flattened data
  77414. */
  77415. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  77416. /**
  77417. * Binds this uniform buffer to an effect.
  77418. * @param effect Define the effect to bind the buffer to
  77419. * @param name Name of the uniform block in the shader.
  77420. */
  77421. bindToEffect(effect: Effect, name: string): void;
  77422. /**
  77423. * Disposes the uniform buffer.
  77424. */
  77425. dispose(): void;
  77426. }
  77427. }
  77428. declare module BABYLON {
  77429. /**
  77430. * Enum that determines the text-wrapping mode to use.
  77431. */
  77432. export enum InspectableType {
  77433. /**
  77434. * Checkbox for booleans
  77435. */
  77436. Checkbox = 0,
  77437. /**
  77438. * Sliders for numbers
  77439. */
  77440. Slider = 1,
  77441. /**
  77442. * Vector3
  77443. */
  77444. Vector3 = 2,
  77445. /**
  77446. * Quaternions
  77447. */
  77448. Quaternion = 3,
  77449. /**
  77450. * Color3
  77451. */
  77452. Color3 = 4,
  77453. /**
  77454. * String
  77455. */
  77456. String = 5
  77457. }
  77458. /**
  77459. * Interface used to define custom inspectable properties.
  77460. * This interface is used by the inspector to display custom property grids
  77461. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77462. */
  77463. export interface IInspectable {
  77464. /**
  77465. * Gets the label to display
  77466. */
  77467. label: string;
  77468. /**
  77469. * Gets the name of the property to edit
  77470. */
  77471. propertyName: string;
  77472. /**
  77473. * Gets the type of the editor to use
  77474. */
  77475. type: InspectableType;
  77476. /**
  77477. * Gets the minimum value of the property when using in "slider" mode
  77478. */
  77479. min?: number;
  77480. /**
  77481. * Gets the maximum value of the property when using in "slider" mode
  77482. */
  77483. max?: number;
  77484. /**
  77485. * Gets the setp to use when using in "slider" mode
  77486. */
  77487. step?: number;
  77488. }
  77489. }
  77490. declare module BABYLON {
  77491. /**
  77492. * Class used to provide helper for timing
  77493. */
  77494. export class TimingTools {
  77495. /**
  77496. * Polyfill for setImmediate
  77497. * @param action defines the action to execute after the current execution block
  77498. */
  77499. static SetImmediate(action: () => void): void;
  77500. }
  77501. }
  77502. declare module BABYLON {
  77503. /**
  77504. * Class used to enable instatition of objects by class name
  77505. */
  77506. export class InstantiationTools {
  77507. /**
  77508. * Use this object to register external classes like custom textures or material
  77509. * to allow the laoders to instantiate them
  77510. */
  77511. static RegisteredExternalClasses: {
  77512. [key: string]: Object;
  77513. };
  77514. /**
  77515. * Tries to instantiate a new object from a given class name
  77516. * @param className defines the class name to instantiate
  77517. * @returns the new object or null if the system was not able to do the instantiation
  77518. */
  77519. static Instantiate(className: string): any;
  77520. }
  77521. }
  77522. declare module BABYLON {
  77523. /**
  77524. * Define options used to create a depth texture
  77525. */
  77526. export class DepthTextureCreationOptions {
  77527. /** Specifies whether or not a stencil should be allocated in the texture */
  77528. generateStencil?: boolean;
  77529. /** Specifies whether or not bilinear filtering is enable on the texture */
  77530. bilinearFiltering?: boolean;
  77531. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  77532. comparisonFunction?: number;
  77533. /** Specifies if the created texture is a cube texture */
  77534. isCube?: boolean;
  77535. }
  77536. }
  77537. declare module BABYLON {
  77538. interface ThinEngine {
  77539. /**
  77540. * Creates a depth stencil cube texture.
  77541. * This is only available in WebGL 2.
  77542. * @param size The size of face edge in the cube texture.
  77543. * @param options The options defining the cube texture.
  77544. * @returns The cube texture
  77545. */
  77546. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  77547. /**
  77548. * Creates a cube texture
  77549. * @param rootUrl defines the url where the files to load is located
  77550. * @param scene defines the current scene
  77551. * @param files defines the list of files to load (1 per face)
  77552. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  77553. * @param onLoad defines an optional callback raised when the texture is loaded
  77554. * @param onError defines an optional callback raised if there is an issue to load the texture
  77555. * @param format defines the format of the data
  77556. * @param forcedExtension defines the extension to use to pick the right loader
  77557. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  77558. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  77559. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  77560. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  77561. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  77562. * @returns the cube texture as an InternalTexture
  77563. */
  77564. 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;
  77565. /**
  77566. * Creates a cube texture
  77567. * @param rootUrl defines the url where the files to load is located
  77568. * @param scene defines the current scene
  77569. * @param files defines the list of files to load (1 per face)
  77570. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  77571. * @param onLoad defines an optional callback raised when the texture is loaded
  77572. * @param onError defines an optional callback raised if there is an issue to load the texture
  77573. * @param format defines the format of the data
  77574. * @param forcedExtension defines the extension to use to pick the right loader
  77575. * @returns the cube texture as an InternalTexture
  77576. */
  77577. 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;
  77578. /**
  77579. * Creates a cube texture
  77580. * @param rootUrl defines the url where the files to load is located
  77581. * @param scene defines the current scene
  77582. * @param files defines the list of files to load (1 per face)
  77583. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  77584. * @param onLoad defines an optional callback raised when the texture is loaded
  77585. * @param onError defines an optional callback raised if there is an issue to load the texture
  77586. * @param format defines the format of the data
  77587. * @param forcedExtension defines the extension to use to pick the right loader
  77588. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  77589. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  77590. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  77591. * @returns the cube texture as an InternalTexture
  77592. */
  77593. 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;
  77594. /** @hidden */
  77595. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  77596. /** @hidden */
  77597. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  77598. /** @hidden */
  77599. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  77600. /** @hidden */
  77601. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  77602. /**
  77603. * @hidden
  77604. */
  77605. _setCubeMapTextureParams(loadMipmap: boolean): void;
  77606. }
  77607. }
  77608. declare module BABYLON {
  77609. /**
  77610. * Class for creating a cube texture
  77611. */
  77612. export class CubeTexture extends BaseTexture {
  77613. private _delayedOnLoad;
  77614. /**
  77615. * The url of the texture
  77616. */
  77617. url: string;
  77618. /**
  77619. * Gets or sets the center of the bounding box associated with the cube texture.
  77620. * It must define where the camera used to render the texture was set
  77621. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77622. */
  77623. boundingBoxPosition: Vector3;
  77624. private _boundingBoxSize;
  77625. /**
  77626. * Gets or sets the size of the bounding box associated with the cube texture
  77627. * When defined, the cubemap will switch to local mode
  77628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77629. * @example https://www.babylonjs-playground.com/#RNASML
  77630. */
  77631. /**
  77632. * Returns the bounding box size
  77633. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77634. */
  77635. boundingBoxSize: Vector3;
  77636. protected _rotationY: number;
  77637. /**
  77638. * Sets texture matrix rotation angle around Y axis in radians.
  77639. */
  77640. /**
  77641. * Gets texture matrix rotation angle around Y axis radians.
  77642. */
  77643. rotationY: number;
  77644. /**
  77645. * Are mip maps generated for this texture or not.
  77646. */
  77647. readonly noMipmap: boolean;
  77648. private _noMipmap;
  77649. private _files;
  77650. protected _forcedExtension: Nullable<string>;
  77651. private _extensions;
  77652. private _textureMatrix;
  77653. private _format;
  77654. private _createPolynomials;
  77655. /** @hidden */
  77656. _prefiltered: boolean;
  77657. /**
  77658. * Creates a cube texture from an array of image urls
  77659. * @param files defines an array of image urls
  77660. * @param scene defines the hosting scene
  77661. * @param noMipmap specifies if mip maps are not used
  77662. * @returns a cube texture
  77663. */
  77664. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  77665. /**
  77666. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  77667. * @param url defines the url of the prefiltered texture
  77668. * @param scene defines the scene the texture is attached to
  77669. * @param forcedExtension defines the extension of the file if different from the url
  77670. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77671. * @return the prefiltered texture
  77672. */
  77673. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  77674. /**
  77675. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  77676. * as prefiltered data.
  77677. * @param rootUrl defines the url of the texture or the root name of the six images
  77678. * @param scene defines the scene the texture is attached to
  77679. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  77680. * @param noMipmap defines if mipmaps should be created or not
  77681. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  77682. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  77683. * @param onError defines a callback triggered in case of error during load
  77684. * @param format defines the internal format to use for the texture once loaded
  77685. * @param prefiltered defines whether or not the texture is created from prefiltered data
  77686. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  77687. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  77689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  77690. * @return the cube texture
  77691. */
  77692. 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);
  77693. /**
  77694. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  77695. */
  77696. readonly isPrefiltered: boolean;
  77697. /**
  77698. * Get the current class name of the texture useful for serialization or dynamic coding.
  77699. * @returns "CubeTexture"
  77700. */
  77701. getClassName(): string;
  77702. /**
  77703. * Update the url (and optional buffer) of this texture if url was null during construction.
  77704. * @param url the url of the texture
  77705. * @param forcedExtension defines the extension to use
  77706. * @param onLoad callback called when the texture is loaded (defaults to null)
  77707. */
  77708. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  77709. /**
  77710. * Delays loading of the cube texture
  77711. * @param forcedExtension defines the extension to use
  77712. */
  77713. delayLoad(forcedExtension?: string): void;
  77714. /**
  77715. * Returns the reflection texture matrix
  77716. * @returns the reflection texture matrix
  77717. */
  77718. getReflectionTextureMatrix(): Matrix;
  77719. /**
  77720. * Sets the reflection texture matrix
  77721. * @param value Reflection texture matrix
  77722. */
  77723. setReflectionTextureMatrix(value: Matrix): void;
  77724. /**
  77725. * Parses text to create a cube texture
  77726. * @param parsedTexture define the serialized text to read from
  77727. * @param scene defines the hosting scene
  77728. * @param rootUrl defines the root url of the cube texture
  77729. * @returns a cube texture
  77730. */
  77731. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  77732. /**
  77733. * Makes a clone, or deep copy, of the cube texture
  77734. * @returns a new cube texture
  77735. */
  77736. clone(): CubeTexture;
  77737. }
  77738. }
  77739. declare module BABYLON {
  77740. /**
  77741. * Manages the defines for the Material
  77742. */
  77743. export class MaterialDefines {
  77744. /** @hidden */
  77745. protected _keys: string[];
  77746. private _isDirty;
  77747. /** @hidden */
  77748. _renderId: number;
  77749. /** @hidden */
  77750. _areLightsDirty: boolean;
  77751. /** @hidden */
  77752. _areLightsDisposed: boolean;
  77753. /** @hidden */
  77754. _areAttributesDirty: boolean;
  77755. /** @hidden */
  77756. _areTexturesDirty: boolean;
  77757. /** @hidden */
  77758. _areFresnelDirty: boolean;
  77759. /** @hidden */
  77760. _areMiscDirty: boolean;
  77761. /** @hidden */
  77762. _areImageProcessingDirty: boolean;
  77763. /** @hidden */
  77764. _normals: boolean;
  77765. /** @hidden */
  77766. _uvs: boolean;
  77767. /** @hidden */
  77768. _needNormals: boolean;
  77769. /** @hidden */
  77770. _needUVs: boolean;
  77771. [id: string]: any;
  77772. /**
  77773. * Specifies if the material needs to be re-calculated
  77774. */
  77775. readonly isDirty: boolean;
  77776. /**
  77777. * Marks the material to indicate that it has been re-calculated
  77778. */
  77779. markAsProcessed(): void;
  77780. /**
  77781. * Marks the material to indicate that it needs to be re-calculated
  77782. */
  77783. markAsUnprocessed(): void;
  77784. /**
  77785. * Marks the material to indicate all of its defines need to be re-calculated
  77786. */
  77787. markAllAsDirty(): void;
  77788. /**
  77789. * Marks the material to indicate that image processing needs to be re-calculated
  77790. */
  77791. markAsImageProcessingDirty(): void;
  77792. /**
  77793. * Marks the material to indicate the lights need to be re-calculated
  77794. * @param disposed Defines whether the light is dirty due to dispose or not
  77795. */
  77796. markAsLightDirty(disposed?: boolean): void;
  77797. /**
  77798. * Marks the attribute state as changed
  77799. */
  77800. markAsAttributesDirty(): void;
  77801. /**
  77802. * Marks the texture state as changed
  77803. */
  77804. markAsTexturesDirty(): void;
  77805. /**
  77806. * Marks the fresnel state as changed
  77807. */
  77808. markAsFresnelDirty(): void;
  77809. /**
  77810. * Marks the misc state as changed
  77811. */
  77812. markAsMiscDirty(): void;
  77813. /**
  77814. * Rebuilds the material defines
  77815. */
  77816. rebuild(): void;
  77817. /**
  77818. * Specifies if two material defines are equal
  77819. * @param other - A material define instance to compare to
  77820. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  77821. */
  77822. isEqual(other: MaterialDefines): boolean;
  77823. /**
  77824. * Clones this instance's defines to another instance
  77825. * @param other - material defines to clone values to
  77826. */
  77827. cloneTo(other: MaterialDefines): void;
  77828. /**
  77829. * Resets the material define values
  77830. */
  77831. reset(): void;
  77832. /**
  77833. * Converts the material define values to a string
  77834. * @returns - String of material define information
  77835. */
  77836. toString(): string;
  77837. }
  77838. }
  77839. declare module BABYLON {
  77840. /**
  77841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  77842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  77843. * 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;
  77844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  77845. */
  77846. export class ColorCurves {
  77847. private _dirty;
  77848. private _tempColor;
  77849. private _globalCurve;
  77850. private _highlightsCurve;
  77851. private _midtonesCurve;
  77852. private _shadowsCurve;
  77853. private _positiveCurve;
  77854. private _negativeCurve;
  77855. private _globalHue;
  77856. private _globalDensity;
  77857. private _globalSaturation;
  77858. private _globalExposure;
  77859. /**
  77860. * Gets the global Hue value.
  77861. * 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).
  77862. */
  77863. /**
  77864. * Sets the global Hue value.
  77865. * 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).
  77866. */
  77867. globalHue: number;
  77868. /**
  77869. * Gets the global Density value.
  77870. * 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.
  77871. * Values less than zero provide a filter of opposite hue.
  77872. */
  77873. /**
  77874. * Sets the global Density value.
  77875. * 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.
  77876. * Values less than zero provide a filter of opposite hue.
  77877. */
  77878. globalDensity: number;
  77879. /**
  77880. * Gets the global Saturation value.
  77881. * 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.
  77882. */
  77883. /**
  77884. * Sets the global Saturation value.
  77885. * 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.
  77886. */
  77887. globalSaturation: number;
  77888. /**
  77889. * Gets the global Exposure value.
  77890. * 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.
  77891. */
  77892. /**
  77893. * Sets the global Exposure value.
  77894. * 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.
  77895. */
  77896. globalExposure: number;
  77897. private _highlightsHue;
  77898. private _highlightsDensity;
  77899. private _highlightsSaturation;
  77900. private _highlightsExposure;
  77901. /**
  77902. * Gets the highlights Hue value.
  77903. * 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).
  77904. */
  77905. /**
  77906. * Sets the highlights Hue value.
  77907. * 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).
  77908. */
  77909. highlightsHue: number;
  77910. /**
  77911. * Gets the highlights Density value.
  77912. * 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.
  77913. * Values less than zero provide a filter of opposite hue.
  77914. */
  77915. /**
  77916. * Sets the highlights Density value.
  77917. * 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.
  77918. * Values less than zero provide a filter of opposite hue.
  77919. */
  77920. highlightsDensity: number;
  77921. /**
  77922. * Gets the highlights Saturation value.
  77923. * 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.
  77924. */
  77925. /**
  77926. * Sets the highlights Saturation value.
  77927. * 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.
  77928. */
  77929. highlightsSaturation: number;
  77930. /**
  77931. * Gets the highlights Exposure value.
  77932. * 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.
  77933. */
  77934. /**
  77935. * Sets the highlights Exposure value.
  77936. * 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.
  77937. */
  77938. highlightsExposure: number;
  77939. private _midtonesHue;
  77940. private _midtonesDensity;
  77941. private _midtonesSaturation;
  77942. private _midtonesExposure;
  77943. /**
  77944. * Gets the midtones Hue value.
  77945. * 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).
  77946. */
  77947. /**
  77948. * Sets the midtones Hue value.
  77949. * 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).
  77950. */
  77951. midtonesHue: number;
  77952. /**
  77953. * Gets the midtones Density value.
  77954. * 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.
  77955. * Values less than zero provide a filter of opposite hue.
  77956. */
  77957. /**
  77958. * Sets the midtones Density value.
  77959. * 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.
  77960. * Values less than zero provide a filter of opposite hue.
  77961. */
  77962. midtonesDensity: number;
  77963. /**
  77964. * Gets the midtones Saturation value.
  77965. * 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.
  77966. */
  77967. /**
  77968. * Sets the midtones Saturation value.
  77969. * 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.
  77970. */
  77971. midtonesSaturation: number;
  77972. /**
  77973. * Gets the midtones Exposure value.
  77974. * 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.
  77975. */
  77976. /**
  77977. * Sets the midtones Exposure value.
  77978. * 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.
  77979. */
  77980. midtonesExposure: number;
  77981. private _shadowsHue;
  77982. private _shadowsDensity;
  77983. private _shadowsSaturation;
  77984. private _shadowsExposure;
  77985. /**
  77986. * Gets the shadows Hue value.
  77987. * 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).
  77988. */
  77989. /**
  77990. * Sets the shadows Hue value.
  77991. * 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).
  77992. */
  77993. shadowsHue: number;
  77994. /**
  77995. * Gets the shadows Density value.
  77996. * 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.
  77997. * Values less than zero provide a filter of opposite hue.
  77998. */
  77999. /**
  78000. * Sets the shadows Density value.
  78001. * 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.
  78002. * Values less than zero provide a filter of opposite hue.
  78003. */
  78004. shadowsDensity: number;
  78005. /**
  78006. * Gets the shadows Saturation value.
  78007. * 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.
  78008. */
  78009. /**
  78010. * Sets the shadows Saturation value.
  78011. * 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.
  78012. */
  78013. shadowsSaturation: number;
  78014. /**
  78015. * Gets the shadows Exposure value.
  78016. * 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.
  78017. */
  78018. /**
  78019. * Sets the shadows Exposure value.
  78020. * 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.
  78021. */
  78022. shadowsExposure: number;
  78023. /**
  78024. * Returns the class name
  78025. * @returns The class name
  78026. */
  78027. getClassName(): string;
  78028. /**
  78029. * Binds the color curves to the shader.
  78030. * @param colorCurves The color curve to bind
  78031. * @param effect The effect to bind to
  78032. * @param positiveUniform The positive uniform shader parameter
  78033. * @param neutralUniform The neutral uniform shader parameter
  78034. * @param negativeUniform The negative uniform shader parameter
  78035. */
  78036. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78037. /**
  78038. * Prepare the list of uniforms associated with the ColorCurves effects.
  78039. * @param uniformsList The list of uniforms used in the effect
  78040. */
  78041. static PrepareUniforms(uniformsList: string[]): void;
  78042. /**
  78043. * Returns color grading data based on a hue, density, saturation and exposure value.
  78044. * @param filterHue The hue of the color filter.
  78045. * @param filterDensity The density of the color filter.
  78046. * @param saturation The saturation.
  78047. * @param exposure The exposure.
  78048. * @param result The result data container.
  78049. */
  78050. private getColorGradingDataToRef;
  78051. /**
  78052. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78053. * @param value The input slider value in range [-100,100].
  78054. * @returns Adjusted value.
  78055. */
  78056. private static applyColorGradingSliderNonlinear;
  78057. /**
  78058. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78059. * @param hue The hue (H) input.
  78060. * @param saturation The saturation (S) input.
  78061. * @param brightness The brightness (B) input.
  78062. * @result An RGBA color represented as Vector4.
  78063. */
  78064. private static fromHSBToRef;
  78065. /**
  78066. * Returns a value clamped between min and max
  78067. * @param value The value to clamp
  78068. * @param min The minimum of value
  78069. * @param max The maximum of value
  78070. * @returns The clamped value.
  78071. */
  78072. private static clamp;
  78073. /**
  78074. * Clones the current color curve instance.
  78075. * @return The cloned curves
  78076. */
  78077. clone(): ColorCurves;
  78078. /**
  78079. * Serializes the current color curve instance to a json representation.
  78080. * @return a JSON representation
  78081. */
  78082. serialize(): any;
  78083. /**
  78084. * Parses the color curve from a json representation.
  78085. * @param source the JSON source to parse
  78086. * @return The parsed curves
  78087. */
  78088. static Parse(source: any): ColorCurves;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * Interface to follow in your material defines to integrate easily the
  78094. * Image proccessing functions.
  78095. * @hidden
  78096. */
  78097. export interface IImageProcessingConfigurationDefines {
  78098. IMAGEPROCESSING: boolean;
  78099. VIGNETTE: boolean;
  78100. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78101. VIGNETTEBLENDMODEOPAQUE: boolean;
  78102. TONEMAPPING: boolean;
  78103. TONEMAPPING_ACES: boolean;
  78104. CONTRAST: boolean;
  78105. EXPOSURE: boolean;
  78106. COLORCURVES: boolean;
  78107. COLORGRADING: boolean;
  78108. COLORGRADING3D: boolean;
  78109. SAMPLER3DGREENDEPTH: boolean;
  78110. SAMPLER3DBGRMAP: boolean;
  78111. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78112. }
  78113. /**
  78114. * @hidden
  78115. */
  78116. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78117. IMAGEPROCESSING: boolean;
  78118. VIGNETTE: boolean;
  78119. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78120. VIGNETTEBLENDMODEOPAQUE: boolean;
  78121. TONEMAPPING: boolean;
  78122. TONEMAPPING_ACES: boolean;
  78123. CONTRAST: boolean;
  78124. COLORCURVES: boolean;
  78125. COLORGRADING: boolean;
  78126. COLORGRADING3D: boolean;
  78127. SAMPLER3DGREENDEPTH: boolean;
  78128. SAMPLER3DBGRMAP: boolean;
  78129. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78130. EXPOSURE: boolean;
  78131. constructor();
  78132. }
  78133. /**
  78134. * This groups together the common properties used for image processing either in direct forward pass
  78135. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78136. * or not.
  78137. */
  78138. export class ImageProcessingConfiguration {
  78139. /**
  78140. * Default tone mapping applied in BabylonJS.
  78141. */
  78142. static readonly TONEMAPPING_STANDARD: number;
  78143. /**
  78144. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78145. * to other engines rendering to increase portability.
  78146. */
  78147. static readonly TONEMAPPING_ACES: number;
  78148. /**
  78149. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78150. */
  78151. colorCurves: Nullable<ColorCurves>;
  78152. private _colorCurvesEnabled;
  78153. /**
  78154. * Gets wether the color curves effect is enabled.
  78155. */
  78156. /**
  78157. * Sets wether the color curves effect is enabled.
  78158. */
  78159. colorCurvesEnabled: boolean;
  78160. private _colorGradingTexture;
  78161. /**
  78162. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78163. */
  78164. /**
  78165. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78166. */
  78167. colorGradingTexture: Nullable<BaseTexture>;
  78168. private _colorGradingEnabled;
  78169. /**
  78170. * Gets wether the color grading effect is enabled.
  78171. */
  78172. /**
  78173. * Sets wether the color grading effect is enabled.
  78174. */
  78175. colorGradingEnabled: boolean;
  78176. private _colorGradingWithGreenDepth;
  78177. /**
  78178. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78179. */
  78180. /**
  78181. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78182. */
  78183. colorGradingWithGreenDepth: boolean;
  78184. private _colorGradingBGR;
  78185. /**
  78186. * Gets wether the color grading texture contains BGR values.
  78187. */
  78188. /**
  78189. * Sets wether the color grading texture contains BGR values.
  78190. */
  78191. colorGradingBGR: boolean;
  78192. /** @hidden */
  78193. _exposure: number;
  78194. /**
  78195. * Gets the Exposure used in the effect.
  78196. */
  78197. /**
  78198. * Sets the Exposure used in the effect.
  78199. */
  78200. exposure: number;
  78201. private _toneMappingEnabled;
  78202. /**
  78203. * Gets wether the tone mapping effect is enabled.
  78204. */
  78205. /**
  78206. * Sets wether the tone mapping effect is enabled.
  78207. */
  78208. toneMappingEnabled: boolean;
  78209. private _toneMappingType;
  78210. /**
  78211. * Gets the type of tone mapping effect.
  78212. */
  78213. /**
  78214. * Sets the type of tone mapping effect used in BabylonJS.
  78215. */
  78216. toneMappingType: number;
  78217. protected _contrast: number;
  78218. /**
  78219. * Gets the contrast used in the effect.
  78220. */
  78221. /**
  78222. * Sets the contrast used in the effect.
  78223. */
  78224. contrast: number;
  78225. /**
  78226. * Vignette stretch size.
  78227. */
  78228. vignetteStretch: number;
  78229. /**
  78230. * Vignette centre X Offset.
  78231. */
  78232. vignetteCentreX: number;
  78233. /**
  78234. * Vignette centre Y Offset.
  78235. */
  78236. vignetteCentreY: number;
  78237. /**
  78238. * Vignette weight or intensity of the vignette effect.
  78239. */
  78240. vignetteWeight: number;
  78241. /**
  78242. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78243. * if vignetteEnabled is set to true.
  78244. */
  78245. vignetteColor: Color4;
  78246. /**
  78247. * Camera field of view used by the Vignette effect.
  78248. */
  78249. vignetteCameraFov: number;
  78250. private _vignetteBlendMode;
  78251. /**
  78252. * Gets the vignette blend mode allowing different kind of effect.
  78253. */
  78254. /**
  78255. * Sets the vignette blend mode allowing different kind of effect.
  78256. */
  78257. vignetteBlendMode: number;
  78258. private _vignetteEnabled;
  78259. /**
  78260. * Gets wether the vignette effect is enabled.
  78261. */
  78262. /**
  78263. * Sets wether the vignette effect is enabled.
  78264. */
  78265. vignetteEnabled: boolean;
  78266. private _applyByPostProcess;
  78267. /**
  78268. * Gets wether the image processing is applied through a post process or not.
  78269. */
  78270. /**
  78271. * Sets wether the image processing is applied through a post process or not.
  78272. */
  78273. applyByPostProcess: boolean;
  78274. private _isEnabled;
  78275. /**
  78276. * Gets wether the image processing is enabled or not.
  78277. */
  78278. /**
  78279. * Sets wether the image processing is enabled or not.
  78280. */
  78281. isEnabled: boolean;
  78282. /**
  78283. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  78284. */
  78285. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  78286. /**
  78287. * Method called each time the image processing information changes requires to recompile the effect.
  78288. */
  78289. protected _updateParameters(): void;
  78290. /**
  78291. * Gets the current class name.
  78292. * @return "ImageProcessingConfiguration"
  78293. */
  78294. getClassName(): string;
  78295. /**
  78296. * Prepare the list of uniforms associated with the Image Processing effects.
  78297. * @param uniforms The list of uniforms used in the effect
  78298. * @param defines the list of defines currently in use
  78299. */
  78300. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  78301. /**
  78302. * Prepare the list of samplers associated with the Image Processing effects.
  78303. * @param samplersList The list of uniforms used in the effect
  78304. * @param defines the list of defines currently in use
  78305. */
  78306. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  78307. /**
  78308. * Prepare the list of defines associated to the shader.
  78309. * @param defines the list of defines to complete
  78310. * @param forPostProcess Define if we are currently in post process mode or not
  78311. */
  78312. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  78313. /**
  78314. * Returns true if all the image processing information are ready.
  78315. * @returns True if ready, otherwise, false
  78316. */
  78317. isReady(): boolean;
  78318. /**
  78319. * Binds the image processing to the shader.
  78320. * @param effect The effect to bind to
  78321. * @param overrideAspectRatio Override the aspect ratio of the effect
  78322. */
  78323. bind(effect: Effect, overrideAspectRatio?: number): void;
  78324. /**
  78325. * Clones the current image processing instance.
  78326. * @return The cloned image processing
  78327. */
  78328. clone(): ImageProcessingConfiguration;
  78329. /**
  78330. * Serializes the current image processing instance to a json representation.
  78331. * @return a JSON representation
  78332. */
  78333. serialize(): any;
  78334. /**
  78335. * Parses the image processing from a json representation.
  78336. * @param source the JSON source to parse
  78337. * @return The parsed image processing
  78338. */
  78339. static Parse(source: any): ImageProcessingConfiguration;
  78340. private static _VIGNETTEMODE_MULTIPLY;
  78341. private static _VIGNETTEMODE_OPAQUE;
  78342. /**
  78343. * Used to apply the vignette as a mix with the pixel color.
  78344. */
  78345. static readonly VIGNETTEMODE_MULTIPLY: number;
  78346. /**
  78347. * Used to apply the vignette as a replacement of the pixel color.
  78348. */
  78349. static readonly VIGNETTEMODE_OPAQUE: number;
  78350. }
  78351. }
  78352. declare module BABYLON {
  78353. /** @hidden */
  78354. export var postprocessVertexShader: {
  78355. name: string;
  78356. shader: string;
  78357. };
  78358. }
  78359. declare module BABYLON {
  78360. interface ThinEngine {
  78361. /**
  78362. * Creates a new render target texture
  78363. * @param size defines the size of the texture
  78364. * @param options defines the options used to create the texture
  78365. * @returns a new render target texture stored in an InternalTexture
  78366. */
  78367. createRenderTargetTexture(size: number | {
  78368. width: number;
  78369. height: number;
  78370. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  78371. /**
  78372. * Creates a depth stencil texture.
  78373. * This is only available in WebGL 2 or with the depth texture extension available.
  78374. * @param size The size of face edge in the texture.
  78375. * @param options The options defining the texture.
  78376. * @returns The texture
  78377. */
  78378. createDepthStencilTexture(size: number | {
  78379. width: number;
  78380. height: number;
  78381. }, options: DepthTextureCreationOptions): InternalTexture;
  78382. /** @hidden */
  78383. _createDepthStencilTexture(size: number | {
  78384. width: number;
  78385. height: number;
  78386. }, options: DepthTextureCreationOptions): InternalTexture;
  78387. }
  78388. }
  78389. declare module BABYLON {
  78390. /** Defines supported spaces */
  78391. export enum Space {
  78392. /** Local (object) space */
  78393. LOCAL = 0,
  78394. /** World space */
  78395. WORLD = 1,
  78396. /** Bone space */
  78397. BONE = 2
  78398. }
  78399. /** Defines the 3 main axes */
  78400. export class Axis {
  78401. /** X axis */
  78402. static X: Vector3;
  78403. /** Y axis */
  78404. static Y: Vector3;
  78405. /** Z axis */
  78406. static Z: Vector3;
  78407. }
  78408. }
  78409. declare module BABYLON {
  78410. /**
  78411. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  78412. * This is the base of the follow, arc rotate cameras and Free camera
  78413. * @see http://doc.babylonjs.com/features/cameras
  78414. */
  78415. export class TargetCamera extends Camera {
  78416. private static _RigCamTransformMatrix;
  78417. private static _TargetTransformMatrix;
  78418. private static _TargetFocalPoint;
  78419. /**
  78420. * Define the current direction the camera is moving to
  78421. */
  78422. cameraDirection: Vector3;
  78423. /**
  78424. * Define the current rotation the camera is rotating to
  78425. */
  78426. cameraRotation: Vector2;
  78427. /**
  78428. * When set, the up vector of the camera will be updated by the rotation of the camera
  78429. */
  78430. updateUpVectorFromRotation: boolean;
  78431. private _tmpQuaternion;
  78432. /**
  78433. * Define the current rotation of the camera
  78434. */
  78435. rotation: Vector3;
  78436. /**
  78437. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  78438. */
  78439. rotationQuaternion: Quaternion;
  78440. /**
  78441. * Define the current speed of the camera
  78442. */
  78443. speed: number;
  78444. /**
  78445. * Add constraint to the camera to prevent it to move freely in all directions and
  78446. * around all axis.
  78447. */
  78448. noRotationConstraint: boolean;
  78449. /**
  78450. * Define the current target of the camera as an object or a position.
  78451. */
  78452. lockedTarget: any;
  78453. /** @hidden */
  78454. _currentTarget: Vector3;
  78455. /** @hidden */
  78456. _initialFocalDistance: number;
  78457. /** @hidden */
  78458. _viewMatrix: Matrix;
  78459. /** @hidden */
  78460. _camMatrix: Matrix;
  78461. /** @hidden */
  78462. _cameraTransformMatrix: Matrix;
  78463. /** @hidden */
  78464. _cameraRotationMatrix: Matrix;
  78465. /** @hidden */
  78466. _referencePoint: Vector3;
  78467. /** @hidden */
  78468. _transformedReferencePoint: Vector3;
  78469. protected _globalCurrentTarget: Vector3;
  78470. protected _globalCurrentUpVector: Vector3;
  78471. /** @hidden */
  78472. _reset: () => void;
  78473. private _defaultUp;
  78474. /**
  78475. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  78476. * This is the base of the follow, arc rotate cameras and Free camera
  78477. * @see http://doc.babylonjs.com/features/cameras
  78478. * @param name Defines the name of the camera in the scene
  78479. * @param position Defines the start position of the camera in the scene
  78480. * @param scene Defines the scene the camera belongs to
  78481. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78482. */
  78483. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78484. /**
  78485. * Gets the position in front of the camera at a given distance.
  78486. * @param distance The distance from the camera we want the position to be
  78487. * @returns the position
  78488. */
  78489. getFrontPosition(distance: number): Vector3;
  78490. /** @hidden */
  78491. _getLockedTargetPosition(): Nullable<Vector3>;
  78492. private _storedPosition;
  78493. private _storedRotation;
  78494. private _storedRotationQuaternion;
  78495. /**
  78496. * Store current camera state of the camera (fov, position, rotation, etc..)
  78497. * @returns the camera
  78498. */
  78499. storeState(): Camera;
  78500. /**
  78501. * Restored camera state. You must call storeState() first
  78502. * @returns whether it was successful or not
  78503. * @hidden
  78504. */
  78505. _restoreStateValues(): boolean;
  78506. /** @hidden */
  78507. _initCache(): void;
  78508. /** @hidden */
  78509. _updateCache(ignoreParentClass?: boolean): void;
  78510. /** @hidden */
  78511. _isSynchronizedViewMatrix(): boolean;
  78512. /** @hidden */
  78513. _computeLocalCameraSpeed(): number;
  78514. /**
  78515. * Defines the target the camera should look at.
  78516. * @param target Defines the new target as a Vector or a mesh
  78517. */
  78518. setTarget(target: Vector3): void;
  78519. /**
  78520. * Return the current target position of the camera. This value is expressed in local space.
  78521. * @returns the target position
  78522. */
  78523. getTarget(): Vector3;
  78524. /** @hidden */
  78525. _decideIfNeedsToMove(): boolean;
  78526. /** @hidden */
  78527. _updatePosition(): void;
  78528. /** @hidden */
  78529. _checkInputs(): void;
  78530. protected _updateCameraRotationMatrix(): void;
  78531. /**
  78532. * 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)
  78533. * @returns the current camera
  78534. */
  78535. private _rotateUpVectorWithCameraRotationMatrix;
  78536. private _cachedRotationZ;
  78537. private _cachedQuaternionRotationZ;
  78538. /** @hidden */
  78539. _getViewMatrix(): Matrix;
  78540. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  78541. /**
  78542. * @hidden
  78543. */
  78544. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  78545. /**
  78546. * @hidden
  78547. */
  78548. _updateRigCameras(): void;
  78549. private _getRigCamPositionAndTarget;
  78550. /**
  78551. * Gets the current object class name.
  78552. * @return the class name
  78553. */
  78554. getClassName(): string;
  78555. }
  78556. }
  78557. declare module BABYLON {
  78558. /**
  78559. * Gather the list of keyboard event types as constants.
  78560. */
  78561. export class KeyboardEventTypes {
  78562. /**
  78563. * The keydown event is fired when a key becomes active (pressed).
  78564. */
  78565. static readonly KEYDOWN: number;
  78566. /**
  78567. * The keyup event is fired when a key has been released.
  78568. */
  78569. static readonly KEYUP: number;
  78570. }
  78571. /**
  78572. * This class is used to store keyboard related info for the onKeyboardObservable event.
  78573. */
  78574. export class KeyboardInfo {
  78575. /**
  78576. * Defines the type of event (KeyboardEventTypes)
  78577. */
  78578. type: number;
  78579. /**
  78580. * Defines the related dom event
  78581. */
  78582. event: KeyboardEvent;
  78583. /**
  78584. * Instantiates a new keyboard info.
  78585. * This class is used to store keyboard related info for the onKeyboardObservable event.
  78586. * @param type Defines the type of event (KeyboardEventTypes)
  78587. * @param event Defines the related dom event
  78588. */
  78589. constructor(
  78590. /**
  78591. * Defines the type of event (KeyboardEventTypes)
  78592. */
  78593. type: number,
  78594. /**
  78595. * Defines the related dom event
  78596. */
  78597. event: KeyboardEvent);
  78598. }
  78599. /**
  78600. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  78601. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  78602. */
  78603. export class KeyboardInfoPre extends KeyboardInfo {
  78604. /**
  78605. * Defines the type of event (KeyboardEventTypes)
  78606. */
  78607. type: number;
  78608. /**
  78609. * Defines the related dom event
  78610. */
  78611. event: KeyboardEvent;
  78612. /**
  78613. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  78614. */
  78615. skipOnPointerObservable: boolean;
  78616. /**
  78617. * Instantiates a new keyboard pre info.
  78618. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  78619. * @param type Defines the type of event (KeyboardEventTypes)
  78620. * @param event Defines the related dom event
  78621. */
  78622. constructor(
  78623. /**
  78624. * Defines the type of event (KeyboardEventTypes)
  78625. */
  78626. type: number,
  78627. /**
  78628. * Defines the related dom event
  78629. */
  78630. event: KeyboardEvent);
  78631. }
  78632. }
  78633. declare module BABYLON {
  78634. /**
  78635. * Manage the keyboard inputs to control the movement of a free camera.
  78636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78637. */
  78638. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  78639. /**
  78640. * Defines the camera the input is attached to.
  78641. */
  78642. camera: FreeCamera;
  78643. /**
  78644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78645. */
  78646. keysUp: number[];
  78647. /**
  78648. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78649. */
  78650. keysDown: number[];
  78651. /**
  78652. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78653. */
  78654. keysLeft: number[];
  78655. /**
  78656. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78657. */
  78658. keysRight: number[];
  78659. private _keys;
  78660. private _onCanvasBlurObserver;
  78661. private _onKeyboardObserver;
  78662. private _engine;
  78663. private _scene;
  78664. /**
  78665. * Attach the input controls to a specific dom element to get the input from.
  78666. * @param element Defines the element the controls should be listened from
  78667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78668. */
  78669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78670. /**
  78671. * Detach the current controls from the specified dom element.
  78672. * @param element Defines the element to stop listening the inputs from
  78673. */
  78674. detachControl(element: Nullable<HTMLElement>): void;
  78675. /**
  78676. * Update the current camera state depending on the inputs that have been used this frame.
  78677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78678. */
  78679. checkInputs(): void;
  78680. /**
  78681. * Gets the class name of the current intput.
  78682. * @returns the class name
  78683. */
  78684. getClassName(): string;
  78685. /** @hidden */
  78686. _onLostFocus(): void;
  78687. /**
  78688. * Get the friendly name associated with the input class.
  78689. * @returns the input friendly name
  78690. */
  78691. getSimpleName(): string;
  78692. }
  78693. }
  78694. declare module BABYLON {
  78695. /**
  78696. * Interface describing all the common properties and methods a shadow light needs to implement.
  78697. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  78698. * as well as binding the different shadow properties to the effects.
  78699. */
  78700. export interface IShadowLight extends Light {
  78701. /**
  78702. * The light id in the scene (used in scene.findLighById for instance)
  78703. */
  78704. id: string;
  78705. /**
  78706. * The position the shdow will be casted from.
  78707. */
  78708. position: Vector3;
  78709. /**
  78710. * In 2d mode (needCube being false), the direction used to cast the shadow.
  78711. */
  78712. direction: Vector3;
  78713. /**
  78714. * The transformed position. Position of the light in world space taking parenting in account.
  78715. */
  78716. transformedPosition: Vector3;
  78717. /**
  78718. * The transformed direction. Direction of the light in world space taking parenting in account.
  78719. */
  78720. transformedDirection: Vector3;
  78721. /**
  78722. * The friendly name of the light in the scene.
  78723. */
  78724. name: string;
  78725. /**
  78726. * Defines the shadow projection clipping minimum z value.
  78727. */
  78728. shadowMinZ: number;
  78729. /**
  78730. * Defines the shadow projection clipping maximum z value.
  78731. */
  78732. shadowMaxZ: number;
  78733. /**
  78734. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78735. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78736. */
  78737. computeTransformedInformation(): boolean;
  78738. /**
  78739. * Gets the scene the light belongs to.
  78740. * @returns The scene
  78741. */
  78742. getScene(): Scene;
  78743. /**
  78744. * Callback defining a custom Projection Matrix Builder.
  78745. * This can be used to override the default projection matrix computation.
  78746. */
  78747. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78748. /**
  78749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78750. * @param matrix The materix to updated with the projection information
  78751. * @param viewMatrix The transform matrix of the light
  78752. * @param renderList The list of mesh to render in the map
  78753. * @returns The current light
  78754. */
  78755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78756. /**
  78757. * Gets the current depth scale used in ESM.
  78758. * @returns The scale
  78759. */
  78760. getDepthScale(): number;
  78761. /**
  78762. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78763. * @returns true if a cube texture needs to be use
  78764. */
  78765. needCube(): boolean;
  78766. /**
  78767. * Detects if the projection matrix requires to be recomputed this frame.
  78768. * @returns true if it requires to be recomputed otherwise, false.
  78769. */
  78770. needProjectionMatrixCompute(): boolean;
  78771. /**
  78772. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78773. */
  78774. forceProjectionMatrixCompute(): void;
  78775. /**
  78776. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78777. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78778. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78779. */
  78780. getShadowDirection(faceIndex?: number): Vector3;
  78781. /**
  78782. * Gets the minZ used for shadow according to both the scene and the light.
  78783. * @param activeCamera The camera we are returning the min for
  78784. * @returns the depth min z
  78785. */
  78786. getDepthMinZ(activeCamera: Camera): number;
  78787. /**
  78788. * Gets the maxZ used for shadow according to both the scene and the light.
  78789. * @param activeCamera The camera we are returning the max for
  78790. * @returns the depth max z
  78791. */
  78792. getDepthMaxZ(activeCamera: Camera): number;
  78793. }
  78794. /**
  78795. * Base implementation IShadowLight
  78796. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  78797. */
  78798. export abstract class ShadowLight extends Light implements IShadowLight {
  78799. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  78800. protected _position: Vector3;
  78801. protected _setPosition(value: Vector3): void;
  78802. /**
  78803. * Sets the position the shadow will be casted from. Also use as the light position for both
  78804. * point and spot lights.
  78805. */
  78806. /**
  78807. * Sets the position the shadow will be casted from. Also use as the light position for both
  78808. * point and spot lights.
  78809. */
  78810. position: Vector3;
  78811. protected _direction: Vector3;
  78812. protected _setDirection(value: Vector3): void;
  78813. /**
  78814. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  78815. * Also use as the light direction on spot and directional lights.
  78816. */
  78817. /**
  78818. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  78819. * Also use as the light direction on spot and directional lights.
  78820. */
  78821. direction: Vector3;
  78822. private _shadowMinZ;
  78823. /**
  78824. * Gets the shadow projection clipping minimum z value.
  78825. */
  78826. /**
  78827. * Sets the shadow projection clipping minimum z value.
  78828. */
  78829. shadowMinZ: number;
  78830. private _shadowMaxZ;
  78831. /**
  78832. * Sets the shadow projection clipping maximum z value.
  78833. */
  78834. /**
  78835. * Gets the shadow projection clipping maximum z value.
  78836. */
  78837. shadowMaxZ: number;
  78838. /**
  78839. * Callback defining a custom Projection Matrix Builder.
  78840. * This can be used to override the default projection matrix computation.
  78841. */
  78842. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78843. /**
  78844. * The transformed position. Position of the light in world space taking parenting in account.
  78845. */
  78846. transformedPosition: Vector3;
  78847. /**
  78848. * The transformed direction. Direction of the light in world space taking parenting in account.
  78849. */
  78850. transformedDirection: Vector3;
  78851. private _needProjectionMatrixCompute;
  78852. /**
  78853. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78854. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78855. */
  78856. computeTransformedInformation(): boolean;
  78857. /**
  78858. * Return the depth scale used for the shadow map.
  78859. * @returns the depth scale.
  78860. */
  78861. getDepthScale(): number;
  78862. /**
  78863. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78864. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78865. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78866. */
  78867. getShadowDirection(faceIndex?: number): Vector3;
  78868. /**
  78869. * Returns the ShadowLight absolute position in the World.
  78870. * @returns the position vector in world space
  78871. */
  78872. getAbsolutePosition(): Vector3;
  78873. /**
  78874. * Sets the ShadowLight direction toward the passed target.
  78875. * @param target The point to target in local space
  78876. * @returns the updated ShadowLight direction
  78877. */
  78878. setDirectionToTarget(target: Vector3): Vector3;
  78879. /**
  78880. * Returns the light rotation in euler definition.
  78881. * @returns the x y z rotation in local space.
  78882. */
  78883. getRotation(): Vector3;
  78884. /**
  78885. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78886. * @returns true if a cube texture needs to be use
  78887. */
  78888. needCube(): boolean;
  78889. /**
  78890. * Detects if the projection matrix requires to be recomputed this frame.
  78891. * @returns true if it requires to be recomputed otherwise, false.
  78892. */
  78893. needProjectionMatrixCompute(): boolean;
  78894. /**
  78895. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78896. */
  78897. forceProjectionMatrixCompute(): void;
  78898. /** @hidden */
  78899. _initCache(): void;
  78900. /** @hidden */
  78901. _isSynchronized(): boolean;
  78902. /**
  78903. * Computes the world matrix of the node
  78904. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78905. * @returns the world matrix
  78906. */
  78907. computeWorldMatrix(force?: boolean): Matrix;
  78908. /**
  78909. * Gets the minZ used for shadow according to both the scene and the light.
  78910. * @param activeCamera The camera we are returning the min for
  78911. * @returns the depth min z
  78912. */
  78913. getDepthMinZ(activeCamera: Camera): number;
  78914. /**
  78915. * Gets the maxZ used for shadow according to both the scene and the light.
  78916. * @param activeCamera The camera we are returning the max for
  78917. * @returns the depth max z
  78918. */
  78919. getDepthMaxZ(activeCamera: Camera): number;
  78920. /**
  78921. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78922. * @param matrix The materix to updated with the projection information
  78923. * @param viewMatrix The transform matrix of the light
  78924. * @param renderList The list of mesh to render in the map
  78925. * @returns The current light
  78926. */
  78927. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78928. }
  78929. }
  78930. declare module BABYLON {
  78931. /**
  78932. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  78933. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  78934. */
  78935. export class EffectFallbacks implements IEffectFallbacks {
  78936. private _defines;
  78937. private _currentRank;
  78938. private _maxRank;
  78939. private _mesh;
  78940. /**
  78941. * Removes the fallback from the bound mesh.
  78942. */
  78943. unBindMesh(): void;
  78944. /**
  78945. * Adds a fallback on the specified property.
  78946. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78947. * @param define The name of the define in the shader
  78948. */
  78949. addFallback(rank: number, define: string): void;
  78950. /**
  78951. * Sets the mesh to use CPU skinning when needing to fallback.
  78952. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78953. * @param mesh The mesh to use the fallbacks.
  78954. */
  78955. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  78956. /**
  78957. * Checks to see if more fallbacks are still availible.
  78958. */
  78959. readonly hasMoreFallbacks: boolean;
  78960. /**
  78961. * Removes the defines that should be removed when falling back.
  78962. * @param currentDefines defines the current define statements for the shader.
  78963. * @param effect defines the current effect we try to compile
  78964. * @returns The resulting defines with defines of the current rank removed.
  78965. */
  78966. reduce(currentDefines: string, effect: Effect): string;
  78967. }
  78968. }
  78969. declare module BABYLON {
  78970. /**
  78971. * "Static Class" containing the most commonly used helper while dealing with material for
  78972. * rendering purpose.
  78973. *
  78974. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  78975. *
  78976. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  78977. */
  78978. export class MaterialHelper {
  78979. /**
  78980. * Bind the current view position to an effect.
  78981. * @param effect The effect to be bound
  78982. * @param scene The scene the eyes position is used from
  78983. */
  78984. static BindEyePosition(effect: Effect, scene: Scene): void;
  78985. /**
  78986. * Helps preparing the defines values about the UVs in used in the effect.
  78987. * UVs are shared as much as we can accross channels in the shaders.
  78988. * @param texture The texture we are preparing the UVs for
  78989. * @param defines The defines to update
  78990. * @param key The channel key "diffuse", "specular"... used in the shader
  78991. */
  78992. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  78993. /**
  78994. * Binds a texture matrix value to its corrsponding uniform
  78995. * @param texture The texture to bind the matrix for
  78996. * @param uniformBuffer The uniform buffer receivin the data
  78997. * @param key The channel key "diffuse", "specular"... used in the shader
  78998. */
  78999. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79000. /**
  79001. * Gets the current status of the fog (should it be enabled?)
  79002. * @param mesh defines the mesh to evaluate for fog support
  79003. * @param scene defines the hosting scene
  79004. * @returns true if fog must be enabled
  79005. */
  79006. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79007. /**
  79008. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79009. * @param mesh defines the current mesh
  79010. * @param scene defines the current scene
  79011. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79012. * @param pointsCloud defines if point cloud rendering has to be turned on
  79013. * @param fogEnabled defines if fog has to be turned on
  79014. * @param alphaTest defines if alpha testing has to be turned on
  79015. * @param defines defines the current list of defines
  79016. */
  79017. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79018. /**
  79019. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79020. * @param scene defines the current scene
  79021. * @param engine defines the current engine
  79022. * @param defines specifies the list of active defines
  79023. * @param useInstances defines if instances have to be turned on
  79024. * @param useClipPlane defines if clip plane have to be turned on
  79025. */
  79026. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79027. /**
  79028. * Prepares the defines for bones
  79029. * @param mesh The mesh containing the geometry data we will draw
  79030. * @param defines The defines to update
  79031. */
  79032. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79033. /**
  79034. * Prepares the defines for morph targets
  79035. * @param mesh The mesh containing the geometry data we will draw
  79036. * @param defines The defines to update
  79037. */
  79038. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79039. /**
  79040. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79041. * @param mesh The mesh containing the geometry data we will draw
  79042. * @param defines The defines to update
  79043. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79044. * @param useBones Precise whether bones should be used or not (override mesh info)
  79045. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79046. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79047. * @returns false if defines are considered not dirty and have not been checked
  79048. */
  79049. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79050. /**
  79051. * Prepares the defines related to multiview
  79052. * @param scene The scene we are intending to draw
  79053. * @param defines The defines to update
  79054. */
  79055. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79056. /**
  79057. * Prepares the defines related to the light information passed in parameter
  79058. * @param scene The scene we are intending to draw
  79059. * @param mesh The mesh the effect is compiling for
  79060. * @param light The light the effect is compiling for
  79061. * @param lightIndex The index of the light
  79062. * @param defines The defines to update
  79063. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79064. * @param state Defines the current state regarding what is needed (normals, etc...)
  79065. */
  79066. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79067. needNormals: boolean;
  79068. needRebuild: boolean;
  79069. shadowEnabled: boolean;
  79070. specularEnabled: boolean;
  79071. lightmapMode: boolean;
  79072. }): void;
  79073. /**
  79074. * Prepares the defines related to the light information passed in parameter
  79075. * @param scene The scene we are intending to draw
  79076. * @param mesh The mesh the effect is compiling for
  79077. * @param defines The defines to update
  79078. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79079. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79080. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79081. * @returns true if normals will be required for the rest of the effect
  79082. */
  79083. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79084. /**
  79085. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79086. * @param lightIndex defines the light index
  79087. * @param uniformsList The uniform list
  79088. * @param samplersList The sampler list
  79089. * @param projectedLightTexture defines if projected texture must be used
  79090. * @param uniformBuffersList defines an optional list of uniform buffers
  79091. */
  79092. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79093. /**
  79094. * Prepares the uniforms and samplers list to be used in the effect
  79095. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79096. * @param samplersList The sampler list
  79097. * @param defines The defines helping in the list generation
  79098. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79099. */
  79100. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79101. /**
  79102. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79103. * @param defines The defines to update while falling back
  79104. * @param fallbacks The authorized effect fallbacks
  79105. * @param maxSimultaneousLights The maximum number of lights allowed
  79106. * @param rank the current rank of the Effect
  79107. * @returns The newly affected rank
  79108. */
  79109. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79110. private static _TmpMorphInfluencers;
  79111. /**
  79112. * Prepares the list of attributes required for morph targets according to the effect defines.
  79113. * @param attribs The current list of supported attribs
  79114. * @param mesh The mesh to prepare the morph targets attributes for
  79115. * @param influencers The number of influencers
  79116. */
  79117. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79118. /**
  79119. * Prepares the list of attributes required for morph targets according to the effect defines.
  79120. * @param attribs The current list of supported attribs
  79121. * @param mesh The mesh to prepare the morph targets attributes for
  79122. * @param defines The current Defines of the effect
  79123. */
  79124. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79125. /**
  79126. * Prepares the list of attributes required for bones according to the effect defines.
  79127. * @param attribs The current list of supported attribs
  79128. * @param mesh The mesh to prepare the bones attributes for
  79129. * @param defines The current Defines of the effect
  79130. * @param fallbacks The current efffect fallback strategy
  79131. */
  79132. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79133. /**
  79134. * Check and prepare the list of attributes required for instances according to the effect defines.
  79135. * @param attribs The current list of supported attribs
  79136. * @param defines The current MaterialDefines of the effect
  79137. */
  79138. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79139. /**
  79140. * Add the list of attributes required for instances to the attribs array.
  79141. * @param attribs The current list of supported attribs
  79142. */
  79143. static PushAttributesForInstances(attribs: string[]): void;
  79144. /**
  79145. * Binds the light information to the effect.
  79146. * @param light The light containing the generator
  79147. * @param effect The effect we are binding the data to
  79148. * @param lightIndex The light index in the effect used to render
  79149. */
  79150. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79151. /**
  79152. * Binds the lights information from the scene to the effect for the given mesh.
  79153. * @param light Light to bind
  79154. * @param lightIndex Light index
  79155. * @param scene The scene where the light belongs to
  79156. * @param effect The effect we are binding the data to
  79157. * @param useSpecular Defines if specular is supported
  79158. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79159. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79160. */
  79161. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79162. /**
  79163. * Binds the lights information from the scene to the effect for the given mesh.
  79164. * @param scene The scene the lights belongs to
  79165. * @param mesh The mesh we are binding the information to render
  79166. * @param effect The effect we are binding the data to
  79167. * @param defines The generated defines for the effect
  79168. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79169. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79170. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79171. */
  79172. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79173. private static _tempFogColor;
  79174. /**
  79175. * Binds the fog information from the scene to the effect for the given mesh.
  79176. * @param scene The scene the lights belongs to
  79177. * @param mesh The mesh we are binding the information to render
  79178. * @param effect The effect we are binding the data to
  79179. * @param linearSpace Defines if the fog effect is applied in linear space
  79180. */
  79181. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79182. /**
  79183. * Binds the bones information from the mesh to the effect.
  79184. * @param mesh The mesh we are binding the information to render
  79185. * @param effect The effect we are binding the data to
  79186. */
  79187. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79188. /**
  79189. * Binds the morph targets information from the mesh to the effect.
  79190. * @param abstractMesh The mesh we are binding the information to render
  79191. * @param effect The effect we are binding the data to
  79192. */
  79193. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79194. /**
  79195. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79196. * @param defines The generated defines used in the effect
  79197. * @param effect The effect we are binding the data to
  79198. * @param scene The scene we are willing to render with logarithmic scale for
  79199. */
  79200. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79201. /**
  79202. * Binds the clip plane information from the scene to the effect.
  79203. * @param scene The scene the clip plane information are extracted from
  79204. * @param effect The effect we are binding the data to
  79205. */
  79206. static BindClipPlane(effect: Effect, scene: Scene): void;
  79207. }
  79208. }
  79209. declare module BABYLON {
  79210. /** @hidden */
  79211. export var packingFunctions: {
  79212. name: string;
  79213. shader: string;
  79214. };
  79215. }
  79216. declare module BABYLON {
  79217. /** @hidden */
  79218. export var shadowMapPixelShader: {
  79219. name: string;
  79220. shader: string;
  79221. };
  79222. }
  79223. declare module BABYLON {
  79224. /** @hidden */
  79225. export var bonesDeclaration: {
  79226. name: string;
  79227. shader: string;
  79228. };
  79229. }
  79230. declare module BABYLON {
  79231. /** @hidden */
  79232. export var morphTargetsVertexGlobalDeclaration: {
  79233. name: string;
  79234. shader: string;
  79235. };
  79236. }
  79237. declare module BABYLON {
  79238. /** @hidden */
  79239. export var morphTargetsVertexDeclaration: {
  79240. name: string;
  79241. shader: string;
  79242. };
  79243. }
  79244. declare module BABYLON {
  79245. /** @hidden */
  79246. export var instancesDeclaration: {
  79247. name: string;
  79248. shader: string;
  79249. };
  79250. }
  79251. declare module BABYLON {
  79252. /** @hidden */
  79253. export var helperFunctions: {
  79254. name: string;
  79255. shader: string;
  79256. };
  79257. }
  79258. declare module BABYLON {
  79259. /** @hidden */
  79260. export var morphTargetsVertex: {
  79261. name: string;
  79262. shader: string;
  79263. };
  79264. }
  79265. declare module BABYLON {
  79266. /** @hidden */
  79267. export var instancesVertex: {
  79268. name: string;
  79269. shader: string;
  79270. };
  79271. }
  79272. declare module BABYLON {
  79273. /** @hidden */
  79274. export var bonesVertex: {
  79275. name: string;
  79276. shader: string;
  79277. };
  79278. }
  79279. declare module BABYLON {
  79280. /** @hidden */
  79281. export var shadowMapVertexShader: {
  79282. name: string;
  79283. shader: string;
  79284. };
  79285. }
  79286. declare module BABYLON {
  79287. /** @hidden */
  79288. export var depthBoxBlurPixelShader: {
  79289. name: string;
  79290. shader: string;
  79291. };
  79292. }
  79293. declare module BABYLON {
  79294. /**
  79295. * Defines the options associated with the creation of a custom shader for a shadow generator.
  79296. */
  79297. export interface ICustomShaderOptions {
  79298. /**
  79299. * Gets or sets the custom shader name to use
  79300. */
  79301. shaderName: string;
  79302. /**
  79303. * The list of attribute names used in the shader
  79304. */
  79305. attributes?: string[];
  79306. /**
  79307. * The list of unifrom names used in the shader
  79308. */
  79309. uniforms?: string[];
  79310. /**
  79311. * The list of sampler names used in the shader
  79312. */
  79313. samplers?: string[];
  79314. /**
  79315. * The list of defines used in the shader
  79316. */
  79317. defines?: string[];
  79318. }
  79319. /**
  79320. * Interface to implement to create a shadow generator compatible with BJS.
  79321. */
  79322. export interface IShadowGenerator {
  79323. /**
  79324. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79325. * @returns The render target texture if present otherwise, null
  79326. */
  79327. getShadowMap(): Nullable<RenderTargetTexture>;
  79328. /**
  79329. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79330. * @returns The render target texture if the shadow map is present otherwise, null
  79331. */
  79332. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79333. /**
  79334. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79335. * @param subMesh The submesh we want to render in the shadow map
  79336. * @param useInstances Defines wether will draw in the map using instances
  79337. * @returns true if ready otherwise, false
  79338. */
  79339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79340. /**
  79341. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79342. * @param defines Defines of the material we want to update
  79343. * @param lightIndex Index of the light in the enabled light list of the material
  79344. */
  79345. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  79346. /**
  79347. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79348. * defined in the generator but impacting the effect).
  79349. * It implies the unifroms available on the materials are the standard BJS ones.
  79350. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79351. * @param effect The effect we are binfing the information for
  79352. */
  79353. bindShadowLight(lightIndex: string, effect: Effect): void;
  79354. /**
  79355. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79356. * (eq to shadow prjection matrix * light transform matrix)
  79357. * @returns The transform matrix used to create the shadow map
  79358. */
  79359. getTransformMatrix(): Matrix;
  79360. /**
  79361. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79362. * Cube and 2D textures for instance.
  79363. */
  79364. recreateShadowMap(): void;
  79365. /**
  79366. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79367. * @param onCompiled Callback triggered at the and of the effects compilation
  79368. * @param options Sets of optional options forcing the compilation with different modes
  79369. */
  79370. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  79371. useInstances: boolean;
  79372. }>): void;
  79373. /**
  79374. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79375. * @param options Sets of optional options forcing the compilation with different modes
  79376. * @returns A promise that resolves when the compilation completes
  79377. */
  79378. forceCompilationAsync(options?: Partial<{
  79379. useInstances: boolean;
  79380. }>): Promise<void>;
  79381. /**
  79382. * Serializes the shadow generator setup to a json object.
  79383. * @returns The serialized JSON object
  79384. */
  79385. serialize(): any;
  79386. /**
  79387. * Disposes the Shadow map and related Textures and effects.
  79388. */
  79389. dispose(): void;
  79390. }
  79391. /**
  79392. * Default implementation IShadowGenerator.
  79393. * This is the main object responsible of generating shadows in the framework.
  79394. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  79395. */
  79396. export class ShadowGenerator implements IShadowGenerator {
  79397. /**
  79398. * Shadow generator mode None: no filtering applied.
  79399. */
  79400. static readonly FILTER_NONE: number;
  79401. /**
  79402. * Shadow generator mode ESM: Exponential Shadow Mapping.
  79403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  79404. */
  79405. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  79406. /**
  79407. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  79408. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  79409. */
  79410. static readonly FILTER_POISSONSAMPLING: number;
  79411. /**
  79412. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  79413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  79414. */
  79415. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  79416. /**
  79417. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  79418. * edge artifacts on steep falloff.
  79419. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  79420. */
  79421. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  79422. /**
  79423. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  79424. * edge artifacts on steep falloff.
  79425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  79426. */
  79427. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  79428. /**
  79429. * Shadow generator mode PCF: Percentage Closer Filtering
  79430. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  79431. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  79432. */
  79433. static readonly FILTER_PCF: number;
  79434. /**
  79435. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  79436. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  79437. * Contact Hardening
  79438. */
  79439. static readonly FILTER_PCSS: number;
  79440. /**
  79441. * Reserved for PCF and PCSS
  79442. * Highest Quality.
  79443. *
  79444. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  79445. *
  79446. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  79447. */
  79448. static readonly QUALITY_HIGH: number;
  79449. /**
  79450. * Reserved for PCF and PCSS
  79451. * Good tradeoff for quality/perf cross devices
  79452. *
  79453. * Execute PCF on a 3*3 kernel.
  79454. *
  79455. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  79456. */
  79457. static readonly QUALITY_MEDIUM: number;
  79458. /**
  79459. * Reserved for PCF and PCSS
  79460. * The lowest quality but the fastest.
  79461. *
  79462. * Execute PCF on a 1*1 kernel.
  79463. *
  79464. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  79465. */
  79466. static readonly QUALITY_LOW: number;
  79467. /** Gets or sets the custom shader name to use */
  79468. customShaderOptions: ICustomShaderOptions;
  79469. /**
  79470. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  79471. */
  79472. onBeforeShadowMapRenderObservable: Observable<Effect>;
  79473. /**
  79474. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  79475. */
  79476. onAfterShadowMapRenderObservable: Observable<Effect>;
  79477. /**
  79478. * Observable triggered before a mesh is rendered in the shadow map.
  79479. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  79480. */
  79481. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  79482. /**
  79483. * Observable triggered after a mesh is rendered in the shadow map.
  79484. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  79485. */
  79486. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  79487. private _bias;
  79488. /**
  79489. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  79490. */
  79491. /**
  79492. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  79493. */
  79494. bias: number;
  79495. private _normalBias;
  79496. /**
  79497. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  79498. */
  79499. /**
  79500. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  79501. */
  79502. normalBias: number;
  79503. private _blurBoxOffset;
  79504. /**
  79505. * Gets the blur box offset: offset applied during the blur pass.
  79506. * Only useful if useKernelBlur = false
  79507. */
  79508. /**
  79509. * Sets the blur box offset: offset applied during the blur pass.
  79510. * Only useful if useKernelBlur = false
  79511. */
  79512. blurBoxOffset: number;
  79513. private _blurScale;
  79514. /**
  79515. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  79516. * 2 means half of the size.
  79517. */
  79518. /**
  79519. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  79520. * 2 means half of the size.
  79521. */
  79522. blurScale: number;
  79523. private _blurKernel;
  79524. /**
  79525. * Gets the blur kernel: kernel size of the blur pass.
  79526. * Only useful if useKernelBlur = true
  79527. */
  79528. /**
  79529. * Sets the blur kernel: kernel size of the blur pass.
  79530. * Only useful if useKernelBlur = true
  79531. */
  79532. blurKernel: number;
  79533. private _useKernelBlur;
  79534. /**
  79535. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  79536. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  79537. */
  79538. /**
  79539. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  79540. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  79541. */
  79542. useKernelBlur: boolean;
  79543. private _depthScale;
  79544. /**
  79545. * Gets the depth scale used in ESM mode.
  79546. */
  79547. /**
  79548. * Sets the depth scale used in ESM mode.
  79549. * This can override the scale stored on the light.
  79550. */
  79551. depthScale: number;
  79552. private _filter;
  79553. /**
  79554. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  79555. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  79556. */
  79557. /**
  79558. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  79559. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  79560. */
  79561. filter: number;
  79562. /**
  79563. * Gets if the current filter is set to Poisson Sampling.
  79564. */
  79565. /**
  79566. * Sets the current filter to Poisson Sampling.
  79567. */
  79568. usePoissonSampling: boolean;
  79569. /**
  79570. * Gets if the current filter is set to ESM.
  79571. */
  79572. /**
  79573. * Sets the current filter is to ESM.
  79574. */
  79575. useExponentialShadowMap: boolean;
  79576. /**
  79577. * Gets if the current filter is set to filtered ESM.
  79578. */
  79579. /**
  79580. * Gets if the current filter is set to filtered ESM.
  79581. */
  79582. useBlurExponentialShadowMap: boolean;
  79583. /**
  79584. * Gets if the current filter is set to "close ESM" (using the inverse of the
  79585. * exponential to prevent steep falloff artifacts).
  79586. */
  79587. /**
  79588. * Sets the current filter to "close ESM" (using the inverse of the
  79589. * exponential to prevent steep falloff artifacts).
  79590. */
  79591. useCloseExponentialShadowMap: boolean;
  79592. /**
  79593. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  79594. * exponential to prevent steep falloff artifacts).
  79595. */
  79596. /**
  79597. * Sets the current filter to filtered "close ESM" (using the inverse of the
  79598. * exponential to prevent steep falloff artifacts).
  79599. */
  79600. useBlurCloseExponentialShadowMap: boolean;
  79601. /**
  79602. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  79603. */
  79604. /**
  79605. * Sets the current filter to "PCF" (percentage closer filtering).
  79606. */
  79607. usePercentageCloserFiltering: boolean;
  79608. private _filteringQuality;
  79609. /**
  79610. * Gets the PCF or PCSS Quality.
  79611. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79612. */
  79613. /**
  79614. * Sets the PCF or PCSS Quality.
  79615. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79616. */
  79617. filteringQuality: number;
  79618. /**
  79619. * Gets if the current filter is set to "PCSS" (contact hardening).
  79620. */
  79621. /**
  79622. * Sets the current filter to "PCSS" (contact hardening).
  79623. */
  79624. useContactHardeningShadow: boolean;
  79625. private _contactHardeningLightSizeUVRatio;
  79626. /**
  79627. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79628. * Using a ratio helps keeping shape stability independently of the map size.
  79629. *
  79630. * It does not account for the light projection as it was having too much
  79631. * instability during the light setup or during light position changes.
  79632. *
  79633. * Only valid if useContactHardeningShadow is true.
  79634. */
  79635. /**
  79636. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79637. * Using a ratio helps keeping shape stability independently of the map size.
  79638. *
  79639. * It does not account for the light projection as it was having too much
  79640. * instability during the light setup or during light position changes.
  79641. *
  79642. * Only valid if useContactHardeningShadow is true.
  79643. */
  79644. contactHardeningLightSizeUVRatio: number;
  79645. private _darkness;
  79646. /** Gets or sets the actual darkness of a shadow */
  79647. darkness: number;
  79648. /**
  79649. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  79650. * 0 means strongest and 1 would means no shadow.
  79651. * @returns the darkness.
  79652. */
  79653. getDarkness(): number;
  79654. /**
  79655. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  79656. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  79657. * @returns the shadow generator allowing fluent coding.
  79658. */
  79659. setDarkness(darkness: number): ShadowGenerator;
  79660. private _transparencyShadow;
  79661. /** Gets or sets the ability to have transparent shadow */
  79662. transparencyShadow: boolean;
  79663. /**
  79664. * Sets the ability to have transparent shadow (boolean).
  79665. * @param transparent True if transparent else False
  79666. * @returns the shadow generator allowing fluent coding
  79667. */
  79668. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  79669. private _shadowMap;
  79670. private _shadowMap2;
  79671. /**
  79672. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79673. * @returns The render target texture if present otherwise, null
  79674. */
  79675. getShadowMap(): Nullable<RenderTargetTexture>;
  79676. /**
  79677. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79678. * @returns The render target texture if the shadow map is present otherwise, null
  79679. */
  79680. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79681. /**
  79682. * Gets the class name of that object
  79683. * @returns "ShadowGenerator"
  79684. */
  79685. getClassName(): string;
  79686. /**
  79687. * Helper function to add a mesh and its descendants to the list of shadow casters.
  79688. * @param mesh Mesh to add
  79689. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  79690. * @returns the Shadow Generator itself
  79691. */
  79692. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79693. /**
  79694. * Helper function to remove a mesh and its descendants from the list of shadow casters
  79695. * @param mesh Mesh to remove
  79696. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  79697. * @returns the Shadow Generator itself
  79698. */
  79699. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79700. /**
  79701. * Controls the extent to which the shadows fade out at the edge of the frustum
  79702. * Used only by directionals and spots
  79703. */
  79704. frustumEdgeFalloff: number;
  79705. private _light;
  79706. /**
  79707. * Returns the associated light object.
  79708. * @returns the light generating the shadow
  79709. */
  79710. getLight(): IShadowLight;
  79711. /**
  79712. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  79713. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  79714. * It might on the other hand introduce peter panning.
  79715. */
  79716. forceBackFacesOnly: boolean;
  79717. private _scene;
  79718. private _lightDirection;
  79719. private _effect;
  79720. private _viewMatrix;
  79721. private _projectionMatrix;
  79722. private _transformMatrix;
  79723. private _cachedPosition;
  79724. private _cachedDirection;
  79725. private _cachedDefines;
  79726. private _currentRenderID;
  79727. private _boxBlurPostprocess;
  79728. private _kernelBlurXPostprocess;
  79729. private _kernelBlurYPostprocess;
  79730. private _blurPostProcesses;
  79731. private _mapSize;
  79732. private _currentFaceIndex;
  79733. private _currentFaceIndexCache;
  79734. private _textureType;
  79735. private _defaultTextureMatrix;
  79736. private _storedUniqueId;
  79737. /** @hidden */
  79738. static _SceneComponentInitialization: (scene: Scene) => void;
  79739. /**
  79740. * Creates a ShadowGenerator object.
  79741. * A ShadowGenerator is the required tool to use the shadows.
  79742. * Each light casting shadows needs to use its own ShadowGenerator.
  79743. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  79744. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  79745. * @param light The light object generating the shadows.
  79746. * @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.
  79747. */
  79748. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  79749. private _initializeGenerator;
  79750. private _initializeShadowMap;
  79751. private _initializeBlurRTTAndPostProcesses;
  79752. private _renderForShadowMap;
  79753. private _renderSubMeshForShadowMap;
  79754. private _applyFilterValues;
  79755. /**
  79756. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79757. * @param onCompiled Callback triggered at the and of the effects compilation
  79758. * @param options Sets of optional options forcing the compilation with different modes
  79759. */
  79760. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  79761. useInstances: boolean;
  79762. }>): void;
  79763. /**
  79764. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79765. * @param options Sets of optional options forcing the compilation with different modes
  79766. * @returns A promise that resolves when the compilation completes
  79767. */
  79768. forceCompilationAsync(options?: Partial<{
  79769. useInstances: boolean;
  79770. }>): Promise<void>;
  79771. /**
  79772. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79773. * @param subMesh The submesh we want to render in the shadow map
  79774. * @param useInstances Defines wether will draw in the map using instances
  79775. * @returns true if ready otherwise, false
  79776. */
  79777. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79778. /**
  79779. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79780. * @param defines Defines of the material we want to update
  79781. * @param lightIndex Index of the light in the enabled light list of the material
  79782. */
  79783. prepareDefines(defines: any, lightIndex: number): void;
  79784. /**
  79785. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79786. * defined in the generator but impacting the effect).
  79787. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79788. * @param effect The effect we are binfing the information for
  79789. */
  79790. bindShadowLight(lightIndex: string, effect: Effect): void;
  79791. /**
  79792. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79793. * (eq to shadow prjection matrix * light transform matrix)
  79794. * @returns The transform matrix used to create the shadow map
  79795. */
  79796. getTransformMatrix(): Matrix;
  79797. /**
  79798. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79799. * Cube and 2D textures for instance.
  79800. */
  79801. recreateShadowMap(): void;
  79802. private _disposeBlurPostProcesses;
  79803. private _disposeRTTandPostProcesses;
  79804. /**
  79805. * Disposes the ShadowGenerator.
  79806. * Returns nothing.
  79807. */
  79808. dispose(): void;
  79809. /**
  79810. * Serializes the shadow generator setup to a json object.
  79811. * @returns The serialized JSON object
  79812. */
  79813. serialize(): any;
  79814. /**
  79815. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  79816. * @param parsedShadowGenerator The JSON object to parse
  79817. * @param scene The scene to create the shadow map for
  79818. * @returns The parsed shadow generator
  79819. */
  79820. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  79821. }
  79822. }
  79823. declare module BABYLON {
  79824. /**
  79825. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  79826. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  79827. * 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.
  79828. */
  79829. export abstract class Light extends Node {
  79830. /**
  79831. * Falloff Default: light is falling off following the material specification:
  79832. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  79833. */
  79834. static readonly FALLOFF_DEFAULT: number;
  79835. /**
  79836. * Falloff Physical: light is falling off following the inverse squared distance law.
  79837. */
  79838. static readonly FALLOFF_PHYSICAL: number;
  79839. /**
  79840. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  79841. * to enhance interoperability with other engines.
  79842. */
  79843. static readonly FALLOFF_GLTF: number;
  79844. /**
  79845. * Falloff Standard: light is falling off like in the standard material
  79846. * to enhance interoperability with other materials.
  79847. */
  79848. static readonly FALLOFF_STANDARD: number;
  79849. /**
  79850. * If every light affecting the material is in this lightmapMode,
  79851. * material.lightmapTexture adds or multiplies
  79852. * (depends on material.useLightmapAsShadowmap)
  79853. * after every other light calculations.
  79854. */
  79855. static readonly LIGHTMAP_DEFAULT: number;
  79856. /**
  79857. * material.lightmapTexture as only diffuse lighting from this light
  79858. * adds only specular lighting from this light
  79859. * adds dynamic shadows
  79860. */
  79861. static readonly LIGHTMAP_SPECULAR: number;
  79862. /**
  79863. * material.lightmapTexture as only lighting
  79864. * no light calculation from this light
  79865. * only adds dynamic shadows from this light
  79866. */
  79867. static readonly LIGHTMAP_SHADOWSONLY: number;
  79868. /**
  79869. * Each light type uses the default quantity according to its type:
  79870. * point/spot lights use luminous intensity
  79871. * directional lights use illuminance
  79872. */
  79873. static readonly INTENSITYMODE_AUTOMATIC: number;
  79874. /**
  79875. * lumen (lm)
  79876. */
  79877. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  79878. /**
  79879. * candela (lm/sr)
  79880. */
  79881. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  79882. /**
  79883. * lux (lm/m^2)
  79884. */
  79885. static readonly INTENSITYMODE_ILLUMINANCE: number;
  79886. /**
  79887. * nit (cd/m^2)
  79888. */
  79889. static readonly INTENSITYMODE_LUMINANCE: number;
  79890. /**
  79891. * Light type const id of the point light.
  79892. */
  79893. static readonly LIGHTTYPEID_POINTLIGHT: number;
  79894. /**
  79895. * Light type const id of the directional light.
  79896. */
  79897. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  79898. /**
  79899. * Light type const id of the spot light.
  79900. */
  79901. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  79902. /**
  79903. * Light type const id of the hemispheric light.
  79904. */
  79905. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  79906. /**
  79907. * Diffuse gives the basic color to an object.
  79908. */
  79909. diffuse: Color3;
  79910. /**
  79911. * Specular produces a highlight color on an object.
  79912. * Note: This is note affecting PBR materials.
  79913. */
  79914. specular: Color3;
  79915. /**
  79916. * Defines the falloff type for this light. This lets overrriding how punctual light are
  79917. * falling off base on range or angle.
  79918. * This can be set to any values in Light.FALLOFF_x.
  79919. *
  79920. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  79921. * other types of materials.
  79922. */
  79923. falloffType: number;
  79924. /**
  79925. * Strength of the light.
  79926. * Note: By default it is define in the framework own unit.
  79927. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  79928. */
  79929. intensity: number;
  79930. private _range;
  79931. protected _inverseSquaredRange: number;
  79932. /**
  79933. * Defines how far from the source the light is impacting in scene units.
  79934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79935. */
  79936. /**
  79937. * Defines how far from the source the light is impacting in scene units.
  79938. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79939. */
  79940. range: number;
  79941. /**
  79942. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  79943. * of light.
  79944. */
  79945. private _photometricScale;
  79946. private _intensityMode;
  79947. /**
  79948. * Gets the photometric scale used to interpret the intensity.
  79949. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79950. */
  79951. /**
  79952. * Sets the photometric scale used to interpret the intensity.
  79953. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79954. */
  79955. intensityMode: number;
  79956. private _radius;
  79957. /**
  79958. * Gets the light radius used by PBR Materials to simulate soft area lights.
  79959. */
  79960. /**
  79961. * sets the light radius used by PBR Materials to simulate soft area lights.
  79962. */
  79963. radius: number;
  79964. private _renderPriority;
  79965. /**
  79966. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  79967. * exceeding the number allowed of the materials.
  79968. */
  79969. renderPriority: number;
  79970. private _shadowEnabled;
  79971. /**
  79972. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79973. * the current shadow generator.
  79974. */
  79975. /**
  79976. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79977. * the current shadow generator.
  79978. */
  79979. shadowEnabled: boolean;
  79980. private _includedOnlyMeshes;
  79981. /**
  79982. * Gets the only meshes impacted by this light.
  79983. */
  79984. /**
  79985. * Sets the only meshes impacted by this light.
  79986. */
  79987. includedOnlyMeshes: AbstractMesh[];
  79988. private _excludedMeshes;
  79989. /**
  79990. * Gets the meshes not impacted by this light.
  79991. */
  79992. /**
  79993. * Sets the meshes not impacted by this light.
  79994. */
  79995. excludedMeshes: AbstractMesh[];
  79996. private _excludeWithLayerMask;
  79997. /**
  79998. * Gets the layer id use to find what meshes are not impacted by the light.
  79999. * Inactive if 0
  80000. */
  80001. /**
  80002. * Sets the layer id use to find what meshes are not impacted by the light.
  80003. * Inactive if 0
  80004. */
  80005. excludeWithLayerMask: number;
  80006. private _includeOnlyWithLayerMask;
  80007. /**
  80008. * Gets the layer id use to find what meshes are impacted by the light.
  80009. * Inactive if 0
  80010. */
  80011. /**
  80012. * Sets the layer id use to find what meshes are impacted by the light.
  80013. * Inactive if 0
  80014. */
  80015. includeOnlyWithLayerMask: number;
  80016. private _lightmapMode;
  80017. /**
  80018. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80019. */
  80020. /**
  80021. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80022. */
  80023. lightmapMode: number;
  80024. /**
  80025. * Shadow generator associted to the light.
  80026. * @hidden Internal use only.
  80027. */
  80028. _shadowGenerator: Nullable<IShadowGenerator>;
  80029. /**
  80030. * @hidden Internal use only.
  80031. */
  80032. _excludedMeshesIds: string[];
  80033. /**
  80034. * @hidden Internal use only.
  80035. */
  80036. _includedOnlyMeshesIds: string[];
  80037. /**
  80038. * The current light unifom buffer.
  80039. * @hidden Internal use only.
  80040. */
  80041. _uniformBuffer: UniformBuffer;
  80042. /** @hidden */
  80043. _renderId: number;
  80044. /**
  80045. * Creates a Light object in the scene.
  80046. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80047. * @param name The firendly name of the light
  80048. * @param scene The scene the light belongs too
  80049. */
  80050. constructor(name: string, scene: Scene);
  80051. protected abstract _buildUniformLayout(): void;
  80052. /**
  80053. * Sets the passed Effect "effect" with the Light information.
  80054. * @param effect The effect to update
  80055. * @param lightIndex The index of the light in the effect to update
  80056. * @returns The light
  80057. */
  80058. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80059. /**
  80060. * Sets the passed Effect "effect" with the Light textures.
  80061. * @param effect The effect to update
  80062. * @param lightIndex The index of the light in the effect to update
  80063. * @returns The light
  80064. */
  80065. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80066. /**
  80067. * Binds the lights information from the scene to the effect for the given mesh.
  80068. * @param lightIndex Light index
  80069. * @param scene The scene where the light belongs to
  80070. * @param effect The effect we are binding the data to
  80071. * @param useSpecular Defines if specular is supported
  80072. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80073. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80074. */
  80075. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80076. /**
  80077. * Sets the passed Effect "effect" with the Light information.
  80078. * @param effect The effect to update
  80079. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80080. * @returns The light
  80081. */
  80082. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80083. /**
  80084. * Returns the string "Light".
  80085. * @returns the class name
  80086. */
  80087. getClassName(): string;
  80088. /** @hidden */
  80089. readonly _isLight: boolean;
  80090. /**
  80091. * Converts the light information to a readable string for debug purpose.
  80092. * @param fullDetails Supports for multiple levels of logging within scene loading
  80093. * @returns the human readable light info
  80094. */
  80095. toString(fullDetails?: boolean): string;
  80096. /** @hidden */
  80097. protected _syncParentEnabledState(): void;
  80098. /**
  80099. * Set the enabled state of this node.
  80100. * @param value - the new enabled state
  80101. */
  80102. setEnabled(value: boolean): void;
  80103. /**
  80104. * Returns the Light associated shadow generator if any.
  80105. * @return the associated shadow generator.
  80106. */
  80107. getShadowGenerator(): Nullable<IShadowGenerator>;
  80108. /**
  80109. * Returns a Vector3, the absolute light position in the World.
  80110. * @returns the world space position of the light
  80111. */
  80112. getAbsolutePosition(): Vector3;
  80113. /**
  80114. * Specifies if the light will affect the passed mesh.
  80115. * @param mesh The mesh to test against the light
  80116. * @return true the mesh is affected otherwise, false.
  80117. */
  80118. canAffectMesh(mesh: AbstractMesh): boolean;
  80119. /**
  80120. * Sort function to order lights for rendering.
  80121. * @param a First Light object to compare to second.
  80122. * @param b Second Light object to compare first.
  80123. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80124. */
  80125. static CompareLightsPriority(a: Light, b: Light): number;
  80126. /**
  80127. * Releases resources associated with this node.
  80128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80130. */
  80131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80132. /**
  80133. * Returns the light type ID (integer).
  80134. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80135. */
  80136. getTypeID(): number;
  80137. /**
  80138. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80139. * @returns the scaled intensity in intensity mode unit
  80140. */
  80141. getScaledIntensity(): number;
  80142. /**
  80143. * Returns a new Light object, named "name", from the current one.
  80144. * @param name The name of the cloned light
  80145. * @returns the new created light
  80146. */
  80147. clone(name: string): Nullable<Light>;
  80148. /**
  80149. * Serializes the current light into a Serialization object.
  80150. * @returns the serialized object.
  80151. */
  80152. serialize(): any;
  80153. /**
  80154. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80155. * This new light is named "name" and added to the passed scene.
  80156. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80157. * @param name The friendly name of the light
  80158. * @param scene The scene the new light will belong to
  80159. * @returns the constructor function
  80160. */
  80161. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80162. /**
  80163. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80164. * @param parsedLight The JSON representation of the light
  80165. * @param scene The scene to create the parsed light in
  80166. * @returns the created light after parsing
  80167. */
  80168. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80169. private _hookArrayForExcluded;
  80170. private _hookArrayForIncludedOnly;
  80171. private _resyncMeshes;
  80172. /**
  80173. * Forces the meshes to update their light related information in their rendering used effects
  80174. * @hidden Internal Use Only
  80175. */
  80176. _markMeshesAsLightDirty(): void;
  80177. /**
  80178. * Recomputes the cached photometric scale if needed.
  80179. */
  80180. private _computePhotometricScale;
  80181. /**
  80182. * Returns the Photometric Scale according to the light type and intensity mode.
  80183. */
  80184. private _getPhotometricScale;
  80185. /**
  80186. * Reorder the light in the scene according to their defined priority.
  80187. * @hidden Internal Use Only
  80188. */
  80189. _reorderLightsInScene(): void;
  80190. /**
  80191. * Prepares the list of defines specific to the light type.
  80192. * @param defines the list of defines
  80193. * @param lightIndex defines the index of the light for the effect
  80194. */
  80195. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80196. }
  80197. }
  80198. declare module BABYLON {
  80199. /**
  80200. * Interface used to define Action
  80201. */
  80202. export interface IAction {
  80203. /**
  80204. * Trigger for the action
  80205. */
  80206. trigger: number;
  80207. /** Options of the trigger */
  80208. triggerOptions: any;
  80209. /**
  80210. * Gets the trigger parameters
  80211. * @returns the trigger parameters
  80212. */
  80213. getTriggerParameter(): any;
  80214. /**
  80215. * Internal only - executes current action event
  80216. * @hidden
  80217. */
  80218. _executeCurrent(evt?: ActionEvent): void;
  80219. /**
  80220. * Serialize placeholder for child classes
  80221. * @param parent of child
  80222. * @returns the serialized object
  80223. */
  80224. serialize(parent: any): any;
  80225. /**
  80226. * Internal only
  80227. * @hidden
  80228. */
  80229. _prepare(): void;
  80230. /**
  80231. * Internal only - manager for action
  80232. * @hidden
  80233. */
  80234. _actionManager: AbstractActionManager;
  80235. /**
  80236. * Adds action to chain of actions, may be a DoNothingAction
  80237. * @param action defines the next action to execute
  80238. * @returns The action passed in
  80239. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80240. */
  80241. then(action: IAction): IAction;
  80242. }
  80243. /**
  80244. * The action to be carried out following a trigger
  80245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80246. */
  80247. export class Action implements IAction {
  80248. /** the trigger, with or without parameters, for the action */
  80249. triggerOptions: any;
  80250. /**
  80251. * Trigger for the action
  80252. */
  80253. trigger: number;
  80254. /**
  80255. * Internal only - manager for action
  80256. * @hidden
  80257. */
  80258. _actionManager: ActionManager;
  80259. private _nextActiveAction;
  80260. private _child;
  80261. private _condition?;
  80262. private _triggerParameter;
  80263. /**
  80264. * An event triggered prior to action being executed.
  80265. */
  80266. onBeforeExecuteObservable: Observable<Action>;
  80267. /**
  80268. * Creates a new Action
  80269. * @param triggerOptions the trigger, with or without parameters, for the action
  80270. * @param condition an optional determinant of action
  80271. */
  80272. constructor(
  80273. /** the trigger, with or without parameters, for the action */
  80274. triggerOptions: any, condition?: Condition);
  80275. /**
  80276. * Internal only
  80277. * @hidden
  80278. */
  80279. _prepare(): void;
  80280. /**
  80281. * Gets the trigger parameters
  80282. * @returns the trigger parameters
  80283. */
  80284. getTriggerParameter(): any;
  80285. /**
  80286. * Internal only - executes current action event
  80287. * @hidden
  80288. */
  80289. _executeCurrent(evt?: ActionEvent): void;
  80290. /**
  80291. * Execute placeholder for child classes
  80292. * @param evt optional action event
  80293. */
  80294. execute(evt?: ActionEvent): void;
  80295. /**
  80296. * Skips to next active action
  80297. */
  80298. skipToNextActiveAction(): void;
  80299. /**
  80300. * Adds action to chain of actions, may be a DoNothingAction
  80301. * @param action defines the next action to execute
  80302. * @returns The action passed in
  80303. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80304. */
  80305. then(action: Action): Action;
  80306. /**
  80307. * Internal only
  80308. * @hidden
  80309. */
  80310. _getProperty(propertyPath: string): string;
  80311. /**
  80312. * Internal only
  80313. * @hidden
  80314. */
  80315. _getEffectiveTarget(target: any, propertyPath: string): any;
  80316. /**
  80317. * Serialize placeholder for child classes
  80318. * @param parent of child
  80319. * @returns the serialized object
  80320. */
  80321. serialize(parent: any): any;
  80322. /**
  80323. * Internal only called by serialize
  80324. * @hidden
  80325. */
  80326. protected _serialize(serializedAction: any, parent?: any): any;
  80327. /**
  80328. * Internal only
  80329. * @hidden
  80330. */
  80331. static _SerializeValueAsString: (value: any) => string;
  80332. /**
  80333. * Internal only
  80334. * @hidden
  80335. */
  80336. static _GetTargetProperty: (target: Node | Scene) => {
  80337. name: string;
  80338. targetType: string;
  80339. value: string;
  80340. };
  80341. }
  80342. }
  80343. declare module BABYLON {
  80344. /**
  80345. * A Condition applied to an Action
  80346. */
  80347. export class Condition {
  80348. /**
  80349. * Internal only - manager for action
  80350. * @hidden
  80351. */
  80352. _actionManager: ActionManager;
  80353. /**
  80354. * Internal only
  80355. * @hidden
  80356. */
  80357. _evaluationId: number;
  80358. /**
  80359. * Internal only
  80360. * @hidden
  80361. */
  80362. _currentResult: boolean;
  80363. /**
  80364. * Creates a new Condition
  80365. * @param actionManager the manager of the action the condition is applied to
  80366. */
  80367. constructor(actionManager: ActionManager);
  80368. /**
  80369. * Check if the current condition is valid
  80370. * @returns a boolean
  80371. */
  80372. isValid(): boolean;
  80373. /**
  80374. * Internal only
  80375. * @hidden
  80376. */
  80377. _getProperty(propertyPath: string): string;
  80378. /**
  80379. * Internal only
  80380. * @hidden
  80381. */
  80382. _getEffectiveTarget(target: any, propertyPath: string): any;
  80383. /**
  80384. * Serialize placeholder for child classes
  80385. * @returns the serialized object
  80386. */
  80387. serialize(): any;
  80388. /**
  80389. * Internal only
  80390. * @hidden
  80391. */
  80392. protected _serialize(serializedCondition: any): any;
  80393. }
  80394. /**
  80395. * Defines specific conditional operators as extensions of Condition
  80396. */
  80397. export class ValueCondition extends Condition {
  80398. /** path to specify the property of the target the conditional operator uses */
  80399. propertyPath: string;
  80400. /** the value compared by the conditional operator against the current value of the property */
  80401. value: any;
  80402. /** the conditional operator, default ValueCondition.IsEqual */
  80403. operator: number;
  80404. /**
  80405. * Internal only
  80406. * @hidden
  80407. */
  80408. private static _IsEqual;
  80409. /**
  80410. * Internal only
  80411. * @hidden
  80412. */
  80413. private static _IsDifferent;
  80414. /**
  80415. * Internal only
  80416. * @hidden
  80417. */
  80418. private static _IsGreater;
  80419. /**
  80420. * Internal only
  80421. * @hidden
  80422. */
  80423. private static _IsLesser;
  80424. /**
  80425. * returns the number for IsEqual
  80426. */
  80427. static readonly IsEqual: number;
  80428. /**
  80429. * Returns the number for IsDifferent
  80430. */
  80431. static readonly IsDifferent: number;
  80432. /**
  80433. * Returns the number for IsGreater
  80434. */
  80435. static readonly IsGreater: number;
  80436. /**
  80437. * Returns the number for IsLesser
  80438. */
  80439. static readonly IsLesser: number;
  80440. /**
  80441. * Internal only The action manager for the condition
  80442. * @hidden
  80443. */
  80444. _actionManager: ActionManager;
  80445. /**
  80446. * Internal only
  80447. * @hidden
  80448. */
  80449. private _target;
  80450. /**
  80451. * Internal only
  80452. * @hidden
  80453. */
  80454. private _effectiveTarget;
  80455. /**
  80456. * Internal only
  80457. * @hidden
  80458. */
  80459. private _property;
  80460. /**
  80461. * Creates a new ValueCondition
  80462. * @param actionManager manager for the action the condition applies to
  80463. * @param target for the action
  80464. * @param propertyPath path to specify the property of the target the conditional operator uses
  80465. * @param value the value compared by the conditional operator against the current value of the property
  80466. * @param operator the conditional operator, default ValueCondition.IsEqual
  80467. */
  80468. constructor(actionManager: ActionManager, target: any,
  80469. /** path to specify the property of the target the conditional operator uses */
  80470. propertyPath: string,
  80471. /** the value compared by the conditional operator against the current value of the property */
  80472. value: any,
  80473. /** the conditional operator, default ValueCondition.IsEqual */
  80474. operator?: number);
  80475. /**
  80476. * Compares the given value with the property value for the specified conditional operator
  80477. * @returns the result of the comparison
  80478. */
  80479. isValid(): boolean;
  80480. /**
  80481. * Serialize the ValueCondition into a JSON compatible object
  80482. * @returns serialization object
  80483. */
  80484. serialize(): any;
  80485. /**
  80486. * Gets the name of the conditional operator for the ValueCondition
  80487. * @param operator the conditional operator
  80488. * @returns the name
  80489. */
  80490. static GetOperatorName(operator: number): string;
  80491. }
  80492. /**
  80493. * Defines a predicate condition as an extension of Condition
  80494. */
  80495. export class PredicateCondition extends Condition {
  80496. /** defines the predicate function used to validate the condition */
  80497. predicate: () => boolean;
  80498. /**
  80499. * Internal only - manager for action
  80500. * @hidden
  80501. */
  80502. _actionManager: ActionManager;
  80503. /**
  80504. * Creates a new PredicateCondition
  80505. * @param actionManager manager for the action the condition applies to
  80506. * @param predicate defines the predicate function used to validate the condition
  80507. */
  80508. constructor(actionManager: ActionManager,
  80509. /** defines the predicate function used to validate the condition */
  80510. predicate: () => boolean);
  80511. /**
  80512. * @returns the validity of the predicate condition
  80513. */
  80514. isValid(): boolean;
  80515. }
  80516. /**
  80517. * Defines a state condition as an extension of Condition
  80518. */
  80519. export class StateCondition extends Condition {
  80520. /** Value to compare with target state */
  80521. value: string;
  80522. /**
  80523. * Internal only - manager for action
  80524. * @hidden
  80525. */
  80526. _actionManager: ActionManager;
  80527. /**
  80528. * Internal only
  80529. * @hidden
  80530. */
  80531. private _target;
  80532. /**
  80533. * Creates a new StateCondition
  80534. * @param actionManager manager for the action the condition applies to
  80535. * @param target of the condition
  80536. * @param value to compare with target state
  80537. */
  80538. constructor(actionManager: ActionManager, target: any,
  80539. /** Value to compare with target state */
  80540. value: string);
  80541. /**
  80542. * Gets a boolean indicating if the current condition is met
  80543. * @returns the validity of the state
  80544. */
  80545. isValid(): boolean;
  80546. /**
  80547. * Serialize the StateCondition into a JSON compatible object
  80548. * @returns serialization object
  80549. */
  80550. serialize(): any;
  80551. }
  80552. }
  80553. declare module BABYLON {
  80554. /**
  80555. * This defines an action responsible to toggle a boolean once triggered.
  80556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80557. */
  80558. export class SwitchBooleanAction extends Action {
  80559. /**
  80560. * The path to the boolean property in the target object
  80561. */
  80562. propertyPath: string;
  80563. private _target;
  80564. private _effectiveTarget;
  80565. private _property;
  80566. /**
  80567. * Instantiate the action
  80568. * @param triggerOptions defines the trigger options
  80569. * @param target defines the object containing the boolean
  80570. * @param propertyPath defines the path to the boolean property in the target object
  80571. * @param condition defines the trigger related conditions
  80572. */
  80573. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  80574. /** @hidden */
  80575. _prepare(): void;
  80576. /**
  80577. * Execute the action toggle the boolean value.
  80578. */
  80579. execute(): void;
  80580. /**
  80581. * Serializes the actions and its related information.
  80582. * @param parent defines the object to serialize in
  80583. * @returns the serialized object
  80584. */
  80585. serialize(parent: any): any;
  80586. }
  80587. /**
  80588. * This defines an action responsible to set a the state field of the target
  80589. * to a desired value once triggered.
  80590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80591. */
  80592. export class SetStateAction extends Action {
  80593. /**
  80594. * The value to store in the state field.
  80595. */
  80596. value: string;
  80597. private _target;
  80598. /**
  80599. * Instantiate the action
  80600. * @param triggerOptions defines the trigger options
  80601. * @param target defines the object containing the state property
  80602. * @param value defines the value to store in the state field
  80603. * @param condition defines the trigger related conditions
  80604. */
  80605. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  80606. /**
  80607. * Execute the action and store the value on the target state property.
  80608. */
  80609. execute(): void;
  80610. /**
  80611. * Serializes the actions and its related information.
  80612. * @param parent defines the object to serialize in
  80613. * @returns the serialized object
  80614. */
  80615. serialize(parent: any): any;
  80616. }
  80617. /**
  80618. * This defines an action responsible to set a property of the target
  80619. * to a desired value once triggered.
  80620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80621. */
  80622. export class SetValueAction extends Action {
  80623. /**
  80624. * The path of the property to set in the target.
  80625. */
  80626. propertyPath: string;
  80627. /**
  80628. * The value to set in the property
  80629. */
  80630. value: any;
  80631. private _target;
  80632. private _effectiveTarget;
  80633. private _property;
  80634. /**
  80635. * Instantiate the action
  80636. * @param triggerOptions defines the trigger options
  80637. * @param target defines the object containing the property
  80638. * @param propertyPath defines the path of the property to set in the target
  80639. * @param value defines the value to set in the property
  80640. * @param condition defines the trigger related conditions
  80641. */
  80642. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80643. /** @hidden */
  80644. _prepare(): void;
  80645. /**
  80646. * Execute the action and set the targetted property to the desired value.
  80647. */
  80648. execute(): void;
  80649. /**
  80650. * Serializes the actions and its related information.
  80651. * @param parent defines the object to serialize in
  80652. * @returns the serialized object
  80653. */
  80654. serialize(parent: any): any;
  80655. }
  80656. /**
  80657. * This defines an action responsible to increment the target value
  80658. * to a desired value once triggered.
  80659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80660. */
  80661. export class IncrementValueAction extends Action {
  80662. /**
  80663. * The path of the property to increment in the target.
  80664. */
  80665. propertyPath: string;
  80666. /**
  80667. * The value we should increment the property by.
  80668. */
  80669. value: any;
  80670. private _target;
  80671. private _effectiveTarget;
  80672. private _property;
  80673. /**
  80674. * Instantiate the action
  80675. * @param triggerOptions defines the trigger options
  80676. * @param target defines the object containing the property
  80677. * @param propertyPath defines the path of the property to increment in the target
  80678. * @param value defines the value value we should increment the property by
  80679. * @param condition defines the trigger related conditions
  80680. */
  80681. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80682. /** @hidden */
  80683. _prepare(): void;
  80684. /**
  80685. * Execute the action and increment the target of the value amount.
  80686. */
  80687. execute(): void;
  80688. /**
  80689. * Serializes the actions and its related information.
  80690. * @param parent defines the object to serialize in
  80691. * @returns the serialized object
  80692. */
  80693. serialize(parent: any): any;
  80694. }
  80695. /**
  80696. * This defines an action responsible to start an animation once triggered.
  80697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80698. */
  80699. export class PlayAnimationAction extends Action {
  80700. /**
  80701. * Where the animation should start (animation frame)
  80702. */
  80703. from: number;
  80704. /**
  80705. * Where the animation should stop (animation frame)
  80706. */
  80707. to: number;
  80708. /**
  80709. * Define if the animation should loop or stop after the first play.
  80710. */
  80711. loop?: boolean;
  80712. private _target;
  80713. /**
  80714. * Instantiate the action
  80715. * @param triggerOptions defines the trigger options
  80716. * @param target defines the target animation or animation name
  80717. * @param from defines from where the animation should start (animation frame)
  80718. * @param end defines where the animation should stop (animation frame)
  80719. * @param loop defines if the animation should loop or stop after the first play
  80720. * @param condition defines the trigger related conditions
  80721. */
  80722. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  80723. /** @hidden */
  80724. _prepare(): void;
  80725. /**
  80726. * Execute the action and play the animation.
  80727. */
  80728. execute(): void;
  80729. /**
  80730. * Serializes the actions and its related information.
  80731. * @param parent defines the object to serialize in
  80732. * @returns the serialized object
  80733. */
  80734. serialize(parent: any): any;
  80735. }
  80736. /**
  80737. * This defines an action responsible to stop an animation once triggered.
  80738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80739. */
  80740. export class StopAnimationAction extends Action {
  80741. private _target;
  80742. /**
  80743. * Instantiate the action
  80744. * @param triggerOptions defines the trigger options
  80745. * @param target defines the target animation or animation name
  80746. * @param condition defines the trigger related conditions
  80747. */
  80748. constructor(triggerOptions: any, target: any, condition?: Condition);
  80749. /** @hidden */
  80750. _prepare(): void;
  80751. /**
  80752. * Execute the action and stop the animation.
  80753. */
  80754. execute(): void;
  80755. /**
  80756. * Serializes the actions and its related information.
  80757. * @param parent defines the object to serialize in
  80758. * @returns the serialized object
  80759. */
  80760. serialize(parent: any): any;
  80761. }
  80762. /**
  80763. * This defines an action responsible that does nothing once triggered.
  80764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80765. */
  80766. export class DoNothingAction extends Action {
  80767. /**
  80768. * Instantiate the action
  80769. * @param triggerOptions defines the trigger options
  80770. * @param condition defines the trigger related conditions
  80771. */
  80772. constructor(triggerOptions?: any, condition?: Condition);
  80773. /**
  80774. * Execute the action and do nothing.
  80775. */
  80776. execute(): void;
  80777. /**
  80778. * Serializes the actions and its related information.
  80779. * @param parent defines the object to serialize in
  80780. * @returns the serialized object
  80781. */
  80782. serialize(parent: any): any;
  80783. }
  80784. /**
  80785. * This defines an action responsible to trigger several actions once triggered.
  80786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80787. */
  80788. export class CombineAction extends Action {
  80789. /**
  80790. * The list of aggregated animations to run.
  80791. */
  80792. children: Action[];
  80793. /**
  80794. * Instantiate the action
  80795. * @param triggerOptions defines the trigger options
  80796. * @param children defines the list of aggregated animations to run
  80797. * @param condition defines the trigger related conditions
  80798. */
  80799. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  80800. /** @hidden */
  80801. _prepare(): void;
  80802. /**
  80803. * Execute the action and executes all the aggregated actions.
  80804. */
  80805. execute(evt: ActionEvent): void;
  80806. /**
  80807. * Serializes the actions and its related information.
  80808. * @param parent defines the object to serialize in
  80809. * @returns the serialized object
  80810. */
  80811. serialize(parent: any): any;
  80812. }
  80813. /**
  80814. * This defines an action responsible to run code (external event) once triggered.
  80815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80816. */
  80817. export class ExecuteCodeAction extends Action {
  80818. /**
  80819. * The callback function to run.
  80820. */
  80821. func: (evt: ActionEvent) => void;
  80822. /**
  80823. * Instantiate the action
  80824. * @param triggerOptions defines the trigger options
  80825. * @param func defines the callback function to run
  80826. * @param condition defines the trigger related conditions
  80827. */
  80828. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  80829. /**
  80830. * Execute the action and run the attached code.
  80831. */
  80832. execute(evt: ActionEvent): void;
  80833. }
  80834. /**
  80835. * This defines an action responsible to set the parent property of the target once triggered.
  80836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80837. */
  80838. export class SetParentAction extends Action {
  80839. private _parent;
  80840. private _target;
  80841. /**
  80842. * Instantiate the action
  80843. * @param triggerOptions defines the trigger options
  80844. * @param target defines the target containing the parent property
  80845. * @param parent defines from where the animation should start (animation frame)
  80846. * @param condition defines the trigger related conditions
  80847. */
  80848. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  80849. /** @hidden */
  80850. _prepare(): void;
  80851. /**
  80852. * Execute the action and set the parent property.
  80853. */
  80854. execute(): void;
  80855. /**
  80856. * Serializes the actions and its related information.
  80857. * @param parent defines the object to serialize in
  80858. * @returns the serialized object
  80859. */
  80860. serialize(parent: any): any;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  80866. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  80867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80868. */
  80869. export class ActionManager extends AbstractActionManager {
  80870. /**
  80871. * Nothing
  80872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80873. */
  80874. static readonly NothingTrigger: number;
  80875. /**
  80876. * On pick
  80877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80878. */
  80879. static readonly OnPickTrigger: number;
  80880. /**
  80881. * On left pick
  80882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80883. */
  80884. static readonly OnLeftPickTrigger: number;
  80885. /**
  80886. * On right pick
  80887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80888. */
  80889. static readonly OnRightPickTrigger: number;
  80890. /**
  80891. * On center pick
  80892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80893. */
  80894. static readonly OnCenterPickTrigger: number;
  80895. /**
  80896. * On pick down
  80897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80898. */
  80899. static readonly OnPickDownTrigger: number;
  80900. /**
  80901. * On double pick
  80902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80903. */
  80904. static readonly OnDoublePickTrigger: number;
  80905. /**
  80906. * On pick up
  80907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80908. */
  80909. static readonly OnPickUpTrigger: number;
  80910. /**
  80911. * On pick out.
  80912. * This trigger will only be raised if you also declared a OnPickDown
  80913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80914. */
  80915. static readonly OnPickOutTrigger: number;
  80916. /**
  80917. * On long press
  80918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80919. */
  80920. static readonly OnLongPressTrigger: number;
  80921. /**
  80922. * On pointer over
  80923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80924. */
  80925. static readonly OnPointerOverTrigger: number;
  80926. /**
  80927. * On pointer out
  80928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80929. */
  80930. static readonly OnPointerOutTrigger: number;
  80931. /**
  80932. * On every frame
  80933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80934. */
  80935. static readonly OnEveryFrameTrigger: number;
  80936. /**
  80937. * On intersection enter
  80938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80939. */
  80940. static readonly OnIntersectionEnterTrigger: number;
  80941. /**
  80942. * On intersection exit
  80943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80944. */
  80945. static readonly OnIntersectionExitTrigger: number;
  80946. /**
  80947. * On key down
  80948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80949. */
  80950. static readonly OnKeyDownTrigger: number;
  80951. /**
  80952. * On key up
  80953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80954. */
  80955. static readonly OnKeyUpTrigger: number;
  80956. private _scene;
  80957. /**
  80958. * Creates a new action manager
  80959. * @param scene defines the hosting scene
  80960. */
  80961. constructor(scene: Scene);
  80962. /**
  80963. * Releases all associated resources
  80964. */
  80965. dispose(): void;
  80966. /**
  80967. * Gets hosting scene
  80968. * @returns the hosting scene
  80969. */
  80970. getScene(): Scene;
  80971. /**
  80972. * Does this action manager handles actions of any of the given triggers
  80973. * @param triggers defines the triggers to be tested
  80974. * @return a boolean indicating whether one (or more) of the triggers is handled
  80975. */
  80976. hasSpecificTriggers(triggers: number[]): boolean;
  80977. /**
  80978. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80979. * speed.
  80980. * @param triggerA defines the trigger to be tested
  80981. * @param triggerB defines the trigger to be tested
  80982. * @return a boolean indicating whether one (or more) of the triggers is handled
  80983. */
  80984. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80985. /**
  80986. * Does this action manager handles actions of a given trigger
  80987. * @param trigger defines the trigger to be tested
  80988. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80989. * @return whether the trigger is handled
  80990. */
  80991. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80992. /**
  80993. * Does this action manager has pointer triggers
  80994. */
  80995. readonly hasPointerTriggers: boolean;
  80996. /**
  80997. * Does this action manager has pick triggers
  80998. */
  80999. readonly hasPickTriggers: boolean;
  81000. /**
  81001. * Registers an action to this action manager
  81002. * @param action defines the action to be registered
  81003. * @return the action amended (prepared) after registration
  81004. */
  81005. registerAction(action: IAction): Nullable<IAction>;
  81006. /**
  81007. * Unregisters an action to this action manager
  81008. * @param action defines the action to be unregistered
  81009. * @return a boolean indicating whether the action has been unregistered
  81010. */
  81011. unregisterAction(action: IAction): Boolean;
  81012. /**
  81013. * Process a specific trigger
  81014. * @param trigger defines the trigger to process
  81015. * @param evt defines the event details to be processed
  81016. */
  81017. processTrigger(trigger: number, evt?: IActionEvent): void;
  81018. /** @hidden */
  81019. _getEffectiveTarget(target: any, propertyPath: string): any;
  81020. /** @hidden */
  81021. _getProperty(propertyPath: string): string;
  81022. /**
  81023. * Serialize this manager to a JSON object
  81024. * @param name defines the property name to store this manager
  81025. * @returns a JSON representation of this manager
  81026. */
  81027. serialize(name: string): any;
  81028. /**
  81029. * Creates a new ActionManager from a JSON data
  81030. * @param parsedActions defines the JSON data to read from
  81031. * @param object defines the hosting mesh
  81032. * @param scene defines the hosting scene
  81033. */
  81034. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81035. /**
  81036. * Get a trigger name by index
  81037. * @param trigger defines the trigger index
  81038. * @returns a trigger name
  81039. */
  81040. static GetTriggerName(trigger: number): string;
  81041. }
  81042. }
  81043. declare module BABYLON {
  81044. /**
  81045. * Class representing a ray with position and direction
  81046. */
  81047. export class Ray {
  81048. /** origin point */
  81049. origin: Vector3;
  81050. /** direction */
  81051. direction: Vector3;
  81052. /** length of the ray */
  81053. length: number;
  81054. private static readonly TmpVector3;
  81055. private _tmpRay;
  81056. /**
  81057. * Creates a new ray
  81058. * @param origin origin point
  81059. * @param direction direction
  81060. * @param length length of the ray
  81061. */
  81062. constructor(
  81063. /** origin point */
  81064. origin: Vector3,
  81065. /** direction */
  81066. direction: Vector3,
  81067. /** length of the ray */
  81068. length?: number);
  81069. /**
  81070. * Checks if the ray intersects a box
  81071. * @param minimum bound of the box
  81072. * @param maximum bound of the box
  81073. * @param intersectionTreshold extra extend to be added to the box in all direction
  81074. * @returns if the box was hit
  81075. */
  81076. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81077. /**
  81078. * Checks if the ray intersects a box
  81079. * @param box the bounding box to check
  81080. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81081. * @returns if the box was hit
  81082. */
  81083. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81084. /**
  81085. * If the ray hits a sphere
  81086. * @param sphere the bounding sphere to check
  81087. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81088. * @returns true if it hits the sphere
  81089. */
  81090. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81091. /**
  81092. * If the ray hits a triange
  81093. * @param vertex0 triangle vertex
  81094. * @param vertex1 triangle vertex
  81095. * @param vertex2 triangle vertex
  81096. * @returns intersection information if hit
  81097. */
  81098. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81099. /**
  81100. * Checks if ray intersects a plane
  81101. * @param plane the plane to check
  81102. * @returns the distance away it was hit
  81103. */
  81104. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81105. /**
  81106. * Calculate the intercept of a ray on a given axis
  81107. * @param axis to check 'x' | 'y' | 'z'
  81108. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81109. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81110. */
  81111. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81112. /**
  81113. * Checks if ray intersects a mesh
  81114. * @param mesh the mesh to check
  81115. * @param fastCheck if only the bounding box should checked
  81116. * @returns picking info of the intersecton
  81117. */
  81118. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81119. /**
  81120. * Checks if ray intersects a mesh
  81121. * @param meshes the meshes to check
  81122. * @param fastCheck if only the bounding box should checked
  81123. * @param results array to store result in
  81124. * @returns Array of picking infos
  81125. */
  81126. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81127. private _comparePickingInfo;
  81128. private static smallnum;
  81129. private static rayl;
  81130. /**
  81131. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81132. * @param sega the first point of the segment to test the intersection against
  81133. * @param segb the second point of the segment to test the intersection against
  81134. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81135. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81136. */
  81137. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81138. /**
  81139. * Update the ray from viewport position
  81140. * @param x position
  81141. * @param y y position
  81142. * @param viewportWidth viewport width
  81143. * @param viewportHeight viewport height
  81144. * @param world world matrix
  81145. * @param view view matrix
  81146. * @param projection projection matrix
  81147. * @returns this ray updated
  81148. */
  81149. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81150. /**
  81151. * Creates a ray with origin and direction of 0,0,0
  81152. * @returns the new ray
  81153. */
  81154. static Zero(): Ray;
  81155. /**
  81156. * Creates a new ray from screen space and viewport
  81157. * @param x position
  81158. * @param y y position
  81159. * @param viewportWidth viewport width
  81160. * @param viewportHeight viewport height
  81161. * @param world world matrix
  81162. * @param view view matrix
  81163. * @param projection projection matrix
  81164. * @returns new ray
  81165. */
  81166. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81167. /**
  81168. * 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
  81169. * transformed to the given world matrix.
  81170. * @param origin The origin point
  81171. * @param end The end point
  81172. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81173. * @returns the new ray
  81174. */
  81175. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81176. /**
  81177. * Transforms a ray by a matrix
  81178. * @param ray ray to transform
  81179. * @param matrix matrix to apply
  81180. * @returns the resulting new ray
  81181. */
  81182. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81183. /**
  81184. * Transforms a ray by a matrix
  81185. * @param ray ray to transform
  81186. * @param matrix matrix to apply
  81187. * @param result ray to store result in
  81188. */
  81189. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81190. /**
  81191. * Unproject a ray from screen space to object space
  81192. * @param sourceX defines the screen space x coordinate to use
  81193. * @param sourceY defines the screen space y coordinate to use
  81194. * @param viewportWidth defines the current width of the viewport
  81195. * @param viewportHeight defines the current height of the viewport
  81196. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81197. * @param view defines the view matrix to use
  81198. * @param projection defines the projection matrix to use
  81199. */
  81200. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81201. }
  81202. /**
  81203. * Type used to define predicate used to select faces when a mesh intersection is detected
  81204. */
  81205. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81206. interface Scene {
  81207. /** @hidden */
  81208. _tempPickingRay: Nullable<Ray>;
  81209. /** @hidden */
  81210. _cachedRayForTransform: Ray;
  81211. /** @hidden */
  81212. _pickWithRayInverseMatrix: Matrix;
  81213. /** @hidden */
  81214. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81215. /** @hidden */
  81216. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81217. }
  81218. }
  81219. declare module BABYLON {
  81220. /**
  81221. * Groups all the scene component constants in one place to ease maintenance.
  81222. * @hidden
  81223. */
  81224. export class SceneComponentConstants {
  81225. static readonly NAME_EFFECTLAYER: string;
  81226. static readonly NAME_LAYER: string;
  81227. static readonly NAME_LENSFLARESYSTEM: string;
  81228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81229. static readonly NAME_PARTICLESYSTEM: string;
  81230. static readonly NAME_GAMEPAD: string;
  81231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81233. static readonly NAME_DEPTHRENDERER: string;
  81234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81235. static readonly NAME_SPRITE: string;
  81236. static readonly NAME_OUTLINERENDERER: string;
  81237. static readonly NAME_PROCEDURALTEXTURE: string;
  81238. static readonly NAME_SHADOWGENERATOR: string;
  81239. static readonly NAME_OCTREE: string;
  81240. static readonly NAME_PHYSICSENGINE: string;
  81241. static readonly NAME_AUDIO: string;
  81242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  81249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  81250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  81251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  81252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  81253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  81254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  81255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  81256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  81257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  81258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  81259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  81260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  81261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  81262. static readonly STEP_AFTERRENDER_AUDIO: number;
  81263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  81264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  81265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  81266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  81267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  81268. static readonly STEP_POINTERMOVE_SPRITE: number;
  81269. static readonly STEP_POINTERDOWN_SPRITE: number;
  81270. static readonly STEP_POINTERUP_SPRITE: number;
  81271. }
  81272. /**
  81273. * This represents a scene component.
  81274. *
  81275. * This is used to decouple the dependency the scene is having on the different workloads like
  81276. * layers, post processes...
  81277. */
  81278. export interface ISceneComponent {
  81279. /**
  81280. * The name of the component. Each component must have a unique name.
  81281. */
  81282. name: string;
  81283. /**
  81284. * The scene the component belongs to.
  81285. */
  81286. scene: Scene;
  81287. /**
  81288. * Register the component to one instance of a scene.
  81289. */
  81290. register(): void;
  81291. /**
  81292. * Rebuilds the elements related to this component in case of
  81293. * context lost for instance.
  81294. */
  81295. rebuild(): void;
  81296. /**
  81297. * Disposes the component and the associated ressources.
  81298. */
  81299. dispose(): void;
  81300. }
  81301. /**
  81302. * This represents a SERIALIZABLE scene component.
  81303. *
  81304. * This extends Scene Component to add Serialization methods on top.
  81305. */
  81306. export interface ISceneSerializableComponent extends ISceneComponent {
  81307. /**
  81308. * Adds all the elements from the container to the scene
  81309. * @param container the container holding the elements
  81310. */
  81311. addFromContainer(container: AbstractScene): void;
  81312. /**
  81313. * Removes all the elements in the container from the scene
  81314. * @param container contains the elements to remove
  81315. * @param dispose if the removed element should be disposed (default: false)
  81316. */
  81317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81318. /**
  81319. * Serializes the component data to the specified json object
  81320. * @param serializationObject The object to serialize to
  81321. */
  81322. serialize(serializationObject: any): void;
  81323. }
  81324. /**
  81325. * Strong typing of a Mesh related stage step action
  81326. */
  81327. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  81328. /**
  81329. * Strong typing of a Evaluate Sub Mesh related stage step action
  81330. */
  81331. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  81332. /**
  81333. * Strong typing of a Active Mesh related stage step action
  81334. */
  81335. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  81336. /**
  81337. * Strong typing of a Camera related stage step action
  81338. */
  81339. export type CameraStageAction = (camera: Camera) => void;
  81340. /**
  81341. * Strong typing of a Camera Frame buffer related stage step action
  81342. */
  81343. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  81344. /**
  81345. * Strong typing of a Render Target related stage step action
  81346. */
  81347. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  81348. /**
  81349. * Strong typing of a RenderingGroup related stage step action
  81350. */
  81351. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  81352. /**
  81353. * Strong typing of a Mesh Render related stage step action
  81354. */
  81355. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  81356. /**
  81357. * Strong typing of a simple stage step action
  81358. */
  81359. export type SimpleStageAction = () => void;
  81360. /**
  81361. * Strong typing of a render target action.
  81362. */
  81363. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  81364. /**
  81365. * Strong typing of a pointer move action.
  81366. */
  81367. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  81368. /**
  81369. * Strong typing of a pointer up/down action.
  81370. */
  81371. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  81372. /**
  81373. * Representation of a stage in the scene (Basically a list of ordered steps)
  81374. * @hidden
  81375. */
  81376. export class Stage<T extends Function> extends Array<{
  81377. index: number;
  81378. component: ISceneComponent;
  81379. action: T;
  81380. }> {
  81381. /**
  81382. * Hide ctor from the rest of the world.
  81383. * @param items The items to add.
  81384. */
  81385. private constructor();
  81386. /**
  81387. * Creates a new Stage.
  81388. * @returns A new instance of a Stage
  81389. */
  81390. static Create<T extends Function>(): Stage<T>;
  81391. /**
  81392. * Registers a step in an ordered way in the targeted stage.
  81393. * @param index Defines the position to register the step in
  81394. * @param component Defines the component attached to the step
  81395. * @param action Defines the action to launch during the step
  81396. */
  81397. registerStep(index: number, component: ISceneComponent, action: T): void;
  81398. /**
  81399. * Clears all the steps from the stage.
  81400. */
  81401. clear(): void;
  81402. }
  81403. }
  81404. declare module BABYLON {
  81405. interface Scene {
  81406. /** @hidden */
  81407. _pointerOverSprite: Nullable<Sprite>;
  81408. /** @hidden */
  81409. _pickedDownSprite: Nullable<Sprite>;
  81410. /** @hidden */
  81411. _tempSpritePickingRay: Nullable<Ray>;
  81412. /**
  81413. * All of the sprite managers added to this scene
  81414. * @see http://doc.babylonjs.com/babylon101/sprites
  81415. */
  81416. spriteManagers: Array<ISpriteManager>;
  81417. /**
  81418. * An event triggered when sprites rendering is about to start
  81419. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  81420. */
  81421. onBeforeSpritesRenderingObservable: Observable<Scene>;
  81422. /**
  81423. * An event triggered when sprites rendering is done
  81424. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  81425. */
  81426. onAfterSpritesRenderingObservable: Observable<Scene>;
  81427. /** @hidden */
  81428. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  81429. /** Launch a ray to try to pick a sprite in the scene
  81430. * @param x position on screen
  81431. * @param y position on screen
  81432. * @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
  81433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  81434. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  81435. * @returns a PickingInfo
  81436. */
  81437. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  81438. /** Use the given ray to pick a sprite in the scene
  81439. * @param ray The ray (in world space) to use to pick meshes
  81440. * @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
  81441. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  81442. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  81443. * @returns a PickingInfo
  81444. */
  81445. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  81446. /** @hidden */
  81447. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  81448. /** Launch a ray to try to pick sprites in the scene
  81449. * @param x position on screen
  81450. * @param y position on screen
  81451. * @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
  81452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  81453. * @returns a PickingInfo array
  81454. */
  81455. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  81456. /** Use the given ray to pick sprites in the scene
  81457. * @param ray The ray (in world space) to use to pick meshes
  81458. * @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
  81459. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  81460. * @returns a PickingInfo array
  81461. */
  81462. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  81463. /**
  81464. * Force the sprite under the pointer
  81465. * @param sprite defines the sprite to use
  81466. */
  81467. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  81468. /**
  81469. * Gets the sprite under the pointer
  81470. * @returns a Sprite or null if no sprite is under the pointer
  81471. */
  81472. getPointerOverSprite(): Nullable<Sprite>;
  81473. }
  81474. /**
  81475. * Defines the sprite scene component responsible to manage sprites
  81476. * in a given scene.
  81477. */
  81478. export class SpriteSceneComponent implements ISceneComponent {
  81479. /**
  81480. * The component name helpfull to identify the component in the list of scene components.
  81481. */
  81482. readonly name: string;
  81483. /**
  81484. * The scene the component belongs to.
  81485. */
  81486. scene: Scene;
  81487. /** @hidden */
  81488. private _spritePredicate;
  81489. /**
  81490. * Creates a new instance of the component for the given scene
  81491. * @param scene Defines the scene to register the component in
  81492. */
  81493. constructor(scene: Scene);
  81494. /**
  81495. * Registers the component in a given scene
  81496. */
  81497. register(): void;
  81498. /**
  81499. * Rebuilds the elements related to this component in case of
  81500. * context lost for instance.
  81501. */
  81502. rebuild(): void;
  81503. /**
  81504. * Disposes the component and the associated ressources.
  81505. */
  81506. dispose(): void;
  81507. private _pickSpriteButKeepRay;
  81508. private _pointerMove;
  81509. private _pointerDown;
  81510. private _pointerUp;
  81511. }
  81512. }
  81513. declare module BABYLON {
  81514. /** @hidden */
  81515. export var fogFragmentDeclaration: {
  81516. name: string;
  81517. shader: string;
  81518. };
  81519. }
  81520. declare module BABYLON {
  81521. /** @hidden */
  81522. export var fogFragment: {
  81523. name: string;
  81524. shader: string;
  81525. };
  81526. }
  81527. declare module BABYLON {
  81528. /** @hidden */
  81529. export var spritesPixelShader: {
  81530. name: string;
  81531. shader: string;
  81532. };
  81533. }
  81534. declare module BABYLON {
  81535. /** @hidden */
  81536. export var fogVertexDeclaration: {
  81537. name: string;
  81538. shader: string;
  81539. };
  81540. }
  81541. declare module BABYLON {
  81542. /** @hidden */
  81543. export var spritesVertexShader: {
  81544. name: string;
  81545. shader: string;
  81546. };
  81547. }
  81548. declare module BABYLON {
  81549. /**
  81550. * Defines the minimum interface to fullfil in order to be a sprite manager.
  81551. */
  81552. export interface ISpriteManager extends IDisposable {
  81553. /**
  81554. * Restricts the camera to viewing objects with the same layerMask.
  81555. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  81556. */
  81557. layerMask: number;
  81558. /**
  81559. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81560. */
  81561. isPickable: boolean;
  81562. /**
  81563. * Specifies the rendering group id for this mesh (0 by default)
  81564. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81565. */
  81566. renderingGroupId: number;
  81567. /**
  81568. * Defines the list of sprites managed by the manager.
  81569. */
  81570. sprites: Array<Sprite>;
  81571. /**
  81572. * Tests the intersection of a sprite with a specific ray.
  81573. * @param ray The ray we are sending to test the collision
  81574. * @param camera The camera space we are sending rays in
  81575. * @param predicate A predicate allowing excluding sprites from the list of object to test
  81576. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  81577. * @returns picking info or null.
  81578. */
  81579. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  81580. /**
  81581. * Intersects the sprites with a ray
  81582. * @param ray defines the ray to intersect with
  81583. * @param camera defines the current active camera
  81584. * @param predicate defines a predicate used to select candidate sprites
  81585. * @returns null if no hit or a PickingInfo array
  81586. */
  81587. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  81588. /**
  81589. * Renders the list of sprites on screen.
  81590. */
  81591. render(): void;
  81592. }
  81593. /**
  81594. * Class used to manage multiple sprites on the same spritesheet
  81595. * @see http://doc.babylonjs.com/babylon101/sprites
  81596. */
  81597. export class SpriteManager implements ISpriteManager {
  81598. /** defines the manager's name */
  81599. name: string;
  81600. /** Gets the list of sprites */
  81601. sprites: Sprite[];
  81602. /** Gets or sets the rendering group id (0 by default) */
  81603. renderingGroupId: number;
  81604. /** Gets or sets camera layer mask */
  81605. layerMask: number;
  81606. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  81607. fogEnabled: boolean;
  81608. /** Gets or sets a boolean indicating if the sprites are pickable */
  81609. isPickable: boolean;
  81610. /** Defines the default width of a cell in the spritesheet */
  81611. cellWidth: number;
  81612. /** Defines the default height of a cell in the spritesheet */
  81613. cellHeight: number;
  81614. /** Associative array from JSON sprite data file */
  81615. private _cellData;
  81616. /** Array of sprite names from JSON sprite data file */
  81617. private _spriteMap;
  81618. /** True when packed cell data from JSON file is ready*/
  81619. private _packedAndReady;
  81620. /**
  81621. * An event triggered when the manager is disposed.
  81622. */
  81623. onDisposeObservable: Observable<SpriteManager>;
  81624. private _onDisposeObserver;
  81625. /**
  81626. * Callback called when the manager is disposed
  81627. */
  81628. onDispose: () => void;
  81629. private _capacity;
  81630. private _fromPacked;
  81631. private _spriteTexture;
  81632. private _epsilon;
  81633. private _scene;
  81634. private _vertexData;
  81635. private _buffer;
  81636. private _vertexBuffers;
  81637. private _indexBuffer;
  81638. private _effectBase;
  81639. private _effectFog;
  81640. /**
  81641. * Gets or sets the spritesheet texture
  81642. */
  81643. texture: Texture;
  81644. /**
  81645. * Creates a new sprite manager
  81646. * @param name defines the manager's name
  81647. * @param imgUrl defines the sprite sheet url
  81648. * @param capacity defines the maximum allowed number of sprites
  81649. * @param cellSize defines the size of a sprite cell
  81650. * @param scene defines the hosting scene
  81651. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81652. * @param samplingMode defines the smapling mode to use with spritesheet
  81653. * @param fromPacked set to false; do not alter
  81654. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  81655. */
  81656. constructor(
  81657. /** defines the manager's name */
  81658. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  81659. private _makePacked;
  81660. private _appendSpriteVertex;
  81661. /**
  81662. * Intersects the sprites with a ray
  81663. * @param ray defines the ray to intersect with
  81664. * @param camera defines the current active camera
  81665. * @param predicate defines a predicate used to select candidate sprites
  81666. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  81667. * @returns null if no hit or a PickingInfo
  81668. */
  81669. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  81670. /**
  81671. * Intersects the sprites with a ray
  81672. * @param ray defines the ray to intersect with
  81673. * @param camera defines the current active camera
  81674. * @param predicate defines a predicate used to select candidate sprites
  81675. * @returns null if no hit or a PickingInfo array
  81676. */
  81677. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  81678. /**
  81679. * Render all child sprites
  81680. */
  81681. render(): void;
  81682. /**
  81683. * Release associated resources
  81684. */
  81685. dispose(): void;
  81686. }
  81687. }
  81688. declare module BABYLON {
  81689. /**
  81690. * Class used to represent a sprite
  81691. * @see http://doc.babylonjs.com/babylon101/sprites
  81692. */
  81693. export class Sprite {
  81694. /** defines the name */
  81695. name: string;
  81696. /** Gets or sets the current world position */
  81697. position: Vector3;
  81698. /** Gets or sets the main color */
  81699. color: Color4;
  81700. /** Gets or sets the width */
  81701. width: number;
  81702. /** Gets or sets the height */
  81703. height: number;
  81704. /** Gets or sets rotation angle */
  81705. angle: number;
  81706. /** Gets or sets the cell index in the sprite sheet */
  81707. cellIndex: number;
  81708. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  81709. cellRef: string;
  81710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  81711. invertU: number;
  81712. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  81713. invertV: number;
  81714. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  81715. disposeWhenFinishedAnimating: boolean;
  81716. /** Gets the list of attached animations */
  81717. animations: Animation[];
  81718. /** Gets or sets a boolean indicating if the sprite can be picked */
  81719. isPickable: boolean;
  81720. /**
  81721. * Gets or sets the associated action manager
  81722. */
  81723. actionManager: Nullable<ActionManager>;
  81724. private _animationStarted;
  81725. private _loopAnimation;
  81726. private _fromIndex;
  81727. private _toIndex;
  81728. private _delay;
  81729. private _direction;
  81730. private _manager;
  81731. private _time;
  81732. private _onAnimationEnd;
  81733. /**
  81734. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  81735. */
  81736. isVisible: boolean;
  81737. /**
  81738. * Gets or sets the sprite size
  81739. */
  81740. size: number;
  81741. /**
  81742. * Creates a new Sprite
  81743. * @param name defines the name
  81744. * @param manager defines the manager
  81745. */
  81746. constructor(
  81747. /** defines the name */
  81748. name: string, manager: ISpriteManager);
  81749. /**
  81750. * Starts an animation
  81751. * @param from defines the initial key
  81752. * @param to defines the end key
  81753. * @param loop defines if the animation must loop
  81754. * @param delay defines the start delay (in ms)
  81755. * @param onAnimationEnd defines a callback to call when animation ends
  81756. */
  81757. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  81758. /** Stops current animation (if any) */
  81759. stopAnimation(): void;
  81760. /** @hidden */
  81761. _animate(deltaTime: number): void;
  81762. /** Release associated resources */
  81763. dispose(): void;
  81764. }
  81765. }
  81766. declare module BABYLON {
  81767. /**
  81768. * Information about the result of picking within a scene
  81769. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  81770. */
  81771. export class PickingInfo {
  81772. /** @hidden */
  81773. _pickingUnavailable: boolean;
  81774. /**
  81775. * If the pick collided with an object
  81776. */
  81777. hit: boolean;
  81778. /**
  81779. * Distance away where the pick collided
  81780. */
  81781. distance: number;
  81782. /**
  81783. * The location of pick collision
  81784. */
  81785. pickedPoint: Nullable<Vector3>;
  81786. /**
  81787. * The mesh corresponding the the pick collision
  81788. */
  81789. pickedMesh: Nullable<AbstractMesh>;
  81790. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  81791. bu: number;
  81792. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  81793. bv: number;
  81794. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  81795. faceId: number;
  81796. /** Id of the the submesh that was picked */
  81797. subMeshId: number;
  81798. /** If a sprite was picked, this will be the sprite the pick collided with */
  81799. pickedSprite: Nullable<Sprite>;
  81800. /**
  81801. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  81802. */
  81803. originMesh: Nullable<AbstractMesh>;
  81804. /**
  81805. * The ray that was used to perform the picking.
  81806. */
  81807. ray: Nullable<Ray>;
  81808. /**
  81809. * Gets the normal correspodning to the face the pick collided with
  81810. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  81811. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  81812. * @returns The normal correspodning to the face the pick collided with
  81813. */
  81814. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  81815. /**
  81816. * Gets the texture coordinates of where the pick occured
  81817. * @returns the vector containing the coordnates of the texture
  81818. */
  81819. getTextureCoordinates(): Nullable<Vector2>;
  81820. }
  81821. }
  81822. declare module BABYLON {
  81823. /**
  81824. * Gather the list of pointer event types as constants.
  81825. */
  81826. export class PointerEventTypes {
  81827. /**
  81828. * 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.
  81829. */
  81830. static readonly POINTERDOWN: number;
  81831. /**
  81832. * The pointerup event is fired when a pointer is no longer active.
  81833. */
  81834. static readonly POINTERUP: number;
  81835. /**
  81836. * The pointermove event is fired when a pointer changes coordinates.
  81837. */
  81838. static readonly POINTERMOVE: number;
  81839. /**
  81840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  81841. */
  81842. static readonly POINTERWHEEL: number;
  81843. /**
  81844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  81845. */
  81846. static readonly POINTERPICK: number;
  81847. /**
  81848. * The pointertap event is fired when a the object has been touched and released without drag.
  81849. */
  81850. static readonly POINTERTAP: number;
  81851. /**
  81852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  81853. */
  81854. static readonly POINTERDOUBLETAP: number;
  81855. }
  81856. /**
  81857. * Base class of pointer info types.
  81858. */
  81859. export class PointerInfoBase {
  81860. /**
  81861. * Defines the type of event (PointerEventTypes)
  81862. */
  81863. type: number;
  81864. /**
  81865. * Defines the related dom event
  81866. */
  81867. event: PointerEvent | MouseWheelEvent;
  81868. /**
  81869. * Instantiates the base class of pointers info.
  81870. * @param type Defines the type of event (PointerEventTypes)
  81871. * @param event Defines the related dom event
  81872. */
  81873. constructor(
  81874. /**
  81875. * Defines the type of event (PointerEventTypes)
  81876. */
  81877. type: number,
  81878. /**
  81879. * Defines the related dom event
  81880. */
  81881. event: PointerEvent | MouseWheelEvent);
  81882. }
  81883. /**
  81884. * This class is used to store pointer related info for the onPrePointerObservable event.
  81885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  81886. */
  81887. export class PointerInfoPre extends PointerInfoBase {
  81888. /**
  81889. * Ray from a pointer if availible (eg. 6dof controller)
  81890. */
  81891. ray: Nullable<Ray>;
  81892. /**
  81893. * Defines the local position of the pointer on the canvas.
  81894. */
  81895. localPosition: Vector2;
  81896. /**
  81897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  81898. */
  81899. skipOnPointerObservable: boolean;
  81900. /**
  81901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  81902. * @param type Defines the type of event (PointerEventTypes)
  81903. * @param event Defines the related dom event
  81904. * @param localX Defines the local x coordinates of the pointer when the event occured
  81905. * @param localY Defines the local y coordinates of the pointer when the event occured
  81906. */
  81907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  81908. }
  81909. /**
  81910. * This type contains all the data related to a pointer event in Babylon.js.
  81911. * 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.
  81912. */
  81913. export class PointerInfo extends PointerInfoBase {
  81914. /**
  81915. * Defines the picking info associated to the info (if any)\
  81916. */
  81917. pickInfo: Nullable<PickingInfo>;
  81918. /**
  81919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  81920. * @param type Defines the type of event (PointerEventTypes)
  81921. * @param event Defines the related dom event
  81922. * @param pickInfo Defines the picking info associated to the info (if any)\
  81923. */
  81924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  81925. /**
  81926. * Defines the picking info associated to the info (if any)\
  81927. */
  81928. pickInfo: Nullable<PickingInfo>);
  81929. }
  81930. /**
  81931. * Data relating to a touch event on the screen.
  81932. */
  81933. export interface PointerTouch {
  81934. /**
  81935. * X coordinate of touch.
  81936. */
  81937. x: number;
  81938. /**
  81939. * Y coordinate of touch.
  81940. */
  81941. y: number;
  81942. /**
  81943. * Id of touch. Unique for each finger.
  81944. */
  81945. pointerId: number;
  81946. /**
  81947. * Event type passed from DOM.
  81948. */
  81949. type: any;
  81950. }
  81951. }
  81952. declare module BABYLON {
  81953. /**
  81954. * Manage the mouse inputs to control the movement of a free camera.
  81955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81956. */
  81957. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  81958. /**
  81959. * Define if touch is enabled in the mouse input
  81960. */
  81961. touchEnabled: boolean;
  81962. /**
  81963. * Defines the camera the input is attached to.
  81964. */
  81965. camera: FreeCamera;
  81966. /**
  81967. * Defines the buttons associated with the input to handle camera move.
  81968. */
  81969. buttons: number[];
  81970. /**
  81971. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  81972. */
  81973. angularSensibility: number;
  81974. private _pointerInput;
  81975. private _onMouseMove;
  81976. private _observer;
  81977. private previousPosition;
  81978. /**
  81979. * Observable for when a pointer move event occurs containing the move offset
  81980. */
  81981. onPointerMovedObservable: Observable<{
  81982. offsetX: number;
  81983. offsetY: number;
  81984. }>;
  81985. /**
  81986. * @hidden
  81987. * If the camera should be rotated automatically based on pointer movement
  81988. */
  81989. _allowCameraRotation: boolean;
  81990. /**
  81991. * Manage the mouse inputs to control the movement of a free camera.
  81992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81993. * @param touchEnabled Defines if touch is enabled or not
  81994. */
  81995. constructor(
  81996. /**
  81997. * Define if touch is enabled in the mouse input
  81998. */
  81999. touchEnabled?: boolean);
  82000. /**
  82001. * Attach the input controls to a specific dom element to get the input from.
  82002. * @param element Defines the element the controls should be listened from
  82003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82004. */
  82005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82006. /**
  82007. * Called on JS contextmenu event.
  82008. * Override this method to provide functionality.
  82009. */
  82010. protected onContextMenu(evt: PointerEvent): void;
  82011. /**
  82012. * Detach the current controls from the specified dom element.
  82013. * @param element Defines the element to stop listening the inputs from
  82014. */
  82015. detachControl(element: Nullable<HTMLElement>): void;
  82016. /**
  82017. * Gets the class name of the current intput.
  82018. * @returns the class name
  82019. */
  82020. getClassName(): string;
  82021. /**
  82022. * Get the friendly name associated with the input class.
  82023. * @returns the input friendly name
  82024. */
  82025. getSimpleName(): string;
  82026. }
  82027. }
  82028. declare module BABYLON {
  82029. /**
  82030. * Manage the touch inputs to control the movement of a free camera.
  82031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82032. */
  82033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82034. /**
  82035. * Defines the camera the input is attached to.
  82036. */
  82037. camera: FreeCamera;
  82038. /**
  82039. * Defines the touch sensibility for rotation.
  82040. * The higher the faster.
  82041. */
  82042. touchAngularSensibility: number;
  82043. /**
  82044. * Defines the touch sensibility for move.
  82045. * The higher the faster.
  82046. */
  82047. touchMoveSensibility: number;
  82048. private _offsetX;
  82049. private _offsetY;
  82050. private _pointerPressed;
  82051. private _pointerInput;
  82052. private _observer;
  82053. private _onLostFocus;
  82054. /**
  82055. * Attach the input controls to a specific dom element to get the input from.
  82056. * @param element Defines the element the controls should be listened from
  82057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82058. */
  82059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82060. /**
  82061. * Detach the current controls from the specified dom element.
  82062. * @param element Defines the element to stop listening the inputs from
  82063. */
  82064. detachControl(element: Nullable<HTMLElement>): void;
  82065. /**
  82066. * Update the current camera state depending on the inputs that have been used this frame.
  82067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82068. */
  82069. checkInputs(): void;
  82070. /**
  82071. * Gets the class name of the current intput.
  82072. * @returns the class name
  82073. */
  82074. getClassName(): string;
  82075. /**
  82076. * Get the friendly name associated with the input class.
  82077. * @returns the input friendly name
  82078. */
  82079. getSimpleName(): string;
  82080. }
  82081. }
  82082. declare module BABYLON {
  82083. /**
  82084. * Default Inputs manager for the FreeCamera.
  82085. * It groups all the default supported inputs for ease of use.
  82086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82087. */
  82088. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82089. /**
  82090. * @hidden
  82091. */
  82092. _mouseInput: Nullable<FreeCameraMouseInput>;
  82093. /**
  82094. * Instantiates a new FreeCameraInputsManager.
  82095. * @param camera Defines the camera the inputs belong to
  82096. */
  82097. constructor(camera: FreeCamera);
  82098. /**
  82099. * Add keyboard input support to the input manager.
  82100. * @returns the current input manager
  82101. */
  82102. addKeyboard(): FreeCameraInputsManager;
  82103. /**
  82104. * Add mouse input support to the input manager.
  82105. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82106. * @returns the current input manager
  82107. */
  82108. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82109. /**
  82110. * Removes the mouse input support from the manager
  82111. * @returns the current input manager
  82112. */
  82113. removeMouse(): FreeCameraInputsManager;
  82114. /**
  82115. * Add touch input support to the input manager.
  82116. * @returns the current input manager
  82117. */
  82118. addTouch(): FreeCameraInputsManager;
  82119. /**
  82120. * Remove all attached input methods from a camera
  82121. */
  82122. clear(): void;
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. /**
  82127. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82128. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82130. */
  82131. export class FreeCamera extends TargetCamera {
  82132. /**
  82133. * Define the collision ellipsoid of the camera.
  82134. * This is helpful to simulate a camera body like the player body around the camera
  82135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82136. */
  82137. ellipsoid: Vector3;
  82138. /**
  82139. * Define an offset for the position of the ellipsoid around the camera.
  82140. * This can be helpful to determine the center of the body near the gravity center of the body
  82141. * instead of its head.
  82142. */
  82143. ellipsoidOffset: Vector3;
  82144. /**
  82145. * Enable or disable collisions of the camera with the rest of the scene objects.
  82146. */
  82147. checkCollisions: boolean;
  82148. /**
  82149. * Enable or disable gravity on the camera.
  82150. */
  82151. applyGravity: boolean;
  82152. /**
  82153. * Define the input manager associated to the camera.
  82154. */
  82155. inputs: FreeCameraInputsManager;
  82156. /**
  82157. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82158. * Higher values reduce sensitivity.
  82159. */
  82160. /**
  82161. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82162. * Higher values reduce sensitivity.
  82163. */
  82164. angularSensibility: number;
  82165. /**
  82166. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82167. */
  82168. keysUp: number[];
  82169. /**
  82170. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82171. */
  82172. keysDown: number[];
  82173. /**
  82174. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82175. */
  82176. keysLeft: number[];
  82177. /**
  82178. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82179. */
  82180. keysRight: number[];
  82181. /**
  82182. * Event raised when the camera collide with a mesh in the scene.
  82183. */
  82184. onCollide: (collidedMesh: AbstractMesh) => void;
  82185. private _collider;
  82186. private _needMoveForGravity;
  82187. private _oldPosition;
  82188. private _diffPosition;
  82189. private _newPosition;
  82190. /** @hidden */
  82191. _localDirection: Vector3;
  82192. /** @hidden */
  82193. _transformedDirection: Vector3;
  82194. /**
  82195. * Instantiates a Free Camera.
  82196. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82197. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82199. * @param name Define the name of the camera in the scene
  82200. * @param position Define the start position of the camera in the scene
  82201. * @param scene Define the scene the camera belongs to
  82202. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82203. */
  82204. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82205. /**
  82206. * Attached controls to the current camera.
  82207. * @param element Defines the element the controls should be listened from
  82208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82209. */
  82210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82211. /**
  82212. * Detach the current controls from the camera.
  82213. * The camera will stop reacting to inputs.
  82214. * @param element Defines the element to stop listening the inputs from
  82215. */
  82216. detachControl(element: HTMLElement): void;
  82217. private _collisionMask;
  82218. /**
  82219. * Define a collision mask to limit the list of object the camera can collide with
  82220. */
  82221. collisionMask: number;
  82222. /** @hidden */
  82223. _collideWithWorld(displacement: Vector3): void;
  82224. private _onCollisionPositionChange;
  82225. /** @hidden */
  82226. _checkInputs(): void;
  82227. /** @hidden */
  82228. _decideIfNeedsToMove(): boolean;
  82229. /** @hidden */
  82230. _updatePosition(): void;
  82231. /**
  82232. * Destroy the camera and release the current resources hold by it.
  82233. */
  82234. dispose(): void;
  82235. /**
  82236. * Gets the current object class name.
  82237. * @return the class name
  82238. */
  82239. getClassName(): string;
  82240. }
  82241. }
  82242. declare module BABYLON {
  82243. /**
  82244. * Represents a gamepad control stick position
  82245. */
  82246. export class StickValues {
  82247. /**
  82248. * The x component of the control stick
  82249. */
  82250. x: number;
  82251. /**
  82252. * The y component of the control stick
  82253. */
  82254. y: number;
  82255. /**
  82256. * Initializes the gamepad x and y control stick values
  82257. * @param x The x component of the gamepad control stick value
  82258. * @param y The y component of the gamepad control stick value
  82259. */
  82260. constructor(
  82261. /**
  82262. * The x component of the control stick
  82263. */
  82264. x: number,
  82265. /**
  82266. * The y component of the control stick
  82267. */
  82268. y: number);
  82269. }
  82270. /**
  82271. * An interface which manages callbacks for gamepad button changes
  82272. */
  82273. export interface GamepadButtonChanges {
  82274. /**
  82275. * Called when a gamepad has been changed
  82276. */
  82277. changed: boolean;
  82278. /**
  82279. * Called when a gamepad press event has been triggered
  82280. */
  82281. pressChanged: boolean;
  82282. /**
  82283. * Called when a touch event has been triggered
  82284. */
  82285. touchChanged: boolean;
  82286. /**
  82287. * Called when a value has changed
  82288. */
  82289. valueChanged: boolean;
  82290. }
  82291. /**
  82292. * Represents a gamepad
  82293. */
  82294. export class Gamepad {
  82295. /**
  82296. * The id of the gamepad
  82297. */
  82298. id: string;
  82299. /**
  82300. * The index of the gamepad
  82301. */
  82302. index: number;
  82303. /**
  82304. * The browser gamepad
  82305. */
  82306. browserGamepad: any;
  82307. /**
  82308. * Specifies what type of gamepad this represents
  82309. */
  82310. type: number;
  82311. private _leftStick;
  82312. private _rightStick;
  82313. /** @hidden */
  82314. _isConnected: boolean;
  82315. private _leftStickAxisX;
  82316. private _leftStickAxisY;
  82317. private _rightStickAxisX;
  82318. private _rightStickAxisY;
  82319. /**
  82320. * Triggered when the left control stick has been changed
  82321. */
  82322. private _onleftstickchanged;
  82323. /**
  82324. * Triggered when the right control stick has been changed
  82325. */
  82326. private _onrightstickchanged;
  82327. /**
  82328. * Represents a gamepad controller
  82329. */
  82330. static GAMEPAD: number;
  82331. /**
  82332. * Represents a generic controller
  82333. */
  82334. static GENERIC: number;
  82335. /**
  82336. * Represents an XBox controller
  82337. */
  82338. static XBOX: number;
  82339. /**
  82340. * Represents a pose-enabled controller
  82341. */
  82342. static POSE_ENABLED: number;
  82343. /**
  82344. * Represents an Dual Shock controller
  82345. */
  82346. static DUALSHOCK: number;
  82347. /**
  82348. * Specifies whether the left control stick should be Y-inverted
  82349. */
  82350. protected _invertLeftStickY: boolean;
  82351. /**
  82352. * Specifies if the gamepad has been connected
  82353. */
  82354. readonly isConnected: boolean;
  82355. /**
  82356. * Initializes the gamepad
  82357. * @param id The id of the gamepad
  82358. * @param index The index of the gamepad
  82359. * @param browserGamepad The browser gamepad
  82360. * @param leftStickX The x component of the left joystick
  82361. * @param leftStickY The y component of the left joystick
  82362. * @param rightStickX The x component of the right joystick
  82363. * @param rightStickY The y component of the right joystick
  82364. */
  82365. constructor(
  82366. /**
  82367. * The id of the gamepad
  82368. */
  82369. id: string,
  82370. /**
  82371. * The index of the gamepad
  82372. */
  82373. index: number,
  82374. /**
  82375. * The browser gamepad
  82376. */
  82377. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  82378. /**
  82379. * Callback triggered when the left joystick has changed
  82380. * @param callback
  82381. */
  82382. onleftstickchanged(callback: (values: StickValues) => void): void;
  82383. /**
  82384. * Callback triggered when the right joystick has changed
  82385. * @param callback
  82386. */
  82387. onrightstickchanged(callback: (values: StickValues) => void): void;
  82388. /**
  82389. * Gets the left joystick
  82390. */
  82391. /**
  82392. * Sets the left joystick values
  82393. */
  82394. leftStick: StickValues;
  82395. /**
  82396. * Gets the right joystick
  82397. */
  82398. /**
  82399. * Sets the right joystick value
  82400. */
  82401. rightStick: StickValues;
  82402. /**
  82403. * Updates the gamepad joystick positions
  82404. */
  82405. update(): void;
  82406. /**
  82407. * Disposes the gamepad
  82408. */
  82409. dispose(): void;
  82410. }
  82411. /**
  82412. * Represents a generic gamepad
  82413. */
  82414. export class GenericPad extends Gamepad {
  82415. private _buttons;
  82416. private _onbuttondown;
  82417. private _onbuttonup;
  82418. /**
  82419. * Observable triggered when a button has been pressed
  82420. */
  82421. onButtonDownObservable: Observable<number>;
  82422. /**
  82423. * Observable triggered when a button has been released
  82424. */
  82425. onButtonUpObservable: Observable<number>;
  82426. /**
  82427. * Callback triggered when a button has been pressed
  82428. * @param callback Called when a button has been pressed
  82429. */
  82430. onbuttondown(callback: (buttonPressed: number) => void): void;
  82431. /**
  82432. * Callback triggered when a button has been released
  82433. * @param callback Called when a button has been released
  82434. */
  82435. onbuttonup(callback: (buttonReleased: number) => void): void;
  82436. /**
  82437. * Initializes the generic gamepad
  82438. * @param id The id of the generic gamepad
  82439. * @param index The index of the generic gamepad
  82440. * @param browserGamepad The browser gamepad
  82441. */
  82442. constructor(id: string, index: number, browserGamepad: any);
  82443. private _setButtonValue;
  82444. /**
  82445. * Updates the generic gamepad
  82446. */
  82447. update(): void;
  82448. /**
  82449. * Disposes the generic gamepad
  82450. */
  82451. dispose(): void;
  82452. }
  82453. }
  82454. declare module BABYLON {
  82455. interface Engine {
  82456. /**
  82457. * Creates a raw texture
  82458. * @param data defines the data to store in the texture
  82459. * @param width defines the width of the texture
  82460. * @param height defines the height of the texture
  82461. * @param format defines the format of the data
  82462. * @param generateMipMaps defines if the engine should generate the mip levels
  82463. * @param invertY defines if data must be stored with Y axis inverted
  82464. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82465. * @param compression defines the compression used (null by default)
  82466. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  82467. * @returns the raw texture inside an InternalTexture
  82468. */
  82469. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  82470. /**
  82471. * Update a raw texture
  82472. * @param texture defines the texture to update
  82473. * @param data defines the data to store in the texture
  82474. * @param format defines the format of the data
  82475. * @param invertY defines if data must be stored with Y axis inverted
  82476. */
  82477. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  82478. /**
  82479. * Update a raw texture
  82480. * @param texture defines the texture to update
  82481. * @param data defines the data to store in the texture
  82482. * @param format defines the format of the data
  82483. * @param invertY defines if data must be stored with Y axis inverted
  82484. * @param compression defines the compression used (null by default)
  82485. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  82486. */
  82487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  82488. /**
  82489. * Creates a new raw cube texture
  82490. * @param data defines the array of data to use to create each face
  82491. * @param size defines the size of the textures
  82492. * @param format defines the format of the data
  82493. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  82494. * @param generateMipMaps defines if the engine should generate the mip levels
  82495. * @param invertY defines if data must be stored with Y axis inverted
  82496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  82497. * @param compression defines the compression used (null by default)
  82498. * @returns the cube texture as an InternalTexture
  82499. */
  82500. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  82501. /**
  82502. * Update a raw cube texture
  82503. * @param texture defines the texture to udpdate
  82504. * @param data defines the data to store
  82505. * @param format defines the data format
  82506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  82507. * @param invertY defines if data must be stored with Y axis inverted
  82508. */
  82509. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  82510. /**
  82511. * Update a raw cube texture
  82512. * @param texture defines the texture to udpdate
  82513. * @param data defines the data to store
  82514. * @param format defines the data format
  82515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  82516. * @param invertY defines if data must be stored with Y axis inverted
  82517. * @param compression defines the compression used (null by default)
  82518. */
  82519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  82520. /**
  82521. * Update a raw cube texture
  82522. * @param texture defines the texture to udpdate
  82523. * @param data defines the data to store
  82524. * @param format defines the data format
  82525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  82526. * @param invertY defines if data must be stored with Y axis inverted
  82527. * @param compression defines the compression used (null by default)
  82528. * @param level defines which level of the texture to update
  82529. */
  82530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  82531. /**
  82532. * Creates a new raw cube texture from a specified url
  82533. * @param url defines the url where the data is located
  82534. * @param scene defines the current scene
  82535. * @param size defines the size of the textures
  82536. * @param format defines the format of the data
  82537. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  82538. * @param noMipmap defines if the engine should avoid generating the mip levels
  82539. * @param callback defines a callback used to extract texture data from loaded data
  82540. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  82541. * @param onLoad defines a callback called when texture is loaded
  82542. * @param onError defines a callback called if there is an error
  82543. * @returns the cube texture as an InternalTexture
  82544. */
  82545. 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;
  82546. /**
  82547. * Creates a new raw cube texture from a specified url
  82548. * @param url defines the url where the data is located
  82549. * @param scene defines the current scene
  82550. * @param size defines the size of the textures
  82551. * @param format defines the format of the data
  82552. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  82553. * @param noMipmap defines if the engine should avoid generating the mip levels
  82554. * @param callback defines a callback used to extract texture data from loaded data
  82555. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  82556. * @param onLoad defines a callback called when texture is loaded
  82557. * @param onError defines a callback called if there is an error
  82558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  82559. * @param invertY defines if data must be stored with Y axis inverted
  82560. * @returns the cube texture as an InternalTexture
  82561. */
  82562. 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;
  82563. /**
  82564. * Creates a new raw 3D texture
  82565. * @param data defines the data used to create the texture
  82566. * @param width defines the width of the texture
  82567. * @param height defines the height of the texture
  82568. * @param depth defines the depth of the texture
  82569. * @param format defines the format of the texture
  82570. * @param generateMipMaps defines if the engine must generate mip levels
  82571. * @param invertY defines if data must be stored with Y axis inverted
  82572. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  82573. * @param compression defines the compressed used (can be null)
  82574. * @param textureType defines the compressed used (can be null)
  82575. * @returns a new raw 3D texture (stored in an InternalTexture)
  82576. */
  82577. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  82578. /**
  82579. * Update a raw 3D texture
  82580. * @param texture defines the texture to update
  82581. * @param data defines the data to store
  82582. * @param format defines the data format
  82583. * @param invertY defines if data must be stored with Y axis inverted
  82584. */
  82585. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  82586. /**
  82587. * Update a raw 3D texture
  82588. * @param texture defines the texture to update
  82589. * @param data defines the data to store
  82590. * @param format defines the data format
  82591. * @param invertY defines if data must be stored with Y axis inverted
  82592. * @param compression defines the used compression (can be null)
  82593. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  82594. */
  82595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  82596. /**
  82597. * Creates a new raw 2D array texture
  82598. * @param data defines the data used to create the texture
  82599. * @param width defines the width of the texture
  82600. * @param height defines the height of the texture
  82601. * @param depth defines the number of layers of the texture
  82602. * @param format defines the format of the texture
  82603. * @param generateMipMaps defines if the engine must generate mip levels
  82604. * @param invertY defines if data must be stored with Y axis inverted
  82605. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  82606. * @param compression defines the compressed used (can be null)
  82607. * @param textureType defines the compressed used (can be null)
  82608. * @returns a new raw 2D array texture (stored in an InternalTexture)
  82609. */
  82610. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  82611. /**
  82612. * Update a raw 2D array texture
  82613. * @param texture defines the texture to update
  82614. * @param data defines the data to store
  82615. * @param format defines the data format
  82616. * @param invertY defines if data must be stored with Y axis inverted
  82617. */
  82618. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  82619. /**
  82620. * Update a raw 2D array texture
  82621. * @param texture defines the texture to update
  82622. * @param data defines the data to store
  82623. * @param format defines the data format
  82624. * @param invertY defines if data must be stored with Y axis inverted
  82625. * @param compression defines the used compression (can be null)
  82626. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  82627. */
  82628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  82629. }
  82630. }
  82631. declare module BABYLON {
  82632. /**
  82633. * Raw texture can help creating a texture directly from an array of data.
  82634. * This can be super useful if you either get the data from an uncompressed source or
  82635. * if you wish to create your texture pixel by pixel.
  82636. */
  82637. export class RawTexture extends Texture {
  82638. /**
  82639. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82640. */
  82641. format: number;
  82642. private _engine;
  82643. /**
  82644. * Instantiates a new RawTexture.
  82645. * Raw texture can help creating a texture directly from an array of data.
  82646. * This can be super useful if you either get the data from an uncompressed source or
  82647. * if you wish to create your texture pixel by pixel.
  82648. * @param data define the array of data to use to create the texture
  82649. * @param width define the width of the texture
  82650. * @param height define the height of the texture
  82651. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82652. * @param scene define the scene the texture belongs to
  82653. * @param generateMipMaps define whether mip maps should be generated or not
  82654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82657. */
  82658. constructor(data: ArrayBufferView, width: number, height: number,
  82659. /**
  82660. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82661. */
  82662. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  82663. /**
  82664. * Updates the texture underlying data.
  82665. * @param data Define the new data of the texture
  82666. */
  82667. update(data: ArrayBufferView): void;
  82668. /**
  82669. * Creates a luminance texture from some data.
  82670. * @param data Define the texture data
  82671. * @param width Define the width of the texture
  82672. * @param height Define the height of the texture
  82673. * @param scene Define the scene the texture belongs to
  82674. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82675. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82676. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82677. * @returns the luminance texture
  82678. */
  82679. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82680. /**
  82681. * Creates a luminance alpha texture from some data.
  82682. * @param data Define the texture data
  82683. * @param width Define the width of the texture
  82684. * @param height Define the height of the texture
  82685. * @param scene Define the scene the texture belongs to
  82686. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82687. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82688. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82689. * @returns the luminance alpha texture
  82690. */
  82691. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82692. /**
  82693. * Creates an alpha texture from some data.
  82694. * @param data Define the texture data
  82695. * @param width Define the width of the texture
  82696. * @param height Define the height of the texture
  82697. * @param scene Define the scene the texture belongs to
  82698. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82699. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82700. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82701. * @returns the alpha texture
  82702. */
  82703. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82704. /**
  82705. * Creates a RGB texture from some data.
  82706. * @param data Define the texture data
  82707. * @param width Define the width of the texture
  82708. * @param height Define the height of the texture
  82709. * @param scene Define the scene the texture belongs to
  82710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82713. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82714. * @returns the RGB alpha texture
  82715. */
  82716. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82717. /**
  82718. * Creates a RGBA texture from some data.
  82719. * @param data Define the texture data
  82720. * @param width Define the width of the texture
  82721. * @param height Define the height of the texture
  82722. * @param scene Define the scene the texture belongs to
  82723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82726. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82727. * @returns the RGBA texture
  82728. */
  82729. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82730. /**
  82731. * Creates a R texture from some data.
  82732. * @param data Define the texture data
  82733. * @param width Define the width of the texture
  82734. * @param height Define the height of the texture
  82735. * @param scene Define the scene the texture belongs to
  82736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82739. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82740. * @returns the R texture
  82741. */
  82742. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82743. }
  82744. }
  82745. declare module BABYLON {
  82746. /**
  82747. * Interface for the size containing width and height
  82748. */
  82749. export interface ISize {
  82750. /**
  82751. * Width
  82752. */
  82753. width: number;
  82754. /**
  82755. * Heighht
  82756. */
  82757. height: number;
  82758. }
  82759. /**
  82760. * Size containing widht and height
  82761. */
  82762. export class Size implements ISize {
  82763. /**
  82764. * Width
  82765. */
  82766. width: number;
  82767. /**
  82768. * Height
  82769. */
  82770. height: number;
  82771. /**
  82772. * Creates a Size object from the given width and height (floats).
  82773. * @param width width of the new size
  82774. * @param height height of the new size
  82775. */
  82776. constructor(width: number, height: number);
  82777. /**
  82778. * Returns a string with the Size width and height
  82779. * @returns a string with the Size width and height
  82780. */
  82781. toString(): string;
  82782. /**
  82783. * "Size"
  82784. * @returns the string "Size"
  82785. */
  82786. getClassName(): string;
  82787. /**
  82788. * Returns the Size hash code.
  82789. * @returns a hash code for a unique width and height
  82790. */
  82791. getHashCode(): number;
  82792. /**
  82793. * Updates the current size from the given one.
  82794. * @param src the given size
  82795. */
  82796. copyFrom(src: Size): void;
  82797. /**
  82798. * Updates in place the current Size from the given floats.
  82799. * @param width width of the new size
  82800. * @param height height of the new size
  82801. * @returns the updated Size.
  82802. */
  82803. copyFromFloats(width: number, height: number): Size;
  82804. /**
  82805. * Updates in place the current Size from the given floats.
  82806. * @param width width to set
  82807. * @param height height to set
  82808. * @returns the updated Size.
  82809. */
  82810. set(width: number, height: number): Size;
  82811. /**
  82812. * Multiplies the width and height by numbers
  82813. * @param w factor to multiple the width by
  82814. * @param h factor to multiple the height by
  82815. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  82816. */
  82817. multiplyByFloats(w: number, h: number): Size;
  82818. /**
  82819. * Clones the size
  82820. * @returns a new Size copied from the given one.
  82821. */
  82822. clone(): Size;
  82823. /**
  82824. * True if the current Size and the given one width and height are strictly equal.
  82825. * @param other the other size to compare against
  82826. * @returns True if the current Size and the given one width and height are strictly equal.
  82827. */
  82828. equals(other: Size): boolean;
  82829. /**
  82830. * The surface of the Size : width * height (float).
  82831. */
  82832. readonly surface: number;
  82833. /**
  82834. * Create a new size of zero
  82835. * @returns a new Size set to (0.0, 0.0)
  82836. */
  82837. static Zero(): Size;
  82838. /**
  82839. * Sums the width and height of two sizes
  82840. * @param otherSize size to add to this size
  82841. * @returns a new Size set as the addition result of the current Size and the given one.
  82842. */
  82843. add(otherSize: Size): Size;
  82844. /**
  82845. * Subtracts the width and height of two
  82846. * @param otherSize size to subtract to this size
  82847. * @returns a new Size set as the subtraction result of the given one from the current Size.
  82848. */
  82849. subtract(otherSize: Size): Size;
  82850. /**
  82851. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  82852. * @param start starting size to lerp between
  82853. * @param end end size to lerp between
  82854. * @param amount amount to lerp between the start and end values
  82855. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  82856. */
  82857. static Lerp(start: Size, end: Size, amount: number): Size;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /**
  82862. * Defines a runtime animation
  82863. */
  82864. export class RuntimeAnimation {
  82865. private _events;
  82866. /**
  82867. * The current frame of the runtime animation
  82868. */
  82869. private _currentFrame;
  82870. /**
  82871. * The animation used by the runtime animation
  82872. */
  82873. private _animation;
  82874. /**
  82875. * The target of the runtime animation
  82876. */
  82877. private _target;
  82878. /**
  82879. * The initiating animatable
  82880. */
  82881. private _host;
  82882. /**
  82883. * The original value of the runtime animation
  82884. */
  82885. private _originalValue;
  82886. /**
  82887. * The original blend value of the runtime animation
  82888. */
  82889. private _originalBlendValue;
  82890. /**
  82891. * The offsets cache of the runtime animation
  82892. */
  82893. private _offsetsCache;
  82894. /**
  82895. * The high limits cache of the runtime animation
  82896. */
  82897. private _highLimitsCache;
  82898. /**
  82899. * Specifies if the runtime animation has been stopped
  82900. */
  82901. private _stopped;
  82902. /**
  82903. * The blending factor of the runtime animation
  82904. */
  82905. private _blendingFactor;
  82906. /**
  82907. * The BabylonJS scene
  82908. */
  82909. private _scene;
  82910. /**
  82911. * The current value of the runtime animation
  82912. */
  82913. private _currentValue;
  82914. /** @hidden */
  82915. _animationState: _IAnimationState;
  82916. /**
  82917. * The active target of the runtime animation
  82918. */
  82919. private _activeTargets;
  82920. private _currentActiveTarget;
  82921. private _directTarget;
  82922. /**
  82923. * The target path of the runtime animation
  82924. */
  82925. private _targetPath;
  82926. /**
  82927. * The weight of the runtime animation
  82928. */
  82929. private _weight;
  82930. /**
  82931. * The ratio offset of the runtime animation
  82932. */
  82933. private _ratioOffset;
  82934. /**
  82935. * The previous delay of the runtime animation
  82936. */
  82937. private _previousDelay;
  82938. /**
  82939. * The previous ratio of the runtime animation
  82940. */
  82941. private _previousRatio;
  82942. private _enableBlending;
  82943. private _keys;
  82944. private _minFrame;
  82945. private _maxFrame;
  82946. private _minValue;
  82947. private _maxValue;
  82948. private _targetIsArray;
  82949. /**
  82950. * Gets the current frame of the runtime animation
  82951. */
  82952. readonly currentFrame: number;
  82953. /**
  82954. * Gets the weight of the runtime animation
  82955. */
  82956. readonly weight: number;
  82957. /**
  82958. * Gets the current value of the runtime animation
  82959. */
  82960. readonly currentValue: any;
  82961. /**
  82962. * Gets the target path of the runtime animation
  82963. */
  82964. readonly targetPath: string;
  82965. /**
  82966. * Gets the actual target of the runtime animation
  82967. */
  82968. readonly target: any;
  82969. /** @hidden */
  82970. _onLoop: () => void;
  82971. /**
  82972. * Create a new RuntimeAnimation object
  82973. * @param target defines the target of the animation
  82974. * @param animation defines the source animation object
  82975. * @param scene defines the hosting scene
  82976. * @param host defines the initiating Animatable
  82977. */
  82978. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  82979. private _preparePath;
  82980. /**
  82981. * Gets the animation from the runtime animation
  82982. */
  82983. readonly animation: Animation;
  82984. /**
  82985. * Resets the runtime animation to the beginning
  82986. * @param restoreOriginal defines whether to restore the target property to the original value
  82987. */
  82988. reset(restoreOriginal?: boolean): void;
  82989. /**
  82990. * Specifies if the runtime animation is stopped
  82991. * @returns Boolean specifying if the runtime animation is stopped
  82992. */
  82993. isStopped(): boolean;
  82994. /**
  82995. * Disposes of the runtime animation
  82996. */
  82997. dispose(): void;
  82998. /**
  82999. * Apply the interpolated value to the target
  83000. * @param currentValue defines the value computed by the animation
  83001. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83002. */
  83003. setValue(currentValue: any, weight: number): void;
  83004. private _getOriginalValues;
  83005. private _setValue;
  83006. /**
  83007. * Gets the loop pmode of the runtime animation
  83008. * @returns Loop Mode
  83009. */
  83010. private _getCorrectLoopMode;
  83011. /**
  83012. * Move the current animation to a given frame
  83013. * @param frame defines the frame to move to
  83014. */
  83015. goToFrame(frame: number): void;
  83016. /**
  83017. * @hidden Internal use only
  83018. */
  83019. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83020. /**
  83021. * Execute the current animation
  83022. * @param delay defines the delay to add to the current frame
  83023. * @param from defines the lower bound of the animation range
  83024. * @param to defines the upper bound of the animation range
  83025. * @param loop defines if the current animation must loop
  83026. * @param speedRatio defines the current speed ratio
  83027. * @param weight defines the weight of the animation (default is -1 so no weight)
  83028. * @param onLoop optional callback called when animation loops
  83029. * @returns a boolean indicating if the animation is running
  83030. */
  83031. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83032. }
  83033. }
  83034. declare module BABYLON {
  83035. /**
  83036. * Class used to store an actual running animation
  83037. */
  83038. export class Animatable {
  83039. /** defines the target object */
  83040. target: any;
  83041. /** defines the starting frame number (default is 0) */
  83042. fromFrame: number;
  83043. /** defines the ending frame number (default is 100) */
  83044. toFrame: number;
  83045. /** defines if the animation must loop (default is false) */
  83046. loopAnimation: boolean;
  83047. /** defines a callback to call when animation ends if it is not looping */
  83048. onAnimationEnd?: (() => void) | null | undefined;
  83049. /** defines a callback to call when animation loops */
  83050. onAnimationLoop?: (() => void) | null | undefined;
  83051. private _localDelayOffset;
  83052. private _pausedDelay;
  83053. private _runtimeAnimations;
  83054. private _paused;
  83055. private _scene;
  83056. private _speedRatio;
  83057. private _weight;
  83058. private _syncRoot;
  83059. /**
  83060. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83061. * This will only apply for non looping animation (default is true)
  83062. */
  83063. disposeOnEnd: boolean;
  83064. /**
  83065. * Gets a boolean indicating if the animation has started
  83066. */
  83067. animationStarted: boolean;
  83068. /**
  83069. * Observer raised when the animation ends
  83070. */
  83071. onAnimationEndObservable: Observable<Animatable>;
  83072. /**
  83073. * Observer raised when the animation loops
  83074. */
  83075. onAnimationLoopObservable: Observable<Animatable>;
  83076. /**
  83077. * Gets the root Animatable used to synchronize and normalize animations
  83078. */
  83079. readonly syncRoot: Nullable<Animatable>;
  83080. /**
  83081. * Gets the current frame of the first RuntimeAnimation
  83082. * Used to synchronize Animatables
  83083. */
  83084. readonly masterFrame: number;
  83085. /**
  83086. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83087. */
  83088. weight: number;
  83089. /**
  83090. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83091. */
  83092. speedRatio: number;
  83093. /**
  83094. * Creates a new Animatable
  83095. * @param scene defines the hosting scene
  83096. * @param target defines the target object
  83097. * @param fromFrame defines the starting frame number (default is 0)
  83098. * @param toFrame defines the ending frame number (default is 100)
  83099. * @param loopAnimation defines if the animation must loop (default is false)
  83100. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83101. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83102. * @param animations defines a group of animation to add to the new Animatable
  83103. * @param onAnimationLoop defines a callback to call when animation loops
  83104. */
  83105. constructor(scene: Scene,
  83106. /** defines the target object */
  83107. target: any,
  83108. /** defines the starting frame number (default is 0) */
  83109. fromFrame?: number,
  83110. /** defines the ending frame number (default is 100) */
  83111. toFrame?: number,
  83112. /** defines if the animation must loop (default is false) */
  83113. loopAnimation?: boolean, speedRatio?: number,
  83114. /** defines a callback to call when animation ends if it is not looping */
  83115. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83116. /** defines a callback to call when animation loops */
  83117. onAnimationLoop?: (() => void) | null | undefined);
  83118. /**
  83119. * Synchronize and normalize current Animatable with a source Animatable
  83120. * This is useful when using animation weights and when animations are not of the same length
  83121. * @param root defines the root Animatable to synchronize with
  83122. * @returns the current Animatable
  83123. */
  83124. syncWith(root: Animatable): Animatable;
  83125. /**
  83126. * Gets the list of runtime animations
  83127. * @returns an array of RuntimeAnimation
  83128. */
  83129. getAnimations(): RuntimeAnimation[];
  83130. /**
  83131. * Adds more animations to the current animatable
  83132. * @param target defines the target of the animations
  83133. * @param animations defines the new animations to add
  83134. */
  83135. appendAnimations(target: any, animations: Animation[]): void;
  83136. /**
  83137. * Gets the source animation for a specific property
  83138. * @param property defines the propertyu to look for
  83139. * @returns null or the source animation for the given property
  83140. */
  83141. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83142. /**
  83143. * Gets the runtime animation for a specific property
  83144. * @param property defines the propertyu to look for
  83145. * @returns null or the runtime animation for the given property
  83146. */
  83147. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83148. /**
  83149. * Resets the animatable to its original state
  83150. */
  83151. reset(): void;
  83152. /**
  83153. * Allows the animatable to blend with current running animations
  83154. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83155. * @param blendingSpeed defines the blending speed to use
  83156. */
  83157. enableBlending(blendingSpeed: number): void;
  83158. /**
  83159. * Disable animation blending
  83160. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83161. */
  83162. disableBlending(): void;
  83163. /**
  83164. * Jump directly to a given frame
  83165. * @param frame defines the frame to jump to
  83166. */
  83167. goToFrame(frame: number): void;
  83168. /**
  83169. * Pause the animation
  83170. */
  83171. pause(): void;
  83172. /**
  83173. * Restart the animation
  83174. */
  83175. restart(): void;
  83176. private _raiseOnAnimationEnd;
  83177. /**
  83178. * Stop and delete the current animation
  83179. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83180. * @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)
  83181. */
  83182. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83183. /**
  83184. * Wait asynchronously for the animation to end
  83185. * @returns a promise which will be fullfilled when the animation ends
  83186. */
  83187. waitAsync(): Promise<Animatable>;
  83188. /** @hidden */
  83189. _animate(delay: number): boolean;
  83190. }
  83191. interface Scene {
  83192. /** @hidden */
  83193. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83194. /** @hidden */
  83195. _processLateAnimationBindingsForMatrices(holder: {
  83196. totalWeight: number;
  83197. animations: RuntimeAnimation[];
  83198. originalValue: Matrix;
  83199. }): any;
  83200. /** @hidden */
  83201. _processLateAnimationBindingsForQuaternions(holder: {
  83202. totalWeight: number;
  83203. animations: RuntimeAnimation[];
  83204. originalValue: Quaternion;
  83205. }, refQuaternion: Quaternion): Quaternion;
  83206. /** @hidden */
  83207. _processLateAnimationBindings(): void;
  83208. /**
  83209. * Will start the animation sequence of a given target
  83210. * @param target defines the target
  83211. * @param from defines from which frame should animation start
  83212. * @param to defines until which frame should animation run.
  83213. * @param weight defines the weight to apply to the animation (1.0 by default)
  83214. * @param loop defines if the animation loops
  83215. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83216. * @param onAnimationEnd defines the function to be executed when the animation ends
  83217. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83218. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83219. * @param onAnimationLoop defines the callback to call when an animation loops
  83220. * @returns the animatable object created for this animation
  83221. */
  83222. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83223. /**
  83224. * Will start the animation sequence of a given target
  83225. * @param target defines the target
  83226. * @param from defines from which frame should animation start
  83227. * @param to defines until which frame should animation run.
  83228. * @param loop defines if the animation loops
  83229. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83230. * @param onAnimationEnd defines the function to be executed when the animation ends
  83231. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83232. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83233. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83234. * @param onAnimationLoop defines the callback to call when an animation loops
  83235. * @returns the animatable object created for this animation
  83236. */
  83237. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83238. /**
  83239. * Will start the animation sequence of a given target and its hierarchy
  83240. * @param target defines the target
  83241. * @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.
  83242. * @param from defines from which frame should animation start
  83243. * @param to defines until which frame should animation run.
  83244. * @param loop defines if the animation loops
  83245. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83246. * @param onAnimationEnd defines the function to be executed when the animation ends
  83247. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83248. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83249. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83250. * @param onAnimationLoop defines the callback to call when an animation loops
  83251. * @returns the list of created animatables
  83252. */
  83253. 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[];
  83254. /**
  83255. * Begin a new animation on a given node
  83256. * @param target defines the target where the animation will take place
  83257. * @param animations defines the list of animations to start
  83258. * @param from defines the initial value
  83259. * @param to defines the final value
  83260. * @param loop defines if you want animation to loop (off by default)
  83261. * @param speedRatio defines the speed ratio to apply to all animations
  83262. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83263. * @param onAnimationLoop defines the callback to call when an animation loops
  83264. * @returns the list of created animatables
  83265. */
  83266. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  83267. /**
  83268. * Begin a new animation on a given node and its hierarchy
  83269. * @param target defines the root node where the animation will take place
  83270. * @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.
  83271. * @param animations defines the list of animations to start
  83272. * @param from defines the initial value
  83273. * @param to defines the final value
  83274. * @param loop defines if you want animation to loop (off by default)
  83275. * @param speedRatio defines the speed ratio to apply to all animations
  83276. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83277. * @param onAnimationLoop defines the callback to call when an animation loops
  83278. * @returns the list of animatables created for all nodes
  83279. */
  83280. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  83281. /**
  83282. * Gets the animatable associated with a specific target
  83283. * @param target defines the target of the animatable
  83284. * @returns the required animatable if found
  83285. */
  83286. getAnimatableByTarget(target: any): Nullable<Animatable>;
  83287. /**
  83288. * Gets all animatables associated with a given target
  83289. * @param target defines the target to look animatables for
  83290. * @returns an array of Animatables
  83291. */
  83292. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  83293. /**
  83294. * Stops and removes all animations that have been applied to the scene
  83295. */
  83296. stopAllAnimations(): void;
  83297. /**
  83298. * Gets the current delta time used by animation engine
  83299. */
  83300. deltaTime: number;
  83301. }
  83302. interface Bone {
  83303. /**
  83304. * Copy an animation range from another bone
  83305. * @param source defines the source bone
  83306. * @param rangeName defines the range name to copy
  83307. * @param frameOffset defines the frame offset
  83308. * @param rescaleAsRequired defines if rescaling must be applied if required
  83309. * @param skelDimensionsRatio defines the scaling ratio
  83310. * @returns true if operation was successful
  83311. */
  83312. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  83313. }
  83314. }
  83315. declare module BABYLON {
  83316. /**
  83317. * Class used to override all child animations of a given target
  83318. */
  83319. export class AnimationPropertiesOverride {
  83320. /**
  83321. * Gets or sets a value indicating if animation blending must be used
  83322. */
  83323. enableBlending: boolean;
  83324. /**
  83325. * Gets or sets the blending speed to use when enableBlending is true
  83326. */
  83327. blendingSpeed: number;
  83328. /**
  83329. * Gets or sets the default loop mode to use
  83330. */
  83331. loopMode: number;
  83332. }
  83333. }
  83334. declare module BABYLON {
  83335. /**
  83336. * Class used to handle skinning animations
  83337. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83338. */
  83339. export class Skeleton implements IAnimatable {
  83340. /** defines the skeleton name */
  83341. name: string;
  83342. /** defines the skeleton Id */
  83343. id: string;
  83344. /**
  83345. * Defines the list of child bones
  83346. */
  83347. bones: Bone[];
  83348. /**
  83349. * Defines an estimate of the dimension of the skeleton at rest
  83350. */
  83351. dimensionsAtRest: Vector3;
  83352. /**
  83353. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  83354. */
  83355. needInitialSkinMatrix: boolean;
  83356. /**
  83357. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  83358. */
  83359. overrideMesh: Nullable<AbstractMesh>;
  83360. /**
  83361. * Gets the list of animations attached to this skeleton
  83362. */
  83363. animations: Array<Animation>;
  83364. private _scene;
  83365. private _isDirty;
  83366. private _transformMatrices;
  83367. private _transformMatrixTexture;
  83368. private _meshesWithPoseMatrix;
  83369. private _animatables;
  83370. private _identity;
  83371. private _synchronizedWithMesh;
  83372. private _ranges;
  83373. private _lastAbsoluteTransformsUpdateId;
  83374. private _canUseTextureForBones;
  83375. private _uniqueId;
  83376. /** @hidden */
  83377. _numBonesWithLinkedTransformNode: number;
  83378. /** @hidden */
  83379. _hasWaitingData: Nullable<boolean>;
  83380. /**
  83381. * Specifies if the skeleton should be serialized
  83382. */
  83383. doNotSerialize: boolean;
  83384. private _useTextureToStoreBoneMatrices;
  83385. /**
  83386. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  83387. * Please note that this option is not available if the hardware does not support it
  83388. */
  83389. useTextureToStoreBoneMatrices: boolean;
  83390. private _animationPropertiesOverride;
  83391. /**
  83392. * Gets or sets the animation properties override
  83393. */
  83394. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83395. /**
  83396. * List of inspectable custom properties (used by the Inspector)
  83397. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83398. */
  83399. inspectableCustomProperties: IInspectable[];
  83400. /**
  83401. * An observable triggered before computing the skeleton's matrices
  83402. */
  83403. onBeforeComputeObservable: Observable<Skeleton>;
  83404. /**
  83405. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  83406. */
  83407. readonly isUsingTextureForMatrices: boolean;
  83408. /**
  83409. * Gets the unique ID of this skeleton
  83410. */
  83411. readonly uniqueId: number;
  83412. /**
  83413. * Creates a new skeleton
  83414. * @param name defines the skeleton name
  83415. * @param id defines the skeleton Id
  83416. * @param scene defines the hosting scene
  83417. */
  83418. constructor(
  83419. /** defines the skeleton name */
  83420. name: string,
  83421. /** defines the skeleton Id */
  83422. id: string, scene: Scene);
  83423. /**
  83424. * Gets the current object class name.
  83425. * @return the class name
  83426. */
  83427. getClassName(): string;
  83428. /**
  83429. * Returns an array containing the root bones
  83430. * @returns an array containing the root bones
  83431. */
  83432. getChildren(): Array<Bone>;
  83433. /**
  83434. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  83435. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  83436. * @returns a Float32Array containing matrices data
  83437. */
  83438. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  83439. /**
  83440. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  83441. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  83442. * @returns a raw texture containing the data
  83443. */
  83444. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  83445. /**
  83446. * Gets the current hosting scene
  83447. * @returns a scene object
  83448. */
  83449. getScene(): Scene;
  83450. /**
  83451. * Gets a string representing the current skeleton data
  83452. * @param fullDetails defines a boolean indicating if we want a verbose version
  83453. * @returns a string representing the current skeleton data
  83454. */
  83455. toString(fullDetails?: boolean): string;
  83456. /**
  83457. * Get bone's index searching by name
  83458. * @param name defines bone's name to search for
  83459. * @return the indice of the bone. Returns -1 if not found
  83460. */
  83461. getBoneIndexByName(name: string): number;
  83462. /**
  83463. * Creater a new animation range
  83464. * @param name defines the name of the range
  83465. * @param from defines the start key
  83466. * @param to defines the end key
  83467. */
  83468. createAnimationRange(name: string, from: number, to: number): void;
  83469. /**
  83470. * Delete a specific animation range
  83471. * @param name defines the name of the range
  83472. * @param deleteFrames defines if frames must be removed as well
  83473. */
  83474. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83475. /**
  83476. * Gets a specific animation range
  83477. * @param name defines the name of the range to look for
  83478. * @returns the requested animation range or null if not found
  83479. */
  83480. getAnimationRange(name: string): Nullable<AnimationRange>;
  83481. /**
  83482. * Gets the list of all animation ranges defined on this skeleton
  83483. * @returns an array
  83484. */
  83485. getAnimationRanges(): Nullable<AnimationRange>[];
  83486. /**
  83487. * Copy animation range from a source skeleton.
  83488. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  83489. * @param source defines the source skeleton
  83490. * @param name defines the name of the range to copy
  83491. * @param rescaleAsRequired defines if rescaling must be applied if required
  83492. * @returns true if operation was successful
  83493. */
  83494. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  83495. /**
  83496. * Forces the skeleton to go to rest pose
  83497. */
  83498. returnToRest(): void;
  83499. private _getHighestAnimationFrame;
  83500. /**
  83501. * Begin a specific animation range
  83502. * @param name defines the name of the range to start
  83503. * @param loop defines if looping must be turned on (false by default)
  83504. * @param speedRatio defines the speed ratio to apply (1 by default)
  83505. * @param onAnimationEnd defines a callback which will be called when animation will end
  83506. * @returns a new animatable
  83507. */
  83508. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83509. /** @hidden */
  83510. _markAsDirty(): void;
  83511. /** @hidden */
  83512. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  83513. /** @hidden */
  83514. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  83515. private _computeTransformMatrices;
  83516. /**
  83517. * Build all resources required to render a skeleton
  83518. */
  83519. prepare(): void;
  83520. /**
  83521. * Gets the list of animatables currently running for this skeleton
  83522. * @returns an array of animatables
  83523. */
  83524. getAnimatables(): IAnimatable[];
  83525. /**
  83526. * Clone the current skeleton
  83527. * @param name defines the name of the new skeleton
  83528. * @param id defines the id of the new skeleton
  83529. * @returns the new skeleton
  83530. */
  83531. clone(name: string, id?: string): Skeleton;
  83532. /**
  83533. * Enable animation blending for this skeleton
  83534. * @param blendingSpeed defines the blending speed to apply
  83535. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83536. */
  83537. enableBlending(blendingSpeed?: number): void;
  83538. /**
  83539. * Releases all resources associated with the current skeleton
  83540. */
  83541. dispose(): void;
  83542. /**
  83543. * Serialize the skeleton in a JSON object
  83544. * @returns a JSON object
  83545. */
  83546. serialize(): any;
  83547. /**
  83548. * Creates a new skeleton from serialized data
  83549. * @param parsedSkeleton defines the serialized data
  83550. * @param scene defines the hosting scene
  83551. * @returns a new skeleton
  83552. */
  83553. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  83554. /**
  83555. * Compute all node absolute transforms
  83556. * @param forceUpdate defines if computation must be done even if cache is up to date
  83557. */
  83558. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  83559. /**
  83560. * Gets the root pose matrix
  83561. * @returns a matrix
  83562. */
  83563. getPoseMatrix(): Nullable<Matrix>;
  83564. /**
  83565. * Sorts bones per internal index
  83566. */
  83567. sortBones(): void;
  83568. private _sortBones;
  83569. }
  83570. }
  83571. declare module BABYLON {
  83572. /**
  83573. * Class used to store bone information
  83574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83575. */
  83576. export class Bone extends Node {
  83577. /**
  83578. * defines the bone name
  83579. */
  83580. name: string;
  83581. private static _tmpVecs;
  83582. private static _tmpQuat;
  83583. private static _tmpMats;
  83584. /**
  83585. * Gets the list of child bones
  83586. */
  83587. children: Bone[];
  83588. /** Gets the animations associated with this bone */
  83589. animations: Animation[];
  83590. /**
  83591. * Gets or sets bone length
  83592. */
  83593. length: number;
  83594. /**
  83595. * @hidden Internal only
  83596. * Set this value to map this bone to a different index in the transform matrices
  83597. * Set this value to -1 to exclude the bone from the transform matrices
  83598. */
  83599. _index: Nullable<number>;
  83600. private _skeleton;
  83601. private _localMatrix;
  83602. private _restPose;
  83603. private _baseMatrix;
  83604. private _absoluteTransform;
  83605. private _invertedAbsoluteTransform;
  83606. private _parent;
  83607. private _scalingDeterminant;
  83608. private _worldTransform;
  83609. private _localScaling;
  83610. private _localRotation;
  83611. private _localPosition;
  83612. private _needToDecompose;
  83613. private _needToCompose;
  83614. /** @hidden */
  83615. _linkedTransformNode: Nullable<TransformNode>;
  83616. /** @hidden */
  83617. _waitingTransformNodeId: Nullable<string>;
  83618. /** @hidden */
  83619. /** @hidden */
  83620. _matrix: Matrix;
  83621. /**
  83622. * Create a new bone
  83623. * @param name defines the bone name
  83624. * @param skeleton defines the parent skeleton
  83625. * @param parentBone defines the parent (can be null if the bone is the root)
  83626. * @param localMatrix defines the local matrix
  83627. * @param restPose defines the rest pose matrix
  83628. * @param baseMatrix defines the base matrix
  83629. * @param index defines index of the bone in the hiearchy
  83630. */
  83631. constructor(
  83632. /**
  83633. * defines the bone name
  83634. */
  83635. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  83636. /**
  83637. * Gets the current object class name.
  83638. * @return the class name
  83639. */
  83640. getClassName(): string;
  83641. /**
  83642. * Gets the parent skeleton
  83643. * @returns a skeleton
  83644. */
  83645. getSkeleton(): Skeleton;
  83646. /**
  83647. * Gets parent bone
  83648. * @returns a bone or null if the bone is the root of the bone hierarchy
  83649. */
  83650. getParent(): Nullable<Bone>;
  83651. /**
  83652. * Returns an array containing the root bones
  83653. * @returns an array containing the root bones
  83654. */
  83655. getChildren(): Array<Bone>;
  83656. /**
  83657. * Gets the node index in matrix array generated for rendering
  83658. * @returns the node index
  83659. */
  83660. getIndex(): number;
  83661. /**
  83662. * Sets the parent bone
  83663. * @param parent defines the parent (can be null if the bone is the root)
  83664. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83665. */
  83666. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  83667. /**
  83668. * Gets the local matrix
  83669. * @returns a matrix
  83670. */
  83671. getLocalMatrix(): Matrix;
  83672. /**
  83673. * Gets the base matrix (initial matrix which remains unchanged)
  83674. * @returns a matrix
  83675. */
  83676. getBaseMatrix(): Matrix;
  83677. /**
  83678. * Gets the rest pose matrix
  83679. * @returns a matrix
  83680. */
  83681. getRestPose(): Matrix;
  83682. /**
  83683. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  83684. */
  83685. getWorldMatrix(): Matrix;
  83686. /**
  83687. * Sets the local matrix to rest pose matrix
  83688. */
  83689. returnToRest(): void;
  83690. /**
  83691. * Gets the inverse of the absolute transform matrix.
  83692. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  83693. * @returns a matrix
  83694. */
  83695. getInvertedAbsoluteTransform(): Matrix;
  83696. /**
  83697. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  83698. * @returns a matrix
  83699. */
  83700. getAbsoluteTransform(): Matrix;
  83701. /**
  83702. * Links with the given transform node.
  83703. * The local matrix of this bone is copied from the transform node every frame.
  83704. * @param transformNode defines the transform node to link to
  83705. */
  83706. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  83707. /**
  83708. * Gets the node used to drive the bone's transformation
  83709. * @returns a transform node or null
  83710. */
  83711. getTransformNode(): Nullable<TransformNode>;
  83712. /** Gets or sets current position (in local space) */
  83713. position: Vector3;
  83714. /** Gets or sets current rotation (in local space) */
  83715. rotation: Vector3;
  83716. /** Gets or sets current rotation quaternion (in local space) */
  83717. rotationQuaternion: Quaternion;
  83718. /** Gets or sets current scaling (in local space) */
  83719. scaling: Vector3;
  83720. /**
  83721. * Gets the animation properties override
  83722. */
  83723. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83724. private _decompose;
  83725. private _compose;
  83726. /**
  83727. * Update the base and local matrices
  83728. * @param matrix defines the new base or local matrix
  83729. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83730. * @param updateLocalMatrix defines if the local matrix should be updated
  83731. */
  83732. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  83733. /** @hidden */
  83734. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  83735. /**
  83736. * Flag the bone as dirty (Forcing it to update everything)
  83737. */
  83738. markAsDirty(): void;
  83739. /** @hidden */
  83740. _markAsDirtyAndCompose(): void;
  83741. private _markAsDirtyAndDecompose;
  83742. /**
  83743. * Translate the bone in local or world space
  83744. * @param vec The amount to translate the bone
  83745. * @param space The space that the translation is in
  83746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83747. */
  83748. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83749. /**
  83750. * Set the postion of the bone in local or world space
  83751. * @param position The position to set the bone
  83752. * @param space The space that the position is in
  83753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83754. */
  83755. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83756. /**
  83757. * Set the absolute position of the bone (world space)
  83758. * @param position The position to set the bone
  83759. * @param mesh The mesh that this bone is attached to
  83760. */
  83761. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  83762. /**
  83763. * Scale the bone on the x, y and z axes (in local space)
  83764. * @param x The amount to scale the bone on the x axis
  83765. * @param y The amount to scale the bone on the y axis
  83766. * @param z The amount to scale the bone on the z axis
  83767. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  83768. */
  83769. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  83770. /**
  83771. * Set the bone scaling in local space
  83772. * @param scale defines the scaling vector
  83773. */
  83774. setScale(scale: Vector3): void;
  83775. /**
  83776. * Gets the current scaling in local space
  83777. * @returns the current scaling vector
  83778. */
  83779. getScale(): Vector3;
  83780. /**
  83781. * Gets the current scaling in local space and stores it in a target vector
  83782. * @param result defines the target vector
  83783. */
  83784. getScaleToRef(result: Vector3): void;
  83785. /**
  83786. * Set the yaw, pitch, and roll of the bone in local or world space
  83787. * @param yaw The rotation of the bone on the y axis
  83788. * @param pitch The rotation of the bone on the x axis
  83789. * @param roll The rotation of the bone on the z axis
  83790. * @param space The space that the axes of rotation are in
  83791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83792. */
  83793. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  83794. /**
  83795. * Add a rotation to the bone on an axis in local or world space
  83796. * @param axis The axis to rotate the bone on
  83797. * @param amount The amount to rotate the bone
  83798. * @param space The space that the axis is in
  83799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83800. */
  83801. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  83802. /**
  83803. * Set the rotation of the bone to a particular axis angle in local or world space
  83804. * @param axis The axis to rotate the bone on
  83805. * @param angle The angle that the bone should be rotated to
  83806. * @param space The space that the axis is in
  83807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83808. */
  83809. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  83810. /**
  83811. * Set the euler rotation of the bone in local of world space
  83812. * @param rotation The euler rotation that the bone should be set to
  83813. * @param space The space that the rotation is in
  83814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83815. */
  83816. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83817. /**
  83818. * Set the quaternion rotation of the bone in local of world space
  83819. * @param quat The quaternion rotation that the bone should be set to
  83820. * @param space The space that the rotation is in
  83821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83822. */
  83823. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  83824. /**
  83825. * Set the rotation matrix of the bone in local of world space
  83826. * @param rotMat The rotation matrix that the bone should be set to
  83827. * @param space The space that the rotation is in
  83828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83829. */
  83830. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  83831. private _rotateWithMatrix;
  83832. private _getNegativeRotationToRef;
  83833. /**
  83834. * Get the position of the bone in local or world space
  83835. * @param space The space that the returned position is in
  83836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83837. * @returns The position of the bone
  83838. */
  83839. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83840. /**
  83841. * Copy the position of the bone to a vector3 in local or world space
  83842. * @param space The space that the returned position is in
  83843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83844. * @param result The vector3 to copy the position to
  83845. */
  83846. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  83847. /**
  83848. * Get the absolute position of the bone (world space)
  83849. * @param mesh The mesh that this bone is attached to
  83850. * @returns The absolute position of the bone
  83851. */
  83852. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  83853. /**
  83854. * Copy the absolute position of the bone (world space) to the result param
  83855. * @param mesh The mesh that this bone is attached to
  83856. * @param result The vector3 to copy the absolute position to
  83857. */
  83858. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  83859. /**
  83860. * Compute the absolute transforms of this bone and its children
  83861. */
  83862. computeAbsoluteTransforms(): void;
  83863. /**
  83864. * Get the world direction from an axis that is in the local space of the bone
  83865. * @param localAxis The local direction that is used to compute the world direction
  83866. * @param mesh The mesh that this bone is attached to
  83867. * @returns The world direction
  83868. */
  83869. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83870. /**
  83871. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  83872. * @param localAxis The local direction that is used to compute the world direction
  83873. * @param mesh The mesh that this bone is attached to
  83874. * @param result The vector3 that the world direction will be copied to
  83875. */
  83876. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83877. /**
  83878. * Get the euler rotation of the bone in local or world space
  83879. * @param space The space that the rotation should be in
  83880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83881. * @returns The euler rotation
  83882. */
  83883. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83884. /**
  83885. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  83886. * @param space The space that the rotation should be in
  83887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83888. * @param result The vector3 that the rotation should be copied to
  83889. */
  83890. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83891. /**
  83892. * Get the quaternion rotation of the bone in either local or world space
  83893. * @param space The space that the rotation should be in
  83894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83895. * @returns The quaternion rotation
  83896. */
  83897. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  83898. /**
  83899. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  83900. * @param space The space that the rotation should be in
  83901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83902. * @param result The quaternion that the rotation should be copied to
  83903. */
  83904. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  83905. /**
  83906. * Get the rotation matrix of the bone in local or world space
  83907. * @param space The space that the rotation should be in
  83908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83909. * @returns The rotation matrix
  83910. */
  83911. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  83912. /**
  83913. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  83914. * @param space The space that the rotation should be in
  83915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83916. * @param result The quaternion that the rotation should be copied to
  83917. */
  83918. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  83919. /**
  83920. * Get the world position of a point that is in the local space of the bone
  83921. * @param position The local position
  83922. * @param mesh The mesh that this bone is attached to
  83923. * @returns The world position
  83924. */
  83925. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83926. /**
  83927. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  83928. * @param position The local position
  83929. * @param mesh The mesh that this bone is attached to
  83930. * @param result The vector3 that the world position should be copied to
  83931. */
  83932. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83933. /**
  83934. * Get the local position of a point that is in world space
  83935. * @param position The world position
  83936. * @param mesh The mesh that this bone is attached to
  83937. * @returns The local position
  83938. */
  83939. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83940. /**
  83941. * Get the local position of a point that is in world space and copy it to the result param
  83942. * @param position The world position
  83943. * @param mesh The mesh that this bone is attached to
  83944. * @param result The vector3 that the local position should be copied to
  83945. */
  83946. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83947. }
  83948. }
  83949. declare module BABYLON {
  83950. /**
  83951. * 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.
  83952. * @see https://doc.babylonjs.com/how_to/transformnode
  83953. */
  83954. export class TransformNode extends Node {
  83955. /**
  83956. * Object will not rotate to face the camera
  83957. */
  83958. static BILLBOARDMODE_NONE: number;
  83959. /**
  83960. * Object will rotate to face the camera but only on the x axis
  83961. */
  83962. static BILLBOARDMODE_X: number;
  83963. /**
  83964. * Object will rotate to face the camera but only on the y axis
  83965. */
  83966. static BILLBOARDMODE_Y: number;
  83967. /**
  83968. * Object will rotate to face the camera but only on the z axis
  83969. */
  83970. static BILLBOARDMODE_Z: number;
  83971. /**
  83972. * Object will rotate to face the camera
  83973. */
  83974. static BILLBOARDMODE_ALL: number;
  83975. /**
  83976. * Object will rotate to face the camera's position instead of orientation
  83977. */
  83978. static BILLBOARDMODE_USE_POSITION: number;
  83979. private _forward;
  83980. private _forwardInverted;
  83981. private _up;
  83982. private _right;
  83983. private _rightInverted;
  83984. private _position;
  83985. private _rotation;
  83986. private _rotationQuaternion;
  83987. protected _scaling: Vector3;
  83988. protected _isDirty: boolean;
  83989. private _transformToBoneReferal;
  83990. private _isAbsoluteSynced;
  83991. private _billboardMode;
  83992. /**
  83993. * Gets or sets the billboard mode. Default is 0.
  83994. *
  83995. * | Value | Type | Description |
  83996. * | --- | --- | --- |
  83997. * | 0 | BILLBOARDMODE_NONE | |
  83998. * | 1 | BILLBOARDMODE_X | |
  83999. * | 2 | BILLBOARDMODE_Y | |
  84000. * | 4 | BILLBOARDMODE_Z | |
  84001. * | 7 | BILLBOARDMODE_ALL | |
  84002. *
  84003. */
  84004. billboardMode: number;
  84005. private _preserveParentRotationForBillboard;
  84006. /**
  84007. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84008. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84009. */
  84010. preserveParentRotationForBillboard: boolean;
  84011. /**
  84012. * 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
  84013. */
  84014. scalingDeterminant: number;
  84015. private _infiniteDistance;
  84016. /**
  84017. * Gets or sets the distance of the object to max, often used by skybox
  84018. */
  84019. infiniteDistance: boolean;
  84020. /**
  84021. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84022. * By default the system will update normals to compensate
  84023. */
  84024. ignoreNonUniformScaling: boolean;
  84025. /**
  84026. * 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
  84027. */
  84028. reIntegrateRotationIntoRotationQuaternion: boolean;
  84029. /** @hidden */
  84030. _poseMatrix: Nullable<Matrix>;
  84031. /** @hidden */
  84032. _localMatrix: Matrix;
  84033. private _usePivotMatrix;
  84034. private _absolutePosition;
  84035. private _absoluteScaling;
  84036. private _absoluteRotationQuaternion;
  84037. private _pivotMatrix;
  84038. private _pivotMatrixInverse;
  84039. protected _postMultiplyPivotMatrix: boolean;
  84040. protected _isWorldMatrixFrozen: boolean;
  84041. /** @hidden */
  84042. _indexInSceneTransformNodesArray: number;
  84043. /**
  84044. * An event triggered after the world matrix is updated
  84045. */
  84046. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84047. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84048. /**
  84049. * Gets a string identifying the name of the class
  84050. * @returns "TransformNode" string
  84051. */
  84052. getClassName(): string;
  84053. /**
  84054. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84055. */
  84056. position: Vector3;
  84057. /**
  84058. * 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)).
  84059. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84060. */
  84061. rotation: Vector3;
  84062. /**
  84063. * 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)).
  84064. */
  84065. scaling: Vector3;
  84066. /**
  84067. * 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).
  84068. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84069. */
  84070. rotationQuaternion: Nullable<Quaternion>;
  84071. /**
  84072. * The forward direction of that transform in world space.
  84073. */
  84074. readonly forward: Vector3;
  84075. /**
  84076. * The up direction of that transform in world space.
  84077. */
  84078. readonly up: Vector3;
  84079. /**
  84080. * The right direction of that transform in world space.
  84081. */
  84082. readonly right: Vector3;
  84083. /**
  84084. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84085. * @param matrix the matrix to copy the pose from
  84086. * @returns this TransformNode.
  84087. */
  84088. updatePoseMatrix(matrix: Matrix): TransformNode;
  84089. /**
  84090. * Returns the mesh Pose matrix.
  84091. * @returns the pose matrix
  84092. */
  84093. getPoseMatrix(): Matrix;
  84094. /** @hidden */
  84095. _isSynchronized(): boolean;
  84096. /** @hidden */
  84097. _initCache(): void;
  84098. /**
  84099. * Flag the transform node as dirty (Forcing it to update everything)
  84100. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84101. * @returns this transform node
  84102. */
  84103. markAsDirty(property: string): TransformNode;
  84104. /**
  84105. * Returns the current mesh absolute position.
  84106. * Returns a Vector3.
  84107. */
  84108. readonly absolutePosition: Vector3;
  84109. /**
  84110. * Returns the current mesh absolute scaling.
  84111. * Returns a Vector3.
  84112. */
  84113. readonly absoluteScaling: Vector3;
  84114. /**
  84115. * Returns the current mesh absolute rotation.
  84116. * Returns a Quaternion.
  84117. */
  84118. readonly absoluteRotationQuaternion: Quaternion;
  84119. /**
  84120. * Sets a new matrix to apply before all other transformation
  84121. * @param matrix defines the transform matrix
  84122. * @returns the current TransformNode
  84123. */
  84124. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84125. /**
  84126. * Sets a new pivot matrix to the current node
  84127. * @param matrix defines the new pivot matrix to use
  84128. * @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
  84129. * @returns the current TransformNode
  84130. */
  84131. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84132. /**
  84133. * Returns the mesh pivot matrix.
  84134. * Default : Identity.
  84135. * @returns the matrix
  84136. */
  84137. getPivotMatrix(): Matrix;
  84138. /**
  84139. * Instantiate (when possible) or clone that node with its hierarchy
  84140. * @param newParent defines the new parent to use for the instance (or clone)
  84141. * @param options defines options to configure how copy is done
  84142. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84143. * @returns an instance (or a clone) of the current node with its hiearchy
  84144. */
  84145. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84146. doNotInstantiate: boolean;
  84147. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84148. /**
  84149. * Prevents the World matrix to be computed any longer
  84150. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84151. * @returns the TransformNode.
  84152. */
  84153. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84154. /**
  84155. * Allows back the World matrix computation.
  84156. * @returns the TransformNode.
  84157. */
  84158. unfreezeWorldMatrix(): this;
  84159. /**
  84160. * True if the World matrix has been frozen.
  84161. */
  84162. readonly isWorldMatrixFrozen: boolean;
  84163. /**
  84164. * Retuns the mesh absolute position in the World.
  84165. * @returns a Vector3.
  84166. */
  84167. getAbsolutePosition(): Vector3;
  84168. /**
  84169. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84170. * @param absolutePosition the absolute position to set
  84171. * @returns the TransformNode.
  84172. */
  84173. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84174. /**
  84175. * Sets the mesh position in its local space.
  84176. * @param vector3 the position to set in localspace
  84177. * @returns the TransformNode.
  84178. */
  84179. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84180. /**
  84181. * Returns the mesh position in the local space from the current World matrix values.
  84182. * @returns a new Vector3.
  84183. */
  84184. getPositionExpressedInLocalSpace(): Vector3;
  84185. /**
  84186. * Translates the mesh along the passed Vector3 in its local space.
  84187. * @param vector3 the distance to translate in localspace
  84188. * @returns the TransformNode.
  84189. */
  84190. locallyTranslate(vector3: Vector3): TransformNode;
  84191. private static _lookAtVectorCache;
  84192. /**
  84193. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84194. * @param targetPoint the position (must be in same space as current mesh) to look at
  84195. * @param yawCor optional yaw (y-axis) correction in radians
  84196. * @param pitchCor optional pitch (x-axis) correction in radians
  84197. * @param rollCor optional roll (z-axis) correction in radians
  84198. * @param space the choosen space of the target
  84199. * @returns the TransformNode.
  84200. */
  84201. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84202. /**
  84203. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84204. * This Vector3 is expressed in the World space.
  84205. * @param localAxis axis to rotate
  84206. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84207. */
  84208. getDirection(localAxis: Vector3): Vector3;
  84209. /**
  84210. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84211. * localAxis is expressed in the mesh local space.
  84212. * result is computed in the Wordl space from the mesh World matrix.
  84213. * @param localAxis axis to rotate
  84214. * @param result the resulting transformnode
  84215. * @returns this TransformNode.
  84216. */
  84217. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84218. /**
  84219. * Sets this transform node rotation to the given local axis.
  84220. * @param localAxis the axis in local space
  84221. * @param yawCor optional yaw (y-axis) correction in radians
  84222. * @param pitchCor optional pitch (x-axis) correction in radians
  84223. * @param rollCor optional roll (z-axis) correction in radians
  84224. * @returns this TransformNode
  84225. */
  84226. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  84227. /**
  84228. * Sets a new pivot point to the current node
  84229. * @param point defines the new pivot point to use
  84230. * @param space defines if the point is in world or local space (local by default)
  84231. * @returns the current TransformNode
  84232. */
  84233. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  84234. /**
  84235. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  84236. * @returns the pivot point
  84237. */
  84238. getPivotPoint(): Vector3;
  84239. /**
  84240. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  84241. * @param result the vector3 to store the result
  84242. * @returns this TransformNode.
  84243. */
  84244. getPivotPointToRef(result: Vector3): TransformNode;
  84245. /**
  84246. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  84247. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  84248. */
  84249. getAbsolutePivotPoint(): Vector3;
  84250. /**
  84251. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  84252. * @param result vector3 to store the result
  84253. * @returns this TransformNode.
  84254. */
  84255. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  84256. /**
  84257. * Defines the passed node as the parent of the current node.
  84258. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  84259. * @see https://doc.babylonjs.com/how_to/parenting
  84260. * @param node the node ot set as the parent
  84261. * @returns this TransformNode.
  84262. */
  84263. setParent(node: Nullable<Node>): TransformNode;
  84264. private _nonUniformScaling;
  84265. /**
  84266. * True if the scaling property of this object is non uniform eg. (1,2,1)
  84267. */
  84268. readonly nonUniformScaling: boolean;
  84269. /** @hidden */
  84270. _updateNonUniformScalingState(value: boolean): boolean;
  84271. /**
  84272. * Attach the current TransformNode to another TransformNode associated with a bone
  84273. * @param bone Bone affecting the TransformNode
  84274. * @param affectedTransformNode TransformNode associated with the bone
  84275. * @returns this object
  84276. */
  84277. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  84278. /**
  84279. * Detach the transform node if its associated with a bone
  84280. * @returns this object
  84281. */
  84282. detachFromBone(): TransformNode;
  84283. private static _rotationAxisCache;
  84284. /**
  84285. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  84286. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84287. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84288. * The passed axis is also normalized.
  84289. * @param axis the axis to rotate around
  84290. * @param amount the amount to rotate in radians
  84291. * @param space Space to rotate in (Default: local)
  84292. * @returns the TransformNode.
  84293. */
  84294. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  84295. /**
  84296. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  84297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84298. * The passed axis is also normalized. .
  84299. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  84300. * @param point the point to rotate around
  84301. * @param axis the axis to rotate around
  84302. * @param amount the amount to rotate in radians
  84303. * @returns the TransformNode
  84304. */
  84305. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  84306. /**
  84307. * Translates the mesh along the axis vector for the passed distance in the given space.
  84308. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84309. * @param axis the axis to translate in
  84310. * @param distance the distance to translate
  84311. * @param space Space to rotate in (Default: local)
  84312. * @returns the TransformNode.
  84313. */
  84314. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  84315. /**
  84316. * Adds a rotation step to the mesh current rotation.
  84317. * x, y, z are Euler angles expressed in radians.
  84318. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  84319. * This means this rotation is made in the mesh local space only.
  84320. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  84321. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  84322. * ```javascript
  84323. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  84324. * ```
  84325. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  84326. * 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.
  84327. * @param x Rotation to add
  84328. * @param y Rotation to add
  84329. * @param z Rotation to add
  84330. * @returns the TransformNode.
  84331. */
  84332. addRotation(x: number, y: number, z: number): TransformNode;
  84333. /**
  84334. * @hidden
  84335. */
  84336. protected _getEffectiveParent(): Nullable<Node>;
  84337. /**
  84338. * Computes the world matrix of the node
  84339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84340. * @returns the world matrix
  84341. */
  84342. computeWorldMatrix(force?: boolean): Matrix;
  84343. protected _afterComputeWorldMatrix(): void;
  84344. /**
  84345. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  84346. * @param func callback function to add
  84347. *
  84348. * @returns the TransformNode.
  84349. */
  84350. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  84351. /**
  84352. * Removes a registered callback function.
  84353. * @param func callback function to remove
  84354. * @returns the TransformNode.
  84355. */
  84356. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  84357. /**
  84358. * Gets the position of the current mesh in camera space
  84359. * @param camera defines the camera to use
  84360. * @returns a position
  84361. */
  84362. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  84363. /**
  84364. * Returns the distance from the mesh to the active camera
  84365. * @param camera defines the camera to use
  84366. * @returns the distance
  84367. */
  84368. getDistanceToCamera(camera?: Nullable<Camera>): number;
  84369. /**
  84370. * Clone the current transform node
  84371. * @param name Name of the new clone
  84372. * @param newParent New parent for the clone
  84373. * @param doNotCloneChildren Do not clone children hierarchy
  84374. * @returns the new transform node
  84375. */
  84376. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  84377. /**
  84378. * Serializes the objects information.
  84379. * @param currentSerializationObject defines the object to serialize in
  84380. * @returns the serialized object
  84381. */
  84382. serialize(currentSerializationObject?: any): any;
  84383. /**
  84384. * Returns a new TransformNode object parsed from the source provided.
  84385. * @param parsedTransformNode is the source.
  84386. * @param scene the scne the object belongs to
  84387. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  84388. * @returns a new TransformNode object parsed from the source provided.
  84389. */
  84390. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  84391. /**
  84392. * Get all child-transformNodes of this node
  84393. * @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
  84394. * @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
  84395. * @returns an array of TransformNode
  84396. */
  84397. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  84398. /**
  84399. * Releases resources associated with this transform node.
  84400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84402. */
  84403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84404. /**
  84405. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84406. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84407. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84408. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  84409. * @returns the current mesh
  84410. */
  84411. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  84412. private _syncAbsoluteScalingAndRotation;
  84413. }
  84414. }
  84415. declare module BABYLON {
  84416. /**
  84417. * Defines the types of pose enabled controllers that are supported
  84418. */
  84419. export enum PoseEnabledControllerType {
  84420. /**
  84421. * HTC Vive
  84422. */
  84423. VIVE = 0,
  84424. /**
  84425. * Oculus Rift
  84426. */
  84427. OCULUS = 1,
  84428. /**
  84429. * Windows mixed reality
  84430. */
  84431. WINDOWS = 2,
  84432. /**
  84433. * Samsung gear VR
  84434. */
  84435. GEAR_VR = 3,
  84436. /**
  84437. * Google Daydream
  84438. */
  84439. DAYDREAM = 4,
  84440. /**
  84441. * Generic
  84442. */
  84443. GENERIC = 5
  84444. }
  84445. /**
  84446. * Defines the MutableGamepadButton interface for the state of a gamepad button
  84447. */
  84448. export interface MutableGamepadButton {
  84449. /**
  84450. * Value of the button/trigger
  84451. */
  84452. value: number;
  84453. /**
  84454. * If the button/trigger is currently touched
  84455. */
  84456. touched: boolean;
  84457. /**
  84458. * If the button/trigger is currently pressed
  84459. */
  84460. pressed: boolean;
  84461. }
  84462. /**
  84463. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  84464. * @hidden
  84465. */
  84466. export interface ExtendedGamepadButton extends GamepadButton {
  84467. /**
  84468. * If the button/trigger is currently pressed
  84469. */
  84470. readonly pressed: boolean;
  84471. /**
  84472. * If the button/trigger is currently touched
  84473. */
  84474. readonly touched: boolean;
  84475. /**
  84476. * Value of the button/trigger
  84477. */
  84478. readonly value: number;
  84479. }
  84480. /** @hidden */
  84481. export interface _GamePadFactory {
  84482. /**
  84483. * Returns wether or not the current gamepad can be created for this type of controller.
  84484. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  84485. * @returns true if it can be created, otherwise false
  84486. */
  84487. canCreate(gamepadInfo: any): boolean;
  84488. /**
  84489. * Creates a new instance of the Gamepad.
  84490. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  84491. * @returns the new gamepad instance
  84492. */
  84493. create(gamepadInfo: any): Gamepad;
  84494. }
  84495. /**
  84496. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  84497. */
  84498. export class PoseEnabledControllerHelper {
  84499. /** @hidden */
  84500. static _ControllerFactories: _GamePadFactory[];
  84501. /** @hidden */
  84502. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  84503. /**
  84504. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  84505. * @param vrGamepad the gamepad to initialized
  84506. * @returns a vr controller of the type the gamepad identified as
  84507. */
  84508. static InitiateController(vrGamepad: any): Gamepad;
  84509. }
  84510. /**
  84511. * Defines the PoseEnabledController object that contains state of a vr capable controller
  84512. */
  84513. export class PoseEnabledController extends Gamepad implements PoseControlled {
  84514. /**
  84515. * If the controller is used in a webXR session
  84516. */
  84517. isXR: boolean;
  84518. private _deviceRoomPosition;
  84519. private _deviceRoomRotationQuaternion;
  84520. /**
  84521. * The device position in babylon space
  84522. */
  84523. devicePosition: Vector3;
  84524. /**
  84525. * The device rotation in babylon space
  84526. */
  84527. deviceRotationQuaternion: Quaternion;
  84528. /**
  84529. * The scale factor of the device in babylon space
  84530. */
  84531. deviceScaleFactor: number;
  84532. /**
  84533. * (Likely devicePosition should be used instead) The device position in its room space
  84534. */
  84535. position: Vector3;
  84536. /**
  84537. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  84538. */
  84539. rotationQuaternion: Quaternion;
  84540. /**
  84541. * The type of controller (Eg. Windows mixed reality)
  84542. */
  84543. controllerType: PoseEnabledControllerType;
  84544. protected _calculatedPosition: Vector3;
  84545. private _calculatedRotation;
  84546. /**
  84547. * The raw pose from the device
  84548. */
  84549. rawPose: DevicePose;
  84550. private _trackPosition;
  84551. private _maxRotationDistFromHeadset;
  84552. private _draggedRoomRotation;
  84553. /**
  84554. * @hidden
  84555. */
  84556. _disableTrackPosition(fixedPosition: Vector3): void;
  84557. /**
  84558. * Internal, the mesh attached to the controller
  84559. * @hidden
  84560. */
  84561. _mesh: Nullable<AbstractMesh>;
  84562. private _poseControlledCamera;
  84563. private _leftHandSystemQuaternion;
  84564. /**
  84565. * Internal, matrix used to convert room space to babylon space
  84566. * @hidden
  84567. */
  84568. _deviceToWorld: Matrix;
  84569. /**
  84570. * Node to be used when casting a ray from the controller
  84571. * @hidden
  84572. */
  84573. _pointingPoseNode: Nullable<TransformNode>;
  84574. /**
  84575. * Name of the child mesh that can be used to cast a ray from the controller
  84576. */
  84577. static readonly POINTING_POSE: string;
  84578. /**
  84579. * Creates a new PoseEnabledController from a gamepad
  84580. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  84581. */
  84582. constructor(browserGamepad: any);
  84583. private _workingMatrix;
  84584. /**
  84585. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  84586. */
  84587. update(): void;
  84588. /**
  84589. * Updates only the pose device and mesh without doing any button event checking
  84590. */
  84591. protected _updatePoseAndMesh(): void;
  84592. /**
  84593. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  84594. * @param poseData raw pose fromthe device
  84595. */
  84596. updateFromDevice(poseData: DevicePose): void;
  84597. /**
  84598. * @hidden
  84599. */
  84600. _meshAttachedObservable: Observable<AbstractMesh>;
  84601. /**
  84602. * Attaches a mesh to the controller
  84603. * @param mesh the mesh to be attached
  84604. */
  84605. attachToMesh(mesh: AbstractMesh): void;
  84606. /**
  84607. * Attaches the controllers mesh to a camera
  84608. * @param camera the camera the mesh should be attached to
  84609. */
  84610. attachToPoseControlledCamera(camera: TargetCamera): void;
  84611. /**
  84612. * Disposes of the controller
  84613. */
  84614. dispose(): void;
  84615. /**
  84616. * The mesh that is attached to the controller
  84617. */
  84618. readonly mesh: Nullable<AbstractMesh>;
  84619. /**
  84620. * Gets the ray of the controller in the direction the controller is pointing
  84621. * @param length the length the resulting ray should be
  84622. * @returns a ray in the direction the controller is pointing
  84623. */
  84624. getForwardRay(length?: number): Ray;
  84625. }
  84626. }
  84627. declare module BABYLON {
  84628. /**
  84629. * Defines the WebVRController object that represents controllers tracked in 3D space
  84630. */
  84631. export abstract class WebVRController extends PoseEnabledController {
  84632. /**
  84633. * Internal, the default controller model for the controller
  84634. */
  84635. protected _defaultModel: Nullable<AbstractMesh>;
  84636. /**
  84637. * Fired when the trigger state has changed
  84638. */
  84639. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  84640. /**
  84641. * Fired when the main button state has changed
  84642. */
  84643. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84644. /**
  84645. * Fired when the secondary button state has changed
  84646. */
  84647. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84648. /**
  84649. * Fired when the pad state has changed
  84650. */
  84651. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  84652. /**
  84653. * Fired when controllers stick values have changed
  84654. */
  84655. onPadValuesChangedObservable: Observable<StickValues>;
  84656. /**
  84657. * Array of button availible on the controller
  84658. */
  84659. protected _buttons: Array<MutableGamepadButton>;
  84660. private _onButtonStateChange;
  84661. /**
  84662. * Fired when a controller button's state has changed
  84663. * @param callback the callback containing the button that was modified
  84664. */
  84665. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  84666. /**
  84667. * X and Y axis corresponding to the controllers joystick
  84668. */
  84669. pad: StickValues;
  84670. /**
  84671. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  84672. */
  84673. hand: string;
  84674. /**
  84675. * The default controller model for the controller
  84676. */
  84677. readonly defaultModel: Nullable<AbstractMesh>;
  84678. /**
  84679. * Creates a new WebVRController from a gamepad
  84680. * @param vrGamepad the gamepad that the WebVRController should be created from
  84681. */
  84682. constructor(vrGamepad: any);
  84683. /**
  84684. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  84685. */
  84686. update(): void;
  84687. /**
  84688. * Function to be called when a button is modified
  84689. */
  84690. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  84691. /**
  84692. * Loads a mesh and attaches it to the controller
  84693. * @param scene the scene the mesh should be added to
  84694. * @param meshLoaded callback for when the mesh has been loaded
  84695. */
  84696. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  84697. private _setButtonValue;
  84698. private _changes;
  84699. private _checkChanges;
  84700. /**
  84701. * Disposes of th webVRCOntroller
  84702. */
  84703. dispose(): void;
  84704. }
  84705. }
  84706. declare module BABYLON {
  84707. /**
  84708. * The HemisphericLight simulates the ambient environment light,
  84709. * so the passed direction is the light reflection direction, not the incoming direction.
  84710. */
  84711. export class HemisphericLight extends Light {
  84712. /**
  84713. * The groundColor is the light in the opposite direction to the one specified during creation.
  84714. * 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.
  84715. */
  84716. groundColor: Color3;
  84717. /**
  84718. * The light reflection direction, not the incoming direction.
  84719. */
  84720. direction: Vector3;
  84721. /**
  84722. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  84723. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  84724. * The HemisphericLight can't cast shadows.
  84725. * Documentation : https://doc.babylonjs.com/babylon101/lights
  84726. * @param name The friendly name of the light
  84727. * @param direction The direction of the light reflection
  84728. * @param scene The scene the light belongs to
  84729. */
  84730. constructor(name: string, direction: Vector3, scene: Scene);
  84731. protected _buildUniformLayout(): void;
  84732. /**
  84733. * Returns the string "HemisphericLight".
  84734. * @return The class name
  84735. */
  84736. getClassName(): string;
  84737. /**
  84738. * Sets the HemisphericLight direction towards the passed target (Vector3).
  84739. * Returns the updated direction.
  84740. * @param target The target the direction should point to
  84741. * @return The computed direction
  84742. */
  84743. setDirectionToTarget(target: Vector3): Vector3;
  84744. /**
  84745. * Returns the shadow generator associated to the light.
  84746. * @returns Always null for hemispheric lights because it does not support shadows.
  84747. */
  84748. getShadowGenerator(): Nullable<IShadowGenerator>;
  84749. /**
  84750. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  84751. * @param effect The effect to update
  84752. * @param lightIndex The index of the light in the effect to update
  84753. * @returns The hemispheric light
  84754. */
  84755. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  84756. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  84757. /**
  84758. * Computes the world matrix of the node
  84759. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84760. * @param useWasUpdatedFlag defines a reserved property
  84761. * @returns the world matrix
  84762. */
  84763. computeWorldMatrix(): Matrix;
  84764. /**
  84765. * Returns the integer 3.
  84766. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  84767. */
  84768. getTypeID(): number;
  84769. /**
  84770. * Prepares the list of defines specific to the light type.
  84771. * @param defines the list of defines
  84772. * @param lightIndex defines the index of the light for the effect
  84773. */
  84774. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  84775. }
  84776. }
  84777. declare module BABYLON {
  84778. /** @hidden */
  84779. export var vrMultiviewToSingleviewPixelShader: {
  84780. name: string;
  84781. shader: string;
  84782. };
  84783. }
  84784. declare module BABYLON {
  84785. /**
  84786. * Renders to multiple views with a single draw call
  84787. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  84788. */
  84789. export class MultiviewRenderTarget extends RenderTargetTexture {
  84790. /**
  84791. * Creates a multiview render target
  84792. * @param scene scene used with the render target
  84793. * @param size the size of the render target (used for each view)
  84794. */
  84795. constructor(scene: Scene, size?: number | {
  84796. width: number;
  84797. height: number;
  84798. } | {
  84799. ratio: number;
  84800. });
  84801. /**
  84802. * @hidden
  84803. * @param faceIndex the face index, if its a cube texture
  84804. */
  84805. _bindFrameBuffer(faceIndex?: number): void;
  84806. /**
  84807. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84808. * @returns the view count
  84809. */
  84810. getViewCount(): number;
  84811. }
  84812. }
  84813. declare module BABYLON {
  84814. /**
  84815. * Represents a camera frustum
  84816. */
  84817. export class Frustum {
  84818. /**
  84819. * Gets the planes representing the frustum
  84820. * @param transform matrix to be applied to the returned planes
  84821. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  84822. */
  84823. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  84824. /**
  84825. * Gets the near frustum plane transformed by the transform matrix
  84826. * @param transform transformation matrix to be applied to the resulting frustum plane
  84827. * @param frustumPlane the resuling frustum plane
  84828. */
  84829. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84830. /**
  84831. * Gets the far frustum plane transformed by the transform matrix
  84832. * @param transform transformation matrix to be applied to the resulting frustum plane
  84833. * @param frustumPlane the resuling frustum plane
  84834. */
  84835. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84836. /**
  84837. * Gets the left frustum plane transformed by the transform matrix
  84838. * @param transform transformation matrix to be applied to the resulting frustum plane
  84839. * @param frustumPlane the resuling frustum plane
  84840. */
  84841. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84842. /**
  84843. * Gets the right frustum plane transformed by the transform matrix
  84844. * @param transform transformation matrix to be applied to the resulting frustum plane
  84845. * @param frustumPlane the resuling frustum plane
  84846. */
  84847. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84848. /**
  84849. * Gets the top frustum plane transformed by the transform matrix
  84850. * @param transform transformation matrix to be applied to the resulting frustum plane
  84851. * @param frustumPlane the resuling frustum plane
  84852. */
  84853. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84854. /**
  84855. * Gets the bottom frustum plane transformed by the transform matrix
  84856. * @param transform transformation matrix to be applied to the resulting frustum plane
  84857. * @param frustumPlane the resuling frustum plane
  84858. */
  84859. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84860. /**
  84861. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  84862. * @param transform transformation matrix to be applied to the resulting frustum planes
  84863. * @param frustumPlanes the resuling frustum planes
  84864. */
  84865. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  84866. }
  84867. }
  84868. declare module BABYLON {
  84869. interface Engine {
  84870. /**
  84871. * Creates a new multiview render target
  84872. * @param width defines the width of the texture
  84873. * @param height defines the height of the texture
  84874. * @returns the created multiview texture
  84875. */
  84876. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  84877. /**
  84878. * Binds a multiview framebuffer to be drawn to
  84879. * @param multiviewTexture texture to bind
  84880. */
  84881. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  84882. }
  84883. interface Camera {
  84884. /**
  84885. * @hidden
  84886. * 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)
  84887. */
  84888. _useMultiviewToSingleView: boolean;
  84889. /**
  84890. * @hidden
  84891. * 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)
  84892. */
  84893. _multiviewTexture: Nullable<RenderTargetTexture>;
  84894. /**
  84895. * @hidden
  84896. * ensures the multiview texture of the camera exists and has the specified width/height
  84897. * @param width height to set on the multiview texture
  84898. * @param height width to set on the multiview texture
  84899. */
  84900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  84901. }
  84902. interface Scene {
  84903. /** @hidden */
  84904. _transformMatrixR: Matrix;
  84905. /** @hidden */
  84906. _multiviewSceneUbo: Nullable<UniformBuffer>;
  84907. /** @hidden */
  84908. _createMultiviewUbo(): void;
  84909. /** @hidden */
  84910. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  84911. /** @hidden */
  84912. _renderMultiviewToSingleView(camera: Camera): void;
  84913. }
  84914. }
  84915. declare module BABYLON {
  84916. /**
  84917. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  84918. * This will not be used for webXR as it supports displaying texture arrays directly
  84919. */
  84920. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  84921. /**
  84922. * Initializes a VRMultiviewToSingleview
  84923. * @param name name of the post process
  84924. * @param camera camera to be applied to
  84925. * @param scaleFactor scaling factor to the size of the output texture
  84926. */
  84927. constructor(name: string, camera: Camera, scaleFactor: number);
  84928. }
  84929. }
  84930. declare module BABYLON {
  84931. /**
  84932. * Interface used to define additional presentation attributes
  84933. */
  84934. export interface IVRPresentationAttributes {
  84935. /**
  84936. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  84937. */
  84938. highRefreshRate: boolean;
  84939. /**
  84940. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  84941. */
  84942. foveationLevel: number;
  84943. }
  84944. interface Engine {
  84945. /** @hidden */
  84946. _vrDisplay: any;
  84947. /** @hidden */
  84948. _vrSupported: boolean;
  84949. /** @hidden */
  84950. _oldSize: Size;
  84951. /** @hidden */
  84952. _oldHardwareScaleFactor: number;
  84953. /** @hidden */
  84954. _vrExclusivePointerMode: boolean;
  84955. /** @hidden */
  84956. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  84957. /** @hidden */
  84958. _onVRDisplayPointerRestricted: () => void;
  84959. /** @hidden */
  84960. _onVRDisplayPointerUnrestricted: () => void;
  84961. /** @hidden */
  84962. _onVrDisplayConnect: Nullable<(display: any) => void>;
  84963. /** @hidden */
  84964. _onVrDisplayDisconnect: Nullable<() => void>;
  84965. /** @hidden */
  84966. _onVrDisplayPresentChange: Nullable<() => void>;
  84967. /**
  84968. * Observable signaled when VR display mode changes
  84969. */
  84970. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84971. /**
  84972. * Observable signaled when VR request present is complete
  84973. */
  84974. onVRRequestPresentComplete: Observable<boolean>;
  84975. /**
  84976. * Observable signaled when VR request present starts
  84977. */
  84978. onVRRequestPresentStart: Observable<Engine>;
  84979. /**
  84980. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84981. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84982. */
  84983. isInVRExclusivePointerMode: boolean;
  84984. /**
  84985. * Gets a boolean indicating if a webVR device was detected
  84986. * @returns true if a webVR device was detected
  84987. */
  84988. isVRDevicePresent(): boolean;
  84989. /**
  84990. * Gets the current webVR device
  84991. * @returns the current webVR device (or null)
  84992. */
  84993. getVRDevice(): any;
  84994. /**
  84995. * Initializes a webVR display and starts listening to display change events
  84996. * The onVRDisplayChangedObservable will be notified upon these changes
  84997. * @returns A promise containing a VRDisplay and if vr is supported
  84998. */
  84999. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85000. /** @hidden */
  85001. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85002. /**
  85003. * Gets or sets the presentation attributes used to configure VR rendering
  85004. */
  85005. vrPresentationAttributes?: IVRPresentationAttributes;
  85006. /**
  85007. * Call this function to switch to webVR mode
  85008. * Will do nothing if webVR is not supported or if there is no webVR device
  85009. * @param options the webvr options provided to the camera. mainly used for multiview
  85010. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85011. */
  85012. enableVR(options: WebVROptions): void;
  85013. /** @hidden */
  85014. _onVRFullScreenTriggered(): void;
  85015. }
  85016. }
  85017. declare module BABYLON {
  85018. /**
  85019. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85020. * IMPORTANT!! The data is right-hand data.
  85021. * @export
  85022. * @interface DevicePose
  85023. */
  85024. export interface DevicePose {
  85025. /**
  85026. * The position of the device, values in array are [x,y,z].
  85027. */
  85028. readonly position: Nullable<Float32Array>;
  85029. /**
  85030. * The linearVelocity of the device, values in array are [x,y,z].
  85031. */
  85032. readonly linearVelocity: Nullable<Float32Array>;
  85033. /**
  85034. * The linearAcceleration of the device, values in array are [x,y,z].
  85035. */
  85036. readonly linearAcceleration: Nullable<Float32Array>;
  85037. /**
  85038. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85039. */
  85040. readonly orientation: Nullable<Float32Array>;
  85041. /**
  85042. * The angularVelocity of the device, values in array are [x,y,z].
  85043. */
  85044. readonly angularVelocity: Nullable<Float32Array>;
  85045. /**
  85046. * The angularAcceleration of the device, values in array are [x,y,z].
  85047. */
  85048. readonly angularAcceleration: Nullable<Float32Array>;
  85049. }
  85050. /**
  85051. * Interface representing a pose controlled object in Babylon.
  85052. * A pose controlled object has both regular pose values as well as pose values
  85053. * from an external device such as a VR head mounted display
  85054. */
  85055. export interface PoseControlled {
  85056. /**
  85057. * The position of the object in babylon space.
  85058. */
  85059. position: Vector3;
  85060. /**
  85061. * The rotation quaternion of the object in babylon space.
  85062. */
  85063. rotationQuaternion: Quaternion;
  85064. /**
  85065. * The position of the device in babylon space.
  85066. */
  85067. devicePosition?: Vector3;
  85068. /**
  85069. * The rotation quaternion of the device in babylon space.
  85070. */
  85071. deviceRotationQuaternion: Quaternion;
  85072. /**
  85073. * The raw pose coming from the device.
  85074. */
  85075. rawPose: Nullable<DevicePose>;
  85076. /**
  85077. * The scale of the device to be used when translating from device space to babylon space.
  85078. */
  85079. deviceScaleFactor: number;
  85080. /**
  85081. * Updates the poseControlled values based on the input device pose.
  85082. * @param poseData the pose data to update the object with
  85083. */
  85084. updateFromDevice(poseData: DevicePose): void;
  85085. }
  85086. /**
  85087. * Set of options to customize the webVRCamera
  85088. */
  85089. export interface WebVROptions {
  85090. /**
  85091. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85092. */
  85093. trackPosition?: boolean;
  85094. /**
  85095. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85096. */
  85097. positionScale?: number;
  85098. /**
  85099. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85100. */
  85101. displayName?: string;
  85102. /**
  85103. * Should the native controller meshes be initialized. (default: true)
  85104. */
  85105. controllerMeshes?: boolean;
  85106. /**
  85107. * Creating a default HemiLight only on controllers. (default: true)
  85108. */
  85109. defaultLightingOnControllers?: boolean;
  85110. /**
  85111. * If you don't want to use the default VR button of the helper. (default: false)
  85112. */
  85113. useCustomVRButton?: boolean;
  85114. /**
  85115. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85116. */
  85117. customVRButton?: HTMLButtonElement;
  85118. /**
  85119. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85120. */
  85121. rayLength?: number;
  85122. /**
  85123. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85124. */
  85125. defaultHeight?: number;
  85126. /**
  85127. * If multiview should be used if availible (default: false)
  85128. */
  85129. useMultiview?: boolean;
  85130. }
  85131. /**
  85132. * This represents a WebVR camera.
  85133. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85134. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85135. */
  85136. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85137. private webVROptions;
  85138. /**
  85139. * @hidden
  85140. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85141. */
  85142. _vrDevice: any;
  85143. /**
  85144. * The rawPose of the vrDevice.
  85145. */
  85146. rawPose: Nullable<DevicePose>;
  85147. private _onVREnabled;
  85148. private _specsVersion;
  85149. private _attached;
  85150. private _frameData;
  85151. protected _descendants: Array<Node>;
  85152. private _deviceRoomPosition;
  85153. /** @hidden */
  85154. _deviceRoomRotationQuaternion: Quaternion;
  85155. private _standingMatrix;
  85156. /**
  85157. * Represents device position in babylon space.
  85158. */
  85159. devicePosition: Vector3;
  85160. /**
  85161. * Represents device rotation in babylon space.
  85162. */
  85163. deviceRotationQuaternion: Quaternion;
  85164. /**
  85165. * The scale of the device to be used when translating from device space to babylon space.
  85166. */
  85167. deviceScaleFactor: number;
  85168. private _deviceToWorld;
  85169. private _worldToDevice;
  85170. /**
  85171. * References to the webVR controllers for the vrDevice.
  85172. */
  85173. controllers: Array<WebVRController>;
  85174. /**
  85175. * Emits an event when a controller is attached.
  85176. */
  85177. onControllersAttachedObservable: Observable<WebVRController[]>;
  85178. /**
  85179. * Emits an event when a controller's mesh has been loaded;
  85180. */
  85181. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85182. /**
  85183. * Emits an event when the HMD's pose has been updated.
  85184. */
  85185. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85186. private _poseSet;
  85187. /**
  85188. * If the rig cameras be used as parent instead of this camera.
  85189. */
  85190. rigParenting: boolean;
  85191. private _lightOnControllers;
  85192. private _defaultHeight?;
  85193. /**
  85194. * Instantiates a WebVRFreeCamera.
  85195. * @param name The name of the WebVRFreeCamera
  85196. * @param position The starting anchor position for the camera
  85197. * @param scene The scene the camera belongs to
  85198. * @param webVROptions a set of customizable options for the webVRCamera
  85199. */
  85200. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85201. /**
  85202. * Gets the device distance from the ground in meters.
  85203. * @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.
  85204. */
  85205. deviceDistanceToRoomGround(): number;
  85206. /**
  85207. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85208. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85209. */
  85210. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85211. /**
  85212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85213. * @returns A promise with a boolean set to if the standing matrix is supported.
  85214. */
  85215. useStandingMatrixAsync(): Promise<boolean>;
  85216. /**
  85217. * Disposes the camera
  85218. */
  85219. dispose(): void;
  85220. /**
  85221. * Gets a vrController by name.
  85222. * @param name The name of the controller to retreive
  85223. * @returns the controller matching the name specified or null if not found
  85224. */
  85225. getControllerByName(name: string): Nullable<WebVRController>;
  85226. private _leftController;
  85227. /**
  85228. * The controller corresponding to the users left hand.
  85229. */
  85230. readonly leftController: Nullable<WebVRController>;
  85231. private _rightController;
  85232. /**
  85233. * The controller corresponding to the users right hand.
  85234. */
  85235. readonly rightController: Nullable<WebVRController>;
  85236. /**
  85237. * Casts a ray forward from the vrCamera's gaze.
  85238. * @param length Length of the ray (default: 100)
  85239. * @returns the ray corresponding to the gaze
  85240. */
  85241. getForwardRay(length?: number): Ray;
  85242. /**
  85243. * @hidden
  85244. * Updates the camera based on device's frame data
  85245. */
  85246. _checkInputs(): void;
  85247. /**
  85248. * Updates the poseControlled values based on the input device pose.
  85249. * @param poseData Pose coming from the device
  85250. */
  85251. updateFromDevice(poseData: DevicePose): void;
  85252. private _htmlElementAttached;
  85253. private _detachIfAttached;
  85254. /**
  85255. * WebVR's attach control will start broadcasting frames to the device.
  85256. * Note that in certain browsers (chrome for example) this function must be called
  85257. * within a user-interaction callback. Example:
  85258. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  85259. *
  85260. * @param element html element to attach the vrDevice to
  85261. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  85262. */
  85263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85264. /**
  85265. * Detaches the camera from the html element and disables VR
  85266. *
  85267. * @param element html element to detach from
  85268. */
  85269. detachControl(element: HTMLElement): void;
  85270. /**
  85271. * @returns the name of this class
  85272. */
  85273. getClassName(): string;
  85274. /**
  85275. * Calls resetPose on the vrDisplay
  85276. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  85277. */
  85278. resetToCurrentRotation(): void;
  85279. /**
  85280. * @hidden
  85281. * Updates the rig cameras (left and right eye)
  85282. */
  85283. _updateRigCameras(): void;
  85284. private _workingVector;
  85285. private _oneVector;
  85286. private _workingMatrix;
  85287. private updateCacheCalled;
  85288. private _correctPositionIfNotTrackPosition;
  85289. /**
  85290. * @hidden
  85291. * Updates the cached values of the camera
  85292. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  85293. */
  85294. _updateCache(ignoreParentClass?: boolean): void;
  85295. /**
  85296. * @hidden
  85297. * Get current device position in babylon world
  85298. */
  85299. _computeDevicePosition(): void;
  85300. /**
  85301. * Updates the current device position and rotation in the babylon world
  85302. */
  85303. update(): void;
  85304. /**
  85305. * @hidden
  85306. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  85307. * @returns an identity matrix
  85308. */
  85309. _getViewMatrix(): Matrix;
  85310. private _tmpMatrix;
  85311. /**
  85312. * This function is called by the two RIG cameras.
  85313. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  85314. * @hidden
  85315. */
  85316. _getWebVRViewMatrix(): Matrix;
  85317. /** @hidden */
  85318. _getWebVRProjectionMatrix(): Matrix;
  85319. private _onGamepadConnectedObserver;
  85320. private _onGamepadDisconnectedObserver;
  85321. private _updateCacheWhenTrackingDisabledObserver;
  85322. /**
  85323. * Initializes the controllers and their meshes
  85324. */
  85325. initControllers(): void;
  85326. }
  85327. }
  85328. declare module BABYLON {
  85329. /**
  85330. * Size options for a post process
  85331. */
  85332. export type PostProcessOptions = {
  85333. width: number;
  85334. height: number;
  85335. };
  85336. /**
  85337. * PostProcess can be used to apply a shader to a texture after it has been rendered
  85338. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85339. */
  85340. export class PostProcess {
  85341. /** Name of the PostProcess. */
  85342. name: string;
  85343. /**
  85344. * Gets or sets the unique id of the post process
  85345. */
  85346. uniqueId: number;
  85347. /**
  85348. * Width of the texture to apply the post process on
  85349. */
  85350. width: number;
  85351. /**
  85352. * Height of the texture to apply the post process on
  85353. */
  85354. height: number;
  85355. /**
  85356. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  85357. * @hidden
  85358. */
  85359. _outputTexture: Nullable<InternalTexture>;
  85360. /**
  85361. * Sampling mode used by the shader
  85362. * See https://doc.babylonjs.com/classes/3.1/texture
  85363. */
  85364. renderTargetSamplingMode: number;
  85365. /**
  85366. * Clear color to use when screen clearing
  85367. */
  85368. clearColor: Color4;
  85369. /**
  85370. * If the buffer needs to be cleared before applying the post process. (default: true)
  85371. * Should be set to false if shader will overwrite all previous pixels.
  85372. */
  85373. autoClear: boolean;
  85374. /**
  85375. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  85376. */
  85377. alphaMode: number;
  85378. /**
  85379. * Sets the setAlphaBlendConstants of the babylon engine
  85380. */
  85381. alphaConstants: Color4;
  85382. /**
  85383. * Animations to be used for the post processing
  85384. */
  85385. animations: Animation[];
  85386. /**
  85387. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  85388. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  85389. */
  85390. enablePixelPerfectMode: boolean;
  85391. /**
  85392. * Force the postprocess to be applied without taking in account viewport
  85393. */
  85394. forceFullscreenViewport: boolean;
  85395. /**
  85396. * List of inspectable custom properties (used by the Inspector)
  85397. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85398. */
  85399. inspectableCustomProperties: IInspectable[];
  85400. /**
  85401. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  85402. *
  85403. * | Value | Type | Description |
  85404. * | ----- | ----------------------------------- | ----------- |
  85405. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  85406. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  85407. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  85408. *
  85409. */
  85410. scaleMode: number;
  85411. /**
  85412. * Force textures to be a power of two (default: false)
  85413. */
  85414. alwaysForcePOT: boolean;
  85415. private _samples;
  85416. /**
  85417. * Number of sample textures (default: 1)
  85418. */
  85419. samples: number;
  85420. /**
  85421. * Modify the scale of the post process to be the same as the viewport (default: false)
  85422. */
  85423. adaptScaleToCurrentViewport: boolean;
  85424. private _camera;
  85425. private _scene;
  85426. private _engine;
  85427. private _options;
  85428. private _reusable;
  85429. private _textureType;
  85430. /**
  85431. * Smart array of input and output textures for the post process.
  85432. * @hidden
  85433. */
  85434. _textures: SmartArray<InternalTexture>;
  85435. /**
  85436. * The index in _textures that corresponds to the output texture.
  85437. * @hidden
  85438. */
  85439. _currentRenderTextureInd: number;
  85440. private _effect;
  85441. private _samplers;
  85442. private _fragmentUrl;
  85443. private _vertexUrl;
  85444. private _parameters;
  85445. private _scaleRatio;
  85446. protected _indexParameters: any;
  85447. private _shareOutputWithPostProcess;
  85448. private _texelSize;
  85449. private _forcedOutputTexture;
  85450. /**
  85451. * Returns the fragment url or shader name used in the post process.
  85452. * @returns the fragment url or name in the shader store.
  85453. */
  85454. getEffectName(): string;
  85455. /**
  85456. * An event triggered when the postprocess is activated.
  85457. */
  85458. onActivateObservable: Observable<Camera>;
  85459. private _onActivateObserver;
  85460. /**
  85461. * A function that is added to the onActivateObservable
  85462. */
  85463. onActivate: Nullable<(camera: Camera) => void>;
  85464. /**
  85465. * An event triggered when the postprocess changes its size.
  85466. */
  85467. onSizeChangedObservable: Observable<PostProcess>;
  85468. private _onSizeChangedObserver;
  85469. /**
  85470. * A function that is added to the onSizeChangedObservable
  85471. */
  85472. onSizeChanged: (postProcess: PostProcess) => void;
  85473. /**
  85474. * An event triggered when the postprocess applies its effect.
  85475. */
  85476. onApplyObservable: Observable<Effect>;
  85477. private _onApplyObserver;
  85478. /**
  85479. * A function that is added to the onApplyObservable
  85480. */
  85481. onApply: (effect: Effect) => void;
  85482. /**
  85483. * An event triggered before rendering the postprocess
  85484. */
  85485. onBeforeRenderObservable: Observable<Effect>;
  85486. private _onBeforeRenderObserver;
  85487. /**
  85488. * A function that is added to the onBeforeRenderObservable
  85489. */
  85490. onBeforeRender: (effect: Effect) => void;
  85491. /**
  85492. * An event triggered after rendering the postprocess
  85493. */
  85494. onAfterRenderObservable: Observable<Effect>;
  85495. private _onAfterRenderObserver;
  85496. /**
  85497. * A function that is added to the onAfterRenderObservable
  85498. */
  85499. onAfterRender: (efect: Effect) => void;
  85500. /**
  85501. * 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
  85502. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  85503. */
  85504. inputTexture: InternalTexture;
  85505. /**
  85506. * Gets the camera which post process is applied to.
  85507. * @returns The camera the post process is applied to.
  85508. */
  85509. getCamera(): Camera;
  85510. /**
  85511. * Gets the texel size of the postprocess.
  85512. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  85513. */
  85514. readonly texelSize: Vector2;
  85515. /**
  85516. * Creates a new instance PostProcess
  85517. * @param name The name of the PostProcess.
  85518. * @param fragmentUrl The url of the fragment shader to be used.
  85519. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  85520. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  85521. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  85522. * @param camera The camera to apply the render pass to.
  85523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  85524. * @param engine The engine which the post process will be applied. (default: current engine)
  85525. * @param reusable If the post process can be reused on the same frame. (default: false)
  85526. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  85527. * @param textureType Type of textures used when performing the post process. (default: 0)
  85528. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  85529. * @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
  85530. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  85531. */
  85532. constructor(
  85533. /** Name of the PostProcess. */
  85534. 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);
  85535. /**
  85536. * Gets a string idenfifying the name of the class
  85537. * @returns "PostProcess" string
  85538. */
  85539. getClassName(): string;
  85540. /**
  85541. * Gets the engine which this post process belongs to.
  85542. * @returns The engine the post process was enabled with.
  85543. */
  85544. getEngine(): Engine;
  85545. /**
  85546. * The effect that is created when initializing the post process.
  85547. * @returns The created effect corresponding the the postprocess.
  85548. */
  85549. getEffect(): Effect;
  85550. /**
  85551. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  85552. * @param postProcess The post process to share the output with.
  85553. * @returns This post process.
  85554. */
  85555. shareOutputWith(postProcess: PostProcess): PostProcess;
  85556. /**
  85557. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  85558. * This should be called if the post process that shares output with this post process is disabled/disposed.
  85559. */
  85560. useOwnOutput(): void;
  85561. /**
  85562. * Updates the effect with the current post process compile time values and recompiles the shader.
  85563. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  85564. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  85565. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  85566. * @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
  85567. * @param onCompiled Called when the shader has been compiled.
  85568. * @param onError Called if there is an error when compiling a shader.
  85569. */
  85570. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85571. /**
  85572. * The post process is reusable if it can be used multiple times within one frame.
  85573. * @returns If the post process is reusable
  85574. */
  85575. isReusable(): boolean;
  85576. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  85577. markTextureDirty(): void;
  85578. /**
  85579. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  85580. * 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.
  85581. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  85582. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  85583. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  85584. * @returns The target texture that was bound to be written to.
  85585. */
  85586. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  85587. /**
  85588. * If the post process is supported.
  85589. */
  85590. readonly isSupported: boolean;
  85591. /**
  85592. * The aspect ratio of the output texture.
  85593. */
  85594. readonly aspectRatio: number;
  85595. /**
  85596. * Get a value indicating if the post-process is ready to be used
  85597. * @returns true if the post-process is ready (shader is compiled)
  85598. */
  85599. isReady(): boolean;
  85600. /**
  85601. * Binds all textures and uniforms to the shader, this will be run on every pass.
  85602. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  85603. */
  85604. apply(): Nullable<Effect>;
  85605. private _disposeTextures;
  85606. /**
  85607. * Disposes the post process.
  85608. * @param camera The camera to dispose the post process on.
  85609. */
  85610. dispose(camera?: Camera): void;
  85611. }
  85612. }
  85613. declare module BABYLON {
  85614. /** @hidden */
  85615. export var kernelBlurVaryingDeclaration: {
  85616. name: string;
  85617. shader: string;
  85618. };
  85619. }
  85620. declare module BABYLON {
  85621. /** @hidden */
  85622. export var kernelBlurFragment: {
  85623. name: string;
  85624. shader: string;
  85625. };
  85626. }
  85627. declare module BABYLON {
  85628. /** @hidden */
  85629. export var kernelBlurFragment2: {
  85630. name: string;
  85631. shader: string;
  85632. };
  85633. }
  85634. declare module BABYLON {
  85635. /** @hidden */
  85636. export var kernelBlurPixelShader: {
  85637. name: string;
  85638. shader: string;
  85639. };
  85640. }
  85641. declare module BABYLON {
  85642. /** @hidden */
  85643. export var kernelBlurVertex: {
  85644. name: string;
  85645. shader: string;
  85646. };
  85647. }
  85648. declare module BABYLON {
  85649. /** @hidden */
  85650. export var kernelBlurVertexShader: {
  85651. name: string;
  85652. shader: string;
  85653. };
  85654. }
  85655. declare module BABYLON {
  85656. /**
  85657. * The Blur Post Process which blurs an image based on a kernel and direction.
  85658. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  85659. */
  85660. export class BlurPostProcess extends PostProcess {
  85661. /** The direction in which to blur the image. */
  85662. direction: Vector2;
  85663. private blockCompilation;
  85664. protected _kernel: number;
  85665. protected _idealKernel: number;
  85666. protected _packedFloat: boolean;
  85667. private _staticDefines;
  85668. /**
  85669. * Sets the length in pixels of the blur sample region
  85670. */
  85671. /**
  85672. * Gets the length in pixels of the blur sample region
  85673. */
  85674. kernel: number;
  85675. /**
  85676. * Sets wether or not the blur needs to unpack/repack floats
  85677. */
  85678. /**
  85679. * Gets wether or not the blur is unpacking/repacking floats
  85680. */
  85681. packedFloat: boolean;
  85682. /**
  85683. * Creates a new instance BlurPostProcess
  85684. * @param name The name of the effect.
  85685. * @param direction The direction in which to blur the image.
  85686. * @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.
  85687. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  85688. * @param camera The camera to apply the render pass to.
  85689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  85690. * @param engine The engine which the post process will be applied. (default: current engine)
  85691. * @param reusable If the post process can be reused on the same frame. (default: false)
  85692. * @param textureType Type of textures used when performing the post process. (default: 0)
  85693. * @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)
  85694. */
  85695. constructor(name: string,
  85696. /** The direction in which to blur the image. */
  85697. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  85698. /**
  85699. * Updates the effect with the current post process compile time values and recompiles the shader.
  85700. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  85701. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  85702. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  85703. * @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
  85704. * @param onCompiled Called when the shader has been compiled.
  85705. * @param onError Called if there is an error when compiling a shader.
  85706. */
  85707. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85708. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85709. /**
  85710. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  85711. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  85712. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  85713. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  85714. * The gaps between physical kernels are compensated for in the weighting of the samples
  85715. * @param idealKernel Ideal blur kernel.
  85716. * @return Nearest best kernel.
  85717. */
  85718. protected _nearestBestKernel(idealKernel: number): number;
  85719. /**
  85720. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  85721. * @param x The point on the Gaussian distribution to sample.
  85722. * @return the value of the Gaussian function at x.
  85723. */
  85724. protected _gaussianWeight(x: number): number;
  85725. /**
  85726. * Generates a string that can be used as a floating point number in GLSL.
  85727. * @param x Value to print.
  85728. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  85729. * @return GLSL float string.
  85730. */
  85731. protected _glslFloat(x: number, decimalFigures?: number): string;
  85732. }
  85733. }
  85734. declare module BABYLON {
  85735. /**
  85736. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85737. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85738. * You can then easily use it as a reflectionTexture on a flat surface.
  85739. * In case the surface is not a plane, please consider relying on reflection probes.
  85740. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85741. */
  85742. export class MirrorTexture extends RenderTargetTexture {
  85743. private scene;
  85744. /**
  85745. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  85746. * 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.
  85747. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85748. */
  85749. mirrorPlane: Plane;
  85750. /**
  85751. * Define the blur ratio used to blur the reflection if needed.
  85752. */
  85753. blurRatio: number;
  85754. /**
  85755. * Define the adaptive blur kernel used to blur the reflection if needed.
  85756. * This will autocompute the closest best match for the `blurKernel`
  85757. */
  85758. adaptiveBlurKernel: number;
  85759. /**
  85760. * Define the blur kernel used to blur the reflection if needed.
  85761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85762. */
  85763. blurKernel: number;
  85764. /**
  85765. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  85766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85767. */
  85768. blurKernelX: number;
  85769. /**
  85770. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  85771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85772. */
  85773. blurKernelY: number;
  85774. private _autoComputeBlurKernel;
  85775. protected _onRatioRescale(): void;
  85776. private _updateGammaSpace;
  85777. private _imageProcessingConfigChangeObserver;
  85778. private _transformMatrix;
  85779. private _mirrorMatrix;
  85780. private _savedViewMatrix;
  85781. private _blurX;
  85782. private _blurY;
  85783. private _adaptiveBlurKernel;
  85784. private _blurKernelX;
  85785. private _blurKernelY;
  85786. private _blurRatio;
  85787. /**
  85788. * Instantiates a Mirror Texture.
  85789. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85790. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85791. * You can then easily use it as a reflectionTexture on a flat surface.
  85792. * In case the surface is not a plane, please consider relying on reflection probes.
  85793. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85794. * @param name
  85795. * @param size
  85796. * @param scene
  85797. * @param generateMipMaps
  85798. * @param type
  85799. * @param samplingMode
  85800. * @param generateDepthBuffer
  85801. */
  85802. constructor(name: string, size: number | {
  85803. width: number;
  85804. height: number;
  85805. } | {
  85806. ratio: number;
  85807. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  85808. private _preparePostProcesses;
  85809. /**
  85810. * Clone the mirror texture.
  85811. * @returns the cloned texture
  85812. */
  85813. clone(): MirrorTexture;
  85814. /**
  85815. * Serialize the texture to a JSON representation you could use in Parse later on
  85816. * @returns the serialized JSON representation
  85817. */
  85818. serialize(): any;
  85819. /**
  85820. * Dispose the texture and release its associated resources.
  85821. */
  85822. dispose(): void;
  85823. }
  85824. }
  85825. declare module BABYLON {
  85826. /**
  85827. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85828. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85829. */
  85830. export class Texture extends BaseTexture {
  85831. /**
  85832. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  85833. */
  85834. static SerializeBuffers: boolean;
  85835. /** @hidden */
  85836. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  85837. /** @hidden */
  85838. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  85839. /** @hidden */
  85840. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  85841. /** nearest is mag = nearest and min = nearest and mip = linear */
  85842. static readonly NEAREST_SAMPLINGMODE: number;
  85843. /** nearest is mag = nearest and min = nearest and mip = linear */
  85844. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  85845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85846. static readonly BILINEAR_SAMPLINGMODE: number;
  85847. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85848. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  85849. /** Trilinear is mag = linear and min = linear and mip = linear */
  85850. static readonly TRILINEAR_SAMPLINGMODE: number;
  85851. /** Trilinear is mag = linear and min = linear and mip = linear */
  85852. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  85853. /** mag = nearest and min = nearest and mip = nearest */
  85854. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  85855. /** mag = nearest and min = linear and mip = nearest */
  85856. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  85857. /** mag = nearest and min = linear and mip = linear */
  85858. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  85859. /** mag = nearest and min = linear and mip = none */
  85860. static readonly NEAREST_LINEAR: number;
  85861. /** mag = nearest and min = nearest and mip = none */
  85862. static readonly NEAREST_NEAREST: number;
  85863. /** mag = linear and min = nearest and mip = nearest */
  85864. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  85865. /** mag = linear and min = nearest and mip = linear */
  85866. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  85867. /** mag = linear and min = linear and mip = none */
  85868. static readonly LINEAR_LINEAR: number;
  85869. /** mag = linear and min = nearest and mip = none */
  85870. static readonly LINEAR_NEAREST: number;
  85871. /** Explicit coordinates mode */
  85872. static readonly EXPLICIT_MODE: number;
  85873. /** Spherical coordinates mode */
  85874. static readonly SPHERICAL_MODE: number;
  85875. /** Planar coordinates mode */
  85876. static readonly PLANAR_MODE: number;
  85877. /** Cubic coordinates mode */
  85878. static readonly CUBIC_MODE: number;
  85879. /** Projection coordinates mode */
  85880. static readonly PROJECTION_MODE: number;
  85881. /** Inverse Cubic coordinates mode */
  85882. static readonly SKYBOX_MODE: number;
  85883. /** Inverse Cubic coordinates mode */
  85884. static readonly INVCUBIC_MODE: number;
  85885. /** Equirectangular coordinates mode */
  85886. static readonly EQUIRECTANGULAR_MODE: number;
  85887. /** Equirectangular Fixed coordinates mode */
  85888. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  85889. /** Equirectangular Fixed Mirrored coordinates mode */
  85890. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85891. /** Texture is not repeating outside of 0..1 UVs */
  85892. static readonly CLAMP_ADDRESSMODE: number;
  85893. /** Texture is repeating outside of 0..1 UVs */
  85894. static readonly WRAP_ADDRESSMODE: number;
  85895. /** Texture is repeating and mirrored */
  85896. static readonly MIRROR_ADDRESSMODE: number;
  85897. /**
  85898. * 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
  85899. */
  85900. static UseSerializedUrlIfAny: boolean;
  85901. /**
  85902. * Define the url of the texture.
  85903. */
  85904. url: Nullable<string>;
  85905. /**
  85906. * Define an offset on the texture to offset the u coordinates of the UVs
  85907. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85908. */
  85909. uOffset: number;
  85910. /**
  85911. * Define an offset on the texture to offset the v coordinates of the UVs
  85912. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85913. */
  85914. vOffset: number;
  85915. /**
  85916. * Define an offset on the texture to scale the u coordinates of the UVs
  85917. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85918. */
  85919. uScale: number;
  85920. /**
  85921. * Define an offset on the texture to scale the v coordinates of the UVs
  85922. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85923. */
  85924. vScale: number;
  85925. /**
  85926. * Define an offset on the texture to rotate around the u coordinates of the UVs
  85927. * @see http://doc.babylonjs.com/how_to/more_materials
  85928. */
  85929. uAng: number;
  85930. /**
  85931. * Define an offset on the texture to rotate around the v coordinates of the UVs
  85932. * @see http://doc.babylonjs.com/how_to/more_materials
  85933. */
  85934. vAng: number;
  85935. /**
  85936. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  85937. * @see http://doc.babylonjs.com/how_to/more_materials
  85938. */
  85939. wAng: number;
  85940. /**
  85941. * Defines the center of rotation (U)
  85942. */
  85943. uRotationCenter: number;
  85944. /**
  85945. * Defines the center of rotation (V)
  85946. */
  85947. vRotationCenter: number;
  85948. /**
  85949. * Defines the center of rotation (W)
  85950. */
  85951. wRotationCenter: number;
  85952. /**
  85953. * Are mip maps generated for this texture or not.
  85954. */
  85955. readonly noMipmap: boolean;
  85956. /**
  85957. * List of inspectable custom properties (used by the Inspector)
  85958. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85959. */
  85960. inspectableCustomProperties: Nullable<IInspectable[]>;
  85961. private _noMipmap;
  85962. /** @hidden */
  85963. _invertY: boolean;
  85964. private _rowGenerationMatrix;
  85965. private _cachedTextureMatrix;
  85966. private _projectionModeMatrix;
  85967. private _t0;
  85968. private _t1;
  85969. private _t2;
  85970. private _cachedUOffset;
  85971. private _cachedVOffset;
  85972. private _cachedUScale;
  85973. private _cachedVScale;
  85974. private _cachedUAng;
  85975. private _cachedVAng;
  85976. private _cachedWAng;
  85977. private _cachedProjectionMatrixId;
  85978. private _cachedCoordinatesMode;
  85979. /** @hidden */
  85980. protected _initialSamplingMode: number;
  85981. /** @hidden */
  85982. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  85983. private _deleteBuffer;
  85984. protected _format: Nullable<number>;
  85985. private _delayedOnLoad;
  85986. private _delayedOnError;
  85987. private _mimeType?;
  85988. /**
  85989. * Observable triggered once the texture has been loaded.
  85990. */
  85991. onLoadObservable: Observable<Texture>;
  85992. protected _isBlocking: boolean;
  85993. /**
  85994. * Is the texture preventing material to render while loading.
  85995. * If false, a default texture will be used instead of the loading one during the preparation step.
  85996. */
  85997. isBlocking: boolean;
  85998. /**
  85999. * Get the current sampling mode associated with the texture.
  86000. */
  86001. readonly samplingMode: number;
  86002. /**
  86003. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86004. */
  86005. readonly invertY: boolean;
  86006. /**
  86007. * Instantiates a new texture.
  86008. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86009. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86010. * @param url defines the url of the picture to load as a texture
  86011. * @param scene defines the scene or engine the texture will belong to
  86012. * @param noMipmap defines if the texture will require mip maps or not
  86013. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86014. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86015. * @param onLoad defines a callback triggered when the texture has been loaded
  86016. * @param onError defines a callback triggered when an error occurred during the loading session
  86017. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86018. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86019. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86020. * @param mimeType defines an optional mime type information
  86021. */
  86022. 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);
  86023. /**
  86024. * Update the url (and optional buffer) of this texture if url was null during construction.
  86025. * @param url the url of the texture
  86026. * @param buffer the buffer of the texture (defaults to null)
  86027. * @param onLoad callback called when the texture is loaded (defaults to null)
  86028. */
  86029. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86030. /**
  86031. * Finish the loading sequence of a texture flagged as delayed load.
  86032. * @hidden
  86033. */
  86034. delayLoad(): void;
  86035. private _prepareRowForTextureGeneration;
  86036. /**
  86037. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86038. * @returns the transform matrix of the texture.
  86039. */
  86040. getTextureMatrix(uBase?: number): Matrix;
  86041. /**
  86042. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86043. * @returns The reflection texture transform
  86044. */
  86045. getReflectionTextureMatrix(): Matrix;
  86046. /**
  86047. * Clones the texture.
  86048. * @returns the cloned texture
  86049. */
  86050. clone(): Texture;
  86051. /**
  86052. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86053. * @returns The JSON representation of the texture
  86054. */
  86055. serialize(): any;
  86056. /**
  86057. * Get the current class name of the texture useful for serialization or dynamic coding.
  86058. * @returns "Texture"
  86059. */
  86060. getClassName(): string;
  86061. /**
  86062. * Dispose the texture and release its associated resources.
  86063. */
  86064. dispose(): void;
  86065. /**
  86066. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86067. * @param parsedTexture Define the JSON representation of the texture
  86068. * @param scene Define the scene the parsed texture should be instantiated in
  86069. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86070. * @returns The parsed texture if successful
  86071. */
  86072. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86073. /**
  86074. * Creates a texture from its base 64 representation.
  86075. * @param data Define the base64 payload without the data: prefix
  86076. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86077. * @param scene Define the scene the texture should belong to
  86078. * @param noMipmap Forces the texture to not create mip map information if true
  86079. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86080. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86081. * @param onLoad define a callback triggered when the texture has been loaded
  86082. * @param onError define a callback triggered when an error occurred during the loading session
  86083. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86084. * @returns the created texture
  86085. */
  86086. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86087. /**
  86088. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86089. * @param data Define the base64 payload without the data: prefix
  86090. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86091. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86092. * @param scene Define the scene the texture should belong to
  86093. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86094. * @param noMipmap Forces the texture to not create mip map information if true
  86095. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86096. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86097. * @param onLoad define a callback triggered when the texture has been loaded
  86098. * @param onError define a callback triggered when an error occurred during the loading session
  86099. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86100. * @returns the created texture
  86101. */
  86102. 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;
  86103. }
  86104. }
  86105. declare module BABYLON {
  86106. /**
  86107. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86109. */
  86110. export class PostProcessManager {
  86111. private _scene;
  86112. private _indexBuffer;
  86113. private _vertexBuffers;
  86114. /**
  86115. * Creates a new instance PostProcess
  86116. * @param scene The scene that the post process is associated with.
  86117. */
  86118. constructor(scene: Scene);
  86119. private _prepareBuffers;
  86120. private _buildIndexBuffer;
  86121. /**
  86122. * Rebuilds the vertex buffers of the manager.
  86123. * @hidden
  86124. */
  86125. _rebuild(): void;
  86126. /**
  86127. * Prepares a frame to be run through a post process.
  86128. * @param sourceTexture The input texture to the post procesess. (default: null)
  86129. * @param postProcesses An array of post processes to be run. (default: null)
  86130. * @returns True if the post processes were able to be run.
  86131. * @hidden
  86132. */
  86133. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86134. /**
  86135. * Manually render a set of post processes to a texture.
  86136. * @param postProcesses An array of post processes to be run.
  86137. * @param targetTexture The target texture to render to.
  86138. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86139. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86140. * @param lodLevel defines which lod of the texture to render to
  86141. */
  86142. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86143. /**
  86144. * Finalize the result of the output of the postprocesses.
  86145. * @param doNotPresent If true the result will not be displayed to the screen.
  86146. * @param targetTexture The target texture to render to.
  86147. * @param faceIndex The index of the face to bind the target texture to.
  86148. * @param postProcesses The array of post processes to render.
  86149. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86150. * @hidden
  86151. */
  86152. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86153. /**
  86154. * Disposes of the post process manager.
  86155. */
  86156. dispose(): void;
  86157. }
  86158. }
  86159. declare module BABYLON {
  86160. /** Interface used by value gradients (color, factor, ...) */
  86161. export interface IValueGradient {
  86162. /**
  86163. * Gets or sets the gradient value (between 0 and 1)
  86164. */
  86165. gradient: number;
  86166. }
  86167. /** Class used to store color4 gradient */
  86168. export class ColorGradient implements IValueGradient {
  86169. /**
  86170. * Gets or sets the gradient value (between 0 and 1)
  86171. */
  86172. gradient: number;
  86173. /**
  86174. * Gets or sets first associated color
  86175. */
  86176. color1: Color4;
  86177. /**
  86178. * Gets or sets second associated color
  86179. */
  86180. color2?: Color4;
  86181. /**
  86182. * Will get a color picked randomly between color1 and color2.
  86183. * If color2 is undefined then color1 will be used
  86184. * @param result defines the target Color4 to store the result in
  86185. */
  86186. getColorToRef(result: Color4): void;
  86187. }
  86188. /** Class used to store color 3 gradient */
  86189. export class Color3Gradient implements IValueGradient {
  86190. /**
  86191. * Gets or sets the gradient value (between 0 and 1)
  86192. */
  86193. gradient: number;
  86194. /**
  86195. * Gets or sets the associated color
  86196. */
  86197. color: Color3;
  86198. }
  86199. /** Class used to store factor gradient */
  86200. export class FactorGradient implements IValueGradient {
  86201. /**
  86202. * Gets or sets the gradient value (between 0 and 1)
  86203. */
  86204. gradient: number;
  86205. /**
  86206. * Gets or sets first associated factor
  86207. */
  86208. factor1: number;
  86209. /**
  86210. * Gets or sets second associated factor
  86211. */
  86212. factor2?: number;
  86213. /**
  86214. * Will get a number picked randomly between factor1 and factor2.
  86215. * If factor2 is undefined then factor1 will be used
  86216. * @returns the picked number
  86217. */
  86218. getFactor(): number;
  86219. }
  86220. /**
  86221. * Helper used to simplify some generic gradient tasks
  86222. */
  86223. export class GradientHelper {
  86224. /**
  86225. * Gets the current gradient from an array of IValueGradient
  86226. * @param ratio defines the current ratio to get
  86227. * @param gradients defines the array of IValueGradient
  86228. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86229. */
  86230. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86231. }
  86232. }
  86233. declare module BABYLON {
  86234. interface ThinEngine {
  86235. /**
  86236. * Creates a dynamic texture
  86237. * @param width defines the width of the texture
  86238. * @param height defines the height of the texture
  86239. * @param generateMipMaps defines if the engine should generate the mip levels
  86240. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86241. * @returns the dynamic texture inside an InternalTexture
  86242. */
  86243. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86244. /**
  86245. * Update the content of a dynamic texture
  86246. * @param texture defines the texture to update
  86247. * @param canvas defines the canvas containing the source
  86248. * @param invertY defines if data must be stored with Y axis inverted
  86249. * @param premulAlpha defines if alpha is stored as premultiplied
  86250. * @param format defines the format of the data
  86251. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86252. */
  86253. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86254. }
  86255. }
  86256. declare module BABYLON {
  86257. /**
  86258. * Helper class used to generate a canvas to manipulate images
  86259. */
  86260. export class CanvasGenerator {
  86261. /**
  86262. * Create a new canvas (or offscreen canvas depending on the context)
  86263. * @param width defines the expected width
  86264. * @param height defines the expected height
  86265. * @return a new canvas or offscreen canvas
  86266. */
  86267. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86268. }
  86269. }
  86270. declare module BABYLON {
  86271. /**
  86272. * A class extending Texture allowing drawing on a texture
  86273. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86274. */
  86275. export class DynamicTexture extends Texture {
  86276. private _generateMipMaps;
  86277. private _canvas;
  86278. private _context;
  86279. private _engine;
  86280. /**
  86281. * Creates a DynamicTexture
  86282. * @param name defines the name of the texture
  86283. * @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
  86284. * @param scene defines the scene where you want the texture
  86285. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86286. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86287. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86288. */
  86289. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86290. /**
  86291. * Get the current class name of the texture useful for serialization or dynamic coding.
  86292. * @returns "DynamicTexture"
  86293. */
  86294. getClassName(): string;
  86295. /**
  86296. * Gets the current state of canRescale
  86297. */
  86298. readonly canRescale: boolean;
  86299. private _recreate;
  86300. /**
  86301. * Scales the texture
  86302. * @param ratio the scale factor to apply to both width and height
  86303. */
  86304. scale(ratio: number): void;
  86305. /**
  86306. * Resizes the texture
  86307. * @param width the new width
  86308. * @param height the new height
  86309. */
  86310. scaleTo(width: number, height: number): void;
  86311. /**
  86312. * Gets the context of the canvas used by the texture
  86313. * @returns the canvas context of the dynamic texture
  86314. */
  86315. getContext(): CanvasRenderingContext2D;
  86316. /**
  86317. * Clears the texture
  86318. */
  86319. clear(): void;
  86320. /**
  86321. * Updates the texture
  86322. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86323. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86324. */
  86325. update(invertY?: boolean, premulAlpha?: boolean): void;
  86326. /**
  86327. * Draws text onto the texture
  86328. * @param text defines the text to be drawn
  86329. * @param x defines the placement of the text from the left
  86330. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86331. * @param font defines the font to be used with font-style, font-size, font-name
  86332. * @param color defines the color used for the text
  86333. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86334. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86335. * @param update defines whether texture is immediately update (default is true)
  86336. */
  86337. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  86338. /**
  86339. * Clones the texture
  86340. * @returns the clone of the texture.
  86341. */
  86342. clone(): DynamicTexture;
  86343. /**
  86344. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86345. * @returns a serialized dynamic texture object
  86346. */
  86347. serialize(): any;
  86348. /** @hidden */
  86349. _rebuild(): void;
  86350. }
  86351. }
  86352. declare module BABYLON {
  86353. interface AbstractScene {
  86354. /**
  86355. * The list of procedural textures added to the scene
  86356. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86357. */
  86358. proceduralTextures: Array<ProceduralTexture>;
  86359. }
  86360. /**
  86361. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86362. * in a given scene.
  86363. */
  86364. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86365. /**
  86366. * The component name helpfull to identify the component in the list of scene components.
  86367. */
  86368. readonly name: string;
  86369. /**
  86370. * The scene the component belongs to.
  86371. */
  86372. scene: Scene;
  86373. /**
  86374. * Creates a new instance of the component for the given scene
  86375. * @param scene Defines the scene to register the component in
  86376. */
  86377. constructor(scene: Scene);
  86378. /**
  86379. * Registers the component in a given scene
  86380. */
  86381. register(): void;
  86382. /**
  86383. * Rebuilds the elements related to this component in case of
  86384. * context lost for instance.
  86385. */
  86386. rebuild(): void;
  86387. /**
  86388. * Disposes the component and the associated ressources.
  86389. */
  86390. dispose(): void;
  86391. private _beforeClear;
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. interface ThinEngine {
  86396. /**
  86397. * Creates a new render target cube texture
  86398. * @param size defines the size of the texture
  86399. * @param options defines the options used to create the texture
  86400. * @returns a new render target cube texture stored in an InternalTexture
  86401. */
  86402. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86403. }
  86404. }
  86405. declare module BABYLON {
  86406. /** @hidden */
  86407. export var proceduralVertexShader: {
  86408. name: string;
  86409. shader: string;
  86410. };
  86411. }
  86412. declare module BABYLON {
  86413. /**
  86414. * 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.
  86415. * This is the base class of any Procedural texture and contains most of the shareable code.
  86416. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86417. */
  86418. export class ProceduralTexture extends Texture {
  86419. isCube: boolean;
  86420. /**
  86421. * Define if the texture is enabled or not (disabled texture will not render)
  86422. */
  86423. isEnabled: boolean;
  86424. /**
  86425. * Define if the texture must be cleared before rendering (default is true)
  86426. */
  86427. autoClear: boolean;
  86428. /**
  86429. * Callback called when the texture is generated
  86430. */
  86431. onGenerated: () => void;
  86432. /**
  86433. * Event raised when the texture is generated
  86434. */
  86435. onGeneratedObservable: Observable<ProceduralTexture>;
  86436. /** @hidden */
  86437. _generateMipMaps: boolean;
  86438. /** @hidden **/
  86439. _effect: Effect;
  86440. /** @hidden */
  86441. _textures: {
  86442. [key: string]: Texture;
  86443. };
  86444. private _size;
  86445. private _currentRefreshId;
  86446. private _refreshRate;
  86447. private _vertexBuffers;
  86448. private _indexBuffer;
  86449. private _uniforms;
  86450. private _samplers;
  86451. private _fragment;
  86452. private _floats;
  86453. private _ints;
  86454. private _floatsArrays;
  86455. private _colors3;
  86456. private _colors4;
  86457. private _vectors2;
  86458. private _vectors3;
  86459. private _matrices;
  86460. private _fallbackTexture;
  86461. private _fallbackTextureUsed;
  86462. private _engine;
  86463. private _cachedDefines;
  86464. private _contentUpdateId;
  86465. private _contentData;
  86466. /**
  86467. * Instantiates a new procedural texture.
  86468. * 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.
  86469. * This is the base class of any Procedural texture and contains most of the shareable code.
  86470. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86471. * @param name Define the name of the texture
  86472. * @param size Define the size of the texture to create
  86473. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86474. * @param scene Define the scene the texture belongs to
  86475. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86476. * @param generateMipMaps Define if the texture should creates mip maps or not
  86477. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86478. */
  86479. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86480. /**
  86481. * The effect that is created when initializing the post process.
  86482. * @returns The created effect corresponding the the postprocess.
  86483. */
  86484. getEffect(): Effect;
  86485. /**
  86486. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86487. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86488. */
  86489. getContent(): Nullable<ArrayBufferView>;
  86490. private _createIndexBuffer;
  86491. /** @hidden */
  86492. _rebuild(): void;
  86493. /**
  86494. * Resets the texture in order to recreate its associated resources.
  86495. * This can be called in case of context loss
  86496. */
  86497. reset(): void;
  86498. protected _getDefines(): string;
  86499. /**
  86500. * Is the texture ready to be used ? (rendered at least once)
  86501. * @returns true if ready, otherwise, false.
  86502. */
  86503. isReady(): boolean;
  86504. /**
  86505. * Resets the refresh counter of the texture and start bak from scratch.
  86506. * Could be useful to regenerate the texture if it is setup to render only once.
  86507. */
  86508. resetRefreshCounter(): void;
  86509. /**
  86510. * Set the fragment shader to use in order to render the texture.
  86511. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86512. */
  86513. setFragment(fragment: any): void;
  86514. /**
  86515. * Define the refresh rate of the texture or the rendering frequency.
  86516. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86517. */
  86518. refreshRate: number;
  86519. /** @hidden */
  86520. _shouldRender(): boolean;
  86521. /**
  86522. * Get the size the texture is rendering at.
  86523. * @returns the size (texture is always squared)
  86524. */
  86525. getRenderSize(): number;
  86526. /**
  86527. * Resize the texture to new value.
  86528. * @param size Define the new size the texture should have
  86529. * @param generateMipMaps Define whether the new texture should create mip maps
  86530. */
  86531. resize(size: number, generateMipMaps: boolean): void;
  86532. private _checkUniform;
  86533. /**
  86534. * Set a texture in the shader program used to render.
  86535. * @param name Define the name of the uniform samplers as defined in the shader
  86536. * @param texture Define the texture to bind to this sampler
  86537. * @return the texture itself allowing "fluent" like uniform updates
  86538. */
  86539. setTexture(name: string, texture: Texture): ProceduralTexture;
  86540. /**
  86541. * Set a float in the shader.
  86542. * @param name Define the name of the uniform as defined in the shader
  86543. * @param value Define the value to give to the uniform
  86544. * @return the texture itself allowing "fluent" like uniform updates
  86545. */
  86546. setFloat(name: string, value: number): ProceduralTexture;
  86547. /**
  86548. * Set a int in the shader.
  86549. * @param name Define the name of the uniform as defined in the shader
  86550. * @param value Define the value to give to the uniform
  86551. * @return the texture itself allowing "fluent" like uniform updates
  86552. */
  86553. setInt(name: string, value: number): ProceduralTexture;
  86554. /**
  86555. * Set an array of floats in the shader.
  86556. * @param name Define the name of the uniform as defined in the shader
  86557. * @param value Define the value to give to the uniform
  86558. * @return the texture itself allowing "fluent" like uniform updates
  86559. */
  86560. setFloats(name: string, value: number[]): ProceduralTexture;
  86561. /**
  86562. * Set a vec3 in the shader from a Color3.
  86563. * @param name Define the name of the uniform as defined in the shader
  86564. * @param value Define the value to give to the uniform
  86565. * @return the texture itself allowing "fluent" like uniform updates
  86566. */
  86567. setColor3(name: string, value: Color3): ProceduralTexture;
  86568. /**
  86569. * Set a vec4 in the shader from a Color4.
  86570. * @param name Define the name of the uniform as defined in the shader
  86571. * @param value Define the value to give to the uniform
  86572. * @return the texture itself allowing "fluent" like uniform updates
  86573. */
  86574. setColor4(name: string, value: Color4): ProceduralTexture;
  86575. /**
  86576. * Set a vec2 in the shader from a Vector2.
  86577. * @param name Define the name of the uniform as defined in the shader
  86578. * @param value Define the value to give to the uniform
  86579. * @return the texture itself allowing "fluent" like uniform updates
  86580. */
  86581. setVector2(name: string, value: Vector2): ProceduralTexture;
  86582. /**
  86583. * Set a vec3 in the shader from a Vector3.
  86584. * @param name Define the name of the uniform as defined in the shader
  86585. * @param value Define the value to give to the uniform
  86586. * @return the texture itself allowing "fluent" like uniform updates
  86587. */
  86588. setVector3(name: string, value: Vector3): ProceduralTexture;
  86589. /**
  86590. * Set a mat4 in the shader from a MAtrix.
  86591. * @param name Define the name of the uniform as defined in the shader
  86592. * @param value Define the value to give to the uniform
  86593. * @return the texture itself allowing "fluent" like uniform updates
  86594. */
  86595. setMatrix(name: string, value: Matrix): ProceduralTexture;
  86596. /**
  86597. * Render the texture to its associated render target.
  86598. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  86599. */
  86600. render(useCameraPostProcess?: boolean): void;
  86601. /**
  86602. * Clone the texture.
  86603. * @returns the cloned texture
  86604. */
  86605. clone(): ProceduralTexture;
  86606. /**
  86607. * Dispose the texture and release its asoociated resources.
  86608. */
  86609. dispose(): void;
  86610. }
  86611. }
  86612. declare module BABYLON {
  86613. /**
  86614. * This represents the base class for particle system in Babylon.
  86615. * 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.
  86616. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86617. * @example https://doc.babylonjs.com/babylon101/particles
  86618. */
  86619. export class BaseParticleSystem {
  86620. /**
  86621. * Source color is added to the destination color without alpha affecting the result
  86622. */
  86623. static BLENDMODE_ONEONE: number;
  86624. /**
  86625. * Blend current color and particle color using particle’s alpha
  86626. */
  86627. static BLENDMODE_STANDARD: number;
  86628. /**
  86629. * Add current color and particle color multiplied by particle’s alpha
  86630. */
  86631. static BLENDMODE_ADD: number;
  86632. /**
  86633. * Multiply current color with particle color
  86634. */
  86635. static BLENDMODE_MULTIPLY: number;
  86636. /**
  86637. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86638. */
  86639. static BLENDMODE_MULTIPLYADD: number;
  86640. /**
  86641. * List of animations used by the particle system.
  86642. */
  86643. animations: Animation[];
  86644. /**
  86645. * The id of the Particle system.
  86646. */
  86647. id: string;
  86648. /**
  86649. * The friendly name of the Particle system.
  86650. */
  86651. name: string;
  86652. /**
  86653. * The rendering group used by the Particle system to chose when to render.
  86654. */
  86655. renderingGroupId: number;
  86656. /**
  86657. * The emitter represents the Mesh or position we are attaching the particle system to.
  86658. */
  86659. emitter: Nullable<AbstractMesh | Vector3>;
  86660. /**
  86661. * The maximum number of particles to emit per frame
  86662. */
  86663. emitRate: number;
  86664. /**
  86665. * If you want to launch only a few particles at once, that can be done, as well.
  86666. */
  86667. manualEmitCount: number;
  86668. /**
  86669. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86670. */
  86671. updateSpeed: number;
  86672. /**
  86673. * The amount of time the particle system is running (depends of the overall update speed).
  86674. */
  86675. targetStopDuration: number;
  86676. /**
  86677. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86678. */
  86679. disposeOnStop: boolean;
  86680. /**
  86681. * Minimum power of emitting particles.
  86682. */
  86683. minEmitPower: number;
  86684. /**
  86685. * Maximum power of emitting particles.
  86686. */
  86687. maxEmitPower: number;
  86688. /**
  86689. * Minimum life time of emitting particles.
  86690. */
  86691. minLifeTime: number;
  86692. /**
  86693. * Maximum life time of emitting particles.
  86694. */
  86695. maxLifeTime: number;
  86696. /**
  86697. * Minimum Size of emitting particles.
  86698. */
  86699. minSize: number;
  86700. /**
  86701. * Maximum Size of emitting particles.
  86702. */
  86703. maxSize: number;
  86704. /**
  86705. * Minimum scale of emitting particles on X axis.
  86706. */
  86707. minScaleX: number;
  86708. /**
  86709. * Maximum scale of emitting particles on X axis.
  86710. */
  86711. maxScaleX: number;
  86712. /**
  86713. * Minimum scale of emitting particles on Y axis.
  86714. */
  86715. minScaleY: number;
  86716. /**
  86717. * Maximum scale of emitting particles on Y axis.
  86718. */
  86719. maxScaleY: number;
  86720. /**
  86721. * Gets or sets the minimal initial rotation in radians.
  86722. */
  86723. minInitialRotation: number;
  86724. /**
  86725. * Gets or sets the maximal initial rotation in radians.
  86726. */
  86727. maxInitialRotation: number;
  86728. /**
  86729. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86730. */
  86731. minAngularSpeed: number;
  86732. /**
  86733. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86734. */
  86735. maxAngularSpeed: number;
  86736. /**
  86737. * The texture used to render each particle. (this can be a spritesheet)
  86738. */
  86739. particleTexture: Nullable<Texture>;
  86740. /**
  86741. * The layer mask we are rendering the particles through.
  86742. */
  86743. layerMask: number;
  86744. /**
  86745. * This can help using your own shader to render the particle system.
  86746. * The according effect will be created
  86747. */
  86748. customShader: any;
  86749. /**
  86750. * By default particle system starts as soon as they are created. This prevents the
  86751. * automatic start to happen and let you decide when to start emitting particles.
  86752. */
  86753. preventAutoStart: boolean;
  86754. private _noiseTexture;
  86755. /**
  86756. * Gets or sets a texture used to add random noise to particle positions
  86757. */
  86758. noiseTexture: Nullable<ProceduralTexture>;
  86759. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86760. noiseStrength: Vector3;
  86761. /**
  86762. * Callback triggered when the particle animation is ending.
  86763. */
  86764. onAnimationEnd: Nullable<() => void>;
  86765. /**
  86766. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  86767. */
  86768. blendMode: number;
  86769. /**
  86770. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  86771. * to override the particles.
  86772. */
  86773. forceDepthWrite: boolean;
  86774. /** 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 */
  86775. preWarmCycles: number;
  86776. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  86777. preWarmStepOffset: number;
  86778. /**
  86779. * 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)
  86780. */
  86781. spriteCellChangeSpeed: number;
  86782. /**
  86783. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86784. */
  86785. startSpriteCellID: number;
  86786. /**
  86787. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86788. */
  86789. endSpriteCellID: number;
  86790. /**
  86791. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86792. */
  86793. spriteCellWidth: number;
  86794. /**
  86795. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86796. */
  86797. spriteCellHeight: number;
  86798. /**
  86799. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86800. */
  86801. spriteRandomStartCell: boolean;
  86802. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86803. translationPivot: Vector2;
  86804. /** @hidden */
  86805. protected _isAnimationSheetEnabled: boolean;
  86806. /**
  86807. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86808. */
  86809. beginAnimationOnStart: boolean;
  86810. /**
  86811. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86812. */
  86813. beginAnimationFrom: number;
  86814. /**
  86815. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86816. */
  86817. beginAnimationTo: number;
  86818. /**
  86819. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86820. */
  86821. beginAnimationLoop: boolean;
  86822. /**
  86823. * Gets or sets a world offset applied to all particles
  86824. */
  86825. worldOffset: Vector3;
  86826. /**
  86827. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  86828. */
  86829. isAnimationSheetEnabled: boolean;
  86830. /**
  86831. * Get hosting scene
  86832. * @returns the scene
  86833. */
  86834. getScene(): Scene;
  86835. /**
  86836. * You can use gravity if you want to give an orientation to your particles.
  86837. */
  86838. gravity: Vector3;
  86839. protected _colorGradients: Nullable<Array<ColorGradient>>;
  86840. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  86841. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  86842. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  86843. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  86844. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  86845. protected _dragGradients: Nullable<Array<FactorGradient>>;
  86846. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  86847. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  86848. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  86849. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  86850. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  86851. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  86852. /**
  86853. * Defines the delay in milliseconds before starting the system (0 by default)
  86854. */
  86855. startDelay: number;
  86856. /**
  86857. * Gets the current list of drag gradients.
  86858. * You must use addDragGradient and removeDragGradient to udpate this list
  86859. * @returns the list of drag gradients
  86860. */
  86861. getDragGradients(): Nullable<Array<FactorGradient>>;
  86862. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86863. limitVelocityDamping: number;
  86864. /**
  86865. * Gets the current list of limit velocity gradients.
  86866. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86867. * @returns the list of limit velocity gradients
  86868. */
  86869. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86870. /**
  86871. * Gets the current list of color gradients.
  86872. * You must use addColorGradient and removeColorGradient to udpate this list
  86873. * @returns the list of color gradients
  86874. */
  86875. getColorGradients(): Nullable<Array<ColorGradient>>;
  86876. /**
  86877. * Gets the current list of size gradients.
  86878. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86879. * @returns the list of size gradients
  86880. */
  86881. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86882. /**
  86883. * Gets the current list of color remap gradients.
  86884. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86885. * @returns the list of color remap gradients
  86886. */
  86887. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86888. /**
  86889. * Gets the current list of alpha remap gradients.
  86890. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86891. * @returns the list of alpha remap gradients
  86892. */
  86893. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86894. /**
  86895. * Gets the current list of life time gradients.
  86896. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86897. * @returns the list of life time gradients
  86898. */
  86899. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86900. /**
  86901. * Gets the current list of angular speed gradients.
  86902. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86903. * @returns the list of angular speed gradients
  86904. */
  86905. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86906. /**
  86907. * Gets the current list of velocity gradients.
  86908. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86909. * @returns the list of velocity gradients
  86910. */
  86911. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86912. /**
  86913. * Gets the current list of start size gradients.
  86914. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86915. * @returns the list of start size gradients
  86916. */
  86917. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86918. /**
  86919. * Gets the current list of emit rate gradients.
  86920. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86921. * @returns the list of emit rate gradients
  86922. */
  86923. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86924. /**
  86925. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86926. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86927. */
  86928. direction1: Vector3;
  86929. /**
  86930. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86931. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86932. */
  86933. direction2: Vector3;
  86934. /**
  86935. * 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.
  86936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86937. */
  86938. minEmitBox: Vector3;
  86939. /**
  86940. * 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.
  86941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86942. */
  86943. maxEmitBox: Vector3;
  86944. /**
  86945. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86946. */
  86947. color1: Color4;
  86948. /**
  86949. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86950. */
  86951. color2: Color4;
  86952. /**
  86953. * Color the particle will have at the end of its lifetime
  86954. */
  86955. colorDead: Color4;
  86956. /**
  86957. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  86958. */
  86959. textureMask: Color4;
  86960. /**
  86961. * The particle emitter type defines the emitter used by the particle system.
  86962. * It can be for example box, sphere, or cone...
  86963. */
  86964. particleEmitterType: IParticleEmitterType;
  86965. /** @hidden */
  86966. _isSubEmitter: boolean;
  86967. /**
  86968. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86969. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86970. */
  86971. billboardMode: number;
  86972. protected _isBillboardBased: boolean;
  86973. /**
  86974. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86975. */
  86976. isBillboardBased: boolean;
  86977. /**
  86978. * The scene the particle system belongs to.
  86979. */
  86980. protected _scene: Scene;
  86981. /**
  86982. * Local cache of defines for image processing.
  86983. */
  86984. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  86985. /**
  86986. * Default configuration related to image processing available in the standard Material.
  86987. */
  86988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  86989. /**
  86990. * Gets the image processing configuration used either in this material.
  86991. */
  86992. /**
  86993. * Sets the Default image processing configuration used either in the this material.
  86994. *
  86995. * If sets to null, the scene one is in use.
  86996. */
  86997. imageProcessingConfiguration: ImageProcessingConfiguration;
  86998. /**
  86999. * Attaches a new image processing configuration to the Standard Material.
  87000. * @param configuration
  87001. */
  87002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87003. /** @hidden */
  87004. protected _reset(): void;
  87005. /** @hidden */
  87006. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87007. /**
  87008. * Instantiates a particle system.
  87009. * 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.
  87010. * @param name The name of the particle system
  87011. */
  87012. constructor(name: string);
  87013. /**
  87014. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87017. * @returns the emitter
  87018. */
  87019. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87020. /**
  87021. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87022. * @param radius The radius of the hemisphere to emit from
  87023. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87024. * @returns the emitter
  87025. */
  87026. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87027. /**
  87028. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87029. * @param radius The radius of the sphere to emit from
  87030. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87031. * @returns the emitter
  87032. */
  87033. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87034. /**
  87035. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87036. * @param radius The radius of the sphere to emit from
  87037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87039. * @returns the emitter
  87040. */
  87041. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87042. /**
  87043. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87044. * @param radius The radius of the emission cylinder
  87045. * @param height The height of the emission cylinder
  87046. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87047. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87048. * @returns the emitter
  87049. */
  87050. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87051. /**
  87052. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87053. * @param radius The radius of the cylinder to emit from
  87054. * @param height The height of the emission cylinder
  87055. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87058. * @returns the emitter
  87059. */
  87060. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87061. /**
  87062. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87063. * @param radius The radius of the cone to emit from
  87064. * @param angle The base angle of the cone
  87065. * @returns the emitter
  87066. */
  87067. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87068. /**
  87069. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87072. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87073. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87074. * @returns the emitter
  87075. */
  87076. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87077. }
  87078. }
  87079. declare module BABYLON {
  87080. /**
  87081. * Type of sub emitter
  87082. */
  87083. export enum SubEmitterType {
  87084. /**
  87085. * Attached to the particle over it's lifetime
  87086. */
  87087. ATTACHED = 0,
  87088. /**
  87089. * Created when the particle dies
  87090. */
  87091. END = 1
  87092. }
  87093. /**
  87094. * Sub emitter class used to emit particles from an existing particle
  87095. */
  87096. export class SubEmitter {
  87097. /**
  87098. * the particle system to be used by the sub emitter
  87099. */
  87100. particleSystem: ParticleSystem;
  87101. /**
  87102. * Type of the submitter (Default: END)
  87103. */
  87104. type: SubEmitterType;
  87105. /**
  87106. * 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)
  87107. * Note: This only is supported when using an emitter of type Mesh
  87108. */
  87109. inheritDirection: boolean;
  87110. /**
  87111. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87112. */
  87113. inheritedVelocityAmount: number;
  87114. /**
  87115. * Creates a sub emitter
  87116. * @param particleSystem the particle system to be used by the sub emitter
  87117. */
  87118. constructor(
  87119. /**
  87120. * the particle system to be used by the sub emitter
  87121. */
  87122. particleSystem: ParticleSystem);
  87123. /**
  87124. * Clones the sub emitter
  87125. * @returns the cloned sub emitter
  87126. */
  87127. clone(): SubEmitter;
  87128. /**
  87129. * Serialize current object to a JSON object
  87130. * @returns the serialized object
  87131. */
  87132. serialize(): any;
  87133. /** @hidden */
  87134. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87135. /**
  87136. * Creates a new SubEmitter from a serialized JSON version
  87137. * @param serializationObject defines the JSON object to read from
  87138. * @param scene defines the hosting scene
  87139. * @param rootUrl defines the rootUrl for data loading
  87140. * @returns a new SubEmitter
  87141. */
  87142. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87143. /** Release associated resources */
  87144. dispose(): void;
  87145. }
  87146. }
  87147. declare module BABYLON {
  87148. /** @hidden */
  87149. export var clipPlaneFragmentDeclaration: {
  87150. name: string;
  87151. shader: string;
  87152. };
  87153. }
  87154. declare module BABYLON {
  87155. /** @hidden */
  87156. export var imageProcessingDeclaration: {
  87157. name: string;
  87158. shader: string;
  87159. };
  87160. }
  87161. declare module BABYLON {
  87162. /** @hidden */
  87163. export var imageProcessingFunctions: {
  87164. name: string;
  87165. shader: string;
  87166. };
  87167. }
  87168. declare module BABYLON {
  87169. /** @hidden */
  87170. export var clipPlaneFragment: {
  87171. name: string;
  87172. shader: string;
  87173. };
  87174. }
  87175. declare module BABYLON {
  87176. /** @hidden */
  87177. export var particlesPixelShader: {
  87178. name: string;
  87179. shader: string;
  87180. };
  87181. }
  87182. declare module BABYLON {
  87183. /** @hidden */
  87184. export var clipPlaneVertexDeclaration: {
  87185. name: string;
  87186. shader: string;
  87187. };
  87188. }
  87189. declare module BABYLON {
  87190. /** @hidden */
  87191. export var clipPlaneVertex: {
  87192. name: string;
  87193. shader: string;
  87194. };
  87195. }
  87196. declare module BABYLON {
  87197. /** @hidden */
  87198. export var particlesVertexShader: {
  87199. name: string;
  87200. shader: string;
  87201. };
  87202. }
  87203. declare module BABYLON {
  87204. /**
  87205. * This represents a particle system in Babylon.
  87206. * 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.
  87207. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87208. * @example https://doc.babylonjs.com/babylon101/particles
  87209. */
  87210. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87211. /**
  87212. * Billboard mode will only apply to Y axis
  87213. */
  87214. static readonly BILLBOARDMODE_Y: number;
  87215. /**
  87216. * Billboard mode will apply to all axes
  87217. */
  87218. static readonly BILLBOARDMODE_ALL: number;
  87219. /**
  87220. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87221. */
  87222. static readonly BILLBOARDMODE_STRETCHED: number;
  87223. /**
  87224. * This function can be defined to provide custom update for active particles.
  87225. * This function will be called instead of regular update (age, position, color, etc.).
  87226. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87227. */
  87228. updateFunction: (particles: Particle[]) => void;
  87229. private _emitterWorldMatrix;
  87230. /**
  87231. * This function can be defined to specify initial direction for every new particle.
  87232. * It by default use the emitterType defined function
  87233. */
  87234. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  87235. /**
  87236. * This function can be defined to specify initial position for every new particle.
  87237. * It by default use the emitterType defined function
  87238. */
  87239. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  87240. /**
  87241. * @hidden
  87242. */
  87243. _inheritedVelocityOffset: Vector3;
  87244. /**
  87245. * An event triggered when the system is disposed
  87246. */
  87247. onDisposeObservable: Observable<ParticleSystem>;
  87248. private _onDisposeObserver;
  87249. /**
  87250. * Sets a callback that will be triggered when the system is disposed
  87251. */
  87252. onDispose: () => void;
  87253. private _particles;
  87254. private _epsilon;
  87255. private _capacity;
  87256. private _stockParticles;
  87257. private _newPartsExcess;
  87258. private _vertexData;
  87259. private _vertexBuffer;
  87260. private _vertexBuffers;
  87261. private _spriteBuffer;
  87262. private _indexBuffer;
  87263. private _effect;
  87264. private _customEffect;
  87265. private _cachedDefines;
  87266. private _scaledColorStep;
  87267. private _colorDiff;
  87268. private _scaledDirection;
  87269. private _scaledGravity;
  87270. private _currentRenderId;
  87271. private _alive;
  87272. private _useInstancing;
  87273. private _started;
  87274. private _stopped;
  87275. private _actualFrame;
  87276. private _scaledUpdateSpeed;
  87277. private _vertexBufferSize;
  87278. /** @hidden */
  87279. _currentEmitRateGradient: Nullable<FactorGradient>;
  87280. /** @hidden */
  87281. _currentEmitRate1: number;
  87282. /** @hidden */
  87283. _currentEmitRate2: number;
  87284. /** @hidden */
  87285. _currentStartSizeGradient: Nullable<FactorGradient>;
  87286. /** @hidden */
  87287. _currentStartSize1: number;
  87288. /** @hidden */
  87289. _currentStartSize2: number;
  87290. private readonly _rawTextureWidth;
  87291. private _rampGradientsTexture;
  87292. private _useRampGradients;
  87293. /** Gets or sets a boolean indicating that ramp gradients must be used
  87294. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87295. */
  87296. useRampGradients: boolean;
  87297. /**
  87298. * 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.
  87299. * 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: [])
  87300. */
  87301. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87302. private _subEmitters;
  87303. /**
  87304. * @hidden
  87305. * If the particle systems emitter should be disposed when the particle system is disposed
  87306. */
  87307. _disposeEmitterOnDispose: boolean;
  87308. /**
  87309. * The current active Sub-systems, this property is used by the root particle system only.
  87310. */
  87311. activeSubSystems: Array<ParticleSystem>;
  87312. private _rootParticleSystem;
  87313. /**
  87314. * Gets the current list of active particles
  87315. */
  87316. readonly particles: Particle[];
  87317. /**
  87318. * Returns the string "ParticleSystem"
  87319. * @returns a string containing the class name
  87320. */
  87321. getClassName(): string;
  87322. /**
  87323. * Instantiates a particle system.
  87324. * 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.
  87325. * @param name The name of the particle system
  87326. * @param capacity The max number of particles alive at the same time
  87327. * @param scene The scene the particle system belongs to
  87328. * @param customEffect a custom effect used to change the way particles are rendered by default
  87329. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87330. * @param epsilon Offset used to render the particles
  87331. */
  87332. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87333. private _addFactorGradient;
  87334. private _removeFactorGradient;
  87335. /**
  87336. * Adds a new life time gradient
  87337. * @param gradient defines the gradient to use (between 0 and 1)
  87338. * @param factor defines the life time factor to affect to the specified gradient
  87339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87340. * @returns the current particle system
  87341. */
  87342. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87343. /**
  87344. * Remove a specific life time gradient
  87345. * @param gradient defines the gradient to remove
  87346. * @returns the current particle system
  87347. */
  87348. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87349. /**
  87350. * Adds a new size gradient
  87351. * @param gradient defines the gradient to use (between 0 and 1)
  87352. * @param factor defines the size factor to affect to the specified gradient
  87353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87354. * @returns the current particle system
  87355. */
  87356. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87357. /**
  87358. * Remove a specific size gradient
  87359. * @param gradient defines the gradient to remove
  87360. * @returns the current particle system
  87361. */
  87362. removeSizeGradient(gradient: number): IParticleSystem;
  87363. /**
  87364. * Adds a new color remap gradient
  87365. * @param gradient defines the gradient to use (between 0 and 1)
  87366. * @param min defines the color remap minimal range
  87367. * @param max defines the color remap maximal range
  87368. * @returns the current particle system
  87369. */
  87370. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87371. /**
  87372. * Remove a specific color remap gradient
  87373. * @param gradient defines the gradient to remove
  87374. * @returns the current particle system
  87375. */
  87376. removeColorRemapGradient(gradient: number): IParticleSystem;
  87377. /**
  87378. * Adds a new alpha remap gradient
  87379. * @param gradient defines the gradient to use (between 0 and 1)
  87380. * @param min defines the alpha remap minimal range
  87381. * @param max defines the alpha remap maximal range
  87382. * @returns the current particle system
  87383. */
  87384. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87385. /**
  87386. * Remove a specific alpha remap gradient
  87387. * @param gradient defines the gradient to remove
  87388. * @returns the current particle system
  87389. */
  87390. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87391. /**
  87392. * Adds a new angular speed gradient
  87393. * @param gradient defines the gradient to use (between 0 and 1)
  87394. * @param factor defines the angular speed to affect to the specified gradient
  87395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87396. * @returns the current particle system
  87397. */
  87398. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87399. /**
  87400. * Remove a specific angular speed gradient
  87401. * @param gradient defines the gradient to remove
  87402. * @returns the current particle system
  87403. */
  87404. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87405. /**
  87406. * Adds a new velocity gradient
  87407. * @param gradient defines the gradient to use (between 0 and 1)
  87408. * @param factor defines the velocity to affect to the specified gradient
  87409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87410. * @returns the current particle system
  87411. */
  87412. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87413. /**
  87414. * Remove a specific velocity gradient
  87415. * @param gradient defines the gradient to remove
  87416. * @returns the current particle system
  87417. */
  87418. removeVelocityGradient(gradient: number): IParticleSystem;
  87419. /**
  87420. * Adds a new limit velocity gradient
  87421. * @param gradient defines the gradient to use (between 0 and 1)
  87422. * @param factor defines the limit velocity value to affect to the specified gradient
  87423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87424. * @returns the current particle system
  87425. */
  87426. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87427. /**
  87428. * Remove a specific limit velocity gradient
  87429. * @param gradient defines the gradient to remove
  87430. * @returns the current particle system
  87431. */
  87432. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87433. /**
  87434. * Adds a new drag gradient
  87435. * @param gradient defines the gradient to use (between 0 and 1)
  87436. * @param factor defines the drag value to affect to the specified gradient
  87437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87438. * @returns the current particle system
  87439. */
  87440. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87441. /**
  87442. * Remove a specific drag gradient
  87443. * @param gradient defines the gradient to remove
  87444. * @returns the current particle system
  87445. */
  87446. removeDragGradient(gradient: number): IParticleSystem;
  87447. /**
  87448. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87449. * @param gradient defines the gradient to use (between 0 and 1)
  87450. * @param factor defines the emit rate value to affect to the specified gradient
  87451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87452. * @returns the current particle system
  87453. */
  87454. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87455. /**
  87456. * Remove a specific emit rate gradient
  87457. * @param gradient defines the gradient to remove
  87458. * @returns the current particle system
  87459. */
  87460. removeEmitRateGradient(gradient: number): IParticleSystem;
  87461. /**
  87462. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87463. * @param gradient defines the gradient to use (between 0 and 1)
  87464. * @param factor defines the start size value to affect to the specified gradient
  87465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87466. * @returns the current particle system
  87467. */
  87468. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87469. /**
  87470. * Remove a specific start size gradient
  87471. * @param gradient defines the gradient to remove
  87472. * @returns the current particle system
  87473. */
  87474. removeStartSizeGradient(gradient: number): IParticleSystem;
  87475. private _createRampGradientTexture;
  87476. /**
  87477. * Gets the current list of ramp gradients.
  87478. * You must use addRampGradient and removeRampGradient to udpate this list
  87479. * @returns the list of ramp gradients
  87480. */
  87481. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87482. /**
  87483. * Adds a new ramp gradient used to remap particle colors
  87484. * @param gradient defines the gradient to use (between 0 and 1)
  87485. * @param color defines the color to affect to the specified gradient
  87486. * @returns the current particle system
  87487. */
  87488. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87489. /**
  87490. * Remove a specific ramp gradient
  87491. * @param gradient defines the gradient to remove
  87492. * @returns the current particle system
  87493. */
  87494. removeRampGradient(gradient: number): ParticleSystem;
  87495. /**
  87496. * Adds a new color gradient
  87497. * @param gradient defines the gradient to use (between 0 and 1)
  87498. * @param color1 defines the color to affect to the specified gradient
  87499. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87500. * @returns this particle system
  87501. */
  87502. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87503. /**
  87504. * Remove a specific color gradient
  87505. * @param gradient defines the gradient to remove
  87506. * @returns this particle system
  87507. */
  87508. removeColorGradient(gradient: number): IParticleSystem;
  87509. private _fetchR;
  87510. protected _reset(): void;
  87511. private _resetEffect;
  87512. private _createVertexBuffers;
  87513. private _createIndexBuffer;
  87514. /**
  87515. * Gets the maximum number of particles active at the same time.
  87516. * @returns The max number of active particles.
  87517. */
  87518. getCapacity(): number;
  87519. /**
  87520. * Gets whether there are still active particles in the system.
  87521. * @returns True if it is alive, otherwise false.
  87522. */
  87523. isAlive(): boolean;
  87524. /**
  87525. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87526. * @returns True if it has been started, otherwise false.
  87527. */
  87528. isStarted(): boolean;
  87529. private _prepareSubEmitterInternalArray;
  87530. /**
  87531. * Starts the particle system and begins to emit
  87532. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87533. */
  87534. start(delay?: number): void;
  87535. /**
  87536. * Stops the particle system.
  87537. * @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.
  87538. */
  87539. stop(stopSubEmitters?: boolean): void;
  87540. /**
  87541. * Remove all active particles
  87542. */
  87543. reset(): void;
  87544. /**
  87545. * @hidden (for internal use only)
  87546. */
  87547. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  87548. /**
  87549. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  87550. * Its lifetime will start back at 0.
  87551. */
  87552. recycleParticle: (particle: Particle) => void;
  87553. private _stopSubEmitters;
  87554. private _createParticle;
  87555. private _removeFromRoot;
  87556. private _emitFromParticle;
  87557. private _update;
  87558. /** @hidden */
  87559. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  87560. /** @hidden */
  87561. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  87562. /** @hidden */
  87563. private _getEffect;
  87564. /**
  87565. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  87566. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  87567. */
  87568. animate(preWarmOnly?: boolean): void;
  87569. private _appendParticleVertices;
  87570. /**
  87571. * Rebuilds the particle system.
  87572. */
  87573. rebuild(): void;
  87574. /**
  87575. * Is this system ready to be used/rendered
  87576. * @return true if the system is ready
  87577. */
  87578. isReady(): boolean;
  87579. private _render;
  87580. /**
  87581. * Renders the particle system in its current state.
  87582. * @returns the current number of particles
  87583. */
  87584. render(): number;
  87585. /**
  87586. * Disposes the particle system and free the associated resources
  87587. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87588. */
  87589. dispose(disposeTexture?: boolean): void;
  87590. /**
  87591. * Clones the particle system.
  87592. * @param name The name of the cloned object
  87593. * @param newEmitter The new emitter to use
  87594. * @returns the cloned particle system
  87595. */
  87596. clone(name: string, newEmitter: any): ParticleSystem;
  87597. /**
  87598. * Serializes the particle system to a JSON object.
  87599. * @returns the JSON object
  87600. */
  87601. serialize(): any;
  87602. /** @hidden */
  87603. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  87604. /** @hidden */
  87605. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  87606. /**
  87607. * Parses a JSON object to create a particle system.
  87608. * @param parsedParticleSystem The JSON object to parse
  87609. * @param scene The scene to create the particle system in
  87610. * @param rootUrl The root url to use to load external dependencies like texture
  87611. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87612. * @returns the Parsed particle system
  87613. */
  87614. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87615. }
  87616. }
  87617. declare module BABYLON {
  87618. /**
  87619. * A particle represents one of the element emitted by a particle system.
  87620. * This is mainly define by its coordinates, direction, velocity and age.
  87621. */
  87622. export class Particle {
  87623. /**
  87624. * The particle system the particle belongs to.
  87625. */
  87626. particleSystem: ParticleSystem;
  87627. private static _Count;
  87628. /**
  87629. * Unique ID of the particle
  87630. */
  87631. id: number;
  87632. /**
  87633. * The world position of the particle in the scene.
  87634. */
  87635. position: Vector3;
  87636. /**
  87637. * The world direction of the particle in the scene.
  87638. */
  87639. direction: Vector3;
  87640. /**
  87641. * The color of the particle.
  87642. */
  87643. color: Color4;
  87644. /**
  87645. * The color change of the particle per step.
  87646. */
  87647. colorStep: Color4;
  87648. /**
  87649. * Defines how long will the life of the particle be.
  87650. */
  87651. lifeTime: number;
  87652. /**
  87653. * The current age of the particle.
  87654. */
  87655. age: number;
  87656. /**
  87657. * The current size of the particle.
  87658. */
  87659. size: number;
  87660. /**
  87661. * The current scale of the particle.
  87662. */
  87663. scale: Vector2;
  87664. /**
  87665. * The current angle of the particle.
  87666. */
  87667. angle: number;
  87668. /**
  87669. * Defines how fast is the angle changing.
  87670. */
  87671. angularSpeed: number;
  87672. /**
  87673. * Defines the cell index used by the particle to be rendered from a sprite.
  87674. */
  87675. cellIndex: number;
  87676. /**
  87677. * The information required to support color remapping
  87678. */
  87679. remapData: Vector4;
  87680. /** @hidden */
  87681. _randomCellOffset?: number;
  87682. /** @hidden */
  87683. _initialDirection: Nullable<Vector3>;
  87684. /** @hidden */
  87685. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87686. /** @hidden */
  87687. _initialStartSpriteCellID: number;
  87688. /** @hidden */
  87689. _initialEndSpriteCellID: number;
  87690. /** @hidden */
  87691. _currentColorGradient: Nullable<ColorGradient>;
  87692. /** @hidden */
  87693. _currentColor1: Color4;
  87694. /** @hidden */
  87695. _currentColor2: Color4;
  87696. /** @hidden */
  87697. _currentSizeGradient: Nullable<FactorGradient>;
  87698. /** @hidden */
  87699. _currentSize1: number;
  87700. /** @hidden */
  87701. _currentSize2: number;
  87702. /** @hidden */
  87703. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87704. /** @hidden */
  87705. _currentAngularSpeed1: number;
  87706. /** @hidden */
  87707. _currentAngularSpeed2: number;
  87708. /** @hidden */
  87709. _currentVelocityGradient: Nullable<FactorGradient>;
  87710. /** @hidden */
  87711. _currentVelocity1: number;
  87712. /** @hidden */
  87713. _currentVelocity2: number;
  87714. /** @hidden */
  87715. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87716. /** @hidden */
  87717. _currentLimitVelocity1: number;
  87718. /** @hidden */
  87719. _currentLimitVelocity2: number;
  87720. /** @hidden */
  87721. _currentDragGradient: Nullable<FactorGradient>;
  87722. /** @hidden */
  87723. _currentDrag1: number;
  87724. /** @hidden */
  87725. _currentDrag2: number;
  87726. /** @hidden */
  87727. _randomNoiseCoordinates1: Vector3;
  87728. /** @hidden */
  87729. _randomNoiseCoordinates2: Vector3;
  87730. /**
  87731. * Creates a new instance Particle
  87732. * @param particleSystem the particle system the particle belongs to
  87733. */
  87734. constructor(
  87735. /**
  87736. * The particle system the particle belongs to.
  87737. */
  87738. particleSystem: ParticleSystem);
  87739. private updateCellInfoFromSystem;
  87740. /**
  87741. * Defines how the sprite cell index is updated for the particle
  87742. */
  87743. updateCellIndex(): void;
  87744. /** @hidden */
  87745. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  87746. /** @hidden */
  87747. _inheritParticleInfoToSubEmitters(): void;
  87748. /** @hidden */
  87749. _reset(): void;
  87750. /**
  87751. * Copy the properties of particle to another one.
  87752. * @param other the particle to copy the information to.
  87753. */
  87754. copyTo(other: Particle): void;
  87755. }
  87756. }
  87757. declare module BABYLON {
  87758. /**
  87759. * Particle emitter represents a volume emitting particles.
  87760. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  87761. */
  87762. export interface IParticleEmitterType {
  87763. /**
  87764. * Called by the particle System when the direction is computed for the created particle.
  87765. * @param worldMatrix is the world matrix of the particle system
  87766. * @param directionToUpdate is the direction vector to update with the result
  87767. * @param particle is the particle we are computed the direction for
  87768. */
  87769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87770. /**
  87771. * Called by the particle System when the position is computed for the created particle.
  87772. * @param worldMatrix is the world matrix of the particle system
  87773. * @param positionToUpdate is the position vector to update with the result
  87774. * @param particle is the particle we are computed the position for
  87775. */
  87776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87777. /**
  87778. * Clones the current emitter and returns a copy of it
  87779. * @returns the new emitter
  87780. */
  87781. clone(): IParticleEmitterType;
  87782. /**
  87783. * Called by the GPUParticleSystem to setup the update shader
  87784. * @param effect defines the update shader
  87785. */
  87786. applyToShader(effect: Effect): void;
  87787. /**
  87788. * Returns a string to use to update the GPU particles update shader
  87789. * @returns the effect defines string
  87790. */
  87791. getEffectDefines(): string;
  87792. /**
  87793. * Returns a string representing the class name
  87794. * @returns a string containing the class name
  87795. */
  87796. getClassName(): string;
  87797. /**
  87798. * Serializes the particle system to a JSON object.
  87799. * @returns the JSON object
  87800. */
  87801. serialize(): any;
  87802. /**
  87803. * Parse properties from a JSON object
  87804. * @param serializationObject defines the JSON object
  87805. */
  87806. parse(serializationObject: any): void;
  87807. }
  87808. }
  87809. declare module BABYLON {
  87810. /**
  87811. * Particle emitter emitting particles from the inside of a box.
  87812. * It emits the particles randomly between 2 given directions.
  87813. */
  87814. export class BoxParticleEmitter implements IParticleEmitterType {
  87815. /**
  87816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87817. */
  87818. direction1: Vector3;
  87819. /**
  87820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87821. */
  87822. direction2: Vector3;
  87823. /**
  87824. * 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.
  87825. */
  87826. minEmitBox: Vector3;
  87827. /**
  87828. * 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.
  87829. */
  87830. maxEmitBox: Vector3;
  87831. /**
  87832. * Creates a new instance BoxParticleEmitter
  87833. */
  87834. constructor();
  87835. /**
  87836. * Called by the particle System when the direction is computed for the created particle.
  87837. * @param worldMatrix is the world matrix of the particle system
  87838. * @param directionToUpdate is the direction vector to update with the result
  87839. * @param particle is the particle we are computed the direction for
  87840. */
  87841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87842. /**
  87843. * Called by the particle System when the position is computed for the created particle.
  87844. * @param worldMatrix is the world matrix of the particle system
  87845. * @param positionToUpdate is the position vector to update with the result
  87846. * @param particle is the particle we are computed the position for
  87847. */
  87848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87849. /**
  87850. * Clones the current emitter and returns a copy of it
  87851. * @returns the new emitter
  87852. */
  87853. clone(): BoxParticleEmitter;
  87854. /**
  87855. * Called by the GPUParticleSystem to setup the update shader
  87856. * @param effect defines the update shader
  87857. */
  87858. applyToShader(effect: Effect): void;
  87859. /**
  87860. * Returns a string to use to update the GPU particles update shader
  87861. * @returns a string containng the defines string
  87862. */
  87863. getEffectDefines(): string;
  87864. /**
  87865. * Returns the string "BoxParticleEmitter"
  87866. * @returns a string containing the class name
  87867. */
  87868. getClassName(): string;
  87869. /**
  87870. * Serializes the particle system to a JSON object.
  87871. * @returns the JSON object
  87872. */
  87873. serialize(): any;
  87874. /**
  87875. * Parse properties from a JSON object
  87876. * @param serializationObject defines the JSON object
  87877. */
  87878. parse(serializationObject: any): void;
  87879. }
  87880. }
  87881. declare module BABYLON {
  87882. /**
  87883. * Particle emitter emitting particles from the inside of a cone.
  87884. * It emits the particles alongside the cone volume from the base to the particle.
  87885. * The emission direction might be randomized.
  87886. */
  87887. export class ConeParticleEmitter implements IParticleEmitterType {
  87888. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87889. directionRandomizer: number;
  87890. private _radius;
  87891. private _angle;
  87892. private _height;
  87893. /**
  87894. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  87895. */
  87896. radiusRange: number;
  87897. /**
  87898. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  87899. */
  87900. heightRange: number;
  87901. /**
  87902. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  87903. */
  87904. emitFromSpawnPointOnly: boolean;
  87905. /**
  87906. * Gets or sets the radius of the emission cone
  87907. */
  87908. radius: number;
  87909. /**
  87910. * Gets or sets the angle of the emission cone
  87911. */
  87912. angle: number;
  87913. private _buildHeight;
  87914. /**
  87915. * Creates a new instance ConeParticleEmitter
  87916. * @param radius the radius of the emission cone (1 by default)
  87917. * @param angle the cone base angle (PI by default)
  87918. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  87919. */
  87920. constructor(radius?: number, angle?: number,
  87921. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87922. directionRandomizer?: number);
  87923. /**
  87924. * Called by the particle System when the direction is computed for the created particle.
  87925. * @param worldMatrix is the world matrix of the particle system
  87926. * @param directionToUpdate is the direction vector to update with the result
  87927. * @param particle is the particle we are computed the direction for
  87928. */
  87929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87930. /**
  87931. * Called by the particle System when the position is computed for the created particle.
  87932. * @param worldMatrix is the world matrix of the particle system
  87933. * @param positionToUpdate is the position vector to update with the result
  87934. * @param particle is the particle we are computed the position for
  87935. */
  87936. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87937. /**
  87938. * Clones the current emitter and returns a copy of it
  87939. * @returns the new emitter
  87940. */
  87941. clone(): ConeParticleEmitter;
  87942. /**
  87943. * Called by the GPUParticleSystem to setup the update shader
  87944. * @param effect defines the update shader
  87945. */
  87946. applyToShader(effect: Effect): void;
  87947. /**
  87948. * Returns a string to use to update the GPU particles update shader
  87949. * @returns a string containng the defines string
  87950. */
  87951. getEffectDefines(): string;
  87952. /**
  87953. * Returns the string "ConeParticleEmitter"
  87954. * @returns a string containing the class name
  87955. */
  87956. getClassName(): string;
  87957. /**
  87958. * Serializes the particle system to a JSON object.
  87959. * @returns the JSON object
  87960. */
  87961. serialize(): any;
  87962. /**
  87963. * Parse properties from a JSON object
  87964. * @param serializationObject defines the JSON object
  87965. */
  87966. parse(serializationObject: any): void;
  87967. }
  87968. }
  87969. declare module BABYLON {
  87970. /**
  87971. * Particle emitter emitting particles from the inside of a cylinder.
  87972. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  87973. */
  87974. export class CylinderParticleEmitter implements IParticleEmitterType {
  87975. /**
  87976. * The radius of the emission cylinder.
  87977. */
  87978. radius: number;
  87979. /**
  87980. * The height of the emission cylinder.
  87981. */
  87982. height: number;
  87983. /**
  87984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87985. */
  87986. radiusRange: number;
  87987. /**
  87988. * How much to randomize the particle direction [0-1].
  87989. */
  87990. directionRandomizer: number;
  87991. /**
  87992. * Creates a new instance CylinderParticleEmitter
  87993. * @param radius the radius of the emission cylinder (1 by default)
  87994. * @param height the height of the emission cylinder (1 by default)
  87995. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87997. */
  87998. constructor(
  87999. /**
  88000. * The radius of the emission cylinder.
  88001. */
  88002. radius?: number,
  88003. /**
  88004. * The height of the emission cylinder.
  88005. */
  88006. height?: number,
  88007. /**
  88008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88009. */
  88010. radiusRange?: number,
  88011. /**
  88012. * How much to randomize the particle direction [0-1].
  88013. */
  88014. directionRandomizer?: number);
  88015. /**
  88016. * Called by the particle System when the direction is computed for the created particle.
  88017. * @param worldMatrix is the world matrix of the particle system
  88018. * @param directionToUpdate is the direction vector to update with the result
  88019. * @param particle is the particle we are computed the direction for
  88020. */
  88021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88022. /**
  88023. * Called by the particle System when the position is computed for the created particle.
  88024. * @param worldMatrix is the world matrix of the particle system
  88025. * @param positionToUpdate is the position vector to update with the result
  88026. * @param particle is the particle we are computed the position for
  88027. */
  88028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88029. /**
  88030. * Clones the current emitter and returns a copy of it
  88031. * @returns the new emitter
  88032. */
  88033. clone(): CylinderParticleEmitter;
  88034. /**
  88035. * Called by the GPUParticleSystem to setup the update shader
  88036. * @param effect defines the update shader
  88037. */
  88038. applyToShader(effect: Effect): void;
  88039. /**
  88040. * Returns a string to use to update the GPU particles update shader
  88041. * @returns a string containng the defines string
  88042. */
  88043. getEffectDefines(): string;
  88044. /**
  88045. * Returns the string "CylinderParticleEmitter"
  88046. * @returns a string containing the class name
  88047. */
  88048. getClassName(): string;
  88049. /**
  88050. * Serializes the particle system to a JSON object.
  88051. * @returns the JSON object
  88052. */
  88053. serialize(): any;
  88054. /**
  88055. * Parse properties from a JSON object
  88056. * @param serializationObject defines the JSON object
  88057. */
  88058. parse(serializationObject: any): void;
  88059. }
  88060. /**
  88061. * Particle emitter emitting particles from the inside of a cylinder.
  88062. * It emits the particles randomly between two vectors.
  88063. */
  88064. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88065. /**
  88066. * The min limit of the emission direction.
  88067. */
  88068. direction1: Vector3;
  88069. /**
  88070. * The max limit of the emission direction.
  88071. */
  88072. direction2: Vector3;
  88073. /**
  88074. * Creates a new instance CylinderDirectedParticleEmitter
  88075. * @param radius the radius of the emission cylinder (1 by default)
  88076. * @param height the height of the emission cylinder (1 by default)
  88077. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88078. * @param direction1 the min limit of the emission direction (up vector by default)
  88079. * @param direction2 the max limit of the emission direction (up vector by default)
  88080. */
  88081. constructor(radius?: number, height?: number, radiusRange?: number,
  88082. /**
  88083. * The min limit of the emission direction.
  88084. */
  88085. direction1?: Vector3,
  88086. /**
  88087. * The max limit of the emission direction.
  88088. */
  88089. direction2?: Vector3);
  88090. /**
  88091. * Called by the particle System when the direction is computed for the created particle.
  88092. * @param worldMatrix is the world matrix of the particle system
  88093. * @param directionToUpdate is the direction vector to update with the result
  88094. * @param particle is the particle we are computed the direction for
  88095. */
  88096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88097. /**
  88098. * Clones the current emitter and returns a copy of it
  88099. * @returns the new emitter
  88100. */
  88101. clone(): CylinderDirectedParticleEmitter;
  88102. /**
  88103. * Called by the GPUParticleSystem to setup the update shader
  88104. * @param effect defines the update shader
  88105. */
  88106. applyToShader(effect: Effect): void;
  88107. /**
  88108. * Returns a string to use to update the GPU particles update shader
  88109. * @returns a string containng the defines string
  88110. */
  88111. getEffectDefines(): string;
  88112. /**
  88113. * Returns the string "CylinderDirectedParticleEmitter"
  88114. * @returns a string containing the class name
  88115. */
  88116. getClassName(): string;
  88117. /**
  88118. * Serializes the particle system to a JSON object.
  88119. * @returns the JSON object
  88120. */
  88121. serialize(): any;
  88122. /**
  88123. * Parse properties from a JSON object
  88124. * @param serializationObject defines the JSON object
  88125. */
  88126. parse(serializationObject: any): void;
  88127. }
  88128. }
  88129. declare module BABYLON {
  88130. /**
  88131. * Particle emitter emitting particles from the inside of a hemisphere.
  88132. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88133. */
  88134. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88135. /**
  88136. * The radius of the emission hemisphere.
  88137. */
  88138. radius: number;
  88139. /**
  88140. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88141. */
  88142. radiusRange: number;
  88143. /**
  88144. * How much to randomize the particle direction [0-1].
  88145. */
  88146. directionRandomizer: number;
  88147. /**
  88148. * Creates a new instance HemisphericParticleEmitter
  88149. * @param radius the radius of the emission hemisphere (1 by default)
  88150. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88151. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88152. */
  88153. constructor(
  88154. /**
  88155. * The radius of the emission hemisphere.
  88156. */
  88157. radius?: number,
  88158. /**
  88159. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88160. */
  88161. radiusRange?: number,
  88162. /**
  88163. * How much to randomize the particle direction [0-1].
  88164. */
  88165. directionRandomizer?: number);
  88166. /**
  88167. * Called by the particle System when the direction is computed for the created particle.
  88168. * @param worldMatrix is the world matrix of the particle system
  88169. * @param directionToUpdate is the direction vector to update with the result
  88170. * @param particle is the particle we are computed the direction for
  88171. */
  88172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88173. /**
  88174. * Called by the particle System when the position is computed for the created particle.
  88175. * @param worldMatrix is the world matrix of the particle system
  88176. * @param positionToUpdate is the position vector to update with the result
  88177. * @param particle is the particle we are computed the position for
  88178. */
  88179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88180. /**
  88181. * Clones the current emitter and returns a copy of it
  88182. * @returns the new emitter
  88183. */
  88184. clone(): HemisphericParticleEmitter;
  88185. /**
  88186. * Called by the GPUParticleSystem to setup the update shader
  88187. * @param effect defines the update shader
  88188. */
  88189. applyToShader(effect: Effect): void;
  88190. /**
  88191. * Returns a string to use to update the GPU particles update shader
  88192. * @returns a string containng the defines string
  88193. */
  88194. getEffectDefines(): string;
  88195. /**
  88196. * Returns the string "HemisphericParticleEmitter"
  88197. * @returns a string containing the class name
  88198. */
  88199. getClassName(): string;
  88200. /**
  88201. * Serializes the particle system to a JSON object.
  88202. * @returns the JSON object
  88203. */
  88204. serialize(): any;
  88205. /**
  88206. * Parse properties from a JSON object
  88207. * @param serializationObject defines the JSON object
  88208. */
  88209. parse(serializationObject: any): void;
  88210. }
  88211. }
  88212. declare module BABYLON {
  88213. /**
  88214. * Particle emitter emitting particles from a point.
  88215. * It emits the particles randomly between 2 given directions.
  88216. */
  88217. export class PointParticleEmitter implements IParticleEmitterType {
  88218. /**
  88219. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88220. */
  88221. direction1: Vector3;
  88222. /**
  88223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88224. */
  88225. direction2: Vector3;
  88226. /**
  88227. * Creates a new instance PointParticleEmitter
  88228. */
  88229. constructor();
  88230. /**
  88231. * Called by the particle System when the direction is computed for the created particle.
  88232. * @param worldMatrix is the world matrix of the particle system
  88233. * @param directionToUpdate is the direction vector to update with the result
  88234. * @param particle is the particle we are computed the direction for
  88235. */
  88236. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88237. /**
  88238. * Called by the particle System when the position is computed for the created particle.
  88239. * @param worldMatrix is the world matrix of the particle system
  88240. * @param positionToUpdate is the position vector to update with the result
  88241. * @param particle is the particle we are computed the position for
  88242. */
  88243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88244. /**
  88245. * Clones the current emitter and returns a copy of it
  88246. * @returns the new emitter
  88247. */
  88248. clone(): PointParticleEmitter;
  88249. /**
  88250. * Called by the GPUParticleSystem to setup the update shader
  88251. * @param effect defines the update shader
  88252. */
  88253. applyToShader(effect: Effect): void;
  88254. /**
  88255. * Returns a string to use to update the GPU particles update shader
  88256. * @returns a string containng the defines string
  88257. */
  88258. getEffectDefines(): string;
  88259. /**
  88260. * Returns the string "PointParticleEmitter"
  88261. * @returns a string containing the class name
  88262. */
  88263. getClassName(): string;
  88264. /**
  88265. * Serializes the particle system to a JSON object.
  88266. * @returns the JSON object
  88267. */
  88268. serialize(): any;
  88269. /**
  88270. * Parse properties from a JSON object
  88271. * @param serializationObject defines the JSON object
  88272. */
  88273. parse(serializationObject: any): void;
  88274. }
  88275. }
  88276. declare module BABYLON {
  88277. /**
  88278. * Particle emitter emitting particles from the inside of a sphere.
  88279. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88280. */
  88281. export class SphereParticleEmitter implements IParticleEmitterType {
  88282. /**
  88283. * The radius of the emission sphere.
  88284. */
  88285. radius: number;
  88286. /**
  88287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88288. */
  88289. radiusRange: number;
  88290. /**
  88291. * How much to randomize the particle direction [0-1].
  88292. */
  88293. directionRandomizer: number;
  88294. /**
  88295. * Creates a new instance SphereParticleEmitter
  88296. * @param radius the radius of the emission sphere (1 by default)
  88297. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88298. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88299. */
  88300. constructor(
  88301. /**
  88302. * The radius of the emission sphere.
  88303. */
  88304. radius?: number,
  88305. /**
  88306. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88307. */
  88308. radiusRange?: number,
  88309. /**
  88310. * How much to randomize the particle direction [0-1].
  88311. */
  88312. directionRandomizer?: number);
  88313. /**
  88314. * Called by the particle System when the direction is computed for the created particle.
  88315. * @param worldMatrix is the world matrix of the particle system
  88316. * @param directionToUpdate is the direction vector to update with the result
  88317. * @param particle is the particle we are computed the direction for
  88318. */
  88319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88320. /**
  88321. * Called by the particle System when the position is computed for the created particle.
  88322. * @param worldMatrix is the world matrix of the particle system
  88323. * @param positionToUpdate is the position vector to update with the result
  88324. * @param particle is the particle we are computed the position for
  88325. */
  88326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88327. /**
  88328. * Clones the current emitter and returns a copy of it
  88329. * @returns the new emitter
  88330. */
  88331. clone(): SphereParticleEmitter;
  88332. /**
  88333. * Called by the GPUParticleSystem to setup the update shader
  88334. * @param effect defines the update shader
  88335. */
  88336. applyToShader(effect: Effect): void;
  88337. /**
  88338. * Returns a string to use to update the GPU particles update shader
  88339. * @returns a string containng the defines string
  88340. */
  88341. getEffectDefines(): string;
  88342. /**
  88343. * Returns the string "SphereParticleEmitter"
  88344. * @returns a string containing the class name
  88345. */
  88346. getClassName(): string;
  88347. /**
  88348. * Serializes the particle system to a JSON object.
  88349. * @returns the JSON object
  88350. */
  88351. serialize(): any;
  88352. /**
  88353. * Parse properties from a JSON object
  88354. * @param serializationObject defines the JSON object
  88355. */
  88356. parse(serializationObject: any): void;
  88357. }
  88358. /**
  88359. * Particle emitter emitting particles from the inside of a sphere.
  88360. * It emits the particles randomly between two vectors.
  88361. */
  88362. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88363. /**
  88364. * The min limit of the emission direction.
  88365. */
  88366. direction1: Vector3;
  88367. /**
  88368. * The max limit of the emission direction.
  88369. */
  88370. direction2: Vector3;
  88371. /**
  88372. * Creates a new instance SphereDirectedParticleEmitter
  88373. * @param radius the radius of the emission sphere (1 by default)
  88374. * @param direction1 the min limit of the emission direction (up vector by default)
  88375. * @param direction2 the max limit of the emission direction (up vector by default)
  88376. */
  88377. constructor(radius?: number,
  88378. /**
  88379. * The min limit of the emission direction.
  88380. */
  88381. direction1?: Vector3,
  88382. /**
  88383. * The max limit of the emission direction.
  88384. */
  88385. direction2?: Vector3);
  88386. /**
  88387. * Called by the particle System when the direction is computed for the created particle.
  88388. * @param worldMatrix is the world matrix of the particle system
  88389. * @param directionToUpdate is the direction vector to update with the result
  88390. * @param particle is the particle we are computed the direction for
  88391. */
  88392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88393. /**
  88394. * Clones the current emitter and returns a copy of it
  88395. * @returns the new emitter
  88396. */
  88397. clone(): SphereDirectedParticleEmitter;
  88398. /**
  88399. * Called by the GPUParticleSystem to setup the update shader
  88400. * @param effect defines the update shader
  88401. */
  88402. applyToShader(effect: Effect): void;
  88403. /**
  88404. * Returns a string to use to update the GPU particles update shader
  88405. * @returns a string containng the defines string
  88406. */
  88407. getEffectDefines(): string;
  88408. /**
  88409. * Returns the string "SphereDirectedParticleEmitter"
  88410. * @returns a string containing the class name
  88411. */
  88412. getClassName(): string;
  88413. /**
  88414. * Serializes the particle system to a JSON object.
  88415. * @returns the JSON object
  88416. */
  88417. serialize(): any;
  88418. /**
  88419. * Parse properties from a JSON object
  88420. * @param serializationObject defines the JSON object
  88421. */
  88422. parse(serializationObject: any): void;
  88423. }
  88424. }
  88425. declare module BABYLON {
  88426. /**
  88427. * Interface representing a particle system in Babylon.js.
  88428. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  88429. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  88430. */
  88431. export interface IParticleSystem {
  88432. /**
  88433. * List of animations used by the particle system.
  88434. */
  88435. animations: Animation[];
  88436. /**
  88437. * The id of the Particle system.
  88438. */
  88439. id: string;
  88440. /**
  88441. * The name of the Particle system.
  88442. */
  88443. name: string;
  88444. /**
  88445. * The emitter represents the Mesh or position we are attaching the particle system to.
  88446. */
  88447. emitter: Nullable<AbstractMesh | Vector3>;
  88448. /**
  88449. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88450. */
  88451. isBillboardBased: boolean;
  88452. /**
  88453. * The rendering group used by the Particle system to chose when to render.
  88454. */
  88455. renderingGroupId: number;
  88456. /**
  88457. * The layer mask we are rendering the particles through.
  88458. */
  88459. layerMask: number;
  88460. /**
  88461. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88462. */
  88463. updateSpeed: number;
  88464. /**
  88465. * The amount of time the particle system is running (depends of the overall update speed).
  88466. */
  88467. targetStopDuration: number;
  88468. /**
  88469. * The texture used to render each particle. (this can be a spritesheet)
  88470. */
  88471. particleTexture: Nullable<Texture>;
  88472. /**
  88473. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  88474. */
  88475. blendMode: number;
  88476. /**
  88477. * Minimum life time of emitting particles.
  88478. */
  88479. minLifeTime: number;
  88480. /**
  88481. * Maximum life time of emitting particles.
  88482. */
  88483. maxLifeTime: number;
  88484. /**
  88485. * Minimum Size of emitting particles.
  88486. */
  88487. minSize: number;
  88488. /**
  88489. * Maximum Size of emitting particles.
  88490. */
  88491. maxSize: number;
  88492. /**
  88493. * Minimum scale of emitting particles on X axis.
  88494. */
  88495. minScaleX: number;
  88496. /**
  88497. * Maximum scale of emitting particles on X axis.
  88498. */
  88499. maxScaleX: number;
  88500. /**
  88501. * Minimum scale of emitting particles on Y axis.
  88502. */
  88503. minScaleY: number;
  88504. /**
  88505. * Maximum scale of emitting particles on Y axis.
  88506. */
  88507. maxScaleY: number;
  88508. /**
  88509. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88510. */
  88511. color1: Color4;
  88512. /**
  88513. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88514. */
  88515. color2: Color4;
  88516. /**
  88517. * Color the particle will have at the end of its lifetime.
  88518. */
  88519. colorDead: Color4;
  88520. /**
  88521. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  88522. */
  88523. emitRate: number;
  88524. /**
  88525. * You can use gravity if you want to give an orientation to your particles.
  88526. */
  88527. gravity: Vector3;
  88528. /**
  88529. * Minimum power of emitting particles.
  88530. */
  88531. minEmitPower: number;
  88532. /**
  88533. * Maximum power of emitting particles.
  88534. */
  88535. maxEmitPower: number;
  88536. /**
  88537. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88538. */
  88539. minAngularSpeed: number;
  88540. /**
  88541. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88542. */
  88543. maxAngularSpeed: number;
  88544. /**
  88545. * Gets or sets the minimal initial rotation in radians.
  88546. */
  88547. minInitialRotation: number;
  88548. /**
  88549. * Gets or sets the maximal initial rotation in radians.
  88550. */
  88551. maxInitialRotation: number;
  88552. /**
  88553. * The particle emitter type defines the emitter used by the particle system.
  88554. * It can be for example box, sphere, or cone...
  88555. */
  88556. particleEmitterType: Nullable<IParticleEmitterType>;
  88557. /**
  88558. * Defines the delay in milliseconds before starting the system (0 by default)
  88559. */
  88560. startDelay: number;
  88561. /**
  88562. * 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
  88563. */
  88564. preWarmCycles: number;
  88565. /**
  88566. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  88567. */
  88568. preWarmStepOffset: number;
  88569. /**
  88570. * 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)
  88571. */
  88572. spriteCellChangeSpeed: number;
  88573. /**
  88574. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88575. */
  88576. startSpriteCellID: number;
  88577. /**
  88578. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88579. */
  88580. endSpriteCellID: number;
  88581. /**
  88582. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88583. */
  88584. spriteCellWidth: number;
  88585. /**
  88586. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88587. */
  88588. spriteCellHeight: number;
  88589. /**
  88590. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88591. */
  88592. spriteRandomStartCell: boolean;
  88593. /**
  88594. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  88595. */
  88596. isAnimationSheetEnabled: boolean;
  88597. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88598. translationPivot: Vector2;
  88599. /**
  88600. * Gets or sets a texture used to add random noise to particle positions
  88601. */
  88602. noiseTexture: Nullable<BaseTexture>;
  88603. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88604. noiseStrength: Vector3;
  88605. /**
  88606. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88607. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88608. */
  88609. billboardMode: number;
  88610. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88611. limitVelocityDamping: number;
  88612. /**
  88613. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88614. */
  88615. beginAnimationOnStart: boolean;
  88616. /**
  88617. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88618. */
  88619. beginAnimationFrom: number;
  88620. /**
  88621. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88622. */
  88623. beginAnimationTo: number;
  88624. /**
  88625. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88626. */
  88627. beginAnimationLoop: boolean;
  88628. /**
  88629. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88630. */
  88631. disposeOnStop: boolean;
  88632. /**
  88633. * Gets the maximum number of particles active at the same time.
  88634. * @returns The max number of active particles.
  88635. */
  88636. getCapacity(): number;
  88637. /**
  88638. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88639. * @returns True if it has been started, otherwise false.
  88640. */
  88641. isStarted(): boolean;
  88642. /**
  88643. * Animates the particle system for this frame.
  88644. */
  88645. animate(): void;
  88646. /**
  88647. * Renders the particle system in its current state.
  88648. * @returns the current number of particles
  88649. */
  88650. render(): number;
  88651. /**
  88652. * Dispose the particle system and frees its associated resources.
  88653. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88654. */
  88655. dispose(disposeTexture?: boolean): void;
  88656. /**
  88657. * Clones the particle system.
  88658. * @param name The name of the cloned object
  88659. * @param newEmitter The new emitter to use
  88660. * @returns the cloned particle system
  88661. */
  88662. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  88663. /**
  88664. * Serializes the particle system to a JSON object.
  88665. * @returns the JSON object
  88666. */
  88667. serialize(): any;
  88668. /**
  88669. * Rebuild the particle system
  88670. */
  88671. rebuild(): void;
  88672. /**
  88673. * Starts the particle system and begins to emit
  88674. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  88675. */
  88676. start(delay?: number): void;
  88677. /**
  88678. * Stops the particle system.
  88679. */
  88680. stop(): void;
  88681. /**
  88682. * Remove all active particles
  88683. */
  88684. reset(): void;
  88685. /**
  88686. * Is this system ready to be used/rendered
  88687. * @return true if the system is ready
  88688. */
  88689. isReady(): boolean;
  88690. /**
  88691. * Adds a new color gradient
  88692. * @param gradient defines the gradient to use (between 0 and 1)
  88693. * @param color1 defines the color to affect to the specified gradient
  88694. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88695. * @returns the current particle system
  88696. */
  88697. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88698. /**
  88699. * Remove a specific color gradient
  88700. * @param gradient defines the gradient to remove
  88701. * @returns the current particle system
  88702. */
  88703. removeColorGradient(gradient: number): IParticleSystem;
  88704. /**
  88705. * Adds a new size gradient
  88706. * @param gradient defines the gradient to use (between 0 and 1)
  88707. * @param factor defines the size factor to affect to the specified gradient
  88708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88709. * @returns the current particle system
  88710. */
  88711. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88712. /**
  88713. * Remove a specific size gradient
  88714. * @param gradient defines the gradient to remove
  88715. * @returns the current particle system
  88716. */
  88717. removeSizeGradient(gradient: number): IParticleSystem;
  88718. /**
  88719. * Gets the current list of color gradients.
  88720. * You must use addColorGradient and removeColorGradient to udpate this list
  88721. * @returns the list of color gradients
  88722. */
  88723. getColorGradients(): Nullable<Array<ColorGradient>>;
  88724. /**
  88725. * Gets the current list of size gradients.
  88726. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88727. * @returns the list of size gradients
  88728. */
  88729. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88730. /**
  88731. * Gets the current list of angular speed gradients.
  88732. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88733. * @returns the list of angular speed gradients
  88734. */
  88735. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88736. /**
  88737. * Adds a new angular speed gradient
  88738. * @param gradient defines the gradient to use (between 0 and 1)
  88739. * @param factor defines the angular speed to affect to the specified gradient
  88740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88741. * @returns the current particle system
  88742. */
  88743. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88744. /**
  88745. * Remove a specific angular speed gradient
  88746. * @param gradient defines the gradient to remove
  88747. * @returns the current particle system
  88748. */
  88749. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88750. /**
  88751. * Gets the current list of velocity gradients.
  88752. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88753. * @returns the list of velocity gradients
  88754. */
  88755. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88756. /**
  88757. * Adds a new velocity gradient
  88758. * @param gradient defines the gradient to use (between 0 and 1)
  88759. * @param factor defines the velocity to affect to the specified gradient
  88760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88761. * @returns the current particle system
  88762. */
  88763. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88764. /**
  88765. * Remove a specific velocity gradient
  88766. * @param gradient defines the gradient to remove
  88767. * @returns the current particle system
  88768. */
  88769. removeVelocityGradient(gradient: number): IParticleSystem;
  88770. /**
  88771. * Gets the current list of limit velocity gradients.
  88772. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88773. * @returns the list of limit velocity gradients
  88774. */
  88775. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88776. /**
  88777. * Adds a new limit velocity gradient
  88778. * @param gradient defines the gradient to use (between 0 and 1)
  88779. * @param factor defines the limit velocity to affect to the specified gradient
  88780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88781. * @returns the current particle system
  88782. */
  88783. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88784. /**
  88785. * Remove a specific limit velocity gradient
  88786. * @param gradient defines the gradient to remove
  88787. * @returns the current particle system
  88788. */
  88789. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88790. /**
  88791. * Adds a new drag gradient
  88792. * @param gradient defines the gradient to use (between 0 and 1)
  88793. * @param factor defines the drag to affect to the specified gradient
  88794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88795. * @returns the current particle system
  88796. */
  88797. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88798. /**
  88799. * Remove a specific drag gradient
  88800. * @param gradient defines the gradient to remove
  88801. * @returns the current particle system
  88802. */
  88803. removeDragGradient(gradient: number): IParticleSystem;
  88804. /**
  88805. * Gets the current list of drag gradients.
  88806. * You must use addDragGradient and removeDragGradient to udpate this list
  88807. * @returns the list of drag gradients
  88808. */
  88809. getDragGradients(): Nullable<Array<FactorGradient>>;
  88810. /**
  88811. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88812. * @param gradient defines the gradient to use (between 0 and 1)
  88813. * @param factor defines the emit rate to affect to the specified gradient
  88814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88815. * @returns the current particle system
  88816. */
  88817. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88818. /**
  88819. * Remove a specific emit rate gradient
  88820. * @param gradient defines the gradient to remove
  88821. * @returns the current particle system
  88822. */
  88823. removeEmitRateGradient(gradient: number): IParticleSystem;
  88824. /**
  88825. * Gets the current list of emit rate gradients.
  88826. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88827. * @returns the list of emit rate gradients
  88828. */
  88829. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88830. /**
  88831. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88832. * @param gradient defines the gradient to use (between 0 and 1)
  88833. * @param factor defines the start size to affect to the specified gradient
  88834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88835. * @returns the current particle system
  88836. */
  88837. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88838. /**
  88839. * Remove a specific start size gradient
  88840. * @param gradient defines the gradient to remove
  88841. * @returns the current particle system
  88842. */
  88843. removeStartSizeGradient(gradient: number): IParticleSystem;
  88844. /**
  88845. * Gets the current list of start size gradients.
  88846. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88847. * @returns the list of start size gradients
  88848. */
  88849. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88850. /**
  88851. * Adds a new life time gradient
  88852. * @param gradient defines the gradient to use (between 0 and 1)
  88853. * @param factor defines the life time factor to affect to the specified gradient
  88854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88855. * @returns the current particle system
  88856. */
  88857. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88858. /**
  88859. * Remove a specific life time gradient
  88860. * @param gradient defines the gradient to remove
  88861. * @returns the current particle system
  88862. */
  88863. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88864. /**
  88865. * Gets the current list of life time gradients.
  88866. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88867. * @returns the list of life time gradients
  88868. */
  88869. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88870. /**
  88871. * Gets the current list of color gradients.
  88872. * You must use addColorGradient and removeColorGradient to udpate this list
  88873. * @returns the list of color gradients
  88874. */
  88875. getColorGradients(): Nullable<Array<ColorGradient>>;
  88876. /**
  88877. * Adds a new ramp gradient used to remap particle colors
  88878. * @param gradient defines the gradient to use (between 0 and 1)
  88879. * @param color defines the color to affect to the specified gradient
  88880. * @returns the current particle system
  88881. */
  88882. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88883. /**
  88884. * Gets the current list of ramp gradients.
  88885. * You must use addRampGradient and removeRampGradient to udpate this list
  88886. * @returns the list of ramp gradients
  88887. */
  88888. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88889. /** Gets or sets a boolean indicating that ramp gradients must be used
  88890. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88891. */
  88892. useRampGradients: boolean;
  88893. /**
  88894. * Adds a new color remap gradient
  88895. * @param gradient defines the gradient to use (between 0 and 1)
  88896. * @param min defines the color remap minimal range
  88897. * @param max defines the color remap maximal range
  88898. * @returns the current particle system
  88899. */
  88900. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88901. /**
  88902. * Gets the current list of color remap gradients.
  88903. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88904. * @returns the list of color remap gradients
  88905. */
  88906. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88907. /**
  88908. * Adds a new alpha remap gradient
  88909. * @param gradient defines the gradient to use (between 0 and 1)
  88910. * @param min defines the alpha remap minimal range
  88911. * @param max defines the alpha remap maximal range
  88912. * @returns the current particle system
  88913. */
  88914. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88915. /**
  88916. * Gets the current list of alpha remap gradients.
  88917. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88918. * @returns the list of alpha remap gradients
  88919. */
  88920. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88921. /**
  88922. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88925. * @returns the emitter
  88926. */
  88927. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88928. /**
  88929. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88930. * @param radius The radius of the hemisphere to emit from
  88931. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88932. * @returns the emitter
  88933. */
  88934. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  88935. /**
  88936. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88937. * @param radius The radius of the sphere to emit from
  88938. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88939. * @returns the emitter
  88940. */
  88941. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  88942. /**
  88943. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88944. * @param radius The radius of the sphere to emit from
  88945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88947. * @returns the emitter
  88948. */
  88949. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88950. /**
  88951. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88952. * @param radius The radius of the emission cylinder
  88953. * @param height The height of the emission cylinder
  88954. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88955. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88956. * @returns the emitter
  88957. */
  88958. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  88959. /**
  88960. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88961. * @param radius The radius of the cylinder to emit from
  88962. * @param height The height of the emission cylinder
  88963. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88966. * @returns the emitter
  88967. */
  88968. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88969. /**
  88970. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88971. * @param radius The radius of the cone to emit from
  88972. * @param angle The base angle of the cone
  88973. * @returns the emitter
  88974. */
  88975. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  88976. /**
  88977. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88980. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88981. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88982. * @returns the emitter
  88983. */
  88984. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88985. /**
  88986. * Get hosting scene
  88987. * @returns the scene
  88988. */
  88989. getScene(): Scene;
  88990. }
  88991. }
  88992. declare module BABYLON {
  88993. /**
  88994. * Creates an instance based on a source mesh.
  88995. */
  88996. export class InstancedMesh extends AbstractMesh {
  88997. private _sourceMesh;
  88998. private _currentLOD;
  88999. /** @hidden */
  89000. _indexInSourceMeshInstanceArray: number;
  89001. constructor(name: string, source: Mesh);
  89002. /**
  89003. * Returns the string "InstancedMesh".
  89004. */
  89005. getClassName(): string;
  89006. /** Gets the list of lights affecting that mesh */
  89007. readonly lightSources: Light[];
  89008. _resyncLightSources(): void;
  89009. _resyncLightSource(light: Light): void;
  89010. _removeLightSource(light: Light, dispose: boolean): void;
  89011. /**
  89012. * If the source mesh receives shadows
  89013. */
  89014. readonly receiveShadows: boolean;
  89015. /**
  89016. * The material of the source mesh
  89017. */
  89018. readonly material: Nullable<Material>;
  89019. /**
  89020. * Visibility of the source mesh
  89021. */
  89022. readonly visibility: number;
  89023. /**
  89024. * Skeleton of the source mesh
  89025. */
  89026. readonly skeleton: Nullable<Skeleton>;
  89027. /**
  89028. * Rendering ground id of the source mesh
  89029. */
  89030. renderingGroupId: number;
  89031. /**
  89032. * Returns the total number of vertices (integer).
  89033. */
  89034. getTotalVertices(): number;
  89035. /**
  89036. * Returns a positive integer : the total number of indices in this mesh geometry.
  89037. * @returns the numner of indices or zero if the mesh has no geometry.
  89038. */
  89039. getTotalIndices(): number;
  89040. /**
  89041. * The source mesh of the instance
  89042. */
  89043. readonly sourceMesh: Mesh;
  89044. /**
  89045. * Is this node ready to be used/rendered
  89046. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89047. * @return {boolean} is it ready
  89048. */
  89049. isReady(completeCheck?: boolean): boolean;
  89050. /**
  89051. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89052. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89053. * @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.
  89054. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89055. */
  89056. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89057. /**
  89058. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89059. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89060. * The `data` are either a numeric array either a Float32Array.
  89061. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89062. * 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).
  89063. * Note that a new underlying VertexBuffer object is created each call.
  89064. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89065. *
  89066. * Possible `kind` values :
  89067. * - VertexBuffer.PositionKind
  89068. * - VertexBuffer.UVKind
  89069. * - VertexBuffer.UV2Kind
  89070. * - VertexBuffer.UV3Kind
  89071. * - VertexBuffer.UV4Kind
  89072. * - VertexBuffer.UV5Kind
  89073. * - VertexBuffer.UV6Kind
  89074. * - VertexBuffer.ColorKind
  89075. * - VertexBuffer.MatricesIndicesKind
  89076. * - VertexBuffer.MatricesIndicesExtraKind
  89077. * - VertexBuffer.MatricesWeightsKind
  89078. * - VertexBuffer.MatricesWeightsExtraKind
  89079. *
  89080. * Returns the Mesh.
  89081. */
  89082. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89083. /**
  89084. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89085. * If the mesh has no geometry, it is simply returned as it is.
  89086. * The `data` are either a numeric array either a Float32Array.
  89087. * No new underlying VertexBuffer object is created.
  89088. * 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.
  89089. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89090. *
  89091. * Possible `kind` values :
  89092. * - VertexBuffer.PositionKind
  89093. * - VertexBuffer.UVKind
  89094. * - VertexBuffer.UV2Kind
  89095. * - VertexBuffer.UV3Kind
  89096. * - VertexBuffer.UV4Kind
  89097. * - VertexBuffer.UV5Kind
  89098. * - VertexBuffer.UV6Kind
  89099. * - VertexBuffer.ColorKind
  89100. * - VertexBuffer.MatricesIndicesKind
  89101. * - VertexBuffer.MatricesIndicesExtraKind
  89102. * - VertexBuffer.MatricesWeightsKind
  89103. * - VertexBuffer.MatricesWeightsExtraKind
  89104. *
  89105. * Returns the Mesh.
  89106. */
  89107. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89108. /**
  89109. * Sets the mesh indices.
  89110. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89111. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89112. * This method creates a new index buffer each call.
  89113. * Returns the Mesh.
  89114. */
  89115. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89116. /**
  89117. * Boolean : True if the mesh owns the requested kind of data.
  89118. */
  89119. isVerticesDataPresent(kind: string): boolean;
  89120. /**
  89121. * Returns an array of indices (IndicesArray).
  89122. */
  89123. getIndices(): Nullable<IndicesArray>;
  89124. readonly _positions: Nullable<Vector3[]>;
  89125. /**
  89126. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89127. * This means the mesh underlying bounding box and sphere are recomputed.
  89128. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89129. * @returns the current mesh
  89130. */
  89131. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89132. /** @hidden */
  89133. _preActivate(): InstancedMesh;
  89134. /** @hidden */
  89135. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89136. /** @hidden */
  89137. _postActivate(): void;
  89138. getWorldMatrix(): Matrix;
  89139. readonly isAnInstance: boolean;
  89140. /**
  89141. * Returns the current associated LOD AbstractMesh.
  89142. */
  89143. getLOD(camera: Camera): AbstractMesh;
  89144. /** @hidden */
  89145. _syncSubMeshes(): InstancedMesh;
  89146. /** @hidden */
  89147. _generatePointsArray(): boolean;
  89148. /**
  89149. * Creates a new InstancedMesh from the current mesh.
  89150. * - name (string) : the cloned mesh name
  89151. * - newParent (optional Node) : the optional Node to parent the clone to.
  89152. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89153. *
  89154. * Returns the clone.
  89155. */
  89156. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89157. /**
  89158. * Disposes the InstancedMesh.
  89159. * Returns nothing.
  89160. */
  89161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89162. }
  89163. interface Mesh {
  89164. /**
  89165. * Register a custom buffer that will be instanced
  89166. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89167. * @param kind defines the buffer kind
  89168. * @param stride defines the stride in floats
  89169. */
  89170. registerInstancedBuffer(kind: string, stride: number): void;
  89171. /** @hidden */
  89172. _userInstancedBuffersStorage: {
  89173. data: {
  89174. [key: string]: Float32Array;
  89175. };
  89176. sizes: {
  89177. [key: string]: number;
  89178. };
  89179. vertexBuffers: {
  89180. [key: string]: Nullable<VertexBuffer>;
  89181. };
  89182. strides: {
  89183. [key: string]: number;
  89184. };
  89185. };
  89186. }
  89187. interface AbstractMesh {
  89188. /**
  89189. * Object used to store instanced buffers defined by user
  89190. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89191. */
  89192. instancedBuffers: {
  89193. [key: string]: any;
  89194. };
  89195. }
  89196. }
  89197. declare module BABYLON {
  89198. /**
  89199. * Defines the options associated with the creation of a shader material.
  89200. */
  89201. export interface IShaderMaterialOptions {
  89202. /**
  89203. * Does the material work in alpha blend mode
  89204. */
  89205. needAlphaBlending: boolean;
  89206. /**
  89207. * Does the material work in alpha test mode
  89208. */
  89209. needAlphaTesting: boolean;
  89210. /**
  89211. * The list of attribute names used in the shader
  89212. */
  89213. attributes: string[];
  89214. /**
  89215. * The list of unifrom names used in the shader
  89216. */
  89217. uniforms: string[];
  89218. /**
  89219. * The list of UBO names used in the shader
  89220. */
  89221. uniformBuffers: string[];
  89222. /**
  89223. * The list of sampler names used in the shader
  89224. */
  89225. samplers: string[];
  89226. /**
  89227. * The list of defines used in the shader
  89228. */
  89229. defines: string[];
  89230. }
  89231. /**
  89232. * 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.
  89233. *
  89234. * This returned material effects how the mesh will look based on the code in the shaders.
  89235. *
  89236. * @see http://doc.babylonjs.com/how_to/shader_material
  89237. */
  89238. export class ShaderMaterial extends Material {
  89239. private _shaderPath;
  89240. private _options;
  89241. private _textures;
  89242. private _textureArrays;
  89243. private _floats;
  89244. private _ints;
  89245. private _floatsArrays;
  89246. private _colors3;
  89247. private _colors3Arrays;
  89248. private _colors4;
  89249. private _colors4Arrays;
  89250. private _vectors2;
  89251. private _vectors3;
  89252. private _vectors4;
  89253. private _matrices;
  89254. private _matrixArrays;
  89255. private _matrices3x3;
  89256. private _matrices2x2;
  89257. private _vectors2Arrays;
  89258. private _vectors3Arrays;
  89259. private _vectors4Arrays;
  89260. private _cachedWorldViewMatrix;
  89261. private _cachedWorldViewProjectionMatrix;
  89262. private _renderId;
  89263. private _multiview;
  89264. /**
  89265. * Instantiate a new shader material.
  89266. * 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.
  89267. * This returned material effects how the mesh will look based on the code in the shaders.
  89268. * @see http://doc.babylonjs.com/how_to/shader_material
  89269. * @param name Define the name of the material in the scene
  89270. * @param scene Define the scene the material belongs to
  89271. * @param shaderPath Defines the route to the shader code in one of three ways:
  89272. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89273. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89274. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89275. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89276. * @param options Define the options used to create the shader
  89277. */
  89278. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89279. /**
  89280. * Gets the shader path used to define the shader code
  89281. * It can be modified to trigger a new compilation
  89282. */
  89283. /**
  89284. * Sets the shader path used to define the shader code
  89285. * It can be modified to trigger a new compilation
  89286. */
  89287. shaderPath: any;
  89288. /**
  89289. * Gets the options used to compile the shader.
  89290. * They can be modified to trigger a new compilation
  89291. */
  89292. readonly options: IShaderMaterialOptions;
  89293. /**
  89294. * Gets the current class name of the material e.g. "ShaderMaterial"
  89295. * Mainly use in serialization.
  89296. * @returns the class name
  89297. */
  89298. getClassName(): string;
  89299. /**
  89300. * Specifies if the material will require alpha blending
  89301. * @returns a boolean specifying if alpha blending is needed
  89302. */
  89303. needAlphaBlending(): boolean;
  89304. /**
  89305. * Specifies if this material should be rendered in alpha test mode
  89306. * @returns a boolean specifying if an alpha test is needed.
  89307. */
  89308. needAlphaTesting(): boolean;
  89309. private _checkUniform;
  89310. /**
  89311. * Set a texture in the shader.
  89312. * @param name Define the name of the uniform samplers as defined in the shader
  89313. * @param texture Define the texture to bind to this sampler
  89314. * @return the material itself allowing "fluent" like uniform updates
  89315. */
  89316. setTexture(name: string, texture: Texture): ShaderMaterial;
  89317. /**
  89318. * Set a texture array in the shader.
  89319. * @param name Define the name of the uniform sampler array as defined in the shader
  89320. * @param textures Define the list of textures to bind to this sampler
  89321. * @return the material itself allowing "fluent" like uniform updates
  89322. */
  89323. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  89324. /**
  89325. * Set a float in the shader.
  89326. * @param name Define the name of the uniform as defined in the shader
  89327. * @param value Define the value to give to the uniform
  89328. * @return the material itself allowing "fluent" like uniform updates
  89329. */
  89330. setFloat(name: string, value: number): ShaderMaterial;
  89331. /**
  89332. * Set a int in the shader.
  89333. * @param name Define the name of the uniform as defined in the shader
  89334. * @param value Define the value to give to the uniform
  89335. * @return the material itself allowing "fluent" like uniform updates
  89336. */
  89337. setInt(name: string, value: number): ShaderMaterial;
  89338. /**
  89339. * Set an array of floats in the shader.
  89340. * @param name Define the name of the uniform as defined in the shader
  89341. * @param value Define the value to give to the uniform
  89342. * @return the material itself allowing "fluent" like uniform updates
  89343. */
  89344. setFloats(name: string, value: number[]): ShaderMaterial;
  89345. /**
  89346. * Set a vec3 in the shader from a Color3.
  89347. * @param name Define the name of the uniform as defined in the shader
  89348. * @param value Define the value to give to the uniform
  89349. * @return the material itself allowing "fluent" like uniform updates
  89350. */
  89351. setColor3(name: string, value: Color3): ShaderMaterial;
  89352. /**
  89353. * Set a vec3 array in the shader from a Color3 array.
  89354. * @param name Define the name of the uniform as defined in the shader
  89355. * @param value Define the value to give to the uniform
  89356. * @return the material itself allowing "fluent" like uniform updates
  89357. */
  89358. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89359. /**
  89360. * Set a vec4 in the shader from a Color4.
  89361. * @param name Define the name of the uniform as defined in the shader
  89362. * @param value Define the value to give to the uniform
  89363. * @return the material itself allowing "fluent" like uniform updates
  89364. */
  89365. setColor4(name: string, value: Color4): ShaderMaterial;
  89366. /**
  89367. * Set a vec4 array in the shader from a Color4 array.
  89368. * @param name Define the name of the uniform as defined in the shader
  89369. * @param value Define the value to give to the uniform
  89370. * @return the material itself allowing "fluent" like uniform updates
  89371. */
  89372. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89373. /**
  89374. * Set a vec2 in the shader from a Vector2.
  89375. * @param name Define the name of the uniform as defined in the shader
  89376. * @param value Define the value to give to the uniform
  89377. * @return the material itself allowing "fluent" like uniform updates
  89378. */
  89379. setVector2(name: string, value: Vector2): ShaderMaterial;
  89380. /**
  89381. * Set a vec3 in the shader from a Vector3.
  89382. * @param name Define the name of the uniform as defined in the shader
  89383. * @param value Define the value to give to the uniform
  89384. * @return the material itself allowing "fluent" like uniform updates
  89385. */
  89386. setVector3(name: string, value: Vector3): ShaderMaterial;
  89387. /**
  89388. * Set a vec4 in the shader from a Vector4.
  89389. * @param name Define the name of the uniform as defined in the shader
  89390. * @param value Define the value to give to the uniform
  89391. * @return the material itself allowing "fluent" like uniform updates
  89392. */
  89393. setVector4(name: string, value: Vector4): ShaderMaterial;
  89394. /**
  89395. * Set a mat4 in the shader from a Matrix.
  89396. * @param name Define the name of the uniform as defined in the shader
  89397. * @param value Define the value to give to the uniform
  89398. * @return the material itself allowing "fluent" like uniform updates
  89399. */
  89400. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89401. /**
  89402. * Set a float32Array in the shader from a matrix array.
  89403. * @param name Define the name of the uniform as defined in the shader
  89404. * @param value Define the value to give to the uniform
  89405. * @return the material itself allowing "fluent" like uniform updates
  89406. */
  89407. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89408. /**
  89409. * Set a mat3 in the shader from a Float32Array.
  89410. * @param name Define the name of the uniform as defined in the shader
  89411. * @param value Define the value to give to the uniform
  89412. * @return the material itself allowing "fluent" like uniform updates
  89413. */
  89414. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89415. /**
  89416. * Set a mat2 in the shader from a Float32Array.
  89417. * @param name Define the name of the uniform as defined in the shader
  89418. * @param value Define the value to give to the uniform
  89419. * @return the material itself allowing "fluent" like uniform updates
  89420. */
  89421. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89422. /**
  89423. * Set a vec2 array in the shader from a number array.
  89424. * @param name Define the name of the uniform as defined in the shader
  89425. * @param value Define the value to give to the uniform
  89426. * @return the material itself allowing "fluent" like uniform updates
  89427. */
  89428. setArray2(name: string, value: number[]): ShaderMaterial;
  89429. /**
  89430. * Set a vec3 array in the shader from a number array.
  89431. * @param name Define the name of the uniform as defined in the shader
  89432. * @param value Define the value to give to the uniform
  89433. * @return the material itself allowing "fluent" like uniform updates
  89434. */
  89435. setArray3(name: string, value: number[]): ShaderMaterial;
  89436. /**
  89437. * Set a vec4 array in the shader from a number array.
  89438. * @param name Define the name of the uniform as defined in the shader
  89439. * @param value Define the value to give to the uniform
  89440. * @return the material itself allowing "fluent" like uniform updates
  89441. */
  89442. setArray4(name: string, value: number[]): ShaderMaterial;
  89443. private _checkCache;
  89444. /**
  89445. * Specifies that the submesh is ready to be used
  89446. * @param mesh defines the mesh to check
  89447. * @param subMesh defines which submesh to check
  89448. * @param useInstances specifies that instances should be used
  89449. * @returns a boolean indicating that the submesh is ready or not
  89450. */
  89451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89452. /**
  89453. * Checks if the material is ready to render the requested mesh
  89454. * @param mesh Define the mesh to render
  89455. * @param useInstances Define whether or not the material is used with instances
  89456. * @returns true if ready, otherwise false
  89457. */
  89458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89459. /**
  89460. * Binds the world matrix to the material
  89461. * @param world defines the world transformation matrix
  89462. */
  89463. bindOnlyWorldMatrix(world: Matrix): void;
  89464. /**
  89465. * Binds the material to the mesh
  89466. * @param world defines the world transformation matrix
  89467. * @param mesh defines the mesh to bind the material to
  89468. */
  89469. bind(world: Matrix, mesh?: Mesh): void;
  89470. /**
  89471. * Gets the active textures from the material
  89472. * @returns an array of textures
  89473. */
  89474. getActiveTextures(): BaseTexture[];
  89475. /**
  89476. * Specifies if the material uses a texture
  89477. * @param texture defines the texture to check against the material
  89478. * @returns a boolean specifying if the material uses the texture
  89479. */
  89480. hasTexture(texture: BaseTexture): boolean;
  89481. /**
  89482. * Makes a duplicate of the material, and gives it a new name
  89483. * @param name defines the new name for the duplicated material
  89484. * @returns the cloned material
  89485. */
  89486. clone(name: string): ShaderMaterial;
  89487. /**
  89488. * Disposes the material
  89489. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89490. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89491. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89492. */
  89493. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89494. /**
  89495. * Serializes this material in a JSON representation
  89496. * @returns the serialized material object
  89497. */
  89498. serialize(): any;
  89499. /**
  89500. * Creates a shader material from parsed shader material data
  89501. * @param source defines the JSON represnetation of the material
  89502. * @param scene defines the hosting scene
  89503. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89504. * @returns a new material
  89505. */
  89506. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89507. }
  89508. }
  89509. declare module BABYLON {
  89510. /** @hidden */
  89511. export var colorPixelShader: {
  89512. name: string;
  89513. shader: string;
  89514. };
  89515. }
  89516. declare module BABYLON {
  89517. /** @hidden */
  89518. export var colorVertexShader: {
  89519. name: string;
  89520. shader: string;
  89521. };
  89522. }
  89523. declare module BABYLON {
  89524. /**
  89525. * Line mesh
  89526. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89527. */
  89528. export class LinesMesh extends Mesh {
  89529. /**
  89530. * If vertex color should be applied to the mesh
  89531. */
  89532. readonly useVertexColor?: boolean | undefined;
  89533. /**
  89534. * If vertex alpha should be applied to the mesh
  89535. */
  89536. readonly useVertexAlpha?: boolean | undefined;
  89537. /**
  89538. * Color of the line (Default: White)
  89539. */
  89540. color: Color3;
  89541. /**
  89542. * Alpha of the line (Default: 1)
  89543. */
  89544. alpha: number;
  89545. /**
  89546. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89547. * This margin is expressed in world space coordinates, so its value may vary.
  89548. * Default value is 0.1
  89549. */
  89550. intersectionThreshold: number;
  89551. private _colorShader;
  89552. private color4;
  89553. /**
  89554. * Creates a new LinesMesh
  89555. * @param name defines the name
  89556. * @param scene defines the hosting scene
  89557. * @param parent defines the parent mesh if any
  89558. * @param source defines the optional source LinesMesh used to clone data from
  89559. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89560. * When false, achieved by calling a clone(), also passing False.
  89561. * This will make creation of children, recursive.
  89562. * @param useVertexColor defines if this LinesMesh supports vertex color
  89563. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89564. */
  89565. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89566. /**
  89567. * If vertex color should be applied to the mesh
  89568. */
  89569. useVertexColor?: boolean | undefined,
  89570. /**
  89571. * If vertex alpha should be applied to the mesh
  89572. */
  89573. useVertexAlpha?: boolean | undefined);
  89574. private _addClipPlaneDefine;
  89575. private _removeClipPlaneDefine;
  89576. isReady(): boolean;
  89577. /**
  89578. * Returns the string "LineMesh"
  89579. */
  89580. getClassName(): string;
  89581. /**
  89582. * @hidden
  89583. */
  89584. /**
  89585. * @hidden
  89586. */
  89587. material: Material;
  89588. /**
  89589. * @hidden
  89590. */
  89591. readonly checkCollisions: boolean;
  89592. /** @hidden */
  89593. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89594. /** @hidden */
  89595. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89596. /**
  89597. * Disposes of the line mesh
  89598. * @param doNotRecurse If children should be disposed
  89599. */
  89600. dispose(doNotRecurse?: boolean): void;
  89601. /**
  89602. * Returns a new LineMesh object cloned from the current one.
  89603. */
  89604. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89605. /**
  89606. * Creates a new InstancedLinesMesh object from the mesh model.
  89607. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89608. * @param name defines the name of the new instance
  89609. * @returns a new InstancedLinesMesh
  89610. */
  89611. createInstance(name: string): InstancedLinesMesh;
  89612. }
  89613. /**
  89614. * Creates an instance based on a source LinesMesh
  89615. */
  89616. export class InstancedLinesMesh extends InstancedMesh {
  89617. /**
  89618. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89619. * This margin is expressed in world space coordinates, so its value may vary.
  89620. * Initilized with the intersectionThreshold value of the source LinesMesh
  89621. */
  89622. intersectionThreshold: number;
  89623. constructor(name: string, source: LinesMesh);
  89624. /**
  89625. * Returns the string "InstancedLinesMesh".
  89626. */
  89627. getClassName(): string;
  89628. }
  89629. }
  89630. declare module BABYLON {
  89631. /** @hidden */
  89632. export var linePixelShader: {
  89633. name: string;
  89634. shader: string;
  89635. };
  89636. }
  89637. declare module BABYLON {
  89638. /** @hidden */
  89639. export var lineVertexShader: {
  89640. name: string;
  89641. shader: string;
  89642. };
  89643. }
  89644. declare module BABYLON {
  89645. interface AbstractMesh {
  89646. /**
  89647. * Gets the edgesRenderer associated with the mesh
  89648. */
  89649. edgesRenderer: Nullable<EdgesRenderer>;
  89650. }
  89651. interface LinesMesh {
  89652. /**
  89653. * Enables the edge rendering mode on the mesh.
  89654. * This mode makes the mesh edges visible
  89655. * @param epsilon defines the maximal distance between two angles to detect a face
  89656. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89657. * @returns the currentAbstractMesh
  89658. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89659. */
  89660. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89661. }
  89662. interface InstancedLinesMesh {
  89663. /**
  89664. * Enables the edge rendering mode on the mesh.
  89665. * This mode makes the mesh edges visible
  89666. * @param epsilon defines the maximal distance between two angles to detect a face
  89667. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89668. * @returns the current InstancedLinesMesh
  89669. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89670. */
  89671. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89672. }
  89673. /**
  89674. * Defines the minimum contract an Edges renderer should follow.
  89675. */
  89676. export interface IEdgesRenderer extends IDisposable {
  89677. /**
  89678. * Gets or sets a boolean indicating if the edgesRenderer is active
  89679. */
  89680. isEnabled: boolean;
  89681. /**
  89682. * Renders the edges of the attached mesh,
  89683. */
  89684. render(): void;
  89685. /**
  89686. * Checks wether or not the edges renderer is ready to render.
  89687. * @return true if ready, otherwise false.
  89688. */
  89689. isReady(): boolean;
  89690. }
  89691. /**
  89692. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89693. */
  89694. export class EdgesRenderer implements IEdgesRenderer {
  89695. /**
  89696. * Define the size of the edges with an orthographic camera
  89697. */
  89698. edgesWidthScalerForOrthographic: number;
  89699. /**
  89700. * Define the size of the edges with a perspective camera
  89701. */
  89702. edgesWidthScalerForPerspective: number;
  89703. protected _source: AbstractMesh;
  89704. protected _linesPositions: number[];
  89705. protected _linesNormals: number[];
  89706. protected _linesIndices: number[];
  89707. protected _epsilon: number;
  89708. protected _indicesCount: number;
  89709. protected _lineShader: ShaderMaterial;
  89710. protected _ib: DataBuffer;
  89711. protected _buffers: {
  89712. [key: string]: Nullable<VertexBuffer>;
  89713. };
  89714. protected _checkVerticesInsteadOfIndices: boolean;
  89715. private _meshRebuildObserver;
  89716. private _meshDisposeObserver;
  89717. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89718. isEnabled: boolean;
  89719. /**
  89720. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89721. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89722. * @param source Mesh used to create edges
  89723. * @param epsilon sum of angles in adjacency to check for edge
  89724. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89725. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89726. */
  89727. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89728. protected _prepareRessources(): void;
  89729. /** @hidden */
  89730. _rebuild(): void;
  89731. /**
  89732. * Releases the required resources for the edges renderer
  89733. */
  89734. dispose(): void;
  89735. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89736. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89737. /**
  89738. * Checks if the pair of p0 and p1 is en edge
  89739. * @param faceIndex
  89740. * @param edge
  89741. * @param faceNormals
  89742. * @param p0
  89743. * @param p1
  89744. * @private
  89745. */
  89746. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89747. /**
  89748. * push line into the position, normal and index buffer
  89749. * @protected
  89750. */
  89751. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89752. /**
  89753. * Generates lines edges from adjacencjes
  89754. * @private
  89755. */
  89756. _generateEdgesLines(): void;
  89757. /**
  89758. * Checks wether or not the edges renderer is ready to render.
  89759. * @return true if ready, otherwise false.
  89760. */
  89761. isReady(): boolean;
  89762. /**
  89763. * Renders the edges of the attached mesh,
  89764. */
  89765. render(): void;
  89766. }
  89767. /**
  89768. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89769. */
  89770. export class LineEdgesRenderer extends EdgesRenderer {
  89771. /**
  89772. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89773. * @param source LineMesh used to generate edges
  89774. * @param epsilon not important (specified angle for edge detection)
  89775. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89776. */
  89777. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89778. /**
  89779. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89780. */
  89781. _generateEdgesLines(): void;
  89782. }
  89783. }
  89784. declare module BABYLON {
  89785. /**
  89786. * This represents the object necessary to create a rendering group.
  89787. * This is exclusively used and created by the rendering manager.
  89788. * To modify the behavior, you use the available helpers in your scene or meshes.
  89789. * @hidden
  89790. */
  89791. export class RenderingGroup {
  89792. index: number;
  89793. private static _zeroVector;
  89794. private _scene;
  89795. private _opaqueSubMeshes;
  89796. private _transparentSubMeshes;
  89797. private _alphaTestSubMeshes;
  89798. private _depthOnlySubMeshes;
  89799. private _particleSystems;
  89800. private _spriteManagers;
  89801. private _opaqueSortCompareFn;
  89802. private _alphaTestSortCompareFn;
  89803. private _transparentSortCompareFn;
  89804. private _renderOpaque;
  89805. private _renderAlphaTest;
  89806. private _renderTransparent;
  89807. /** @hidden */
  89808. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89809. onBeforeTransparentRendering: () => void;
  89810. /**
  89811. * Set the opaque sort comparison function.
  89812. * If null the sub meshes will be render in the order they were created
  89813. */
  89814. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89815. /**
  89816. * Set the alpha test sort comparison function.
  89817. * If null the sub meshes will be render in the order they were created
  89818. */
  89819. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89820. /**
  89821. * Set the transparent sort comparison function.
  89822. * If null the sub meshes will be render in the order they were created
  89823. */
  89824. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89825. /**
  89826. * Creates a new rendering group.
  89827. * @param index The rendering group index
  89828. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89829. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89830. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89831. */
  89832. 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>);
  89833. /**
  89834. * Render all the sub meshes contained in the group.
  89835. * @param customRenderFunction Used to override the default render behaviour of the group.
  89836. * @returns true if rendered some submeshes.
  89837. */
  89838. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89839. /**
  89840. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89841. * @param subMeshes The submeshes to render
  89842. */
  89843. private renderOpaqueSorted;
  89844. /**
  89845. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89846. * @param subMeshes The submeshes to render
  89847. */
  89848. private renderAlphaTestSorted;
  89849. /**
  89850. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89851. * @param subMeshes The submeshes to render
  89852. */
  89853. private renderTransparentSorted;
  89854. /**
  89855. * Renders the submeshes in a specified order.
  89856. * @param subMeshes The submeshes to sort before render
  89857. * @param sortCompareFn The comparison function use to sort
  89858. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89859. * @param transparent Specifies to activate blending if true
  89860. */
  89861. private static renderSorted;
  89862. /**
  89863. * Renders the submeshes in the order they were dispatched (no sort applied).
  89864. * @param subMeshes The submeshes to render
  89865. */
  89866. private static renderUnsorted;
  89867. /**
  89868. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89869. * are rendered back to front if in the same alpha index.
  89870. *
  89871. * @param a The first submesh
  89872. * @param b The second submesh
  89873. * @returns The result of the comparison
  89874. */
  89875. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89876. /**
  89877. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89878. * are rendered back to front.
  89879. *
  89880. * @param a The first submesh
  89881. * @param b The second submesh
  89882. * @returns The result of the comparison
  89883. */
  89884. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89885. /**
  89886. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89887. * are rendered front to back (prevent overdraw).
  89888. *
  89889. * @param a The first submesh
  89890. * @param b The second submesh
  89891. * @returns The result of the comparison
  89892. */
  89893. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89894. /**
  89895. * Resets the different lists of submeshes to prepare a new frame.
  89896. */
  89897. prepare(): void;
  89898. dispose(): void;
  89899. /**
  89900. * Inserts the submesh in its correct queue depending on its material.
  89901. * @param subMesh The submesh to dispatch
  89902. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89903. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89904. */
  89905. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89906. dispatchSprites(spriteManager: ISpriteManager): void;
  89907. dispatchParticles(particleSystem: IParticleSystem): void;
  89908. private _renderParticles;
  89909. private _renderSprites;
  89910. }
  89911. }
  89912. declare module BABYLON {
  89913. /**
  89914. * Interface describing the different options available in the rendering manager
  89915. * regarding Auto Clear between groups.
  89916. */
  89917. export interface IRenderingManagerAutoClearSetup {
  89918. /**
  89919. * Defines whether or not autoclear is enable.
  89920. */
  89921. autoClear: boolean;
  89922. /**
  89923. * Defines whether or not to autoclear the depth buffer.
  89924. */
  89925. depth: boolean;
  89926. /**
  89927. * Defines whether or not to autoclear the stencil buffer.
  89928. */
  89929. stencil: boolean;
  89930. }
  89931. /**
  89932. * This class is used by the onRenderingGroupObservable
  89933. */
  89934. export class RenderingGroupInfo {
  89935. /**
  89936. * The Scene that being rendered
  89937. */
  89938. scene: Scene;
  89939. /**
  89940. * The camera currently used for the rendering pass
  89941. */
  89942. camera: Nullable<Camera>;
  89943. /**
  89944. * The ID of the renderingGroup being processed
  89945. */
  89946. renderingGroupId: number;
  89947. }
  89948. /**
  89949. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89950. * It is enable to manage the different groups as well as the different necessary sort functions.
  89951. * This should not be used directly aside of the few static configurations
  89952. */
  89953. export class RenderingManager {
  89954. /**
  89955. * The max id used for rendering groups (not included)
  89956. */
  89957. static MAX_RENDERINGGROUPS: number;
  89958. /**
  89959. * The min id used for rendering groups (included)
  89960. */
  89961. static MIN_RENDERINGGROUPS: number;
  89962. /**
  89963. * Used to globally prevent autoclearing scenes.
  89964. */
  89965. static AUTOCLEAR: boolean;
  89966. /**
  89967. * @hidden
  89968. */
  89969. _useSceneAutoClearSetup: boolean;
  89970. private _scene;
  89971. private _renderingGroups;
  89972. private _depthStencilBufferAlreadyCleaned;
  89973. private _autoClearDepthStencil;
  89974. private _customOpaqueSortCompareFn;
  89975. private _customAlphaTestSortCompareFn;
  89976. private _customTransparentSortCompareFn;
  89977. private _renderingGroupInfo;
  89978. /**
  89979. * Instantiates a new rendering group for a particular scene
  89980. * @param scene Defines the scene the groups belongs to
  89981. */
  89982. constructor(scene: Scene);
  89983. private _clearDepthStencilBuffer;
  89984. /**
  89985. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89986. * @hidden
  89987. */
  89988. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89989. /**
  89990. * Resets the different information of the group to prepare a new frame
  89991. * @hidden
  89992. */
  89993. reset(): void;
  89994. /**
  89995. * Dispose and release the group and its associated resources.
  89996. * @hidden
  89997. */
  89998. dispose(): void;
  89999. /**
  90000. * Clear the info related to rendering groups preventing retention points during dispose.
  90001. */
  90002. freeRenderingGroups(): void;
  90003. private _prepareRenderingGroup;
  90004. /**
  90005. * Add a sprite manager to the rendering manager in order to render it this frame.
  90006. * @param spriteManager Define the sprite manager to render
  90007. */
  90008. dispatchSprites(spriteManager: ISpriteManager): void;
  90009. /**
  90010. * Add a particle system to the rendering manager in order to render it this frame.
  90011. * @param particleSystem Define the particle system to render
  90012. */
  90013. dispatchParticles(particleSystem: IParticleSystem): void;
  90014. /**
  90015. * Add a submesh to the manager in order to render it this frame
  90016. * @param subMesh The submesh to dispatch
  90017. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90018. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90019. */
  90020. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90021. /**
  90022. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90023. * This allowed control for front to back rendering or reversly depending of the special needs.
  90024. *
  90025. * @param renderingGroupId The rendering group id corresponding to its index
  90026. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90027. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90028. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90029. */
  90030. 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;
  90031. /**
  90032. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90033. *
  90034. * @param renderingGroupId The rendering group id corresponding to its index
  90035. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90036. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90037. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90038. */
  90039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90040. /**
  90041. * Gets the current auto clear configuration for one rendering group of the rendering
  90042. * manager.
  90043. * @param index the rendering group index to get the information for
  90044. * @returns The auto clear setup for the requested rendering group
  90045. */
  90046. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90047. }
  90048. }
  90049. declare module BABYLON {
  90050. /**
  90051. * This Helps creating a texture that will be created from a camera in your scene.
  90052. * It is basically a dynamic texture that could be used to create special effects for instance.
  90053. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90054. */
  90055. export class RenderTargetTexture extends Texture {
  90056. isCube: boolean;
  90057. /**
  90058. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90059. */
  90060. static readonly REFRESHRATE_RENDER_ONCE: number;
  90061. /**
  90062. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90063. */
  90064. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90065. /**
  90066. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90067. * the central point of your effect and can save a lot of performances.
  90068. */
  90069. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90070. /**
  90071. * Use this predicate to dynamically define the list of mesh you want to render.
  90072. * If set, the renderList property will be overwritten.
  90073. */
  90074. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90075. private _renderList;
  90076. /**
  90077. * Use this list to define the list of mesh you want to render.
  90078. */
  90079. renderList: Nullable<Array<AbstractMesh>>;
  90080. private _hookArray;
  90081. /**
  90082. * Define if particles should be rendered in your texture.
  90083. */
  90084. renderParticles: boolean;
  90085. /**
  90086. * Define if sprites should be rendered in your texture.
  90087. */
  90088. renderSprites: boolean;
  90089. /**
  90090. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90091. */
  90092. coordinatesMode: number;
  90093. /**
  90094. * Define the camera used to render the texture.
  90095. */
  90096. activeCamera: Nullable<Camera>;
  90097. /**
  90098. * Override the render function of the texture with your own one.
  90099. */
  90100. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90101. /**
  90102. * Define if camera post processes should be use while rendering the texture.
  90103. */
  90104. useCameraPostProcesses: boolean;
  90105. /**
  90106. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90107. */
  90108. ignoreCameraViewport: boolean;
  90109. private _postProcessManager;
  90110. private _postProcesses;
  90111. private _resizeObserver;
  90112. /**
  90113. * An event triggered when the texture is unbind.
  90114. */
  90115. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90116. /**
  90117. * An event triggered when the texture is unbind.
  90118. */
  90119. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90120. private _onAfterUnbindObserver;
  90121. /**
  90122. * Set a after unbind callback in the texture.
  90123. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90124. */
  90125. onAfterUnbind: () => void;
  90126. /**
  90127. * An event triggered before rendering the texture
  90128. */
  90129. onBeforeRenderObservable: Observable<number>;
  90130. private _onBeforeRenderObserver;
  90131. /**
  90132. * Set a before render callback in the texture.
  90133. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90134. */
  90135. onBeforeRender: (faceIndex: number) => void;
  90136. /**
  90137. * An event triggered after rendering the texture
  90138. */
  90139. onAfterRenderObservable: Observable<number>;
  90140. private _onAfterRenderObserver;
  90141. /**
  90142. * Set a after render callback in the texture.
  90143. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90144. */
  90145. onAfterRender: (faceIndex: number) => void;
  90146. /**
  90147. * An event triggered after the texture clear
  90148. */
  90149. onClearObservable: Observable<Engine>;
  90150. private _onClearObserver;
  90151. /**
  90152. * Set a clear callback in the texture.
  90153. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90154. */
  90155. onClear: (Engine: Engine) => void;
  90156. /**
  90157. * An event triggered when the texture is resized.
  90158. */
  90159. onResizeObservable: Observable<RenderTargetTexture>;
  90160. /**
  90161. * Define the clear color of the Render Target if it should be different from the scene.
  90162. */
  90163. clearColor: Color4;
  90164. protected _size: number | {
  90165. width: number;
  90166. height: number;
  90167. };
  90168. protected _initialSizeParameter: number | {
  90169. width: number;
  90170. height: number;
  90171. } | {
  90172. ratio: number;
  90173. };
  90174. protected _sizeRatio: Nullable<number>;
  90175. /** @hidden */
  90176. _generateMipMaps: boolean;
  90177. protected _renderingManager: RenderingManager;
  90178. /** @hidden */
  90179. _waitingRenderList: string[];
  90180. protected _doNotChangeAspectRatio: boolean;
  90181. protected _currentRefreshId: number;
  90182. protected _refreshRate: number;
  90183. protected _textureMatrix: Matrix;
  90184. protected _samples: number;
  90185. protected _renderTargetOptions: RenderTargetCreationOptions;
  90186. /**
  90187. * Gets render target creation options that were used.
  90188. */
  90189. readonly renderTargetOptions: RenderTargetCreationOptions;
  90190. protected _engine: Engine;
  90191. protected _onRatioRescale(): void;
  90192. /**
  90193. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90194. * It must define where the camera used to render the texture is set
  90195. */
  90196. boundingBoxPosition: Vector3;
  90197. private _boundingBoxSize;
  90198. /**
  90199. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  90200. * When defined, the cubemap will switch to local mode
  90201. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  90202. * @example https://www.babylonjs-playground.com/#RNASML
  90203. */
  90204. boundingBoxSize: Vector3;
  90205. /**
  90206. * In case the RTT has been created with a depth texture, get the associated
  90207. * depth texture.
  90208. * Otherwise, return null.
  90209. */
  90210. depthStencilTexture: Nullable<InternalTexture>;
  90211. /**
  90212. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  90213. * or used a shadow, depth texture...
  90214. * @param name The friendly name of the texture
  90215. * @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)
  90216. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  90217. * @param generateMipMaps True if mip maps need to be generated after render.
  90218. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  90219. * @param type The type of the buffer in the RTT (int, half float, float...)
  90220. * @param isCube True if a cube texture needs to be created
  90221. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  90222. * @param generateDepthBuffer True to generate a depth buffer
  90223. * @param generateStencilBuffer True to generate a stencil buffer
  90224. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  90225. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  90226. * @param delayAllocation if the texture allocation should be delayed (default: false)
  90227. */
  90228. constructor(name: string, size: number | {
  90229. width: number;
  90230. height: number;
  90231. } | {
  90232. ratio: number;
  90233. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  90234. /**
  90235. * Creates a depth stencil texture.
  90236. * This is only available in WebGL 2 or with the depth texture extension available.
  90237. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  90238. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  90239. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  90240. */
  90241. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  90242. private _processSizeParameter;
  90243. /**
  90244. * Define the number of samples to use in case of MSAA.
  90245. * It defaults to one meaning no MSAA has been enabled.
  90246. */
  90247. samples: number;
  90248. /**
  90249. * Resets the refresh counter of the texture and start bak from scratch.
  90250. * Could be useful to regenerate the texture if it is setup to render only once.
  90251. */
  90252. resetRefreshCounter(): void;
  90253. /**
  90254. * Define the refresh rate of the texture or the rendering frequency.
  90255. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90256. */
  90257. refreshRate: number;
  90258. /**
  90259. * Adds a post process to the render target rendering passes.
  90260. * @param postProcess define the post process to add
  90261. */
  90262. addPostProcess(postProcess: PostProcess): void;
  90263. /**
  90264. * Clear all the post processes attached to the render target
  90265. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  90266. */
  90267. clearPostProcesses(dispose?: boolean): void;
  90268. /**
  90269. * Remove one of the post process from the list of attached post processes to the texture
  90270. * @param postProcess define the post process to remove from the list
  90271. */
  90272. removePostProcess(postProcess: PostProcess): void;
  90273. /** @hidden */
  90274. _shouldRender(): boolean;
  90275. /**
  90276. * Gets the actual render size of the texture.
  90277. * @returns the width of the render size
  90278. */
  90279. getRenderSize(): number;
  90280. /**
  90281. * Gets the actual render width of the texture.
  90282. * @returns the width of the render size
  90283. */
  90284. getRenderWidth(): number;
  90285. /**
  90286. * Gets the actual render height of the texture.
  90287. * @returns the height of the render size
  90288. */
  90289. getRenderHeight(): number;
  90290. /**
  90291. * Get if the texture can be rescaled or not.
  90292. */
  90293. readonly canRescale: boolean;
  90294. /**
  90295. * Resize the texture using a ratio.
  90296. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  90297. */
  90298. scale(ratio: number): void;
  90299. /**
  90300. * Get the texture reflection matrix used to rotate/transform the reflection.
  90301. * @returns the reflection matrix
  90302. */
  90303. getReflectionTextureMatrix(): Matrix;
  90304. /**
  90305. * Resize the texture to a new desired size.
  90306. * Be carrefull as it will recreate all the data in the new texture.
  90307. * @param size Define the new size. It can be:
  90308. * - a number for squared texture,
  90309. * - an object containing { width: number, height: number }
  90310. * - or an object containing a ratio { ratio: number }
  90311. */
  90312. resize(size: number | {
  90313. width: number;
  90314. height: number;
  90315. } | {
  90316. ratio: number;
  90317. }): void;
  90318. /**
  90319. * Renders all the objects from the render list into the texture.
  90320. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  90321. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  90322. */
  90323. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  90324. private _bestReflectionRenderTargetDimension;
  90325. /**
  90326. * @hidden
  90327. * @param faceIndex face index to bind to if this is a cubetexture
  90328. */
  90329. _bindFrameBuffer(faceIndex?: number): void;
  90330. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  90331. private renderToTarget;
  90332. /**
  90333. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90334. * This allowed control for front to back rendering or reversly depending of the special needs.
  90335. *
  90336. * @param renderingGroupId The rendering group id corresponding to its index
  90337. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90338. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90339. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90340. */
  90341. 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;
  90342. /**
  90343. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90344. *
  90345. * @param renderingGroupId The rendering group id corresponding to its index
  90346. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90347. */
  90348. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  90349. /**
  90350. * Clones the texture.
  90351. * @returns the cloned texture
  90352. */
  90353. clone(): RenderTargetTexture;
  90354. /**
  90355. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  90356. * @returns The JSON representation of the texture
  90357. */
  90358. serialize(): any;
  90359. /**
  90360. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  90361. */
  90362. disposeFramebufferObjects(): void;
  90363. /**
  90364. * Dispose the texture and release its associated resources.
  90365. */
  90366. dispose(): void;
  90367. /** @hidden */
  90368. _rebuild(): void;
  90369. /**
  90370. * Clear the info related to rendering groups preventing retention point in material dispose.
  90371. */
  90372. freeRenderingGroups(): void;
  90373. /**
  90374. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  90375. * @returns the view count
  90376. */
  90377. getViewCount(): number;
  90378. }
  90379. }
  90380. declare module BABYLON {
  90381. /**
  90382. * Options for compiling materials.
  90383. */
  90384. export interface IMaterialCompilationOptions {
  90385. /**
  90386. * Defines whether clip planes are enabled.
  90387. */
  90388. clipPlane: boolean;
  90389. /**
  90390. * Defines whether instances are enabled.
  90391. */
  90392. useInstances: boolean;
  90393. }
  90394. /**
  90395. * Base class for the main features of a material in Babylon.js
  90396. */
  90397. export class Material implements IAnimatable {
  90398. /**
  90399. * Returns the triangle fill mode
  90400. */
  90401. static readonly TriangleFillMode: number;
  90402. /**
  90403. * Returns the wireframe mode
  90404. */
  90405. static readonly WireFrameFillMode: number;
  90406. /**
  90407. * Returns the point fill mode
  90408. */
  90409. static readonly PointFillMode: number;
  90410. /**
  90411. * Returns the point list draw mode
  90412. */
  90413. static readonly PointListDrawMode: number;
  90414. /**
  90415. * Returns the line list draw mode
  90416. */
  90417. static readonly LineListDrawMode: number;
  90418. /**
  90419. * Returns the line loop draw mode
  90420. */
  90421. static readonly LineLoopDrawMode: number;
  90422. /**
  90423. * Returns the line strip draw mode
  90424. */
  90425. static readonly LineStripDrawMode: number;
  90426. /**
  90427. * Returns the triangle strip draw mode
  90428. */
  90429. static readonly TriangleStripDrawMode: number;
  90430. /**
  90431. * Returns the triangle fan draw mode
  90432. */
  90433. static readonly TriangleFanDrawMode: number;
  90434. /**
  90435. * Stores the clock-wise side orientation
  90436. */
  90437. static readonly ClockWiseSideOrientation: number;
  90438. /**
  90439. * Stores the counter clock-wise side orientation
  90440. */
  90441. static readonly CounterClockWiseSideOrientation: number;
  90442. /**
  90443. * The dirty texture flag value
  90444. */
  90445. static readonly TextureDirtyFlag: number;
  90446. /**
  90447. * The dirty light flag value
  90448. */
  90449. static readonly LightDirtyFlag: number;
  90450. /**
  90451. * The dirty fresnel flag value
  90452. */
  90453. static readonly FresnelDirtyFlag: number;
  90454. /**
  90455. * The dirty attribute flag value
  90456. */
  90457. static readonly AttributesDirtyFlag: number;
  90458. /**
  90459. * The dirty misc flag value
  90460. */
  90461. static readonly MiscDirtyFlag: number;
  90462. /**
  90463. * The all dirty flag value
  90464. */
  90465. static readonly AllDirtyFlag: number;
  90466. /**
  90467. * The ID of the material
  90468. */
  90469. id: string;
  90470. /**
  90471. * Gets or sets the unique id of the material
  90472. */
  90473. uniqueId: number;
  90474. /**
  90475. * The name of the material
  90476. */
  90477. name: string;
  90478. /**
  90479. * Gets or sets user defined metadata
  90480. */
  90481. metadata: any;
  90482. /**
  90483. * For internal use only. Please do not use.
  90484. */
  90485. reservedDataStore: any;
  90486. /**
  90487. * Specifies if the ready state should be checked on each call
  90488. */
  90489. checkReadyOnEveryCall: boolean;
  90490. /**
  90491. * Specifies if the ready state should be checked once
  90492. */
  90493. checkReadyOnlyOnce: boolean;
  90494. /**
  90495. * The state of the material
  90496. */
  90497. state: string;
  90498. /**
  90499. * The alpha value of the material
  90500. */
  90501. protected _alpha: number;
  90502. /**
  90503. * List of inspectable custom properties (used by the Inspector)
  90504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90505. */
  90506. inspectableCustomProperties: IInspectable[];
  90507. /**
  90508. * Sets the alpha value of the material
  90509. */
  90510. /**
  90511. * Gets the alpha value of the material
  90512. */
  90513. alpha: number;
  90514. /**
  90515. * Specifies if back face culling is enabled
  90516. */
  90517. protected _backFaceCulling: boolean;
  90518. /**
  90519. * Sets the back-face culling state
  90520. */
  90521. /**
  90522. * Gets the back-face culling state
  90523. */
  90524. backFaceCulling: boolean;
  90525. /**
  90526. * Stores the value for side orientation
  90527. */
  90528. sideOrientation: number;
  90529. /**
  90530. * Callback triggered when the material is compiled
  90531. */
  90532. onCompiled: Nullable<(effect: Effect) => void>;
  90533. /**
  90534. * Callback triggered when an error occurs
  90535. */
  90536. onError: Nullable<(effect: Effect, errors: string) => void>;
  90537. /**
  90538. * Callback triggered to get the render target textures
  90539. */
  90540. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  90541. /**
  90542. * Gets a boolean indicating that current material needs to register RTT
  90543. */
  90544. readonly hasRenderTargetTextures: boolean;
  90545. /**
  90546. * Specifies if the material should be serialized
  90547. */
  90548. doNotSerialize: boolean;
  90549. /**
  90550. * @hidden
  90551. */
  90552. _storeEffectOnSubMeshes: boolean;
  90553. /**
  90554. * Stores the animations for the material
  90555. */
  90556. animations: Nullable<Array<Animation>>;
  90557. /**
  90558. * An event triggered when the material is disposed
  90559. */
  90560. onDisposeObservable: Observable<Material>;
  90561. /**
  90562. * An observer which watches for dispose events
  90563. */
  90564. private _onDisposeObserver;
  90565. private _onUnBindObservable;
  90566. /**
  90567. * Called during a dispose event
  90568. */
  90569. onDispose: () => void;
  90570. private _onBindObservable;
  90571. /**
  90572. * An event triggered when the material is bound
  90573. */
  90574. readonly onBindObservable: Observable<AbstractMesh>;
  90575. /**
  90576. * An observer which watches for bind events
  90577. */
  90578. private _onBindObserver;
  90579. /**
  90580. * Called during a bind event
  90581. */
  90582. onBind: (Mesh: AbstractMesh) => void;
  90583. /**
  90584. * An event triggered when the material is unbound
  90585. */
  90586. readonly onUnBindObservable: Observable<Material>;
  90587. /**
  90588. * Stores the value of the alpha mode
  90589. */
  90590. private _alphaMode;
  90591. /**
  90592. * Sets the value of the alpha mode.
  90593. *
  90594. * | Value | Type | Description |
  90595. * | --- | --- | --- |
  90596. * | 0 | ALPHA_DISABLE | |
  90597. * | 1 | ALPHA_ADD | |
  90598. * | 2 | ALPHA_COMBINE | |
  90599. * | 3 | ALPHA_SUBTRACT | |
  90600. * | 4 | ALPHA_MULTIPLY | |
  90601. * | 5 | ALPHA_MAXIMIZED | |
  90602. * | 6 | ALPHA_ONEONE | |
  90603. * | 7 | ALPHA_PREMULTIPLIED | |
  90604. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  90605. * | 9 | ALPHA_INTERPOLATE | |
  90606. * | 10 | ALPHA_SCREENMODE | |
  90607. *
  90608. */
  90609. /**
  90610. * Gets the value of the alpha mode
  90611. */
  90612. alphaMode: number;
  90613. /**
  90614. * Stores the state of the need depth pre-pass value
  90615. */
  90616. private _needDepthPrePass;
  90617. /**
  90618. * Sets the need depth pre-pass value
  90619. */
  90620. /**
  90621. * Gets the depth pre-pass value
  90622. */
  90623. needDepthPrePass: boolean;
  90624. /**
  90625. * Specifies if depth writing should be disabled
  90626. */
  90627. disableDepthWrite: boolean;
  90628. /**
  90629. * Specifies if depth writing should be forced
  90630. */
  90631. forceDepthWrite: boolean;
  90632. /**
  90633. * Specifies the depth function that should be used. 0 means the default engine function
  90634. */
  90635. depthFunction: number;
  90636. /**
  90637. * Specifies if there should be a separate pass for culling
  90638. */
  90639. separateCullingPass: boolean;
  90640. /**
  90641. * Stores the state specifing if fog should be enabled
  90642. */
  90643. private _fogEnabled;
  90644. /**
  90645. * Sets the state for enabling fog
  90646. */
  90647. /**
  90648. * Gets the value of the fog enabled state
  90649. */
  90650. fogEnabled: boolean;
  90651. /**
  90652. * Stores the size of points
  90653. */
  90654. pointSize: number;
  90655. /**
  90656. * Stores the z offset value
  90657. */
  90658. zOffset: number;
  90659. /**
  90660. * Gets a value specifying if wireframe mode is enabled
  90661. */
  90662. /**
  90663. * Sets the state of wireframe mode
  90664. */
  90665. wireframe: boolean;
  90666. /**
  90667. * Gets the value specifying if point clouds are enabled
  90668. */
  90669. /**
  90670. * Sets the state of point cloud mode
  90671. */
  90672. pointsCloud: boolean;
  90673. /**
  90674. * Gets the material fill mode
  90675. */
  90676. /**
  90677. * Sets the material fill mode
  90678. */
  90679. fillMode: number;
  90680. /**
  90681. * @hidden
  90682. * Stores the effects for the material
  90683. */
  90684. _effect: Nullable<Effect>;
  90685. /**
  90686. * @hidden
  90687. * Specifies if the material was previously ready
  90688. */
  90689. _wasPreviouslyReady: boolean;
  90690. /**
  90691. * Specifies if uniform buffers should be used
  90692. */
  90693. private _useUBO;
  90694. /**
  90695. * Stores a reference to the scene
  90696. */
  90697. private _scene;
  90698. /**
  90699. * Stores the fill mode state
  90700. */
  90701. private _fillMode;
  90702. /**
  90703. * Specifies if the depth write state should be cached
  90704. */
  90705. private _cachedDepthWriteState;
  90706. /**
  90707. * Specifies if the depth function state should be cached
  90708. */
  90709. private _cachedDepthFunctionState;
  90710. /**
  90711. * Stores the uniform buffer
  90712. */
  90713. protected _uniformBuffer: UniformBuffer;
  90714. /** @hidden */
  90715. _indexInSceneMaterialArray: number;
  90716. /** @hidden */
  90717. meshMap: Nullable<{
  90718. [id: string]: AbstractMesh | undefined;
  90719. }>;
  90720. /**
  90721. * Creates a material instance
  90722. * @param name defines the name of the material
  90723. * @param scene defines the scene to reference
  90724. * @param doNotAdd specifies if the material should be added to the scene
  90725. */
  90726. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  90727. /**
  90728. * Returns a string representation of the current material
  90729. * @param fullDetails defines a boolean indicating which levels of logging is desired
  90730. * @returns a string with material information
  90731. */
  90732. toString(fullDetails?: boolean): string;
  90733. /**
  90734. * Gets the class name of the material
  90735. * @returns a string with the class name of the material
  90736. */
  90737. getClassName(): string;
  90738. /**
  90739. * Specifies if updates for the material been locked
  90740. */
  90741. readonly isFrozen: boolean;
  90742. /**
  90743. * Locks updates for the material
  90744. */
  90745. freeze(): void;
  90746. /**
  90747. * Unlocks updates for the material
  90748. */
  90749. unfreeze(): void;
  90750. /**
  90751. * Specifies if the material is ready to be used
  90752. * @param mesh defines the mesh to check
  90753. * @param useInstances specifies if instances should be used
  90754. * @returns a boolean indicating if the material is ready to be used
  90755. */
  90756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90757. /**
  90758. * Specifies that the submesh is ready to be used
  90759. * @param mesh defines the mesh to check
  90760. * @param subMesh defines which submesh to check
  90761. * @param useInstances specifies that instances should be used
  90762. * @returns a boolean indicating that the submesh is ready or not
  90763. */
  90764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90765. /**
  90766. * Returns the material effect
  90767. * @returns the effect associated with the material
  90768. */
  90769. getEffect(): Nullable<Effect>;
  90770. /**
  90771. * Returns the current scene
  90772. * @returns a Scene
  90773. */
  90774. getScene(): Scene;
  90775. /**
  90776. * Specifies if the material will require alpha blending
  90777. * @returns a boolean specifying if alpha blending is needed
  90778. */
  90779. needAlphaBlending(): boolean;
  90780. /**
  90781. * Specifies if the mesh will require alpha blending
  90782. * @param mesh defines the mesh to check
  90783. * @returns a boolean specifying if alpha blending is needed for the mesh
  90784. */
  90785. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  90786. /**
  90787. * Specifies if this material should be rendered in alpha test mode
  90788. * @returns a boolean specifying if an alpha test is needed.
  90789. */
  90790. needAlphaTesting(): boolean;
  90791. /**
  90792. * Gets the texture used for the alpha test
  90793. * @returns the texture to use for alpha testing
  90794. */
  90795. getAlphaTestTexture(): Nullable<BaseTexture>;
  90796. /**
  90797. * Marks the material to indicate that it needs to be re-calculated
  90798. */
  90799. markDirty(): void;
  90800. /** @hidden */
  90801. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  90802. /**
  90803. * Binds the material to the mesh
  90804. * @param world defines the world transformation matrix
  90805. * @param mesh defines the mesh to bind the material to
  90806. */
  90807. bind(world: Matrix, mesh?: Mesh): void;
  90808. /**
  90809. * Binds the submesh to the material
  90810. * @param world defines the world transformation matrix
  90811. * @param mesh defines the mesh containing the submesh
  90812. * @param subMesh defines the submesh to bind the material to
  90813. */
  90814. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  90815. /**
  90816. * Binds the world matrix to the material
  90817. * @param world defines the world transformation matrix
  90818. */
  90819. bindOnlyWorldMatrix(world: Matrix): void;
  90820. /**
  90821. * Binds the scene's uniform buffer to the effect.
  90822. * @param effect defines the effect to bind to the scene uniform buffer
  90823. * @param sceneUbo defines the uniform buffer storing scene data
  90824. */
  90825. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  90826. /**
  90827. * Binds the view matrix to the effect
  90828. * @param effect defines the effect to bind the view matrix to
  90829. */
  90830. bindView(effect: Effect): void;
  90831. /**
  90832. * Binds the view projection matrix to the effect
  90833. * @param effect defines the effect to bind the view projection matrix to
  90834. */
  90835. bindViewProjection(effect: Effect): void;
  90836. /**
  90837. * Specifies if material alpha testing should be turned on for the mesh
  90838. * @param mesh defines the mesh to check
  90839. */
  90840. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  90841. /**
  90842. * Processes to execute after binding the material to a mesh
  90843. * @param mesh defines the rendered mesh
  90844. */
  90845. protected _afterBind(mesh?: Mesh): void;
  90846. /**
  90847. * Unbinds the material from the mesh
  90848. */
  90849. unbind(): void;
  90850. /**
  90851. * Gets the active textures from the material
  90852. * @returns an array of textures
  90853. */
  90854. getActiveTextures(): BaseTexture[];
  90855. /**
  90856. * Specifies if the material uses a texture
  90857. * @param texture defines the texture to check against the material
  90858. * @returns a boolean specifying if the material uses the texture
  90859. */
  90860. hasTexture(texture: BaseTexture): boolean;
  90861. /**
  90862. * Makes a duplicate of the material, and gives it a new name
  90863. * @param name defines the new name for the duplicated material
  90864. * @returns the cloned material
  90865. */
  90866. clone(name: string): Nullable<Material>;
  90867. /**
  90868. * Gets the meshes bound to the material
  90869. * @returns an array of meshes bound to the material
  90870. */
  90871. getBindedMeshes(): AbstractMesh[];
  90872. /**
  90873. * Force shader compilation
  90874. * @param mesh defines the mesh associated with this material
  90875. * @param onCompiled defines a function to execute once the material is compiled
  90876. * @param options defines the options to configure the compilation
  90877. * @param onError defines a function to execute if the material fails compiling
  90878. */
  90879. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  90880. /**
  90881. * Force shader compilation
  90882. * @param mesh defines the mesh that will use this material
  90883. * @param options defines additional options for compiling the shaders
  90884. * @returns a promise that resolves when the compilation completes
  90885. */
  90886. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  90887. private static readonly _AllDirtyCallBack;
  90888. private static readonly _ImageProcessingDirtyCallBack;
  90889. private static readonly _TextureDirtyCallBack;
  90890. private static readonly _FresnelDirtyCallBack;
  90891. private static readonly _MiscDirtyCallBack;
  90892. private static readonly _LightsDirtyCallBack;
  90893. private static readonly _AttributeDirtyCallBack;
  90894. private static _FresnelAndMiscDirtyCallBack;
  90895. private static _TextureAndMiscDirtyCallBack;
  90896. private static readonly _DirtyCallbackArray;
  90897. private static readonly _RunDirtyCallBacks;
  90898. /**
  90899. * Marks a define in the material to indicate that it needs to be re-computed
  90900. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  90901. */
  90902. markAsDirty(flag: number): void;
  90903. /**
  90904. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  90905. * @param func defines a function which checks material defines against the submeshes
  90906. */
  90907. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  90908. /**
  90909. * Indicates that we need to re-calculated for all submeshes
  90910. */
  90911. protected _markAllSubMeshesAsAllDirty(): void;
  90912. /**
  90913. * Indicates that image processing needs to be re-calculated for all submeshes
  90914. */
  90915. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  90916. /**
  90917. * Indicates that textures need to be re-calculated for all submeshes
  90918. */
  90919. protected _markAllSubMeshesAsTexturesDirty(): void;
  90920. /**
  90921. * Indicates that fresnel needs to be re-calculated for all submeshes
  90922. */
  90923. protected _markAllSubMeshesAsFresnelDirty(): void;
  90924. /**
  90925. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  90926. */
  90927. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  90928. /**
  90929. * Indicates that lights need to be re-calculated for all submeshes
  90930. */
  90931. protected _markAllSubMeshesAsLightsDirty(): void;
  90932. /**
  90933. * Indicates that attributes need to be re-calculated for all submeshes
  90934. */
  90935. protected _markAllSubMeshesAsAttributesDirty(): void;
  90936. /**
  90937. * Indicates that misc needs to be re-calculated for all submeshes
  90938. */
  90939. protected _markAllSubMeshesAsMiscDirty(): void;
  90940. /**
  90941. * Indicates that textures and misc need to be re-calculated for all submeshes
  90942. */
  90943. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  90944. /**
  90945. * Disposes the material
  90946. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90947. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90948. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90949. */
  90950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90951. /** @hidden */
  90952. private releaseVertexArrayObject;
  90953. /**
  90954. * Serializes this material
  90955. * @returns the serialized material object
  90956. */
  90957. serialize(): any;
  90958. /**
  90959. * Creates a material from parsed material data
  90960. * @param parsedMaterial defines parsed material data
  90961. * @param scene defines the hosting scene
  90962. * @param rootUrl defines the root URL to use to load textures
  90963. * @returns a new material
  90964. */
  90965. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  90966. }
  90967. }
  90968. declare module BABYLON {
  90969. /**
  90970. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90971. * separate meshes. This can be use to improve performances.
  90972. * @see http://doc.babylonjs.com/how_to/multi_materials
  90973. */
  90974. export class MultiMaterial extends Material {
  90975. private _subMaterials;
  90976. /**
  90977. * Gets or Sets the list of Materials used within the multi material.
  90978. * They need to be ordered according to the submeshes order in the associated mesh
  90979. */
  90980. subMaterials: Nullable<Material>[];
  90981. /**
  90982. * Function used to align with Node.getChildren()
  90983. * @returns the list of Materials used within the multi material
  90984. */
  90985. getChildren(): Nullable<Material>[];
  90986. /**
  90987. * Instantiates a new Multi Material
  90988. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90989. * separate meshes. This can be use to improve performances.
  90990. * @see http://doc.babylonjs.com/how_to/multi_materials
  90991. * @param name Define the name in the scene
  90992. * @param scene Define the scene the material belongs to
  90993. */
  90994. constructor(name: string, scene: Scene);
  90995. private _hookArray;
  90996. /**
  90997. * Get one of the submaterial by its index in the submaterials array
  90998. * @param index The index to look the sub material at
  90999. * @returns The Material if the index has been defined
  91000. */
  91001. getSubMaterial(index: number): Nullable<Material>;
  91002. /**
  91003. * Get the list of active textures for the whole sub materials list.
  91004. * @returns All the textures that will be used during the rendering
  91005. */
  91006. getActiveTextures(): BaseTexture[];
  91007. /**
  91008. * Gets the current class name of the material e.g. "MultiMaterial"
  91009. * Mainly use in serialization.
  91010. * @returns the class name
  91011. */
  91012. getClassName(): string;
  91013. /**
  91014. * Checks if the material is ready to render the requested sub mesh
  91015. * @param mesh Define the mesh the submesh belongs to
  91016. * @param subMesh Define the sub mesh to look readyness for
  91017. * @param useInstances Define whether or not the material is used with instances
  91018. * @returns true if ready, otherwise false
  91019. */
  91020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91021. /**
  91022. * Clones the current material and its related sub materials
  91023. * @param name Define the name of the newly cloned material
  91024. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91025. * @returns the cloned material
  91026. */
  91027. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91028. /**
  91029. * Serializes the materials into a JSON representation.
  91030. * @returns the JSON representation
  91031. */
  91032. serialize(): any;
  91033. /**
  91034. * Dispose the material and release its associated resources
  91035. * @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)
  91036. * @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)
  91037. * @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)
  91038. */
  91039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91040. /**
  91041. * Creates a MultiMaterial from parsed MultiMaterial data.
  91042. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91043. * @param scene defines the hosting scene
  91044. * @returns a new MultiMaterial
  91045. */
  91046. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91047. }
  91048. }
  91049. declare module BABYLON {
  91050. /**
  91051. * Base class for submeshes
  91052. */
  91053. export class BaseSubMesh {
  91054. /** @hidden */
  91055. _materialDefines: Nullable<MaterialDefines>;
  91056. /** @hidden */
  91057. _materialEffect: Nullable<Effect>;
  91058. /**
  91059. * Gets material defines used by the effect associated to the sub mesh
  91060. */
  91061. /**
  91062. * Sets material defines used by the effect associated to the sub mesh
  91063. */
  91064. materialDefines: Nullable<MaterialDefines>;
  91065. /**
  91066. * Gets associated effect
  91067. */
  91068. readonly effect: Nullable<Effect>;
  91069. /**
  91070. * Sets associated effect (effect used to render this submesh)
  91071. * @param effect defines the effect to associate with
  91072. * @param defines defines the set of defines used to compile this effect
  91073. */
  91074. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91075. }
  91076. /**
  91077. * Defines a subdivision inside a mesh
  91078. */
  91079. export class SubMesh extends BaseSubMesh implements ICullable {
  91080. /** the material index to use */
  91081. materialIndex: number;
  91082. /** vertex index start */
  91083. verticesStart: number;
  91084. /** vertices count */
  91085. verticesCount: number;
  91086. /** index start */
  91087. indexStart: number;
  91088. /** indices count */
  91089. indexCount: number;
  91090. /** @hidden */
  91091. _linesIndexCount: number;
  91092. private _mesh;
  91093. private _renderingMesh;
  91094. private _boundingInfo;
  91095. private _linesIndexBuffer;
  91096. /** @hidden */
  91097. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91098. /** @hidden */
  91099. _trianglePlanes: Plane[];
  91100. /** @hidden */
  91101. _lastColliderTransformMatrix: Nullable<Matrix>;
  91102. /** @hidden */
  91103. _renderId: number;
  91104. /** @hidden */
  91105. _alphaIndex: number;
  91106. /** @hidden */
  91107. _distanceToCamera: number;
  91108. /** @hidden */
  91109. _id: number;
  91110. private _currentMaterial;
  91111. /**
  91112. * Add a new submesh to a mesh
  91113. * @param materialIndex defines the material index to use
  91114. * @param verticesStart defines vertex index start
  91115. * @param verticesCount defines vertices count
  91116. * @param indexStart defines index start
  91117. * @param indexCount defines indices count
  91118. * @param mesh defines the parent mesh
  91119. * @param renderingMesh defines an optional rendering mesh
  91120. * @param createBoundingBox defines if bounding box should be created for this submesh
  91121. * @returns the new submesh
  91122. */
  91123. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91124. /**
  91125. * Creates a new submesh
  91126. * @param materialIndex defines the material index to use
  91127. * @param verticesStart defines vertex index start
  91128. * @param verticesCount defines vertices count
  91129. * @param indexStart defines index start
  91130. * @param indexCount defines indices count
  91131. * @param mesh defines the parent mesh
  91132. * @param renderingMesh defines an optional rendering mesh
  91133. * @param createBoundingBox defines if bounding box should be created for this submesh
  91134. */
  91135. constructor(
  91136. /** the material index to use */
  91137. materialIndex: number,
  91138. /** vertex index start */
  91139. verticesStart: number,
  91140. /** vertices count */
  91141. verticesCount: number,
  91142. /** index start */
  91143. indexStart: number,
  91144. /** indices count */
  91145. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91146. /**
  91147. * Returns true if this submesh covers the entire parent mesh
  91148. * @ignorenaming
  91149. */
  91150. readonly IsGlobal: boolean;
  91151. /**
  91152. * Returns the submesh BoudingInfo object
  91153. * @returns current bounding info (or mesh's one if the submesh is global)
  91154. */
  91155. getBoundingInfo(): BoundingInfo;
  91156. /**
  91157. * Sets the submesh BoundingInfo
  91158. * @param boundingInfo defines the new bounding info to use
  91159. * @returns the SubMesh
  91160. */
  91161. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91162. /**
  91163. * Returns the mesh of the current submesh
  91164. * @return the parent mesh
  91165. */
  91166. getMesh(): AbstractMesh;
  91167. /**
  91168. * Returns the rendering mesh of the submesh
  91169. * @returns the rendering mesh (could be different from parent mesh)
  91170. */
  91171. getRenderingMesh(): Mesh;
  91172. /**
  91173. * Returns the submesh material
  91174. * @returns null or the current material
  91175. */
  91176. getMaterial(): Nullable<Material>;
  91177. /**
  91178. * Sets a new updated BoundingInfo object to the submesh
  91179. * @param data defines an optional position array to use to determine the bounding info
  91180. * @returns the SubMesh
  91181. */
  91182. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91183. /** @hidden */
  91184. _checkCollision(collider: Collider): boolean;
  91185. /**
  91186. * Updates the submesh BoundingInfo
  91187. * @param world defines the world matrix to use to update the bounding info
  91188. * @returns the submesh
  91189. */
  91190. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  91191. /**
  91192. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91193. * @param frustumPlanes defines the frustum planes
  91194. * @returns true if the submesh is intersecting with the frustum
  91195. */
  91196. isInFrustum(frustumPlanes: Plane[]): boolean;
  91197. /**
  91198. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91199. * @param frustumPlanes defines the frustum planes
  91200. * @returns true if the submesh is inside the frustum
  91201. */
  91202. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91203. /**
  91204. * Renders the submesh
  91205. * @param enableAlphaMode defines if alpha needs to be used
  91206. * @returns the submesh
  91207. */
  91208. render(enableAlphaMode: boolean): SubMesh;
  91209. /**
  91210. * @hidden
  91211. */
  91212. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  91213. /**
  91214. * Checks if the submesh intersects with a ray
  91215. * @param ray defines the ray to test
  91216. * @returns true is the passed ray intersects the submesh bounding box
  91217. */
  91218. canIntersects(ray: Ray): boolean;
  91219. /**
  91220. * Intersects current submesh with a ray
  91221. * @param ray defines the ray to test
  91222. * @param positions defines mesh's positions array
  91223. * @param indices defines mesh's indices array
  91224. * @param fastCheck defines if only bounding info should be used
  91225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91226. * @returns intersection info or null if no intersection
  91227. */
  91228. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  91229. /** @hidden */
  91230. private _intersectLines;
  91231. /** @hidden */
  91232. private _intersectUnIndexedLines;
  91233. /** @hidden */
  91234. private _intersectTriangles;
  91235. /** @hidden */
  91236. private _intersectUnIndexedTriangles;
  91237. /** @hidden */
  91238. _rebuild(): void;
  91239. /**
  91240. * Creates a new submesh from the passed mesh
  91241. * @param newMesh defines the new hosting mesh
  91242. * @param newRenderingMesh defines an optional rendering mesh
  91243. * @returns the new submesh
  91244. */
  91245. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  91246. /**
  91247. * Release associated resources
  91248. */
  91249. dispose(): void;
  91250. /**
  91251. * Gets the class name
  91252. * @returns the string "SubMesh".
  91253. */
  91254. getClassName(): string;
  91255. /**
  91256. * Creates a new submesh from indices data
  91257. * @param materialIndex the index of the main mesh material
  91258. * @param startIndex the index where to start the copy in the mesh indices array
  91259. * @param indexCount the number of indices to copy then from the startIndex
  91260. * @param mesh the main mesh to create the submesh from
  91261. * @param renderingMesh the optional rendering mesh
  91262. * @returns a new submesh
  91263. */
  91264. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  91265. }
  91266. }
  91267. declare module BABYLON {
  91268. /**
  91269. * Class used to represent data loading progression
  91270. */
  91271. export class SceneLoaderFlags {
  91272. private static _ForceFullSceneLoadingForIncremental;
  91273. private static _ShowLoadingScreen;
  91274. private static _CleanBoneMatrixWeights;
  91275. private static _loggingLevel;
  91276. /**
  91277. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  91278. */
  91279. static ForceFullSceneLoadingForIncremental: boolean;
  91280. /**
  91281. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  91282. */
  91283. static ShowLoadingScreen: boolean;
  91284. /**
  91285. * Defines the current logging level (while loading the scene)
  91286. * @ignorenaming
  91287. */
  91288. static loggingLevel: number;
  91289. /**
  91290. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  91291. */
  91292. static CleanBoneMatrixWeights: boolean;
  91293. }
  91294. }
  91295. declare module BABYLON {
  91296. /**
  91297. * Class used to store geometry data (vertex buffers + index buffer)
  91298. */
  91299. export class Geometry implements IGetSetVerticesData {
  91300. /**
  91301. * Gets or sets the ID of the geometry
  91302. */
  91303. id: string;
  91304. /**
  91305. * Gets or sets the unique ID of the geometry
  91306. */
  91307. uniqueId: number;
  91308. /**
  91309. * Gets the delay loading state of the geometry (none by default which means not delayed)
  91310. */
  91311. delayLoadState: number;
  91312. /**
  91313. * Gets the file containing the data to load when running in delay load state
  91314. */
  91315. delayLoadingFile: Nullable<string>;
  91316. /**
  91317. * Callback called when the geometry is updated
  91318. */
  91319. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  91320. private _scene;
  91321. private _engine;
  91322. private _meshes;
  91323. private _totalVertices;
  91324. /** @hidden */
  91325. _indices: IndicesArray;
  91326. /** @hidden */
  91327. _vertexBuffers: {
  91328. [key: string]: VertexBuffer;
  91329. };
  91330. private _isDisposed;
  91331. private _extend;
  91332. private _boundingBias;
  91333. /** @hidden */
  91334. _delayInfo: Array<string>;
  91335. private _indexBuffer;
  91336. private _indexBufferIsUpdatable;
  91337. /** @hidden */
  91338. _boundingInfo: Nullable<BoundingInfo>;
  91339. /** @hidden */
  91340. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  91341. /** @hidden */
  91342. _softwareSkinningFrameId: number;
  91343. private _vertexArrayObjects;
  91344. private _updatable;
  91345. /** @hidden */
  91346. _positions: Nullable<Vector3[]>;
  91347. /**
  91348. * 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
  91349. */
  91350. /**
  91351. * 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
  91352. */
  91353. boundingBias: Vector2;
  91354. /**
  91355. * Static function used to attach a new empty geometry to a mesh
  91356. * @param mesh defines the mesh to attach the geometry to
  91357. * @returns the new Geometry
  91358. */
  91359. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  91360. /**
  91361. * Creates a new geometry
  91362. * @param id defines the unique ID
  91363. * @param scene defines the hosting scene
  91364. * @param vertexData defines the VertexData used to get geometry data
  91365. * @param updatable defines if geometry must be updatable (false by default)
  91366. * @param mesh defines the mesh that will be associated with the geometry
  91367. */
  91368. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  91369. /**
  91370. * Gets the current extend of the geometry
  91371. */
  91372. readonly extend: {
  91373. minimum: Vector3;
  91374. maximum: Vector3;
  91375. };
  91376. /**
  91377. * Gets the hosting scene
  91378. * @returns the hosting Scene
  91379. */
  91380. getScene(): Scene;
  91381. /**
  91382. * Gets the hosting engine
  91383. * @returns the hosting Engine
  91384. */
  91385. getEngine(): Engine;
  91386. /**
  91387. * Defines if the geometry is ready to use
  91388. * @returns true if the geometry is ready to be used
  91389. */
  91390. isReady(): boolean;
  91391. /**
  91392. * Gets a value indicating that the geometry should not be serialized
  91393. */
  91394. readonly doNotSerialize: boolean;
  91395. /** @hidden */
  91396. _rebuild(): void;
  91397. /**
  91398. * Affects all geometry data in one call
  91399. * @param vertexData defines the geometry data
  91400. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  91401. */
  91402. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  91403. /**
  91404. * Set specific vertex data
  91405. * @param kind defines the data kind (Position, normal, etc...)
  91406. * @param data defines the vertex data to use
  91407. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  91408. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  91409. */
  91410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  91411. /**
  91412. * Removes a specific vertex data
  91413. * @param kind defines the data kind (Position, normal, etc...)
  91414. */
  91415. removeVerticesData(kind: string): void;
  91416. /**
  91417. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  91418. * @param buffer defines the vertex buffer to use
  91419. * @param totalVertices defines the total number of vertices for position kind (could be null)
  91420. */
  91421. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  91422. /**
  91423. * Update a specific vertex buffer
  91424. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  91425. * It will do nothing if the buffer is not updatable
  91426. * @param kind defines the data kind (Position, normal, etc...)
  91427. * @param data defines the data to use
  91428. * @param offset defines the offset in the target buffer where to store the data
  91429. * @param useBytes set to true if the offset is in bytes
  91430. */
  91431. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  91432. /**
  91433. * Update a specific vertex buffer
  91434. * This function will create a new buffer if the current one is not updatable
  91435. * @param kind defines the data kind (Position, normal, etc...)
  91436. * @param data defines the data to use
  91437. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  91438. */
  91439. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  91440. private _updateBoundingInfo;
  91441. /** @hidden */
  91442. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  91443. /**
  91444. * Gets total number of vertices
  91445. * @returns the total number of vertices
  91446. */
  91447. getTotalVertices(): number;
  91448. /**
  91449. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  91450. * @param kind defines the data kind (Position, normal, etc...)
  91451. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  91452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91453. * @returns a float array containing vertex data
  91454. */
  91455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91456. /**
  91457. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  91458. * @param kind defines the data kind (Position, normal, etc...)
  91459. * @returns true if the vertex buffer with the specified kind is updatable
  91460. */
  91461. isVertexBufferUpdatable(kind: string): boolean;
  91462. /**
  91463. * Gets a specific vertex buffer
  91464. * @param kind defines the data kind (Position, normal, etc...)
  91465. * @returns a VertexBuffer
  91466. */
  91467. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91468. /**
  91469. * Returns all vertex buffers
  91470. * @return an object holding all vertex buffers indexed by kind
  91471. */
  91472. getVertexBuffers(): Nullable<{
  91473. [key: string]: VertexBuffer;
  91474. }>;
  91475. /**
  91476. * Gets a boolean indicating if specific vertex buffer is present
  91477. * @param kind defines the data kind (Position, normal, etc...)
  91478. * @returns true if data is present
  91479. */
  91480. isVerticesDataPresent(kind: string): boolean;
  91481. /**
  91482. * Gets a list of all attached data kinds (Position, normal, etc...)
  91483. * @returns a list of string containing all kinds
  91484. */
  91485. getVerticesDataKinds(): string[];
  91486. /**
  91487. * Update index buffer
  91488. * @param indices defines the indices to store in the index buffer
  91489. * @param offset defines the offset in the target buffer where to store the data
  91490. * @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)
  91491. */
  91492. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  91493. /**
  91494. * Creates a new index buffer
  91495. * @param indices defines the indices to store in the index buffer
  91496. * @param totalVertices defines the total number of vertices (could be null)
  91497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  91498. */
  91499. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  91500. /**
  91501. * Return the total number of indices
  91502. * @returns the total number of indices
  91503. */
  91504. getTotalIndices(): number;
  91505. /**
  91506. * Gets the index buffer array
  91507. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  91508. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91509. * @returns the index buffer array
  91510. */
  91511. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91512. /**
  91513. * Gets the index buffer
  91514. * @return the index buffer
  91515. */
  91516. getIndexBuffer(): Nullable<DataBuffer>;
  91517. /** @hidden */
  91518. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  91519. /**
  91520. * Release the associated resources for a specific mesh
  91521. * @param mesh defines the source mesh
  91522. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  91523. */
  91524. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  91525. /**
  91526. * Apply current geometry to a given mesh
  91527. * @param mesh defines the mesh to apply geometry to
  91528. */
  91529. applyToMesh(mesh: Mesh): void;
  91530. private _updateExtend;
  91531. private _applyToMesh;
  91532. private notifyUpdate;
  91533. /**
  91534. * Load the geometry if it was flagged as delay loaded
  91535. * @param scene defines the hosting scene
  91536. * @param onLoaded defines a callback called when the geometry is loaded
  91537. */
  91538. load(scene: Scene, onLoaded?: () => void): void;
  91539. private _queueLoad;
  91540. /**
  91541. * Invert the geometry to move from a right handed system to a left handed one.
  91542. */
  91543. toLeftHanded(): void;
  91544. /** @hidden */
  91545. _resetPointsArrayCache(): void;
  91546. /** @hidden */
  91547. _generatePointsArray(): boolean;
  91548. /**
  91549. * Gets a value indicating if the geometry is disposed
  91550. * @returns true if the geometry was disposed
  91551. */
  91552. isDisposed(): boolean;
  91553. private _disposeVertexArrayObjects;
  91554. /**
  91555. * Free all associated resources
  91556. */
  91557. dispose(): void;
  91558. /**
  91559. * Clone the current geometry into a new geometry
  91560. * @param id defines the unique ID of the new geometry
  91561. * @returns a new geometry object
  91562. */
  91563. copy(id: string): Geometry;
  91564. /**
  91565. * Serialize the current geometry info (and not the vertices data) into a JSON object
  91566. * @return a JSON representation of the current geometry data (without the vertices data)
  91567. */
  91568. serialize(): any;
  91569. private toNumberArray;
  91570. /**
  91571. * Serialize all vertices data into a JSON oject
  91572. * @returns a JSON representation of the current geometry data
  91573. */
  91574. serializeVerticeData(): any;
  91575. /**
  91576. * Extracts a clone of a mesh geometry
  91577. * @param mesh defines the source mesh
  91578. * @param id defines the unique ID of the new geometry object
  91579. * @returns the new geometry object
  91580. */
  91581. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  91582. /**
  91583. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  91584. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91585. * Be aware Math.random() could cause collisions, but:
  91586. * "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"
  91587. * @returns a string containing a new GUID
  91588. */
  91589. static RandomId(): string;
  91590. /** @hidden */
  91591. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  91592. private static _CleanMatricesWeights;
  91593. /**
  91594. * Create a new geometry from persisted data (Using .babylon file format)
  91595. * @param parsedVertexData defines the persisted data
  91596. * @param scene defines the hosting scene
  91597. * @param rootUrl defines the root url to use to load assets (like delayed data)
  91598. * @returns the new geometry object
  91599. */
  91600. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  91601. }
  91602. }
  91603. declare module BABYLON {
  91604. /**
  91605. * Define an interface for all classes that will get and set the data on vertices
  91606. */
  91607. export interface IGetSetVerticesData {
  91608. /**
  91609. * Gets a boolean indicating if specific vertex data is present
  91610. * @param kind defines the vertex data kind to use
  91611. * @returns true is data kind is present
  91612. */
  91613. isVerticesDataPresent(kind: string): boolean;
  91614. /**
  91615. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  91616. * @param kind defines the data kind (Position, normal, etc...)
  91617. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  91618. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91619. * @returns a float array containing vertex data
  91620. */
  91621. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91622. /**
  91623. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91624. * @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.
  91625. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91626. * @returns the indices array or an empty array if the mesh has no geometry
  91627. */
  91628. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91629. /**
  91630. * Set specific vertex data
  91631. * @param kind defines the data kind (Position, normal, etc...)
  91632. * @param data defines the vertex data to use
  91633. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  91634. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  91635. */
  91636. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  91637. /**
  91638. * Update a specific associated vertex buffer
  91639. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91640. * - VertexBuffer.PositionKind
  91641. * - VertexBuffer.UVKind
  91642. * - VertexBuffer.UV2Kind
  91643. * - VertexBuffer.UV3Kind
  91644. * - VertexBuffer.UV4Kind
  91645. * - VertexBuffer.UV5Kind
  91646. * - VertexBuffer.UV6Kind
  91647. * - VertexBuffer.ColorKind
  91648. * - VertexBuffer.MatricesIndicesKind
  91649. * - VertexBuffer.MatricesIndicesExtraKind
  91650. * - VertexBuffer.MatricesWeightsKind
  91651. * - VertexBuffer.MatricesWeightsExtraKind
  91652. * @param data defines the data source
  91653. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91654. * @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)
  91655. */
  91656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  91657. /**
  91658. * Creates a new index buffer
  91659. * @param indices defines the indices to store in the index buffer
  91660. * @param totalVertices defines the total number of vertices (could be null)
  91661. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  91662. */
  91663. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  91664. }
  91665. /**
  91666. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  91667. */
  91668. export class VertexData {
  91669. /**
  91670. * Mesh side orientation : usually the external or front surface
  91671. */
  91672. static readonly FRONTSIDE: number;
  91673. /**
  91674. * Mesh side orientation : usually the internal or back surface
  91675. */
  91676. static readonly BACKSIDE: number;
  91677. /**
  91678. * Mesh side orientation : both internal and external or front and back surfaces
  91679. */
  91680. static readonly DOUBLESIDE: number;
  91681. /**
  91682. * Mesh side orientation : by default, `FRONTSIDE`
  91683. */
  91684. static readonly DEFAULTSIDE: number;
  91685. /**
  91686. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  91687. */
  91688. positions: Nullable<FloatArray>;
  91689. /**
  91690. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  91691. */
  91692. normals: Nullable<FloatArray>;
  91693. /**
  91694. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  91695. */
  91696. tangents: Nullable<FloatArray>;
  91697. /**
  91698. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91699. */
  91700. uvs: Nullable<FloatArray>;
  91701. /**
  91702. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91703. */
  91704. uvs2: Nullable<FloatArray>;
  91705. /**
  91706. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91707. */
  91708. uvs3: Nullable<FloatArray>;
  91709. /**
  91710. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91711. */
  91712. uvs4: Nullable<FloatArray>;
  91713. /**
  91714. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91715. */
  91716. uvs5: Nullable<FloatArray>;
  91717. /**
  91718. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91719. */
  91720. uvs6: Nullable<FloatArray>;
  91721. /**
  91722. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  91723. */
  91724. colors: Nullable<FloatArray>;
  91725. /**
  91726. * 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).
  91727. */
  91728. matricesIndices: Nullable<FloatArray>;
  91729. /**
  91730. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  91731. */
  91732. matricesWeights: Nullable<FloatArray>;
  91733. /**
  91734. * An array extending the number of possible indices
  91735. */
  91736. matricesIndicesExtra: Nullable<FloatArray>;
  91737. /**
  91738. * An array extending the number of possible weights when the number of indices is extended
  91739. */
  91740. matricesWeightsExtra: Nullable<FloatArray>;
  91741. /**
  91742. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  91743. */
  91744. indices: Nullable<IndicesArray>;
  91745. /**
  91746. * Uses the passed data array to set the set the values for the specified kind of data
  91747. * @param data a linear array of floating numbers
  91748. * @param kind the type of data that is being set, eg positions, colors etc
  91749. */
  91750. set(data: FloatArray, kind: string): void;
  91751. /**
  91752. * Associates the vertexData to the passed Mesh.
  91753. * Sets it as updatable or not (default `false`)
  91754. * @param mesh the mesh the vertexData is applied to
  91755. * @param updatable when used and having the value true allows new data to update the vertexData
  91756. * @returns the VertexData
  91757. */
  91758. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  91759. /**
  91760. * Associates the vertexData to the passed Geometry.
  91761. * Sets it as updatable or not (default `false`)
  91762. * @param geometry the geometry the vertexData is applied to
  91763. * @param updatable when used and having the value true allows new data to update the vertexData
  91764. * @returns VertexData
  91765. */
  91766. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  91767. /**
  91768. * Updates the associated mesh
  91769. * @param mesh the mesh to be updated
  91770. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91771. * @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
  91772. * @returns VertexData
  91773. */
  91774. updateMesh(mesh: Mesh): VertexData;
  91775. /**
  91776. * Updates the associated geometry
  91777. * @param geometry the geometry to be updated
  91778. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91779. * @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
  91780. * @returns VertexData.
  91781. */
  91782. updateGeometry(geometry: Geometry): VertexData;
  91783. private _applyTo;
  91784. private _update;
  91785. /**
  91786. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91787. * @param matrix the transforming matrix
  91788. * @returns the VertexData
  91789. */
  91790. transform(matrix: Matrix): VertexData;
  91791. /**
  91792. * Merges the passed VertexData into the current one
  91793. * @param other the VertexData to be merged into the current one
  91794. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91795. * @returns the modified VertexData
  91796. */
  91797. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  91798. private _mergeElement;
  91799. private _validate;
  91800. /**
  91801. * Serializes the VertexData
  91802. * @returns a serialized object
  91803. */
  91804. serialize(): any;
  91805. /**
  91806. * Extracts the vertexData from a mesh
  91807. * @param mesh the mesh from which to extract the VertexData
  91808. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91809. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91810. * @returns the object VertexData associated to the passed mesh
  91811. */
  91812. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91813. /**
  91814. * Extracts the vertexData from the geometry
  91815. * @param geometry the geometry from which to extract the VertexData
  91816. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91817. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91818. * @returns the object VertexData associated to the passed mesh
  91819. */
  91820. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91821. private static _ExtractFrom;
  91822. /**
  91823. * Creates the VertexData for a Ribbon
  91824. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91825. * * pathArray array of paths, each of which an array of successive Vector3
  91826. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91827. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91828. * * 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
  91829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91830. * * 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)
  91831. * * 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)
  91832. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91833. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91834. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91835. * @returns the VertexData of the ribbon
  91836. */
  91837. static CreateRibbon(options: {
  91838. pathArray: Vector3[][];
  91839. closeArray?: boolean;
  91840. closePath?: boolean;
  91841. offset?: number;
  91842. sideOrientation?: number;
  91843. frontUVs?: Vector4;
  91844. backUVs?: Vector4;
  91845. invertUV?: boolean;
  91846. uvs?: Vector2[];
  91847. colors?: Color4[];
  91848. }): VertexData;
  91849. /**
  91850. * Creates the VertexData for a box
  91851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91852. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91853. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91854. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91855. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91856. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91857. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91859. * * 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)
  91860. * * 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)
  91861. * @returns the VertexData of the box
  91862. */
  91863. static CreateBox(options: {
  91864. size?: number;
  91865. width?: number;
  91866. height?: number;
  91867. depth?: number;
  91868. faceUV?: Vector4[];
  91869. faceColors?: Color4[];
  91870. sideOrientation?: number;
  91871. frontUVs?: Vector4;
  91872. backUVs?: Vector4;
  91873. }): VertexData;
  91874. /**
  91875. * Creates the VertexData for a tiled box
  91876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91877. * * faceTiles sets the pattern, tile size and number of tiles for a face
  91878. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91879. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91881. * @returns the VertexData of the box
  91882. */
  91883. static CreateTiledBox(options: {
  91884. pattern?: number;
  91885. width?: number;
  91886. height?: number;
  91887. depth?: number;
  91888. tileSize?: number;
  91889. tileWidth?: number;
  91890. tileHeight?: number;
  91891. alignHorizontal?: number;
  91892. alignVertical?: number;
  91893. faceUV?: Vector4[];
  91894. faceColors?: Color4[];
  91895. sideOrientation?: number;
  91896. }): VertexData;
  91897. /**
  91898. * Creates the VertexData for a tiled plane
  91899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91900. * * pattern a limited pattern arrangement depending on the number
  91901. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  91902. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  91903. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  91904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91905. * * 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)
  91906. * * 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)
  91907. * @returns the VertexData of the tiled plane
  91908. */
  91909. static CreateTiledPlane(options: {
  91910. pattern?: number;
  91911. tileSize?: number;
  91912. tileWidth?: number;
  91913. tileHeight?: number;
  91914. size?: number;
  91915. width?: number;
  91916. height?: number;
  91917. alignHorizontal?: number;
  91918. alignVertical?: number;
  91919. sideOrientation?: number;
  91920. frontUVs?: Vector4;
  91921. backUVs?: Vector4;
  91922. }): VertexData;
  91923. /**
  91924. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91925. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91926. * * segments sets the number of horizontal strips optional, default 32
  91927. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91928. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91929. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91930. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91931. * * 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
  91932. * * 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
  91933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91934. * * 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)
  91935. * * 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)
  91936. * @returns the VertexData of the ellipsoid
  91937. */
  91938. static CreateSphere(options: {
  91939. segments?: number;
  91940. diameter?: number;
  91941. diameterX?: number;
  91942. diameterY?: number;
  91943. diameterZ?: number;
  91944. arc?: number;
  91945. slice?: number;
  91946. sideOrientation?: number;
  91947. frontUVs?: Vector4;
  91948. backUVs?: Vector4;
  91949. }): VertexData;
  91950. /**
  91951. * Creates the VertexData for a cylinder, cone or prism
  91952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91953. * * height sets the height (y direction) of the cylinder, optional, default 2
  91954. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91955. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91956. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91957. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91958. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91959. * * 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
  91960. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91961. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91962. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91963. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91964. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91965. * * 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)
  91966. * * 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)
  91967. * @returns the VertexData of the cylinder, cone or prism
  91968. */
  91969. static CreateCylinder(options: {
  91970. height?: number;
  91971. diameterTop?: number;
  91972. diameterBottom?: number;
  91973. diameter?: number;
  91974. tessellation?: number;
  91975. subdivisions?: number;
  91976. arc?: number;
  91977. faceColors?: Color4[];
  91978. faceUV?: Vector4[];
  91979. hasRings?: boolean;
  91980. enclose?: boolean;
  91981. sideOrientation?: number;
  91982. frontUVs?: Vector4;
  91983. backUVs?: Vector4;
  91984. }): VertexData;
  91985. /**
  91986. * Creates the VertexData for a torus
  91987. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91988. * * diameter the diameter of the torus, optional default 1
  91989. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91990. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91992. * * 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)
  91993. * * 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)
  91994. * @returns the VertexData of the torus
  91995. */
  91996. static CreateTorus(options: {
  91997. diameter?: number;
  91998. thickness?: number;
  91999. tessellation?: number;
  92000. sideOrientation?: number;
  92001. frontUVs?: Vector4;
  92002. backUVs?: Vector4;
  92003. }): VertexData;
  92004. /**
  92005. * Creates the VertexData of the LineSystem
  92006. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92007. * - lines an array of lines, each line being an array of successive Vector3
  92008. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92009. * @returns the VertexData of the LineSystem
  92010. */
  92011. static CreateLineSystem(options: {
  92012. lines: Vector3[][];
  92013. colors?: Nullable<Color4[][]>;
  92014. }): VertexData;
  92015. /**
  92016. * Create the VertexData for a DashedLines
  92017. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92018. * - points an array successive Vector3
  92019. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92020. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92021. * - dashNb the intended total number of dashes, optional, default 200
  92022. * @returns the VertexData for the DashedLines
  92023. */
  92024. static CreateDashedLines(options: {
  92025. points: Vector3[];
  92026. dashSize?: number;
  92027. gapSize?: number;
  92028. dashNb?: number;
  92029. }): VertexData;
  92030. /**
  92031. * Creates the VertexData for a Ground
  92032. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92033. * - width the width (x direction) of the ground, optional, default 1
  92034. * - height the height (z direction) of the ground, optional, default 1
  92035. * - subdivisions the number of subdivisions per side, optional, default 1
  92036. * @returns the VertexData of the Ground
  92037. */
  92038. static CreateGround(options: {
  92039. width?: number;
  92040. height?: number;
  92041. subdivisions?: number;
  92042. subdivisionsX?: number;
  92043. subdivisionsY?: number;
  92044. }): VertexData;
  92045. /**
  92046. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92047. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92048. * * xmin the ground minimum X coordinate, optional, default -1
  92049. * * zmin the ground minimum Z coordinate, optional, default -1
  92050. * * xmax the ground maximum X coordinate, optional, default 1
  92051. * * zmax the ground maximum Z coordinate, optional, default 1
  92052. * * 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}
  92053. * * 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}
  92054. * @returns the VertexData of the TiledGround
  92055. */
  92056. static CreateTiledGround(options: {
  92057. xmin: number;
  92058. zmin: number;
  92059. xmax: number;
  92060. zmax: number;
  92061. subdivisions?: {
  92062. w: number;
  92063. h: number;
  92064. };
  92065. precision?: {
  92066. w: number;
  92067. h: number;
  92068. };
  92069. }): VertexData;
  92070. /**
  92071. * Creates the VertexData of the Ground designed from a heightmap
  92072. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92073. * * width the width (x direction) of the ground
  92074. * * height the height (z direction) of the ground
  92075. * * subdivisions the number of subdivisions per side
  92076. * * minHeight the minimum altitude on the ground, optional, default 0
  92077. * * maxHeight the maximum altitude on the ground, optional default 1
  92078. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92079. * * buffer the array holding the image color data
  92080. * * bufferWidth the width of image
  92081. * * bufferHeight the height of image
  92082. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92083. * @returns the VertexData of the Ground designed from a heightmap
  92084. */
  92085. static CreateGroundFromHeightMap(options: {
  92086. width: number;
  92087. height: number;
  92088. subdivisions: number;
  92089. minHeight: number;
  92090. maxHeight: number;
  92091. colorFilter: Color3;
  92092. buffer: Uint8Array;
  92093. bufferWidth: number;
  92094. bufferHeight: number;
  92095. alphaFilter: number;
  92096. }): VertexData;
  92097. /**
  92098. * Creates the VertexData for a Plane
  92099. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92100. * * size sets the width and height of the plane to the value of size, optional default 1
  92101. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92102. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92104. * * 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)
  92105. * * 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)
  92106. * @returns the VertexData of the box
  92107. */
  92108. static CreatePlane(options: {
  92109. size?: number;
  92110. width?: number;
  92111. height?: number;
  92112. sideOrientation?: number;
  92113. frontUVs?: Vector4;
  92114. backUVs?: Vector4;
  92115. }): VertexData;
  92116. /**
  92117. * Creates the VertexData of the Disc or regular Polygon
  92118. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92119. * * radius the radius of the disc, optional default 0.5
  92120. * * tessellation the number of polygon sides, optional, default 64
  92121. * * 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
  92122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92123. * * 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)
  92124. * * 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)
  92125. * @returns the VertexData of the box
  92126. */
  92127. static CreateDisc(options: {
  92128. radius?: number;
  92129. tessellation?: number;
  92130. arc?: number;
  92131. sideOrientation?: number;
  92132. frontUVs?: Vector4;
  92133. backUVs?: Vector4;
  92134. }): VertexData;
  92135. /**
  92136. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92137. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92138. * @param polygon a mesh built from polygonTriangulation.build()
  92139. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92140. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92141. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92142. * @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)
  92143. * @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)
  92144. * @returns the VertexData of the Polygon
  92145. */
  92146. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92147. /**
  92148. * Creates the VertexData of the IcoSphere
  92149. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92150. * * radius the radius of the IcoSphere, optional default 1
  92151. * * radiusX allows stretching in the x direction, optional, default radius
  92152. * * radiusY allows stretching in the y direction, optional, default radius
  92153. * * radiusZ allows stretching in the z direction, optional, default radius
  92154. * * flat when true creates a flat shaded mesh, optional, default true
  92155. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92157. * * 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)
  92158. * * 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)
  92159. * @returns the VertexData of the IcoSphere
  92160. */
  92161. static CreateIcoSphere(options: {
  92162. radius?: number;
  92163. radiusX?: number;
  92164. radiusY?: number;
  92165. radiusZ?: number;
  92166. flat?: boolean;
  92167. subdivisions?: number;
  92168. sideOrientation?: number;
  92169. frontUVs?: Vector4;
  92170. backUVs?: Vector4;
  92171. }): VertexData;
  92172. /**
  92173. * Creates the VertexData for a Polyhedron
  92174. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92175. * * type provided types are:
  92176. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92177. * * 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)
  92178. * * size the size of the IcoSphere, optional default 1
  92179. * * sizeX allows stretching in the x direction, optional, default size
  92180. * * sizeY allows stretching in the y direction, optional, default size
  92181. * * sizeZ allows stretching in the z direction, optional, default size
  92182. * * 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
  92183. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92184. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92185. * * flat when true creates a flat shaded mesh, optional, default true
  92186. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92188. * * 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)
  92189. * * 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)
  92190. * @returns the VertexData of the Polyhedron
  92191. */
  92192. static CreatePolyhedron(options: {
  92193. type?: number;
  92194. size?: number;
  92195. sizeX?: number;
  92196. sizeY?: number;
  92197. sizeZ?: number;
  92198. custom?: any;
  92199. faceUV?: Vector4[];
  92200. faceColors?: Color4[];
  92201. flat?: boolean;
  92202. sideOrientation?: number;
  92203. frontUVs?: Vector4;
  92204. backUVs?: Vector4;
  92205. }): VertexData;
  92206. /**
  92207. * Creates the VertexData for a TorusKnot
  92208. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  92209. * * radius the radius of the torus knot, optional, default 2
  92210. * * tube the thickness of the tube, optional, default 0.5
  92211. * * radialSegments the number of sides on each tube segments, optional, default 32
  92212. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  92213. * * p the number of windings around the z axis, optional, default 2
  92214. * * q the number of windings around the x axis, optional, default 3
  92215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92216. * * 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)
  92217. * * 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)
  92218. * @returns the VertexData of the Torus Knot
  92219. */
  92220. static CreateTorusKnot(options: {
  92221. radius?: number;
  92222. tube?: number;
  92223. radialSegments?: number;
  92224. tubularSegments?: number;
  92225. p?: number;
  92226. q?: number;
  92227. sideOrientation?: number;
  92228. frontUVs?: Vector4;
  92229. backUVs?: Vector4;
  92230. }): VertexData;
  92231. /**
  92232. * Compute normals for given positions and indices
  92233. * @param positions an array of vertex positions, [...., x, y, z, ......]
  92234. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  92235. * @param normals an array of vertex normals, [...., x, y, z, ......]
  92236. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  92237. * * facetNormals : optional array of facet normals (vector3)
  92238. * * facetPositions : optional array of facet positions (vector3)
  92239. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  92240. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  92241. * * bInfo : optional bounding info, required for facetPartitioning computation
  92242. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  92243. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  92244. * * useRightHandedSystem: optional boolean to for right handed system computation
  92245. * * depthSort : optional boolean to enable the facet depth sort computation
  92246. * * distanceTo : optional Vector3 to compute the facet depth from this location
  92247. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  92248. */
  92249. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  92250. facetNormals?: any;
  92251. facetPositions?: any;
  92252. facetPartitioning?: any;
  92253. ratio?: number;
  92254. bInfo?: any;
  92255. bbSize?: Vector3;
  92256. subDiv?: any;
  92257. useRightHandedSystem?: boolean;
  92258. depthSort?: boolean;
  92259. distanceTo?: Vector3;
  92260. depthSortedFacets?: any;
  92261. }): void;
  92262. /** @hidden */
  92263. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  92264. /**
  92265. * Applies VertexData created from the imported parameters to the geometry
  92266. * @param parsedVertexData the parsed data from an imported file
  92267. * @param geometry the geometry to apply the VertexData to
  92268. */
  92269. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  92270. }
  92271. }
  92272. declare module BABYLON {
  92273. /**
  92274. * Defines a target to use with MorphTargetManager
  92275. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92276. */
  92277. export class MorphTarget implements IAnimatable {
  92278. /** defines the name of the target */
  92279. name: string;
  92280. /**
  92281. * Gets or sets the list of animations
  92282. */
  92283. animations: Animation[];
  92284. private _scene;
  92285. private _positions;
  92286. private _normals;
  92287. private _tangents;
  92288. private _uvs;
  92289. private _influence;
  92290. private _uniqueId;
  92291. /**
  92292. * Observable raised when the influence changes
  92293. */
  92294. onInfluenceChanged: Observable<boolean>;
  92295. /** @hidden */
  92296. _onDataLayoutChanged: Observable<void>;
  92297. /**
  92298. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  92299. */
  92300. influence: number;
  92301. /**
  92302. * Gets or sets the id of the morph Target
  92303. */
  92304. id: string;
  92305. private _animationPropertiesOverride;
  92306. /**
  92307. * Gets or sets the animation properties override
  92308. */
  92309. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92310. /**
  92311. * Creates a new MorphTarget
  92312. * @param name defines the name of the target
  92313. * @param influence defines the influence to use
  92314. * @param scene defines the scene the morphtarget belongs to
  92315. */
  92316. constructor(
  92317. /** defines the name of the target */
  92318. name: string, influence?: number, scene?: Nullable<Scene>);
  92319. /**
  92320. * Gets the unique ID of this manager
  92321. */
  92322. readonly uniqueId: number;
  92323. /**
  92324. * Gets a boolean defining if the target contains position data
  92325. */
  92326. readonly hasPositions: boolean;
  92327. /**
  92328. * Gets a boolean defining if the target contains normal data
  92329. */
  92330. readonly hasNormals: boolean;
  92331. /**
  92332. * Gets a boolean defining if the target contains tangent data
  92333. */
  92334. readonly hasTangents: boolean;
  92335. /**
  92336. * Gets a boolean defining if the target contains texture coordinates data
  92337. */
  92338. readonly hasUVs: boolean;
  92339. /**
  92340. * Affects position data to this target
  92341. * @param data defines the position data to use
  92342. */
  92343. setPositions(data: Nullable<FloatArray>): void;
  92344. /**
  92345. * Gets the position data stored in this target
  92346. * @returns a FloatArray containing the position data (or null if not present)
  92347. */
  92348. getPositions(): Nullable<FloatArray>;
  92349. /**
  92350. * Affects normal data to this target
  92351. * @param data defines the normal data to use
  92352. */
  92353. setNormals(data: Nullable<FloatArray>): void;
  92354. /**
  92355. * Gets the normal data stored in this target
  92356. * @returns a FloatArray containing the normal data (or null if not present)
  92357. */
  92358. getNormals(): Nullable<FloatArray>;
  92359. /**
  92360. * Affects tangent data to this target
  92361. * @param data defines the tangent data to use
  92362. */
  92363. setTangents(data: Nullable<FloatArray>): void;
  92364. /**
  92365. * Gets the tangent data stored in this target
  92366. * @returns a FloatArray containing the tangent data (or null if not present)
  92367. */
  92368. getTangents(): Nullable<FloatArray>;
  92369. /**
  92370. * Affects texture coordinates data to this target
  92371. * @param data defines the texture coordinates data to use
  92372. */
  92373. setUVs(data: Nullable<FloatArray>): void;
  92374. /**
  92375. * Gets the texture coordinates data stored in this target
  92376. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  92377. */
  92378. getUVs(): Nullable<FloatArray>;
  92379. /**
  92380. * Clone the current target
  92381. * @returns a new MorphTarget
  92382. */
  92383. clone(): MorphTarget;
  92384. /**
  92385. * Serializes the current target into a Serialization object
  92386. * @returns the serialized object
  92387. */
  92388. serialize(): any;
  92389. /**
  92390. * Returns the string "MorphTarget"
  92391. * @returns "MorphTarget"
  92392. */
  92393. getClassName(): string;
  92394. /**
  92395. * Creates a new target from serialized data
  92396. * @param serializationObject defines the serialized data to use
  92397. * @returns a new MorphTarget
  92398. */
  92399. static Parse(serializationObject: any): MorphTarget;
  92400. /**
  92401. * Creates a MorphTarget from mesh data
  92402. * @param mesh defines the source mesh
  92403. * @param name defines the name to use for the new target
  92404. * @param influence defines the influence to attach to the target
  92405. * @returns a new MorphTarget
  92406. */
  92407. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  92408. }
  92409. }
  92410. declare module BABYLON {
  92411. /**
  92412. * This class is used to deform meshes using morphing between different targets
  92413. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92414. */
  92415. export class MorphTargetManager {
  92416. private _targets;
  92417. private _targetInfluenceChangedObservers;
  92418. private _targetDataLayoutChangedObservers;
  92419. private _activeTargets;
  92420. private _scene;
  92421. private _influences;
  92422. private _supportsNormals;
  92423. private _supportsTangents;
  92424. private _supportsUVs;
  92425. private _vertexCount;
  92426. private _uniqueId;
  92427. private _tempInfluences;
  92428. /**
  92429. * Gets or sets a boolean indicating if normals must be morphed
  92430. */
  92431. enableNormalMorphing: boolean;
  92432. /**
  92433. * Gets or sets a boolean indicating if tangents must be morphed
  92434. */
  92435. enableTangentMorphing: boolean;
  92436. /**
  92437. * Gets or sets a boolean indicating if UV must be morphed
  92438. */
  92439. enableUVMorphing: boolean;
  92440. /**
  92441. * Creates a new MorphTargetManager
  92442. * @param scene defines the current scene
  92443. */
  92444. constructor(scene?: Nullable<Scene>);
  92445. /**
  92446. * Gets the unique ID of this manager
  92447. */
  92448. readonly uniqueId: number;
  92449. /**
  92450. * Gets the number of vertices handled by this manager
  92451. */
  92452. readonly vertexCount: number;
  92453. /**
  92454. * Gets a boolean indicating if this manager supports morphing of normals
  92455. */
  92456. readonly supportsNormals: boolean;
  92457. /**
  92458. * Gets a boolean indicating if this manager supports morphing of tangents
  92459. */
  92460. readonly supportsTangents: boolean;
  92461. /**
  92462. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  92463. */
  92464. readonly supportsUVs: boolean;
  92465. /**
  92466. * Gets the number of targets stored in this manager
  92467. */
  92468. readonly numTargets: number;
  92469. /**
  92470. * Gets the number of influencers (ie. the number of targets with influences > 0)
  92471. */
  92472. readonly numInfluencers: number;
  92473. /**
  92474. * Gets the list of influences (one per target)
  92475. */
  92476. readonly influences: Float32Array;
  92477. /**
  92478. * Gets the active target at specified index. An active target is a target with an influence > 0
  92479. * @param index defines the index to check
  92480. * @returns the requested target
  92481. */
  92482. getActiveTarget(index: number): MorphTarget;
  92483. /**
  92484. * Gets the target at specified index
  92485. * @param index defines the index to check
  92486. * @returns the requested target
  92487. */
  92488. getTarget(index: number): MorphTarget;
  92489. /**
  92490. * Add a new target to this manager
  92491. * @param target defines the target to add
  92492. */
  92493. addTarget(target: MorphTarget): void;
  92494. /**
  92495. * Removes a target from the manager
  92496. * @param target defines the target to remove
  92497. */
  92498. removeTarget(target: MorphTarget): void;
  92499. /**
  92500. * Clone the current manager
  92501. * @returns a new MorphTargetManager
  92502. */
  92503. clone(): MorphTargetManager;
  92504. /**
  92505. * Serializes the current manager into a Serialization object
  92506. * @returns the serialized object
  92507. */
  92508. serialize(): any;
  92509. private _syncActiveTargets;
  92510. /**
  92511. * Syncrhonize the targets with all the meshes using this morph target manager
  92512. */
  92513. synchronize(): void;
  92514. /**
  92515. * Creates a new MorphTargetManager from serialized data
  92516. * @param serializationObject defines the serialized data
  92517. * @param scene defines the hosting scene
  92518. * @returns the new MorphTargetManager
  92519. */
  92520. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  92521. }
  92522. }
  92523. declare module BABYLON {
  92524. /**
  92525. * Class used to represent a specific level of detail of a mesh
  92526. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92527. */
  92528. export class MeshLODLevel {
  92529. /** Defines the distance where this level should start being displayed */
  92530. distance: number;
  92531. /** Defines the mesh to use to render this level */
  92532. mesh: Nullable<Mesh>;
  92533. /**
  92534. * Creates a new LOD level
  92535. * @param distance defines the distance where this level should star being displayed
  92536. * @param mesh defines the mesh to use to render this level
  92537. */
  92538. constructor(
  92539. /** Defines the distance where this level should start being displayed */
  92540. distance: number,
  92541. /** Defines the mesh to use to render this level */
  92542. mesh: Nullable<Mesh>);
  92543. }
  92544. }
  92545. declare module BABYLON {
  92546. /**
  92547. * Mesh representing the gorund
  92548. */
  92549. export class GroundMesh extends Mesh {
  92550. /** If octree should be generated */
  92551. generateOctree: boolean;
  92552. private _heightQuads;
  92553. /** @hidden */
  92554. _subdivisionsX: number;
  92555. /** @hidden */
  92556. _subdivisionsY: number;
  92557. /** @hidden */
  92558. _width: number;
  92559. /** @hidden */
  92560. _height: number;
  92561. /** @hidden */
  92562. _minX: number;
  92563. /** @hidden */
  92564. _maxX: number;
  92565. /** @hidden */
  92566. _minZ: number;
  92567. /** @hidden */
  92568. _maxZ: number;
  92569. constructor(name: string, scene: Scene);
  92570. /**
  92571. * "GroundMesh"
  92572. * @returns "GroundMesh"
  92573. */
  92574. getClassName(): string;
  92575. /**
  92576. * The minimum of x and y subdivisions
  92577. */
  92578. readonly subdivisions: number;
  92579. /**
  92580. * X subdivisions
  92581. */
  92582. readonly subdivisionsX: number;
  92583. /**
  92584. * Y subdivisions
  92585. */
  92586. readonly subdivisionsY: number;
  92587. /**
  92588. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  92589. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  92590. * @param chunksCount the number of subdivisions for x and y
  92591. * @param octreeBlocksSize (Default: 32)
  92592. */
  92593. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  92594. /**
  92595. * Returns a height (y) value in the Worl system :
  92596. * the ground altitude at the coordinates (x, z) expressed in the World system.
  92597. * @param x x coordinate
  92598. * @param z z coordinate
  92599. * @returns the ground y position if (x, z) are outside the ground surface.
  92600. */
  92601. getHeightAtCoordinates(x: number, z: number): number;
  92602. /**
  92603. * Returns a normalized vector (Vector3) orthogonal to the ground
  92604. * at the ground coordinates (x, z) expressed in the World system.
  92605. * @param x x coordinate
  92606. * @param z z coordinate
  92607. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  92608. */
  92609. getNormalAtCoordinates(x: number, z: number): Vector3;
  92610. /**
  92611. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  92612. * at the ground coordinates (x, z) expressed in the World system.
  92613. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  92614. * @param x x coordinate
  92615. * @param z z coordinate
  92616. * @param ref vector to store the result
  92617. * @returns the GroundMesh.
  92618. */
  92619. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  92620. /**
  92621. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  92622. * if the ground has been updated.
  92623. * This can be used in the render loop.
  92624. * @returns the GroundMesh.
  92625. */
  92626. updateCoordinateHeights(): GroundMesh;
  92627. private _getFacetAt;
  92628. private _initHeightQuads;
  92629. private _computeHeightQuads;
  92630. /**
  92631. * Serializes this ground mesh
  92632. * @param serializationObject object to write serialization to
  92633. */
  92634. serialize(serializationObject: any): void;
  92635. /**
  92636. * Parses a serialized ground mesh
  92637. * @param parsedMesh the serialized mesh
  92638. * @param scene the scene to create the ground mesh in
  92639. * @returns the created ground mesh
  92640. */
  92641. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  92642. }
  92643. }
  92644. declare module BABYLON {
  92645. /**
  92646. * Interface for Physics-Joint data
  92647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92648. */
  92649. export interface PhysicsJointData {
  92650. /**
  92651. * The main pivot of the joint
  92652. */
  92653. mainPivot?: Vector3;
  92654. /**
  92655. * The connected pivot of the joint
  92656. */
  92657. connectedPivot?: Vector3;
  92658. /**
  92659. * The main axis of the joint
  92660. */
  92661. mainAxis?: Vector3;
  92662. /**
  92663. * The connected axis of the joint
  92664. */
  92665. connectedAxis?: Vector3;
  92666. /**
  92667. * The collision of the joint
  92668. */
  92669. collision?: boolean;
  92670. /**
  92671. * Native Oimo/Cannon/Energy data
  92672. */
  92673. nativeParams?: any;
  92674. }
  92675. /**
  92676. * This is a holder class for the physics joint created by the physics plugin
  92677. * It holds a set of functions to control the underlying joint
  92678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92679. */
  92680. export class PhysicsJoint {
  92681. /**
  92682. * The type of the physics joint
  92683. */
  92684. type: number;
  92685. /**
  92686. * The data for the physics joint
  92687. */
  92688. jointData: PhysicsJointData;
  92689. private _physicsJoint;
  92690. protected _physicsPlugin: IPhysicsEnginePlugin;
  92691. /**
  92692. * Initializes the physics joint
  92693. * @param type The type of the physics joint
  92694. * @param jointData The data for the physics joint
  92695. */
  92696. constructor(
  92697. /**
  92698. * The type of the physics joint
  92699. */
  92700. type: number,
  92701. /**
  92702. * The data for the physics joint
  92703. */
  92704. jointData: PhysicsJointData);
  92705. /**
  92706. * Gets the physics joint
  92707. */
  92708. /**
  92709. * Sets the physics joint
  92710. */
  92711. physicsJoint: any;
  92712. /**
  92713. * Sets the physics plugin
  92714. */
  92715. physicsPlugin: IPhysicsEnginePlugin;
  92716. /**
  92717. * Execute a function that is physics-plugin specific.
  92718. * @param {Function} func the function that will be executed.
  92719. * It accepts two parameters: the physics world and the physics joint
  92720. */
  92721. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  92722. /**
  92723. * Distance-Joint type
  92724. */
  92725. static DistanceJoint: number;
  92726. /**
  92727. * Hinge-Joint type
  92728. */
  92729. static HingeJoint: number;
  92730. /**
  92731. * Ball-and-Socket joint type
  92732. */
  92733. static BallAndSocketJoint: number;
  92734. /**
  92735. * Wheel-Joint type
  92736. */
  92737. static WheelJoint: number;
  92738. /**
  92739. * Slider-Joint type
  92740. */
  92741. static SliderJoint: number;
  92742. /**
  92743. * Prismatic-Joint type
  92744. */
  92745. static PrismaticJoint: number;
  92746. /**
  92747. * Universal-Joint type
  92748. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  92749. */
  92750. static UniversalJoint: number;
  92751. /**
  92752. * Hinge-Joint 2 type
  92753. */
  92754. static Hinge2Joint: number;
  92755. /**
  92756. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  92757. */
  92758. static PointToPointJoint: number;
  92759. /**
  92760. * Spring-Joint type
  92761. */
  92762. static SpringJoint: number;
  92763. /**
  92764. * Lock-Joint type
  92765. */
  92766. static LockJoint: number;
  92767. }
  92768. /**
  92769. * A class representing a physics distance joint
  92770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92771. */
  92772. export class DistanceJoint extends PhysicsJoint {
  92773. /**
  92774. *
  92775. * @param jointData The data for the Distance-Joint
  92776. */
  92777. constructor(jointData: DistanceJointData);
  92778. /**
  92779. * Update the predefined distance.
  92780. * @param maxDistance The maximum preferred distance
  92781. * @param minDistance The minimum preferred distance
  92782. */
  92783. updateDistance(maxDistance: number, minDistance?: number): void;
  92784. }
  92785. /**
  92786. * Represents a Motor-Enabled Joint
  92787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92788. */
  92789. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  92790. /**
  92791. * Initializes the Motor-Enabled Joint
  92792. * @param type The type of the joint
  92793. * @param jointData The physica joint data for the joint
  92794. */
  92795. constructor(type: number, jointData: PhysicsJointData);
  92796. /**
  92797. * Set the motor values.
  92798. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92799. * @param force the force to apply
  92800. * @param maxForce max force for this motor.
  92801. */
  92802. setMotor(force?: number, maxForce?: number): void;
  92803. /**
  92804. * Set the motor's limits.
  92805. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92806. * @param upperLimit The upper limit of the motor
  92807. * @param lowerLimit The lower limit of the motor
  92808. */
  92809. setLimit(upperLimit: number, lowerLimit?: number): void;
  92810. }
  92811. /**
  92812. * This class represents a single physics Hinge-Joint
  92813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92814. */
  92815. export class HingeJoint extends MotorEnabledJoint {
  92816. /**
  92817. * Initializes the Hinge-Joint
  92818. * @param jointData The joint data for the Hinge-Joint
  92819. */
  92820. constructor(jointData: PhysicsJointData);
  92821. /**
  92822. * Set the motor values.
  92823. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92824. * @param {number} force the force to apply
  92825. * @param {number} maxForce max force for this motor.
  92826. */
  92827. setMotor(force?: number, maxForce?: number): void;
  92828. /**
  92829. * Set the motor's limits.
  92830. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92831. * @param upperLimit The upper limit of the motor
  92832. * @param lowerLimit The lower limit of the motor
  92833. */
  92834. setLimit(upperLimit: number, lowerLimit?: number): void;
  92835. }
  92836. /**
  92837. * This class represents a dual hinge physics joint (same as wheel joint)
  92838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92839. */
  92840. export class Hinge2Joint extends MotorEnabledJoint {
  92841. /**
  92842. * Initializes the Hinge2-Joint
  92843. * @param jointData The joint data for the Hinge2-Joint
  92844. */
  92845. constructor(jointData: PhysicsJointData);
  92846. /**
  92847. * Set the motor values.
  92848. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92849. * @param {number} targetSpeed the speed the motor is to reach
  92850. * @param {number} maxForce max force for this motor.
  92851. * @param {motorIndex} the motor's index, 0 or 1.
  92852. */
  92853. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  92854. /**
  92855. * Set the motor limits.
  92856. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92857. * @param {number} upperLimit the upper limit
  92858. * @param {number} lowerLimit lower limit
  92859. * @param {motorIndex} the motor's index, 0 or 1.
  92860. */
  92861. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92862. }
  92863. /**
  92864. * Interface for a motor enabled joint
  92865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92866. */
  92867. export interface IMotorEnabledJoint {
  92868. /**
  92869. * Physics joint
  92870. */
  92871. physicsJoint: any;
  92872. /**
  92873. * Sets the motor of the motor-enabled joint
  92874. * @param force The force of the motor
  92875. * @param maxForce The maximum force of the motor
  92876. * @param motorIndex The index of the motor
  92877. */
  92878. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  92879. /**
  92880. * Sets the limit of the motor
  92881. * @param upperLimit The upper limit of the motor
  92882. * @param lowerLimit The lower limit of the motor
  92883. * @param motorIndex The index of the motor
  92884. */
  92885. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92886. }
  92887. /**
  92888. * Joint data for a Distance-Joint
  92889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92890. */
  92891. export interface DistanceJointData extends PhysicsJointData {
  92892. /**
  92893. * Max distance the 2 joint objects can be apart
  92894. */
  92895. maxDistance: number;
  92896. }
  92897. /**
  92898. * Joint data from a spring joint
  92899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92900. */
  92901. export interface SpringJointData extends PhysicsJointData {
  92902. /**
  92903. * Length of the spring
  92904. */
  92905. length: number;
  92906. /**
  92907. * Stiffness of the spring
  92908. */
  92909. stiffness: number;
  92910. /**
  92911. * Damping of the spring
  92912. */
  92913. damping: number;
  92914. /** this callback will be called when applying the force to the impostors. */
  92915. forceApplicationCallback: () => void;
  92916. }
  92917. }
  92918. declare module BABYLON {
  92919. /**
  92920. * Holds the data for the raycast result
  92921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92922. */
  92923. export class PhysicsRaycastResult {
  92924. private _hasHit;
  92925. private _hitDistance;
  92926. private _hitNormalWorld;
  92927. private _hitPointWorld;
  92928. private _rayFromWorld;
  92929. private _rayToWorld;
  92930. /**
  92931. * Gets if there was a hit
  92932. */
  92933. readonly hasHit: boolean;
  92934. /**
  92935. * Gets the distance from the hit
  92936. */
  92937. readonly hitDistance: number;
  92938. /**
  92939. * Gets the hit normal/direction in the world
  92940. */
  92941. readonly hitNormalWorld: Vector3;
  92942. /**
  92943. * Gets the hit point in the world
  92944. */
  92945. readonly hitPointWorld: Vector3;
  92946. /**
  92947. * Gets the ray "start point" of the ray in the world
  92948. */
  92949. readonly rayFromWorld: Vector3;
  92950. /**
  92951. * Gets the ray "end point" of the ray in the world
  92952. */
  92953. readonly rayToWorld: Vector3;
  92954. /**
  92955. * Sets the hit data (normal & point in world space)
  92956. * @param hitNormalWorld defines the normal in world space
  92957. * @param hitPointWorld defines the point in world space
  92958. */
  92959. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  92960. /**
  92961. * Sets the distance from the start point to the hit point
  92962. * @param distance
  92963. */
  92964. setHitDistance(distance: number): void;
  92965. /**
  92966. * Calculates the distance manually
  92967. */
  92968. calculateHitDistance(): void;
  92969. /**
  92970. * Resets all the values to default
  92971. * @param from The from point on world space
  92972. * @param to The to point on world space
  92973. */
  92974. reset(from?: Vector3, to?: Vector3): void;
  92975. }
  92976. /**
  92977. * Interface for the size containing width and height
  92978. */
  92979. interface IXYZ {
  92980. /**
  92981. * X
  92982. */
  92983. x: number;
  92984. /**
  92985. * Y
  92986. */
  92987. y: number;
  92988. /**
  92989. * Z
  92990. */
  92991. z: number;
  92992. }
  92993. }
  92994. declare module BABYLON {
  92995. /**
  92996. * Interface used to describe a physics joint
  92997. */
  92998. export interface PhysicsImpostorJoint {
  92999. /** Defines the main impostor to which the joint is linked */
  93000. mainImpostor: PhysicsImpostor;
  93001. /** Defines the impostor that is connected to the main impostor using this joint */
  93002. connectedImpostor: PhysicsImpostor;
  93003. /** Defines the joint itself */
  93004. joint: PhysicsJoint;
  93005. }
  93006. /** @hidden */
  93007. export interface IPhysicsEnginePlugin {
  93008. world: any;
  93009. name: string;
  93010. setGravity(gravity: Vector3): void;
  93011. setTimeStep(timeStep: number): void;
  93012. getTimeStep(): number;
  93013. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93014. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93015. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93016. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93017. removePhysicsBody(impostor: PhysicsImpostor): void;
  93018. generateJoint(joint: PhysicsImpostorJoint): void;
  93019. removeJoint(joint: PhysicsImpostorJoint): void;
  93020. isSupported(): boolean;
  93021. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93022. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93023. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93024. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93025. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93026. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93027. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93028. getBodyMass(impostor: PhysicsImpostor): number;
  93029. getBodyFriction(impostor: PhysicsImpostor): number;
  93030. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93031. getBodyRestitution(impostor: PhysicsImpostor): number;
  93032. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93033. getBodyPressure?(impostor: PhysicsImpostor): number;
  93034. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93035. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93036. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93037. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93038. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93039. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93040. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93041. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93042. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93043. sleepBody(impostor: PhysicsImpostor): void;
  93044. wakeUpBody(impostor: PhysicsImpostor): void;
  93045. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93046. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93047. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93048. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93049. getRadius(impostor: PhysicsImpostor): number;
  93050. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93051. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93052. dispose(): void;
  93053. }
  93054. /**
  93055. * Interface used to define a physics engine
  93056. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93057. */
  93058. export interface IPhysicsEngine {
  93059. /**
  93060. * Gets the gravity vector used by the simulation
  93061. */
  93062. gravity: Vector3;
  93063. /**
  93064. * Sets the gravity vector used by the simulation
  93065. * @param gravity defines the gravity vector to use
  93066. */
  93067. setGravity(gravity: Vector3): void;
  93068. /**
  93069. * Set the time step of the physics engine.
  93070. * Default is 1/60.
  93071. * To slow it down, enter 1/600 for example.
  93072. * To speed it up, 1/30
  93073. * @param newTimeStep the new timestep to apply to this world.
  93074. */
  93075. setTimeStep(newTimeStep: number): void;
  93076. /**
  93077. * Get the time step of the physics engine.
  93078. * @returns the current time step
  93079. */
  93080. getTimeStep(): number;
  93081. /**
  93082. * Set the sub time step of the physics engine.
  93083. * Default is 0 meaning there is no sub steps
  93084. * To increase physics resolution precision, set a small value (like 1 ms)
  93085. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93086. */
  93087. setSubTimeStep(subTimeStep: number): void;
  93088. /**
  93089. * Get the sub time step of the physics engine.
  93090. * @returns the current sub time step
  93091. */
  93092. getSubTimeStep(): number;
  93093. /**
  93094. * Release all resources
  93095. */
  93096. dispose(): void;
  93097. /**
  93098. * Gets the name of the current physics plugin
  93099. * @returns the name of the plugin
  93100. */
  93101. getPhysicsPluginName(): string;
  93102. /**
  93103. * Adding a new impostor for the impostor tracking.
  93104. * This will be done by the impostor itself.
  93105. * @param impostor the impostor to add
  93106. */
  93107. addImpostor(impostor: PhysicsImpostor): void;
  93108. /**
  93109. * Remove an impostor from the engine.
  93110. * This impostor and its mesh will not longer be updated by the physics engine.
  93111. * @param impostor the impostor to remove
  93112. */
  93113. removeImpostor(impostor: PhysicsImpostor): void;
  93114. /**
  93115. * Add a joint to the physics engine
  93116. * @param mainImpostor defines the main impostor to which the joint is added.
  93117. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93118. * @param joint defines the joint that will connect both impostors.
  93119. */
  93120. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93121. /**
  93122. * Removes a joint from the simulation
  93123. * @param mainImpostor defines the impostor used with the joint
  93124. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93125. * @param joint defines the joint to remove
  93126. */
  93127. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93128. /**
  93129. * Gets the current plugin used to run the simulation
  93130. * @returns current plugin
  93131. */
  93132. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93133. /**
  93134. * Gets the list of physic impostors
  93135. * @returns an array of PhysicsImpostor
  93136. */
  93137. getImpostors(): Array<PhysicsImpostor>;
  93138. /**
  93139. * Gets the impostor for a physics enabled object
  93140. * @param object defines the object impersonated by the impostor
  93141. * @returns the PhysicsImpostor or null if not found
  93142. */
  93143. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93144. /**
  93145. * Gets the impostor for a physics body object
  93146. * @param body defines physics body used by the impostor
  93147. * @returns the PhysicsImpostor or null if not found
  93148. */
  93149. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93150. /**
  93151. * Does a raycast in the physics world
  93152. * @param from when should the ray start?
  93153. * @param to when should the ray end?
  93154. * @returns PhysicsRaycastResult
  93155. */
  93156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93157. /**
  93158. * Called by the scene. No need to call it.
  93159. * @param delta defines the timespam between frames
  93160. */
  93161. _step(delta: number): void;
  93162. }
  93163. }
  93164. declare module BABYLON {
  93165. /**
  93166. * The interface for the physics imposter parameters
  93167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93168. */
  93169. export interface PhysicsImpostorParameters {
  93170. /**
  93171. * The mass of the physics imposter
  93172. */
  93173. mass: number;
  93174. /**
  93175. * The friction of the physics imposter
  93176. */
  93177. friction?: number;
  93178. /**
  93179. * The coefficient of restitution of the physics imposter
  93180. */
  93181. restitution?: number;
  93182. /**
  93183. * The native options of the physics imposter
  93184. */
  93185. nativeOptions?: any;
  93186. /**
  93187. * Specifies if the parent should be ignored
  93188. */
  93189. ignoreParent?: boolean;
  93190. /**
  93191. * Specifies if bi-directional transformations should be disabled
  93192. */
  93193. disableBidirectionalTransformation?: boolean;
  93194. /**
  93195. * The pressure inside the physics imposter, soft object only
  93196. */
  93197. pressure?: number;
  93198. /**
  93199. * The stiffness the physics imposter, soft object only
  93200. */
  93201. stiffness?: number;
  93202. /**
  93203. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  93204. */
  93205. velocityIterations?: number;
  93206. /**
  93207. * The number of iterations used in maintaining consistent vertex positions, soft object only
  93208. */
  93209. positionIterations?: number;
  93210. /**
  93211. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  93212. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  93213. * Add to fix multiple points
  93214. */
  93215. fixedPoints?: number;
  93216. /**
  93217. * The collision margin around a soft object
  93218. */
  93219. margin?: number;
  93220. /**
  93221. * The collision margin around a soft object
  93222. */
  93223. damping?: number;
  93224. /**
  93225. * The path for a rope based on an extrusion
  93226. */
  93227. path?: any;
  93228. /**
  93229. * The shape of an extrusion used for a rope based on an extrusion
  93230. */
  93231. shape?: any;
  93232. }
  93233. /**
  93234. * Interface for a physics-enabled object
  93235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93236. */
  93237. export interface IPhysicsEnabledObject {
  93238. /**
  93239. * The position of the physics-enabled object
  93240. */
  93241. position: Vector3;
  93242. /**
  93243. * The rotation of the physics-enabled object
  93244. */
  93245. rotationQuaternion: Nullable<Quaternion>;
  93246. /**
  93247. * The scale of the physics-enabled object
  93248. */
  93249. scaling: Vector3;
  93250. /**
  93251. * The rotation of the physics-enabled object
  93252. */
  93253. rotation?: Vector3;
  93254. /**
  93255. * The parent of the physics-enabled object
  93256. */
  93257. parent?: any;
  93258. /**
  93259. * The bounding info of the physics-enabled object
  93260. * @returns The bounding info of the physics-enabled object
  93261. */
  93262. getBoundingInfo(): BoundingInfo;
  93263. /**
  93264. * Computes the world matrix
  93265. * @param force Specifies if the world matrix should be computed by force
  93266. * @returns A world matrix
  93267. */
  93268. computeWorldMatrix(force: boolean): Matrix;
  93269. /**
  93270. * Gets the world matrix
  93271. * @returns A world matrix
  93272. */
  93273. getWorldMatrix?(): Matrix;
  93274. /**
  93275. * Gets the child meshes
  93276. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  93277. * @returns An array of abstract meshes
  93278. */
  93279. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  93280. /**
  93281. * Gets the vertex data
  93282. * @param kind The type of vertex data
  93283. * @returns A nullable array of numbers, or a float32 array
  93284. */
  93285. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  93286. /**
  93287. * Gets the indices from the mesh
  93288. * @returns A nullable array of index arrays
  93289. */
  93290. getIndices?(): Nullable<IndicesArray>;
  93291. /**
  93292. * Gets the scene from the mesh
  93293. * @returns the indices array or null
  93294. */
  93295. getScene?(): Scene;
  93296. /**
  93297. * Gets the absolute position from the mesh
  93298. * @returns the absolute position
  93299. */
  93300. getAbsolutePosition(): Vector3;
  93301. /**
  93302. * Gets the absolute pivot point from the mesh
  93303. * @returns the absolute pivot point
  93304. */
  93305. getAbsolutePivotPoint(): Vector3;
  93306. /**
  93307. * Rotates the mesh
  93308. * @param axis The axis of rotation
  93309. * @param amount The amount of rotation
  93310. * @param space The space of the rotation
  93311. * @returns The rotation transform node
  93312. */
  93313. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93314. /**
  93315. * Translates the mesh
  93316. * @param axis The axis of translation
  93317. * @param distance The distance of translation
  93318. * @param space The space of the translation
  93319. * @returns The transform node
  93320. */
  93321. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93322. /**
  93323. * Sets the absolute position of the mesh
  93324. * @param absolutePosition The absolute position of the mesh
  93325. * @returns The transform node
  93326. */
  93327. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93328. /**
  93329. * Gets the class name of the mesh
  93330. * @returns The class name
  93331. */
  93332. getClassName(): string;
  93333. }
  93334. /**
  93335. * Represents a physics imposter
  93336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93337. */
  93338. export class PhysicsImpostor {
  93339. /**
  93340. * The physics-enabled object used as the physics imposter
  93341. */
  93342. object: IPhysicsEnabledObject;
  93343. /**
  93344. * The type of the physics imposter
  93345. */
  93346. type: number;
  93347. private _options;
  93348. private _scene?;
  93349. /**
  93350. * The default object size of the imposter
  93351. */
  93352. static DEFAULT_OBJECT_SIZE: Vector3;
  93353. /**
  93354. * The identity quaternion of the imposter
  93355. */
  93356. static IDENTITY_QUATERNION: Quaternion;
  93357. /** @hidden */
  93358. _pluginData: any;
  93359. private _physicsEngine;
  93360. private _physicsBody;
  93361. private _bodyUpdateRequired;
  93362. private _onBeforePhysicsStepCallbacks;
  93363. private _onAfterPhysicsStepCallbacks;
  93364. /** @hidden */
  93365. _onPhysicsCollideCallbacks: Array<{
  93366. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  93367. otherImpostors: Array<PhysicsImpostor>;
  93368. }>;
  93369. private _deltaPosition;
  93370. private _deltaRotation;
  93371. private _deltaRotationConjugated;
  93372. /** @hidden */
  93373. _isFromLine: boolean;
  93374. private _parent;
  93375. private _isDisposed;
  93376. private static _tmpVecs;
  93377. private static _tmpQuat;
  93378. /**
  93379. * Specifies if the physics imposter is disposed
  93380. */
  93381. readonly isDisposed: boolean;
  93382. /**
  93383. * Gets the mass of the physics imposter
  93384. */
  93385. mass: number;
  93386. /**
  93387. * Gets the coefficient of friction
  93388. */
  93389. /**
  93390. * Sets the coefficient of friction
  93391. */
  93392. friction: number;
  93393. /**
  93394. * Gets the coefficient of restitution
  93395. */
  93396. /**
  93397. * Sets the coefficient of restitution
  93398. */
  93399. restitution: number;
  93400. /**
  93401. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  93402. */
  93403. /**
  93404. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  93405. */
  93406. pressure: number;
  93407. /**
  93408. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  93409. */
  93410. /**
  93411. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  93412. */
  93413. stiffness: number;
  93414. /**
  93415. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  93416. */
  93417. /**
  93418. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  93419. */
  93420. velocityIterations: number;
  93421. /**
  93422. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  93423. */
  93424. /**
  93425. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  93426. */
  93427. positionIterations: number;
  93428. /**
  93429. * The unique id of the physics imposter
  93430. * set by the physics engine when adding this impostor to the array
  93431. */
  93432. uniqueId: number;
  93433. /**
  93434. * @hidden
  93435. */
  93436. soft: boolean;
  93437. /**
  93438. * @hidden
  93439. */
  93440. segments: number;
  93441. private _joints;
  93442. /**
  93443. * Initializes the physics imposter
  93444. * @param object The physics-enabled object used as the physics imposter
  93445. * @param type The type of the physics imposter
  93446. * @param _options The options for the physics imposter
  93447. * @param _scene The Babylon scene
  93448. */
  93449. constructor(
  93450. /**
  93451. * The physics-enabled object used as the physics imposter
  93452. */
  93453. object: IPhysicsEnabledObject,
  93454. /**
  93455. * The type of the physics imposter
  93456. */
  93457. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  93458. /**
  93459. * This function will completly initialize this impostor.
  93460. * It will create a new body - but only if this mesh has no parent.
  93461. * If it has, this impostor will not be used other than to define the impostor
  93462. * of the child mesh.
  93463. * @hidden
  93464. */
  93465. _init(): void;
  93466. private _getPhysicsParent;
  93467. /**
  93468. * Should a new body be generated.
  93469. * @returns boolean specifying if body initialization is required
  93470. */
  93471. isBodyInitRequired(): boolean;
  93472. /**
  93473. * Sets the updated scaling
  93474. * @param updated Specifies if the scaling is updated
  93475. */
  93476. setScalingUpdated(): void;
  93477. /**
  93478. * Force a regeneration of this or the parent's impostor's body.
  93479. * Use under cautious - This will remove all joints already implemented.
  93480. */
  93481. forceUpdate(): void;
  93482. /**
  93483. * Gets the body that holds this impostor. Either its own, or its parent.
  93484. */
  93485. /**
  93486. * Set the physics body. Used mainly by the physics engine/plugin
  93487. */
  93488. physicsBody: any;
  93489. /**
  93490. * Get the parent of the physics imposter
  93491. * @returns Physics imposter or null
  93492. */
  93493. /**
  93494. * Sets the parent of the physics imposter
  93495. */
  93496. parent: Nullable<PhysicsImpostor>;
  93497. /**
  93498. * Resets the update flags
  93499. */
  93500. resetUpdateFlags(): void;
  93501. /**
  93502. * Gets the object extend size
  93503. * @returns the object extend size
  93504. */
  93505. getObjectExtendSize(): Vector3;
  93506. /**
  93507. * Gets the object center
  93508. * @returns The object center
  93509. */
  93510. getObjectCenter(): Vector3;
  93511. /**
  93512. * Get a specific parametes from the options parameter
  93513. * @param paramName The object parameter name
  93514. * @returns The object parameter
  93515. */
  93516. getParam(paramName: string): any;
  93517. /**
  93518. * Sets a specific parameter in the options given to the physics plugin
  93519. * @param paramName The parameter name
  93520. * @param value The value of the parameter
  93521. */
  93522. setParam(paramName: string, value: number): void;
  93523. /**
  93524. * Specifically change the body's mass option. Won't recreate the physics body object
  93525. * @param mass The mass of the physics imposter
  93526. */
  93527. setMass(mass: number): void;
  93528. /**
  93529. * Gets the linear velocity
  93530. * @returns linear velocity or null
  93531. */
  93532. getLinearVelocity(): Nullable<Vector3>;
  93533. /**
  93534. * Sets the linear velocity
  93535. * @param velocity linear velocity or null
  93536. */
  93537. setLinearVelocity(velocity: Nullable<Vector3>): void;
  93538. /**
  93539. * Gets the angular velocity
  93540. * @returns angular velocity or null
  93541. */
  93542. getAngularVelocity(): Nullable<Vector3>;
  93543. /**
  93544. * Sets the angular velocity
  93545. * @param velocity The velocity or null
  93546. */
  93547. setAngularVelocity(velocity: Nullable<Vector3>): void;
  93548. /**
  93549. * Execute a function with the physics plugin native code
  93550. * Provide a function the will have two variables - the world object and the physics body object
  93551. * @param func The function to execute with the physics plugin native code
  93552. */
  93553. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  93554. /**
  93555. * Register a function that will be executed before the physics world is stepping forward
  93556. * @param func The function to execute before the physics world is stepped forward
  93557. */
  93558. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  93559. /**
  93560. * Unregister a function that will be executed before the physics world is stepping forward
  93561. * @param func The function to execute before the physics world is stepped forward
  93562. */
  93563. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  93564. /**
  93565. * Register a function that will be executed after the physics step
  93566. * @param func The function to execute after physics step
  93567. */
  93568. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  93569. /**
  93570. * Unregisters a function that will be executed after the physics step
  93571. * @param func The function to execute after physics step
  93572. */
  93573. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  93574. /**
  93575. * register a function that will be executed when this impostor collides against a different body
  93576. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  93577. * @param func Callback that is executed on collision
  93578. */
  93579. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  93580. /**
  93581. * Unregisters the physics imposter on contact
  93582. * @param collideAgainst The physics object to collide against
  93583. * @param func Callback to execute on collision
  93584. */
  93585. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  93586. private _tmpQuat;
  93587. private _tmpQuat2;
  93588. /**
  93589. * Get the parent rotation
  93590. * @returns The parent rotation
  93591. */
  93592. getParentsRotation(): Quaternion;
  93593. /**
  93594. * this function is executed by the physics engine.
  93595. */
  93596. beforeStep: () => void;
  93597. /**
  93598. * this function is executed by the physics engine
  93599. */
  93600. afterStep: () => void;
  93601. /**
  93602. * Legacy collision detection event support
  93603. */
  93604. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  93605. /**
  93606. * event and body object due to cannon's event-based architecture.
  93607. */
  93608. onCollide: (e: {
  93609. body: any;
  93610. }) => void;
  93611. /**
  93612. * Apply a force
  93613. * @param force The force to apply
  93614. * @param contactPoint The contact point for the force
  93615. * @returns The physics imposter
  93616. */
  93617. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93618. /**
  93619. * Apply an impulse
  93620. * @param force The impulse force
  93621. * @param contactPoint The contact point for the impulse force
  93622. * @returns The physics imposter
  93623. */
  93624. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93625. /**
  93626. * A help function to create a joint
  93627. * @param otherImpostor A physics imposter used to create a joint
  93628. * @param jointType The type of joint
  93629. * @param jointData The data for the joint
  93630. * @returns The physics imposter
  93631. */
  93632. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  93633. /**
  93634. * Add a joint to this impostor with a different impostor
  93635. * @param otherImpostor A physics imposter used to add a joint
  93636. * @param joint The joint to add
  93637. * @returns The physics imposter
  93638. */
  93639. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  93640. /**
  93641. * Add an anchor to a cloth impostor
  93642. * @param otherImpostor rigid impostor to anchor to
  93643. * @param width ratio across width from 0 to 1
  93644. * @param height ratio up height from 0 to 1
  93645. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  93646. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  93647. * @returns impostor the soft imposter
  93648. */
  93649. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93650. /**
  93651. * Add a hook to a rope impostor
  93652. * @param otherImpostor rigid impostor to anchor to
  93653. * @param length ratio across rope from 0 to 1
  93654. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  93655. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  93656. * @returns impostor the rope imposter
  93657. */
  93658. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93659. /**
  93660. * Will keep this body still, in a sleep mode.
  93661. * @returns the physics imposter
  93662. */
  93663. sleep(): PhysicsImpostor;
  93664. /**
  93665. * Wake the body up.
  93666. * @returns The physics imposter
  93667. */
  93668. wakeUp(): PhysicsImpostor;
  93669. /**
  93670. * Clones the physics imposter
  93671. * @param newObject The physics imposter clones to this physics-enabled object
  93672. * @returns A nullable physics imposter
  93673. */
  93674. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93675. /**
  93676. * Disposes the physics imposter
  93677. */
  93678. dispose(): void;
  93679. /**
  93680. * Sets the delta position
  93681. * @param position The delta position amount
  93682. */
  93683. setDeltaPosition(position: Vector3): void;
  93684. /**
  93685. * Sets the delta rotation
  93686. * @param rotation The delta rotation amount
  93687. */
  93688. setDeltaRotation(rotation: Quaternion): void;
  93689. /**
  93690. * Gets the box size of the physics imposter and stores the result in the input parameter
  93691. * @param result Stores the box size
  93692. * @returns The physics imposter
  93693. */
  93694. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  93695. /**
  93696. * Gets the radius of the physics imposter
  93697. * @returns Radius of the physics imposter
  93698. */
  93699. getRadius(): number;
  93700. /**
  93701. * Sync a bone with this impostor
  93702. * @param bone The bone to sync to the impostor.
  93703. * @param boneMesh The mesh that the bone is influencing.
  93704. * @param jointPivot The pivot of the joint / bone in local space.
  93705. * @param distToJoint Optional distance from the impostor to the joint.
  93706. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93707. */
  93708. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  93709. /**
  93710. * Sync impostor to a bone
  93711. * @param bone The bone that the impostor will be synced to.
  93712. * @param boneMesh The mesh that the bone is influencing.
  93713. * @param jointPivot The pivot of the joint / bone in local space.
  93714. * @param distToJoint Optional distance from the impostor to the joint.
  93715. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93716. * @param boneAxis Optional vector3 axis the bone is aligned with
  93717. */
  93718. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  93719. /**
  93720. * No-Imposter type
  93721. */
  93722. static NoImpostor: number;
  93723. /**
  93724. * Sphere-Imposter type
  93725. */
  93726. static SphereImpostor: number;
  93727. /**
  93728. * Box-Imposter type
  93729. */
  93730. static BoxImpostor: number;
  93731. /**
  93732. * Plane-Imposter type
  93733. */
  93734. static PlaneImpostor: number;
  93735. /**
  93736. * Mesh-imposter type
  93737. */
  93738. static MeshImpostor: number;
  93739. /**
  93740. * Capsule-Impostor type (Ammo.js plugin only)
  93741. */
  93742. static CapsuleImpostor: number;
  93743. /**
  93744. * Cylinder-Imposter type
  93745. */
  93746. static CylinderImpostor: number;
  93747. /**
  93748. * Particle-Imposter type
  93749. */
  93750. static ParticleImpostor: number;
  93751. /**
  93752. * Heightmap-Imposter type
  93753. */
  93754. static HeightmapImpostor: number;
  93755. /**
  93756. * ConvexHull-Impostor type (Ammo.js plugin only)
  93757. */
  93758. static ConvexHullImpostor: number;
  93759. /**
  93760. * Custom-Imposter type (Ammo.js plugin only)
  93761. */
  93762. static CustomImpostor: number;
  93763. /**
  93764. * Rope-Imposter type
  93765. */
  93766. static RopeImpostor: number;
  93767. /**
  93768. * Cloth-Imposter type
  93769. */
  93770. static ClothImpostor: number;
  93771. /**
  93772. * Softbody-Imposter type
  93773. */
  93774. static SoftbodyImpostor: number;
  93775. }
  93776. }
  93777. declare module BABYLON {
  93778. /**
  93779. * @hidden
  93780. **/
  93781. export class _CreationDataStorage {
  93782. closePath?: boolean;
  93783. closeArray?: boolean;
  93784. idx: number[];
  93785. dashSize: number;
  93786. gapSize: number;
  93787. path3D: Path3D;
  93788. pathArray: Vector3[][];
  93789. arc: number;
  93790. radius: number;
  93791. cap: number;
  93792. tessellation: number;
  93793. }
  93794. /**
  93795. * @hidden
  93796. **/
  93797. class _InstanceDataStorage {
  93798. visibleInstances: any;
  93799. batchCache: _InstancesBatch;
  93800. instancesBufferSize: number;
  93801. instancesBuffer: Nullable<Buffer>;
  93802. instancesData: Float32Array;
  93803. overridenInstanceCount: number;
  93804. isFrozen: boolean;
  93805. previousBatch: Nullable<_InstancesBatch>;
  93806. hardwareInstancedRendering: boolean;
  93807. sideOrientation: number;
  93808. manualUpdate: boolean;
  93809. }
  93810. /**
  93811. * @hidden
  93812. **/
  93813. export class _InstancesBatch {
  93814. mustReturn: boolean;
  93815. visibleInstances: Nullable<InstancedMesh[]>[];
  93816. renderSelf: boolean[];
  93817. hardwareInstancedRendering: boolean[];
  93818. }
  93819. /**
  93820. * Class used to represent renderable models
  93821. */
  93822. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  93823. /**
  93824. * Mesh side orientation : usually the external or front surface
  93825. */
  93826. static readonly FRONTSIDE: number;
  93827. /**
  93828. * Mesh side orientation : usually the internal or back surface
  93829. */
  93830. static readonly BACKSIDE: number;
  93831. /**
  93832. * Mesh side orientation : both internal and external or front and back surfaces
  93833. */
  93834. static readonly DOUBLESIDE: number;
  93835. /**
  93836. * Mesh side orientation : by default, `FRONTSIDE`
  93837. */
  93838. static readonly DEFAULTSIDE: number;
  93839. /**
  93840. * Mesh cap setting : no cap
  93841. */
  93842. static readonly NO_CAP: number;
  93843. /**
  93844. * Mesh cap setting : one cap at the beginning of the mesh
  93845. */
  93846. static readonly CAP_START: number;
  93847. /**
  93848. * Mesh cap setting : one cap at the end of the mesh
  93849. */
  93850. static readonly CAP_END: number;
  93851. /**
  93852. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  93853. */
  93854. static readonly CAP_ALL: number;
  93855. /**
  93856. * Mesh pattern setting : no flip or rotate
  93857. */
  93858. static readonly NO_FLIP: number;
  93859. /**
  93860. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  93861. */
  93862. static readonly FLIP_TILE: number;
  93863. /**
  93864. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  93865. */
  93866. static readonly ROTATE_TILE: number;
  93867. /**
  93868. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  93869. */
  93870. static readonly FLIP_ROW: number;
  93871. /**
  93872. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  93873. */
  93874. static readonly ROTATE_ROW: number;
  93875. /**
  93876. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  93877. */
  93878. static readonly FLIP_N_ROTATE_TILE: number;
  93879. /**
  93880. * Mesh pattern setting : rotate pattern and rotate
  93881. */
  93882. static readonly FLIP_N_ROTATE_ROW: number;
  93883. /**
  93884. * Mesh tile positioning : part tiles same on left/right or top/bottom
  93885. */
  93886. static readonly CENTER: number;
  93887. /**
  93888. * Mesh tile positioning : part tiles on left
  93889. */
  93890. static readonly LEFT: number;
  93891. /**
  93892. * Mesh tile positioning : part tiles on right
  93893. */
  93894. static readonly RIGHT: number;
  93895. /**
  93896. * Mesh tile positioning : part tiles on top
  93897. */
  93898. static readonly TOP: number;
  93899. /**
  93900. * Mesh tile positioning : part tiles on bottom
  93901. */
  93902. static readonly BOTTOM: number;
  93903. /**
  93904. * Gets the default side orientation.
  93905. * @param orientation the orientation to value to attempt to get
  93906. * @returns the default orientation
  93907. * @hidden
  93908. */
  93909. static _GetDefaultSideOrientation(orientation?: number): number;
  93910. private _internalMeshDataInfo;
  93911. /**
  93912. * An event triggered before rendering the mesh
  93913. */
  93914. readonly onBeforeRenderObservable: Observable<Mesh>;
  93915. /**
  93916. * An event triggered before binding the mesh
  93917. */
  93918. readonly onBeforeBindObservable: Observable<Mesh>;
  93919. /**
  93920. * An event triggered after rendering the mesh
  93921. */
  93922. readonly onAfterRenderObservable: Observable<Mesh>;
  93923. /**
  93924. * An event triggered before drawing the mesh
  93925. */
  93926. readonly onBeforeDrawObservable: Observable<Mesh>;
  93927. private _onBeforeDrawObserver;
  93928. /**
  93929. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  93930. */
  93931. onBeforeDraw: () => void;
  93932. readonly hasInstances: boolean;
  93933. /**
  93934. * Gets the delay loading state of the mesh (when delay loading is turned on)
  93935. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  93936. */
  93937. delayLoadState: number;
  93938. /**
  93939. * Gets the list of instances created from this mesh
  93940. * it is not supposed to be modified manually.
  93941. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  93942. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93943. */
  93944. instances: InstancedMesh[];
  93945. /**
  93946. * Gets the file containing delay loading data for this mesh
  93947. */
  93948. delayLoadingFile: string;
  93949. /** @hidden */
  93950. _binaryInfo: any;
  93951. /**
  93952. * User defined function used to change how LOD level selection is done
  93953. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93954. */
  93955. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  93956. /**
  93957. * Gets or sets the morph target manager
  93958. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93959. */
  93960. morphTargetManager: Nullable<MorphTargetManager>;
  93961. /** @hidden */
  93962. _creationDataStorage: Nullable<_CreationDataStorage>;
  93963. /** @hidden */
  93964. _geometry: Nullable<Geometry>;
  93965. /** @hidden */
  93966. _delayInfo: Array<string>;
  93967. /** @hidden */
  93968. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  93969. /** @hidden */
  93970. _instanceDataStorage: _InstanceDataStorage;
  93971. private _effectiveMaterial;
  93972. /** @hidden */
  93973. _shouldGenerateFlatShading: boolean;
  93974. /** @hidden */
  93975. _originalBuilderSideOrientation: number;
  93976. /**
  93977. * Use this property to change the original side orientation defined at construction time
  93978. */
  93979. overrideMaterialSideOrientation: Nullable<number>;
  93980. /**
  93981. * Gets the source mesh (the one used to clone this one from)
  93982. */
  93983. readonly source: Nullable<Mesh>;
  93984. /**
  93985. * Gets or sets a boolean indicating that this mesh does not use index buffer
  93986. */
  93987. isUnIndexed: boolean;
  93988. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  93989. readonly worldMatrixInstancedBuffer: Float32Array;
  93990. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  93991. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  93992. /**
  93993. * @constructor
  93994. * @param name The value used by scene.getMeshByName() to do a lookup.
  93995. * @param scene The scene to add this mesh to.
  93996. * @param parent The parent of this mesh, if it has one
  93997. * @param source An optional Mesh from which geometry is shared, cloned.
  93998. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93999. * When false, achieved by calling a clone(), also passing False.
  94000. * This will make creation of children, recursive.
  94001. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94002. */
  94003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94004. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94005. doNotInstantiate: boolean;
  94006. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94007. /**
  94008. * Gets the class name
  94009. * @returns the string "Mesh".
  94010. */
  94011. getClassName(): string;
  94012. /** @hidden */
  94013. readonly _isMesh: boolean;
  94014. /**
  94015. * Returns a description of this mesh
  94016. * @param fullDetails define if full details about this mesh must be used
  94017. * @returns a descriptive string representing this mesh
  94018. */
  94019. toString(fullDetails?: boolean): string;
  94020. /** @hidden */
  94021. _unBindEffect(): void;
  94022. /**
  94023. * Gets a boolean indicating if this mesh has LOD
  94024. */
  94025. readonly hasLODLevels: boolean;
  94026. /**
  94027. * Gets the list of MeshLODLevel associated with the current mesh
  94028. * @returns an array of MeshLODLevel
  94029. */
  94030. getLODLevels(): MeshLODLevel[];
  94031. private _sortLODLevels;
  94032. /**
  94033. * Add a mesh as LOD level triggered at the given distance.
  94034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94035. * @param distance The distance from the center of the object to show this level
  94036. * @param mesh The mesh to be added as LOD level (can be null)
  94037. * @return This mesh (for chaining)
  94038. */
  94039. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94040. /**
  94041. * Returns the LOD level mesh at the passed distance or null if not found.
  94042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94043. * @param distance The distance from the center of the object to show this level
  94044. * @returns a Mesh or `null`
  94045. */
  94046. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94047. /**
  94048. * Remove a mesh from the LOD array
  94049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94050. * @param mesh defines the mesh to be removed
  94051. * @return This mesh (for chaining)
  94052. */
  94053. removeLODLevel(mesh: Mesh): Mesh;
  94054. /**
  94055. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94057. * @param camera defines the camera to use to compute distance
  94058. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94059. * @return This mesh (for chaining)
  94060. */
  94061. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94062. /**
  94063. * Gets the mesh internal Geometry object
  94064. */
  94065. readonly geometry: Nullable<Geometry>;
  94066. /**
  94067. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94068. * @returns the total number of vertices
  94069. */
  94070. getTotalVertices(): number;
  94071. /**
  94072. * Returns the content of an associated vertex buffer
  94073. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94074. * - VertexBuffer.PositionKind
  94075. * - VertexBuffer.UVKind
  94076. * - VertexBuffer.UV2Kind
  94077. * - VertexBuffer.UV3Kind
  94078. * - VertexBuffer.UV4Kind
  94079. * - VertexBuffer.UV5Kind
  94080. * - VertexBuffer.UV6Kind
  94081. * - VertexBuffer.ColorKind
  94082. * - VertexBuffer.MatricesIndicesKind
  94083. * - VertexBuffer.MatricesIndicesExtraKind
  94084. * - VertexBuffer.MatricesWeightsKind
  94085. * - VertexBuffer.MatricesWeightsExtraKind
  94086. * @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
  94087. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94088. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94089. */
  94090. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94091. /**
  94092. * Returns the mesh VertexBuffer object from the requested `kind`
  94093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94094. * - VertexBuffer.PositionKind
  94095. * - VertexBuffer.NormalKind
  94096. * - VertexBuffer.UVKind
  94097. * - VertexBuffer.UV2Kind
  94098. * - VertexBuffer.UV3Kind
  94099. * - VertexBuffer.UV4Kind
  94100. * - VertexBuffer.UV5Kind
  94101. * - VertexBuffer.UV6Kind
  94102. * - VertexBuffer.ColorKind
  94103. * - VertexBuffer.MatricesIndicesKind
  94104. * - VertexBuffer.MatricesIndicesExtraKind
  94105. * - VertexBuffer.MatricesWeightsKind
  94106. * - VertexBuffer.MatricesWeightsExtraKind
  94107. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94108. */
  94109. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94110. /**
  94111. * Tests if a specific vertex buffer is associated with this mesh
  94112. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94113. * - VertexBuffer.PositionKind
  94114. * - VertexBuffer.NormalKind
  94115. * - VertexBuffer.UVKind
  94116. * - VertexBuffer.UV2Kind
  94117. * - VertexBuffer.UV3Kind
  94118. * - VertexBuffer.UV4Kind
  94119. * - VertexBuffer.UV5Kind
  94120. * - VertexBuffer.UV6Kind
  94121. * - VertexBuffer.ColorKind
  94122. * - VertexBuffer.MatricesIndicesKind
  94123. * - VertexBuffer.MatricesIndicesExtraKind
  94124. * - VertexBuffer.MatricesWeightsKind
  94125. * - VertexBuffer.MatricesWeightsExtraKind
  94126. * @returns a boolean
  94127. */
  94128. isVerticesDataPresent(kind: string): boolean;
  94129. /**
  94130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94131. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94132. * - VertexBuffer.PositionKind
  94133. * - VertexBuffer.UVKind
  94134. * - VertexBuffer.UV2Kind
  94135. * - VertexBuffer.UV3Kind
  94136. * - VertexBuffer.UV4Kind
  94137. * - VertexBuffer.UV5Kind
  94138. * - VertexBuffer.UV6Kind
  94139. * - VertexBuffer.ColorKind
  94140. * - VertexBuffer.MatricesIndicesKind
  94141. * - VertexBuffer.MatricesIndicesExtraKind
  94142. * - VertexBuffer.MatricesWeightsKind
  94143. * - VertexBuffer.MatricesWeightsExtraKind
  94144. * @returns a boolean
  94145. */
  94146. isVertexBufferUpdatable(kind: string): boolean;
  94147. /**
  94148. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94149. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94150. * - VertexBuffer.PositionKind
  94151. * - VertexBuffer.NormalKind
  94152. * - VertexBuffer.UVKind
  94153. * - VertexBuffer.UV2Kind
  94154. * - VertexBuffer.UV3Kind
  94155. * - VertexBuffer.UV4Kind
  94156. * - VertexBuffer.UV5Kind
  94157. * - VertexBuffer.UV6Kind
  94158. * - VertexBuffer.ColorKind
  94159. * - VertexBuffer.MatricesIndicesKind
  94160. * - VertexBuffer.MatricesIndicesExtraKind
  94161. * - VertexBuffer.MatricesWeightsKind
  94162. * - VertexBuffer.MatricesWeightsExtraKind
  94163. * @returns an array of strings
  94164. */
  94165. getVerticesDataKinds(): string[];
  94166. /**
  94167. * Returns a positive integer : the total number of indices in this mesh geometry.
  94168. * @returns the numner of indices or zero if the mesh has no geometry.
  94169. */
  94170. getTotalIndices(): number;
  94171. /**
  94172. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94173. * @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.
  94174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94175. * @returns the indices array or an empty array if the mesh has no geometry
  94176. */
  94177. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94178. readonly isBlocked: boolean;
  94179. /**
  94180. * Determine if the current mesh is ready to be rendered
  94181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94182. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  94183. * @returns true if all associated assets are ready (material, textures, shaders)
  94184. */
  94185. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  94186. /**
  94187. * 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.
  94188. */
  94189. readonly areNormalsFrozen: boolean;
  94190. /**
  94191. * 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.
  94192. * @returns the current mesh
  94193. */
  94194. freezeNormals(): Mesh;
  94195. /**
  94196. * 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
  94197. * @returns the current mesh
  94198. */
  94199. unfreezeNormals(): Mesh;
  94200. /**
  94201. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  94202. */
  94203. overridenInstanceCount: number;
  94204. /** @hidden */
  94205. _preActivate(): Mesh;
  94206. /** @hidden */
  94207. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94208. /** @hidden */
  94209. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  94210. /**
  94211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94212. * This means the mesh underlying bounding box and sphere are recomputed.
  94213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94214. * @returns the current mesh
  94215. */
  94216. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  94217. /** @hidden */
  94218. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  94219. /**
  94220. * This function will subdivide the mesh into multiple submeshes
  94221. * @param count defines the expected number of submeshes
  94222. */
  94223. subdivide(count: number): void;
  94224. /**
  94225. * Copy a FloatArray into a specific associated vertex buffer
  94226. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94227. * - VertexBuffer.PositionKind
  94228. * - VertexBuffer.UVKind
  94229. * - VertexBuffer.UV2Kind
  94230. * - VertexBuffer.UV3Kind
  94231. * - VertexBuffer.UV4Kind
  94232. * - VertexBuffer.UV5Kind
  94233. * - VertexBuffer.UV6Kind
  94234. * - VertexBuffer.ColorKind
  94235. * - VertexBuffer.MatricesIndicesKind
  94236. * - VertexBuffer.MatricesIndicesExtraKind
  94237. * - VertexBuffer.MatricesWeightsKind
  94238. * - VertexBuffer.MatricesWeightsExtraKind
  94239. * @param data defines the data source
  94240. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  94241. * @param stride defines the data stride size (can be null)
  94242. * @returns the current mesh
  94243. */
  94244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94245. /**
  94246. * Delete a vertex buffer associated with this mesh
  94247. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  94248. * - VertexBuffer.PositionKind
  94249. * - VertexBuffer.UVKind
  94250. * - VertexBuffer.UV2Kind
  94251. * - VertexBuffer.UV3Kind
  94252. * - VertexBuffer.UV4Kind
  94253. * - VertexBuffer.UV5Kind
  94254. * - VertexBuffer.UV6Kind
  94255. * - VertexBuffer.ColorKind
  94256. * - VertexBuffer.MatricesIndicesKind
  94257. * - VertexBuffer.MatricesIndicesExtraKind
  94258. * - VertexBuffer.MatricesWeightsKind
  94259. * - VertexBuffer.MatricesWeightsExtraKind
  94260. */
  94261. removeVerticesData(kind: string): void;
  94262. /**
  94263. * Flags an associated vertex buffer as updatable
  94264. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  94265. * - VertexBuffer.PositionKind
  94266. * - VertexBuffer.UVKind
  94267. * - VertexBuffer.UV2Kind
  94268. * - VertexBuffer.UV3Kind
  94269. * - VertexBuffer.UV4Kind
  94270. * - VertexBuffer.UV5Kind
  94271. * - VertexBuffer.UV6Kind
  94272. * - VertexBuffer.ColorKind
  94273. * - VertexBuffer.MatricesIndicesKind
  94274. * - VertexBuffer.MatricesIndicesExtraKind
  94275. * - VertexBuffer.MatricesWeightsKind
  94276. * - VertexBuffer.MatricesWeightsExtraKind
  94277. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  94278. */
  94279. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  94280. /**
  94281. * Sets the mesh global Vertex Buffer
  94282. * @param buffer defines the buffer to use
  94283. * @returns the current mesh
  94284. */
  94285. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  94286. /**
  94287. * Update a specific associated vertex buffer
  94288. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94289. * - VertexBuffer.PositionKind
  94290. * - VertexBuffer.UVKind
  94291. * - VertexBuffer.UV2Kind
  94292. * - VertexBuffer.UV3Kind
  94293. * - VertexBuffer.UV4Kind
  94294. * - VertexBuffer.UV5Kind
  94295. * - VertexBuffer.UV6Kind
  94296. * - VertexBuffer.ColorKind
  94297. * - VertexBuffer.MatricesIndicesKind
  94298. * - VertexBuffer.MatricesIndicesExtraKind
  94299. * - VertexBuffer.MatricesWeightsKind
  94300. * - VertexBuffer.MatricesWeightsExtraKind
  94301. * @param data defines the data source
  94302. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94303. * @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)
  94304. * @returns the current mesh
  94305. */
  94306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94307. /**
  94308. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  94309. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  94310. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  94311. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  94312. * @returns the current mesh
  94313. */
  94314. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  94315. /**
  94316. * Creates a un-shared specific occurence of the geometry for the mesh.
  94317. * @returns the current mesh
  94318. */
  94319. makeGeometryUnique(): Mesh;
  94320. /**
  94321. * Set the index buffer of this mesh
  94322. * @param indices defines the source data
  94323. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  94324. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  94325. * @returns the current mesh
  94326. */
  94327. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  94328. /**
  94329. * Update the current index buffer
  94330. * @param indices defines the source data
  94331. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94332. * @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)
  94333. * @returns the current mesh
  94334. */
  94335. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94336. /**
  94337. * Invert the geometry to move from a right handed system to a left handed one.
  94338. * @returns the current mesh
  94339. */
  94340. toLeftHanded(): Mesh;
  94341. /** @hidden */
  94342. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94343. /** @hidden */
  94344. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94345. /**
  94346. * Registers for this mesh a javascript function called just before the rendering process
  94347. * @param func defines the function to call before rendering this mesh
  94348. * @returns the current mesh
  94349. */
  94350. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  94351. /**
  94352. * Disposes a previously registered javascript function called before the rendering
  94353. * @param func defines the function to remove
  94354. * @returns the current mesh
  94355. */
  94356. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  94357. /**
  94358. * Registers for this mesh a javascript function called just after the rendering is complete
  94359. * @param func defines the function to call after rendering this mesh
  94360. * @returns the current mesh
  94361. */
  94362. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  94363. /**
  94364. * Disposes a previously registered javascript function called after the rendering.
  94365. * @param func defines the function to remove
  94366. * @returns the current mesh
  94367. */
  94368. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  94369. /** @hidden */
  94370. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  94371. /** @hidden */
  94372. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  94373. /** @hidden */
  94374. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  94375. /** @hidden */
  94376. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  94377. /** @hidden */
  94378. _rebuild(): void;
  94379. /** @hidden */
  94380. _freeze(): void;
  94381. /** @hidden */
  94382. _unFreeze(): void;
  94383. /**
  94384. * 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
  94385. * @param subMesh defines the subMesh to render
  94386. * @param enableAlphaMode defines if alpha mode can be changed
  94387. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  94388. * @returns the current mesh
  94389. */
  94390. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  94391. private _onBeforeDraw;
  94392. /**
  94393. * Renormalize the mesh and patch it up if there are no weights
  94394. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  94395. * However in the case of zero weights then we set just a single influence to 1.
  94396. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  94397. */
  94398. cleanMatrixWeights(): void;
  94399. private normalizeSkinFourWeights;
  94400. private normalizeSkinWeightsAndExtra;
  94401. /**
  94402. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  94403. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  94404. * the user know there was an issue with importing the mesh
  94405. * @returns a validation object with skinned, valid and report string
  94406. */
  94407. validateSkinning(): {
  94408. skinned: boolean;
  94409. valid: boolean;
  94410. report: string;
  94411. };
  94412. /** @hidden */
  94413. _checkDelayState(): Mesh;
  94414. private _queueLoad;
  94415. /**
  94416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94417. * A mesh is in the frustum if its bounding box intersects the frustum
  94418. * @param frustumPlanes defines the frustum to test
  94419. * @returns true if the mesh is in the frustum planes
  94420. */
  94421. isInFrustum(frustumPlanes: Plane[]): boolean;
  94422. /**
  94423. * Sets the mesh material by the material or multiMaterial `id` property
  94424. * @param id is a string identifying the material or the multiMaterial
  94425. * @returns the current mesh
  94426. */
  94427. setMaterialByID(id: string): Mesh;
  94428. /**
  94429. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  94430. * @returns an array of IAnimatable
  94431. */
  94432. getAnimatables(): IAnimatable[];
  94433. /**
  94434. * Modifies the mesh geometry according to the passed transformation matrix.
  94435. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  94436. * The mesh normals are modified using the same transformation.
  94437. * Note that, under the hood, this method sets a new VertexBuffer each call.
  94438. * @param transform defines the transform matrix to use
  94439. * @see http://doc.babylonjs.com/resources/baking_transformations
  94440. * @returns the current mesh
  94441. */
  94442. bakeTransformIntoVertices(transform: Matrix): Mesh;
  94443. /**
  94444. * Modifies the mesh geometry according to its own current World Matrix.
  94445. * The mesh World Matrix is then reset.
  94446. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  94447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  94448. * @see http://doc.babylonjs.com/resources/baking_transformations
  94449. * @returns the current mesh
  94450. */
  94451. bakeCurrentTransformIntoVertices(): Mesh;
  94452. /** @hidden */
  94453. readonly _positions: Nullable<Vector3[]>;
  94454. /** @hidden */
  94455. _resetPointsArrayCache(): Mesh;
  94456. /** @hidden */
  94457. _generatePointsArray(): boolean;
  94458. /**
  94459. * Returns a new Mesh object generated from the current mesh properties.
  94460. * This method must not get confused with createInstance()
  94461. * @param name is a string, the name given to the new mesh
  94462. * @param newParent can be any Node object (default `null`)
  94463. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  94464. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  94465. * @returns a new mesh
  94466. */
  94467. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  94468. /**
  94469. * Releases resources associated with this mesh.
  94470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94472. */
  94473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94474. /** @hidden */
  94475. _disposeInstanceSpecificData(): void;
  94476. /**
  94477. * Modifies the mesh geometry according to a displacement map.
  94478. * 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.
  94479. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  94480. * @param url is a string, the URL from the image file is to be downloaded.
  94481. * @param minHeight is the lower limit of the displacement.
  94482. * @param maxHeight is the upper limit of the displacement.
  94483. * @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.
  94484. * @param uvOffset is an optional vector2 used to offset UV.
  94485. * @param uvScale is an optional vector2 used to scale UV.
  94486. * @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.
  94487. * @returns the Mesh.
  94488. */
  94489. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  94490. /**
  94491. * Modifies the mesh geometry according to a displacementMap buffer.
  94492. * 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.
  94493. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  94494. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  94495. * @param heightMapWidth is the width of the buffer image.
  94496. * @param heightMapHeight is the height of the buffer image.
  94497. * @param minHeight is the lower limit of the displacement.
  94498. * @param maxHeight is the upper limit of the displacement.
  94499. * @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.
  94500. * @param uvOffset is an optional vector2 used to offset UV.
  94501. * @param uvScale is an optional vector2 used to scale UV.
  94502. * @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.
  94503. * @returns the Mesh.
  94504. */
  94505. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  94506. /**
  94507. * Modify the mesh to get a flat shading rendering.
  94508. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  94509. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  94510. * @returns current mesh
  94511. */
  94512. convertToFlatShadedMesh(): Mesh;
  94513. /**
  94514. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  94515. * In other words, more vertices, no more indices and a single bigger VBO.
  94516. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  94517. * @returns current mesh
  94518. */
  94519. convertToUnIndexedMesh(): Mesh;
  94520. /**
  94521. * Inverses facet orientations.
  94522. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  94523. * @param flipNormals will also inverts the normals
  94524. * @returns current mesh
  94525. */
  94526. flipFaces(flipNormals?: boolean): Mesh;
  94527. /**
  94528. * Increase the number of facets and hence vertices in a mesh
  94529. * Vertex normals are interpolated from existing vertex normals
  94530. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  94531. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  94532. */
  94533. increaseVertices(numberPerEdge: number): void;
  94534. /**
  94535. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  94536. * This will undo any application of covertToFlatShadedMesh
  94537. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  94538. */
  94539. forceSharedVertices(): void;
  94540. /** @hidden */
  94541. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  94542. /** @hidden */
  94543. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  94544. /**
  94545. * Creates a new InstancedMesh object from the mesh model.
  94546. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94547. * @param name defines the name of the new instance
  94548. * @returns a new InstancedMesh
  94549. */
  94550. createInstance(name: string): InstancedMesh;
  94551. /**
  94552. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  94553. * After this call, all the mesh instances have the same submeshes than the current mesh.
  94554. * @returns the current mesh
  94555. */
  94556. synchronizeInstances(): Mesh;
  94557. /**
  94558. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  94559. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  94560. * This should be used together with the simplification to avoid disappearing triangles.
  94561. * @param successCallback an optional success callback to be called after the optimization finished.
  94562. * @returns the current mesh
  94563. */
  94564. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  94565. /**
  94566. * Serialize current mesh
  94567. * @param serializationObject defines the object which will receive the serialization data
  94568. */
  94569. serialize(serializationObject: any): void;
  94570. /** @hidden */
  94571. _syncGeometryWithMorphTargetManager(): void;
  94572. /** @hidden */
  94573. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  94574. /**
  94575. * Returns a new Mesh object parsed from the source provided.
  94576. * @param parsedMesh is the source
  94577. * @param scene defines the hosting scene
  94578. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  94579. * @returns a new Mesh
  94580. */
  94581. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  94582. /**
  94583. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  94584. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94585. * @param name defines the name of the mesh to create
  94586. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  94587. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  94588. * @param closePath creates a seam between the first and the last points of each path of the path array
  94589. * @param offset is taken in account only if the `pathArray` is containing a single path
  94590. * @param scene defines the hosting scene
  94591. * @param updatable defines if the mesh must be flagged as updatable
  94592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94593. * @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)
  94594. * @returns a new Mesh
  94595. */
  94596. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94597. /**
  94598. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  94599. * @param name defines the name of the mesh to create
  94600. * @param radius sets the radius size (float) of the polygon (default 0.5)
  94601. * @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
  94602. * @param scene defines the hosting scene
  94603. * @param updatable defines if the mesh must be flagged as updatable
  94604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94605. * @returns a new Mesh
  94606. */
  94607. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  94608. /**
  94609. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  94610. * @param name defines the name of the mesh to create
  94611. * @param size sets the size (float) of each box side (default 1)
  94612. * @param scene defines the hosting scene
  94613. * @param updatable defines if the mesh must be flagged as updatable
  94614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94615. * @returns a new Mesh
  94616. */
  94617. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  94618. /**
  94619. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  94620. * @param name defines the name of the mesh to create
  94621. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94622. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94623. * @param scene defines the hosting scene
  94624. * @param updatable defines if the mesh must be flagged as updatable
  94625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94626. * @returns a new Mesh
  94627. */
  94628. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94629. /**
  94630. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  94631. * @param name defines the name of the mesh to create
  94632. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94633. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94634. * @param scene defines the hosting scene
  94635. * @returns a new Mesh
  94636. */
  94637. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  94638. /**
  94639. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  94640. * @param name defines the name of the mesh to create
  94641. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  94642. * @param diameterTop set the top cap diameter (floats, default 1)
  94643. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  94644. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  94645. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  94646. * @param scene defines the hosting scene
  94647. * @param updatable defines if the mesh must be flagged as updatable
  94648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94649. * @returns a new Mesh
  94650. */
  94651. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  94652. /**
  94653. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  94654. * @param name defines the name of the mesh to create
  94655. * @param diameter sets the diameter size (float) of the torus (default 1)
  94656. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  94657. * @param tessellation sets the number of torus sides (postive integer, default 16)
  94658. * @param scene defines the hosting scene
  94659. * @param updatable defines if the mesh must be flagged as updatable
  94660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94661. * @returns a new Mesh
  94662. */
  94663. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94664. /**
  94665. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  94666. * @param name defines the name of the mesh to create
  94667. * @param radius sets the global radius size (float) of the torus knot (default 2)
  94668. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  94669. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  94670. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  94671. * @param p the number of windings on X axis (positive integers, default 2)
  94672. * @param q the number of windings on Y axis (positive integers, default 3)
  94673. * @param scene defines the hosting scene
  94674. * @param updatable defines if the mesh must be flagged as updatable
  94675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94676. * @returns a new Mesh
  94677. */
  94678. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94679. /**
  94680. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  94681. * @param name defines the name of the mesh to create
  94682. * @param points is an array successive Vector3
  94683. * @param scene defines the hosting scene
  94684. * @param updatable defines if the mesh must be flagged as updatable
  94685. * @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).
  94686. * @returns a new Mesh
  94687. */
  94688. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  94689. /**
  94690. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  94691. * @param name defines the name of the mesh to create
  94692. * @param points is an array successive Vector3
  94693. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  94694. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  94695. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  94696. * @param scene defines the hosting scene
  94697. * @param updatable defines if the mesh must be flagged as updatable
  94698. * @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)
  94699. * @returns a new Mesh
  94700. */
  94701. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  94702. /**
  94703. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  94704. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  94705. * 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.
  94706. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94707. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94708. * Remember you can only change the shape positions, not their number when updating a polygon.
  94709. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  94710. * @param name defines the name of the mesh to create
  94711. * @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
  94712. * @param scene defines the hosting scene
  94713. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94714. * @param updatable defines if the mesh must be flagged as updatable
  94715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94716. * @param earcutInjection can be used to inject your own earcut reference
  94717. * @returns a new Mesh
  94718. */
  94719. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94720. /**
  94721. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  94722. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  94723. * @param name defines the name of the mesh to create
  94724. * @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
  94725. * @param depth defines the height of extrusion
  94726. * @param scene defines the hosting scene
  94727. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94728. * @param updatable defines if the mesh must be flagged as updatable
  94729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94730. * @param earcutInjection can be used to inject your own earcut reference
  94731. * @returns a new Mesh
  94732. */
  94733. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94734. /**
  94735. * Creates an extruded shape mesh.
  94736. * 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
  94737. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94738. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94739. * @param name defines the name of the mesh to create
  94740. * @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
  94741. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94742. * @param scale is the value to scale the shape
  94743. * @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
  94744. * @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
  94745. * @param scene defines the hosting scene
  94746. * @param updatable defines if the mesh must be flagged as updatable
  94747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94748. * @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)
  94749. * @returns a new Mesh
  94750. */
  94751. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94752. /**
  94753. * Creates an custom extruded shape mesh.
  94754. * The custom extrusion is a parametric shape.
  94755. * It has no predefined shape. Its final shape will depend on the input parameters.
  94756. * Please consider using the same method from the MeshBuilder class instead
  94757. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94758. * @param name defines the name of the mesh to create
  94759. * @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
  94760. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94761. * @param scaleFunction is a custom Javascript function called on each path point
  94762. * @param rotationFunction is a custom Javascript function called on each path point
  94763. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  94764. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  94765. * @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
  94766. * @param scene defines the hosting scene
  94767. * @param updatable defines if the mesh must be flagged as updatable
  94768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94769. * @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)
  94770. * @returns a new Mesh
  94771. */
  94772. 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;
  94773. /**
  94774. * Creates lathe mesh.
  94775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  94776. * Please consider using the same method from the MeshBuilder class instead
  94777. * @param name defines the name of the mesh to create
  94778. * @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
  94779. * @param radius is the radius value of the lathe
  94780. * @param tessellation is the side number of the lathe.
  94781. * @param scene defines the hosting scene
  94782. * @param updatable defines if the mesh must be flagged as updatable
  94783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94784. * @returns a new Mesh
  94785. */
  94786. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94787. /**
  94788. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  94789. * @param name defines the name of the mesh to create
  94790. * @param size sets the size (float) of both sides of the plane at once (default 1)
  94791. * @param scene defines the hosting scene
  94792. * @param updatable defines if the mesh must be flagged as updatable
  94793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94794. * @returns a new Mesh
  94795. */
  94796. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94797. /**
  94798. * Creates a ground mesh.
  94799. * Please consider using the same method from the MeshBuilder class instead
  94800. * @param name defines the name of the mesh to create
  94801. * @param width set the width of the ground
  94802. * @param height set the height of the ground
  94803. * @param subdivisions sets the number of subdivisions per side
  94804. * @param scene defines the hosting scene
  94805. * @param updatable defines if the mesh must be flagged as updatable
  94806. * @returns a new Mesh
  94807. */
  94808. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  94809. /**
  94810. * Creates a tiled ground mesh.
  94811. * Please consider using the same method from the MeshBuilder class instead
  94812. * @param name defines the name of the mesh to create
  94813. * @param xmin set the ground minimum X coordinate
  94814. * @param zmin set the ground minimum Y coordinate
  94815. * @param xmax set the ground maximum X coordinate
  94816. * @param zmax set the ground maximum Z coordinate
  94817. * @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
  94818. * @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
  94819. * @param scene defines the hosting scene
  94820. * @param updatable defines if the mesh must be flagged as updatable
  94821. * @returns a new Mesh
  94822. */
  94823. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  94824. w: number;
  94825. h: number;
  94826. }, precision: {
  94827. w: number;
  94828. h: number;
  94829. }, scene: Scene, updatable?: boolean): Mesh;
  94830. /**
  94831. * Creates a ground mesh from a height map.
  94832. * Please consider using the same method from the MeshBuilder class instead
  94833. * @see http://doc.babylonjs.com/babylon101/height_map
  94834. * @param name defines the name of the mesh to create
  94835. * @param url sets the URL of the height map image resource
  94836. * @param width set the ground width size
  94837. * @param height set the ground height size
  94838. * @param subdivisions sets the number of subdivision per side
  94839. * @param minHeight is the minimum altitude on the ground
  94840. * @param maxHeight is the maximum altitude on the ground
  94841. * @param scene defines the hosting scene
  94842. * @param updatable defines if the mesh must be flagged as updatable
  94843. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  94844. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94845. * @returns a new Mesh
  94846. */
  94847. 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;
  94848. /**
  94849. * Creates a tube mesh.
  94850. * The tube is a parametric shape.
  94851. * It has no predefined shape. Its final shape will depend on the input parameters.
  94852. * Please consider using the same method from the MeshBuilder class instead
  94853. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94854. * @param name defines the name of the mesh to create
  94855. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  94856. * @param radius sets the tube radius size
  94857. * @param tessellation is the number of sides on the tubular surface
  94858. * @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
  94859. * @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
  94860. * @param scene defines the hosting scene
  94861. * @param updatable defines if the mesh must be flagged as updatable
  94862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94863. * @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)
  94864. * @returns a new Mesh
  94865. */
  94866. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  94867. (i: number, distance: number): number;
  94868. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94869. /**
  94870. * Creates a polyhedron mesh.
  94871. * Please consider using the same method from the MeshBuilder class instead.
  94872. * * 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
  94873. * * The parameter `size` (positive float, default 1) sets the polygon size
  94874. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  94875. * * 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`
  94876. * * 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
  94877. * * 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)`)
  94878. * * 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
  94879. * * 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
  94880. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94881. * * If you create a double-sided mesh, you can choose what parts of 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
  94882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94883. * @param name defines the name of the mesh to create
  94884. * @param options defines the options used to create the mesh
  94885. * @param scene defines the hosting scene
  94886. * @returns a new Mesh
  94887. */
  94888. static CreatePolyhedron(name: string, options: {
  94889. type?: number;
  94890. size?: number;
  94891. sizeX?: number;
  94892. sizeY?: number;
  94893. sizeZ?: number;
  94894. custom?: any;
  94895. faceUV?: Vector4[];
  94896. faceColors?: Color4[];
  94897. updatable?: boolean;
  94898. sideOrientation?: number;
  94899. }, scene: Scene): Mesh;
  94900. /**
  94901. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  94902. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  94903. * * 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`)
  94904. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  94905. * * 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
  94906. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94907. * * If you create a double-sided mesh, you can choose what parts of 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
  94908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94909. * @param name defines the name of the mesh
  94910. * @param options defines the options used to create the mesh
  94911. * @param scene defines the hosting scene
  94912. * @returns a new Mesh
  94913. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  94914. */
  94915. static CreateIcoSphere(name: string, options: {
  94916. radius?: number;
  94917. flat?: boolean;
  94918. subdivisions?: number;
  94919. sideOrientation?: number;
  94920. updatable?: boolean;
  94921. }, scene: Scene): Mesh;
  94922. /**
  94923. * Creates a decal mesh.
  94924. * Please consider using the same method from the MeshBuilder class instead.
  94925. * A decal is a mesh usually applied as a model onto the surface of another mesh
  94926. * @param name defines the name of the mesh
  94927. * @param sourceMesh defines the mesh receiving the decal
  94928. * @param position sets the position of the decal in world coordinates
  94929. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  94930. * @param size sets the decal scaling
  94931. * @param angle sets the angle to rotate the decal
  94932. * @returns a new Mesh
  94933. */
  94934. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  94935. /**
  94936. * Prepare internal position array for software CPU skinning
  94937. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  94938. */
  94939. setPositionsForCPUSkinning(): Float32Array;
  94940. /**
  94941. * Prepare internal normal array for software CPU skinning
  94942. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  94943. */
  94944. setNormalsForCPUSkinning(): Float32Array;
  94945. /**
  94946. * Updates the vertex buffer by applying transformation from the bones
  94947. * @param skeleton defines the skeleton to apply to current mesh
  94948. * @returns the current mesh
  94949. */
  94950. applySkeleton(skeleton: Skeleton): Mesh;
  94951. /**
  94952. * 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
  94953. * @param meshes defines the list of meshes to scan
  94954. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  94955. */
  94956. static MinMax(meshes: AbstractMesh[]): {
  94957. min: Vector3;
  94958. max: Vector3;
  94959. };
  94960. /**
  94961. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  94962. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  94963. * @returns a vector3
  94964. */
  94965. static Center(meshesOrMinMaxVector: {
  94966. min: Vector3;
  94967. max: Vector3;
  94968. } | AbstractMesh[]): Vector3;
  94969. /**
  94970. * Merge the array of meshes into a single mesh for performance reasons.
  94971. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  94972. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  94973. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  94974. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  94975. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  94976. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  94977. * @returns a new mesh
  94978. */
  94979. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  94980. /** @hidden */
  94981. addInstance(instance: InstancedMesh): void;
  94982. /** @hidden */
  94983. removeInstance(instance: InstancedMesh): void;
  94984. }
  94985. }
  94986. declare module BABYLON {
  94987. /**
  94988. * This is the base class of all the camera used in the application.
  94989. * @see http://doc.babylonjs.com/features/cameras
  94990. */
  94991. export class Camera extends Node {
  94992. /** @hidden */
  94993. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  94994. /**
  94995. * This is the default projection mode used by the cameras.
  94996. * It helps recreating a feeling of perspective and better appreciate depth.
  94997. * This is the best way to simulate real life cameras.
  94998. */
  94999. static readonly PERSPECTIVE_CAMERA: number;
  95000. /**
  95001. * This helps creating camera with an orthographic mode.
  95002. * 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.
  95003. */
  95004. static readonly ORTHOGRAPHIC_CAMERA: number;
  95005. /**
  95006. * This is the default FOV mode for perspective cameras.
  95007. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95008. */
  95009. static readonly FOVMODE_VERTICAL_FIXED: number;
  95010. /**
  95011. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95012. */
  95013. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95014. /**
  95015. * This specifies ther is no need for a camera rig.
  95016. * Basically only one eye is rendered corresponding to the camera.
  95017. */
  95018. static readonly RIG_MODE_NONE: number;
  95019. /**
  95020. * Simulates a camera Rig with one blue eye and one red eye.
  95021. * This can be use with 3d blue and red glasses.
  95022. */
  95023. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95024. /**
  95025. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95026. */
  95027. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95028. /**
  95029. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95030. */
  95031. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95032. /**
  95033. * Defines that both eyes of the camera will be rendered over under each other.
  95034. */
  95035. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95036. /**
  95037. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95038. */
  95039. static readonly RIG_MODE_VR: number;
  95040. /**
  95041. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95042. */
  95043. static readonly RIG_MODE_WEBVR: number;
  95044. /**
  95045. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95046. */
  95047. static readonly RIG_MODE_CUSTOM: number;
  95048. /**
  95049. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95050. */
  95051. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95052. /**
  95053. * Define the input manager associated with the camera.
  95054. */
  95055. inputs: CameraInputsManager<Camera>;
  95056. /** @hidden */
  95057. _position: Vector3;
  95058. /**
  95059. * Define the current local position of the camera in the scene
  95060. */
  95061. position: Vector3;
  95062. /**
  95063. * The vector the camera should consider as up.
  95064. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95065. */
  95066. upVector: Vector3;
  95067. /**
  95068. * Define the current limit on the left side for an orthographic camera
  95069. * In scene unit
  95070. */
  95071. orthoLeft: Nullable<number>;
  95072. /**
  95073. * Define the current limit on the right side for an orthographic camera
  95074. * In scene unit
  95075. */
  95076. orthoRight: Nullable<number>;
  95077. /**
  95078. * Define the current limit on the bottom side for an orthographic camera
  95079. * In scene unit
  95080. */
  95081. orthoBottom: Nullable<number>;
  95082. /**
  95083. * Define the current limit on the top side for an orthographic camera
  95084. * In scene unit
  95085. */
  95086. orthoTop: Nullable<number>;
  95087. /**
  95088. * Field Of View is set in Radians. (default is 0.8)
  95089. */
  95090. fov: number;
  95091. /**
  95092. * Define the minimum distance the camera can see from.
  95093. * This is important to note that the depth buffer are not infinite and the closer it starts
  95094. * the more your scene might encounter depth fighting issue.
  95095. */
  95096. minZ: number;
  95097. /**
  95098. * Define the maximum distance the camera can see to.
  95099. * This is important to note that the depth buffer are not infinite and the further it end
  95100. * the more your scene might encounter depth fighting issue.
  95101. */
  95102. maxZ: number;
  95103. /**
  95104. * Define the default inertia of the camera.
  95105. * This helps giving a smooth feeling to the camera movement.
  95106. */
  95107. inertia: number;
  95108. /**
  95109. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95110. */
  95111. mode: number;
  95112. /**
  95113. * Define wether the camera is intermediate.
  95114. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95115. */
  95116. isIntermediate: boolean;
  95117. /**
  95118. * Define the viewport of the camera.
  95119. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95120. */
  95121. viewport: Viewport;
  95122. /**
  95123. * Restricts the camera to viewing objects with the same layerMask.
  95124. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95125. */
  95126. layerMask: number;
  95127. /**
  95128. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95129. */
  95130. fovMode: number;
  95131. /**
  95132. * Rig mode of the camera.
  95133. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95134. * This is normally controlled byt the camera themselves as internal use.
  95135. */
  95136. cameraRigMode: number;
  95137. /**
  95138. * Defines the distance between both "eyes" in case of a RIG
  95139. */
  95140. interaxialDistance: number;
  95141. /**
  95142. * Defines if stereoscopic rendering is done side by side or over under.
  95143. */
  95144. isStereoscopicSideBySide: boolean;
  95145. /**
  95146. * 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
  95147. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95148. * else in the scene. (Eg. security camera)
  95149. *
  95150. * 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)
  95151. */
  95152. customRenderTargets: RenderTargetTexture[];
  95153. /**
  95154. * When set, the camera will render to this render target instead of the default canvas
  95155. *
  95156. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95157. */
  95158. outputRenderTarget: Nullable<RenderTargetTexture>;
  95159. /**
  95160. * Observable triggered when the camera view matrix has changed.
  95161. */
  95162. onViewMatrixChangedObservable: Observable<Camera>;
  95163. /**
  95164. * Observable triggered when the camera Projection matrix has changed.
  95165. */
  95166. onProjectionMatrixChangedObservable: Observable<Camera>;
  95167. /**
  95168. * Observable triggered when the inputs have been processed.
  95169. */
  95170. onAfterCheckInputsObservable: Observable<Camera>;
  95171. /**
  95172. * Observable triggered when reset has been called and applied to the camera.
  95173. */
  95174. onRestoreStateObservable: Observable<Camera>;
  95175. /** @hidden */
  95176. _cameraRigParams: any;
  95177. /** @hidden */
  95178. _rigCameras: Camera[];
  95179. /** @hidden */
  95180. _rigPostProcess: Nullable<PostProcess>;
  95181. protected _webvrViewMatrix: Matrix;
  95182. /** @hidden */
  95183. _skipRendering: boolean;
  95184. /** @hidden */
  95185. _projectionMatrix: Matrix;
  95186. /** @hidden */
  95187. _postProcesses: Nullable<PostProcess>[];
  95188. /** @hidden */
  95189. _activeMeshes: SmartArray<AbstractMesh>;
  95190. protected _globalPosition: Vector3;
  95191. /** @hidden */
  95192. _computedViewMatrix: Matrix;
  95193. private _doNotComputeProjectionMatrix;
  95194. private _transformMatrix;
  95195. private _frustumPlanes;
  95196. private _refreshFrustumPlanes;
  95197. private _storedFov;
  95198. private _stateStored;
  95199. /**
  95200. * Instantiates a new camera object.
  95201. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  95202. * @see http://doc.babylonjs.com/features/cameras
  95203. * @param name Defines the name of the camera in the scene
  95204. * @param position Defines the position of the camera
  95205. * @param scene Defines the scene the camera belongs too
  95206. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  95207. */
  95208. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95209. /**
  95210. * Store current camera state (fov, position, etc..)
  95211. * @returns the camera
  95212. */
  95213. storeState(): Camera;
  95214. /**
  95215. * Restores the camera state values if it has been stored. You must call storeState() first
  95216. */
  95217. protected _restoreStateValues(): boolean;
  95218. /**
  95219. * Restored camera state. You must call storeState() first.
  95220. * @returns true if restored and false otherwise
  95221. */
  95222. restoreState(): boolean;
  95223. /**
  95224. * Gets the class name of the camera.
  95225. * @returns the class name
  95226. */
  95227. getClassName(): string;
  95228. /** @hidden */
  95229. readonly _isCamera: boolean;
  95230. /**
  95231. * Gets a string representation of the camera useful for debug purpose.
  95232. * @param fullDetails Defines that a more verboe level of logging is required
  95233. * @returns the string representation
  95234. */
  95235. toString(fullDetails?: boolean): string;
  95236. /**
  95237. * Gets the current world space position of the camera.
  95238. */
  95239. readonly globalPosition: Vector3;
  95240. /**
  95241. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  95242. * @returns the active meshe list
  95243. */
  95244. getActiveMeshes(): SmartArray<AbstractMesh>;
  95245. /**
  95246. * Check wether a mesh is part of the current active mesh list of the camera
  95247. * @param mesh Defines the mesh to check
  95248. * @returns true if active, false otherwise
  95249. */
  95250. isActiveMesh(mesh: Mesh): boolean;
  95251. /**
  95252. * Is this camera ready to be used/rendered
  95253. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  95254. * @return true if the camera is ready
  95255. */
  95256. isReady(completeCheck?: boolean): boolean;
  95257. /** @hidden */
  95258. _initCache(): void;
  95259. /** @hidden */
  95260. _updateCache(ignoreParentClass?: boolean): void;
  95261. /** @hidden */
  95262. _isSynchronized(): boolean;
  95263. /** @hidden */
  95264. _isSynchronizedViewMatrix(): boolean;
  95265. /** @hidden */
  95266. _isSynchronizedProjectionMatrix(): boolean;
  95267. /**
  95268. * Attach the input controls to a specific dom element to get the input from.
  95269. * @param element Defines the element the controls should be listened from
  95270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95271. */
  95272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95273. /**
  95274. * Detach the current controls from the specified dom element.
  95275. * @param element Defines the element to stop listening the inputs from
  95276. */
  95277. detachControl(element: HTMLElement): void;
  95278. /**
  95279. * Update the camera state according to the different inputs gathered during the frame.
  95280. */
  95281. update(): void;
  95282. /** @hidden */
  95283. _checkInputs(): void;
  95284. /** @hidden */
  95285. readonly rigCameras: Camera[];
  95286. /**
  95287. * Gets the post process used by the rig cameras
  95288. */
  95289. readonly rigPostProcess: Nullable<PostProcess>;
  95290. /**
  95291. * Internal, gets the first post proces.
  95292. * @returns the first post process to be run on this camera.
  95293. */
  95294. _getFirstPostProcess(): Nullable<PostProcess>;
  95295. private _cascadePostProcessesToRigCams;
  95296. /**
  95297. * Attach a post process to the camera.
  95298. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  95299. * @param postProcess The post process to attach to the camera
  95300. * @param insertAt The position of the post process in case several of them are in use in the scene
  95301. * @returns the position the post process has been inserted at
  95302. */
  95303. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  95304. /**
  95305. * Detach a post process to the camera.
  95306. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  95307. * @param postProcess The post process to detach from the camera
  95308. */
  95309. detachPostProcess(postProcess: PostProcess): void;
  95310. /**
  95311. * Gets the current world matrix of the camera
  95312. */
  95313. getWorldMatrix(): Matrix;
  95314. /** @hidden */
  95315. _getViewMatrix(): Matrix;
  95316. /**
  95317. * Gets the current view matrix of the camera.
  95318. * @param force forces the camera to recompute the matrix without looking at the cached state
  95319. * @returns the view matrix
  95320. */
  95321. getViewMatrix(force?: boolean): Matrix;
  95322. /**
  95323. * Freeze the projection matrix.
  95324. * It will prevent the cache check of the camera projection compute and can speed up perf
  95325. * if no parameter of the camera are meant to change
  95326. * @param projection Defines manually a projection if necessary
  95327. */
  95328. freezeProjectionMatrix(projection?: Matrix): void;
  95329. /**
  95330. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  95331. */
  95332. unfreezeProjectionMatrix(): void;
  95333. /**
  95334. * Gets the current projection matrix of the camera.
  95335. * @param force forces the camera to recompute the matrix without looking at the cached state
  95336. * @returns the projection matrix
  95337. */
  95338. getProjectionMatrix(force?: boolean): Matrix;
  95339. /**
  95340. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  95341. * @returns a Matrix
  95342. */
  95343. getTransformationMatrix(): Matrix;
  95344. private _updateFrustumPlanes;
  95345. /**
  95346. * Checks if a cullable object (mesh...) is in the camera frustum
  95347. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  95348. * @param target The object to check
  95349. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  95350. * @returns true if the object is in frustum otherwise false
  95351. */
  95352. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  95353. /**
  95354. * Checks if a cullable object (mesh...) is in the camera frustum
  95355. * Unlike isInFrustum this cheks the full bounding box
  95356. * @param target The object to check
  95357. * @returns true if the object is in frustum otherwise false
  95358. */
  95359. isCompletelyInFrustum(target: ICullable): boolean;
  95360. /**
  95361. * Gets a ray in the forward direction from the camera.
  95362. * @param length Defines the length of the ray to create
  95363. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  95364. * @param origin Defines the start point of the ray which defaults to the camera position
  95365. * @returns the forward ray
  95366. */
  95367. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  95368. /**
  95369. * Releases resources associated with this node.
  95370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95372. */
  95373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95374. /** @hidden */
  95375. _isLeftCamera: boolean;
  95376. /**
  95377. * Gets the left camera of a rig setup in case of Rigged Camera
  95378. */
  95379. readonly isLeftCamera: boolean;
  95380. /** @hidden */
  95381. _isRightCamera: boolean;
  95382. /**
  95383. * Gets the right camera of a rig setup in case of Rigged Camera
  95384. */
  95385. readonly isRightCamera: boolean;
  95386. /**
  95387. * Gets the left camera of a rig setup in case of Rigged Camera
  95388. */
  95389. readonly leftCamera: Nullable<FreeCamera>;
  95390. /**
  95391. * Gets the right camera of a rig setup in case of Rigged Camera
  95392. */
  95393. readonly rightCamera: Nullable<FreeCamera>;
  95394. /**
  95395. * Gets the left camera target of a rig setup in case of Rigged Camera
  95396. * @returns the target position
  95397. */
  95398. getLeftTarget(): Nullable<Vector3>;
  95399. /**
  95400. * Gets the right camera target of a rig setup in case of Rigged Camera
  95401. * @returns the target position
  95402. */
  95403. getRightTarget(): Nullable<Vector3>;
  95404. /**
  95405. * @hidden
  95406. */
  95407. setCameraRigMode(mode: number, rigParams: any): void;
  95408. /** @hidden */
  95409. static _setStereoscopicRigMode(camera: Camera): void;
  95410. /** @hidden */
  95411. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  95412. /** @hidden */
  95413. static _setVRRigMode(camera: Camera, rigParams: any): void;
  95414. /** @hidden */
  95415. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  95416. /** @hidden */
  95417. _getVRProjectionMatrix(): Matrix;
  95418. protected _updateCameraRotationMatrix(): void;
  95419. protected _updateWebVRCameraRotationMatrix(): void;
  95420. /**
  95421. * This function MUST be overwritten by the different WebVR cameras available.
  95422. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  95423. * @hidden
  95424. */
  95425. _getWebVRProjectionMatrix(): Matrix;
  95426. /**
  95427. * This function MUST be overwritten by the different WebVR cameras available.
  95428. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  95429. * @hidden
  95430. */
  95431. _getWebVRViewMatrix(): Matrix;
  95432. /** @hidden */
  95433. setCameraRigParameter(name: string, value: any): void;
  95434. /**
  95435. * needs to be overridden by children so sub has required properties to be copied
  95436. * @hidden
  95437. */
  95438. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95439. /**
  95440. * May need to be overridden by children
  95441. * @hidden
  95442. */
  95443. _updateRigCameras(): void;
  95444. /** @hidden */
  95445. _setupInputs(): void;
  95446. /**
  95447. * Serialiaze the camera setup to a json represention
  95448. * @returns the JSON representation
  95449. */
  95450. serialize(): any;
  95451. /**
  95452. * Clones the current camera.
  95453. * @param name The cloned camera name
  95454. * @returns the cloned camera
  95455. */
  95456. clone(name: string): Camera;
  95457. /**
  95458. * Gets the direction of the camera relative to a given local axis.
  95459. * @param localAxis Defines the reference axis to provide a relative direction.
  95460. * @return the direction
  95461. */
  95462. getDirection(localAxis: Vector3): Vector3;
  95463. /**
  95464. * Returns the current camera absolute rotation
  95465. */
  95466. readonly absoluteRotation: Quaternion;
  95467. /**
  95468. * Gets the direction of the camera relative to a given local axis into a passed vector.
  95469. * @param localAxis Defines the reference axis to provide a relative direction.
  95470. * @param result Defines the vector to store the result in
  95471. */
  95472. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  95473. /**
  95474. * Gets a camera constructor for a given camera type
  95475. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  95476. * @param name The name of the camera the result will be able to instantiate
  95477. * @param scene The scene the result will construct the camera in
  95478. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  95479. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  95480. * @returns a factory method to construc the camera
  95481. */
  95482. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  95483. /**
  95484. * Compute the world matrix of the camera.
  95485. * @returns the camera world matrix
  95486. */
  95487. computeWorldMatrix(): Matrix;
  95488. /**
  95489. * Parse a JSON and creates the camera from the parsed information
  95490. * @param parsedCamera The JSON to parse
  95491. * @param scene The scene to instantiate the camera in
  95492. * @returns the newly constructed camera
  95493. */
  95494. static Parse(parsedCamera: any, scene: Scene): Camera;
  95495. }
  95496. }
  95497. declare module BABYLON {
  95498. /**
  95499. * Class containing static functions to help procedurally build meshes
  95500. */
  95501. export class DiscBuilder {
  95502. /**
  95503. * Creates a plane polygonal mesh. By default, this is a disc
  95504. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  95505. * * 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
  95506. * * 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
  95507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95510. * @param name defines the name of the mesh
  95511. * @param options defines the options used to create the mesh
  95512. * @param scene defines the hosting scene
  95513. * @returns the plane polygonal mesh
  95514. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  95515. */
  95516. static CreateDisc(name: string, options: {
  95517. radius?: number;
  95518. tessellation?: number;
  95519. arc?: number;
  95520. updatable?: boolean;
  95521. sideOrientation?: number;
  95522. frontUVs?: Vector4;
  95523. backUVs?: Vector4;
  95524. }, scene?: Nullable<Scene>): Mesh;
  95525. }
  95526. }
  95527. declare module BABYLON {
  95528. /**
  95529. * This represents all the required information to add a fresnel effect on a material:
  95530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95531. */
  95532. export class FresnelParameters {
  95533. private _isEnabled;
  95534. /**
  95535. * Define if the fresnel effect is enable or not.
  95536. */
  95537. isEnabled: boolean;
  95538. /**
  95539. * Define the color used on edges (grazing angle)
  95540. */
  95541. leftColor: Color3;
  95542. /**
  95543. * Define the color used on center
  95544. */
  95545. rightColor: Color3;
  95546. /**
  95547. * Define bias applied to computed fresnel term
  95548. */
  95549. bias: number;
  95550. /**
  95551. * Defined the power exponent applied to fresnel term
  95552. */
  95553. power: number;
  95554. /**
  95555. * Clones the current fresnel and its valuues
  95556. * @returns a clone fresnel configuration
  95557. */
  95558. clone(): FresnelParameters;
  95559. /**
  95560. * Serializes the current fresnel parameters to a JSON representation.
  95561. * @return the JSON serialization
  95562. */
  95563. serialize(): any;
  95564. /**
  95565. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95566. * @param parsedFresnelParameters Define the JSON representation
  95567. * @returns the parsed parameters
  95568. */
  95569. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95570. }
  95571. }
  95572. declare module BABYLON {
  95573. /**
  95574. * Base class of materials working in push mode in babylon JS
  95575. * @hidden
  95576. */
  95577. export class PushMaterial extends Material {
  95578. protected _activeEffect: Effect;
  95579. protected _normalMatrix: Matrix;
  95580. /**
  95581. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95582. * This means that the material can keep using a previous shader while a new one is being compiled.
  95583. * This is mostly used when shader parallel compilation is supported (true by default)
  95584. */
  95585. allowShaderHotSwapping: boolean;
  95586. constructor(name: string, scene: Scene);
  95587. getEffect(): Effect;
  95588. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95589. /**
  95590. * Binds the given world matrix to the active effect
  95591. *
  95592. * @param world the matrix to bind
  95593. */
  95594. bindOnlyWorldMatrix(world: Matrix): void;
  95595. /**
  95596. * Binds the given normal matrix to the active effect
  95597. *
  95598. * @param normalMatrix the matrix to bind
  95599. */
  95600. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95601. bind(world: Matrix, mesh?: Mesh): void;
  95602. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95603. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95604. }
  95605. }
  95606. declare module BABYLON {
  95607. /**
  95608. * This groups all the flags used to control the materials channel.
  95609. */
  95610. export class MaterialFlags {
  95611. private static _DiffuseTextureEnabled;
  95612. /**
  95613. * Are diffuse textures enabled in the application.
  95614. */
  95615. static DiffuseTextureEnabled: boolean;
  95616. private static _AmbientTextureEnabled;
  95617. /**
  95618. * Are ambient textures enabled in the application.
  95619. */
  95620. static AmbientTextureEnabled: boolean;
  95621. private static _OpacityTextureEnabled;
  95622. /**
  95623. * Are opacity textures enabled in the application.
  95624. */
  95625. static OpacityTextureEnabled: boolean;
  95626. private static _ReflectionTextureEnabled;
  95627. /**
  95628. * Are reflection textures enabled in the application.
  95629. */
  95630. static ReflectionTextureEnabled: boolean;
  95631. private static _EmissiveTextureEnabled;
  95632. /**
  95633. * Are emissive textures enabled in the application.
  95634. */
  95635. static EmissiveTextureEnabled: boolean;
  95636. private static _SpecularTextureEnabled;
  95637. /**
  95638. * Are specular textures enabled in the application.
  95639. */
  95640. static SpecularTextureEnabled: boolean;
  95641. private static _BumpTextureEnabled;
  95642. /**
  95643. * Are bump textures enabled in the application.
  95644. */
  95645. static BumpTextureEnabled: boolean;
  95646. private static _LightmapTextureEnabled;
  95647. /**
  95648. * Are lightmap textures enabled in the application.
  95649. */
  95650. static LightmapTextureEnabled: boolean;
  95651. private static _RefractionTextureEnabled;
  95652. /**
  95653. * Are refraction textures enabled in the application.
  95654. */
  95655. static RefractionTextureEnabled: boolean;
  95656. private static _ColorGradingTextureEnabled;
  95657. /**
  95658. * Are color grading textures enabled in the application.
  95659. */
  95660. static ColorGradingTextureEnabled: boolean;
  95661. private static _FresnelEnabled;
  95662. /**
  95663. * Are fresnels enabled in the application.
  95664. */
  95665. static FresnelEnabled: boolean;
  95666. private static _ClearCoatTextureEnabled;
  95667. /**
  95668. * Are clear coat textures enabled in the application.
  95669. */
  95670. static ClearCoatTextureEnabled: boolean;
  95671. private static _ClearCoatBumpTextureEnabled;
  95672. /**
  95673. * Are clear coat bump textures enabled in the application.
  95674. */
  95675. static ClearCoatBumpTextureEnabled: boolean;
  95676. private static _ClearCoatTintTextureEnabled;
  95677. /**
  95678. * Are clear coat tint textures enabled in the application.
  95679. */
  95680. static ClearCoatTintTextureEnabled: boolean;
  95681. private static _SheenTextureEnabled;
  95682. /**
  95683. * Are sheen textures enabled in the application.
  95684. */
  95685. static SheenTextureEnabled: boolean;
  95686. private static _AnisotropicTextureEnabled;
  95687. /**
  95688. * Are anisotropic textures enabled in the application.
  95689. */
  95690. static AnisotropicTextureEnabled: boolean;
  95691. private static _ThicknessTextureEnabled;
  95692. /**
  95693. * Are thickness textures enabled in the application.
  95694. */
  95695. static ThicknessTextureEnabled: boolean;
  95696. }
  95697. }
  95698. declare module BABYLON {
  95699. /** @hidden */
  95700. export var defaultFragmentDeclaration: {
  95701. name: string;
  95702. shader: string;
  95703. };
  95704. }
  95705. declare module BABYLON {
  95706. /** @hidden */
  95707. export var defaultUboDeclaration: {
  95708. name: string;
  95709. shader: string;
  95710. };
  95711. }
  95712. declare module BABYLON {
  95713. /** @hidden */
  95714. export var lightFragmentDeclaration: {
  95715. name: string;
  95716. shader: string;
  95717. };
  95718. }
  95719. declare module BABYLON {
  95720. /** @hidden */
  95721. export var lightUboDeclaration: {
  95722. name: string;
  95723. shader: string;
  95724. };
  95725. }
  95726. declare module BABYLON {
  95727. /** @hidden */
  95728. export var lightsFragmentFunctions: {
  95729. name: string;
  95730. shader: string;
  95731. };
  95732. }
  95733. declare module BABYLON {
  95734. /** @hidden */
  95735. export var shadowsFragmentFunctions: {
  95736. name: string;
  95737. shader: string;
  95738. };
  95739. }
  95740. declare module BABYLON {
  95741. /** @hidden */
  95742. export var fresnelFunction: {
  95743. name: string;
  95744. shader: string;
  95745. };
  95746. }
  95747. declare module BABYLON {
  95748. /** @hidden */
  95749. export var reflectionFunction: {
  95750. name: string;
  95751. shader: string;
  95752. };
  95753. }
  95754. declare module BABYLON {
  95755. /** @hidden */
  95756. export var bumpFragmentFunctions: {
  95757. name: string;
  95758. shader: string;
  95759. };
  95760. }
  95761. declare module BABYLON {
  95762. /** @hidden */
  95763. export var logDepthDeclaration: {
  95764. name: string;
  95765. shader: string;
  95766. };
  95767. }
  95768. declare module BABYLON {
  95769. /** @hidden */
  95770. export var bumpFragment: {
  95771. name: string;
  95772. shader: string;
  95773. };
  95774. }
  95775. declare module BABYLON {
  95776. /** @hidden */
  95777. export var depthPrePass: {
  95778. name: string;
  95779. shader: string;
  95780. };
  95781. }
  95782. declare module BABYLON {
  95783. /** @hidden */
  95784. export var lightFragment: {
  95785. name: string;
  95786. shader: string;
  95787. };
  95788. }
  95789. declare module BABYLON {
  95790. /** @hidden */
  95791. export var logDepthFragment: {
  95792. name: string;
  95793. shader: string;
  95794. };
  95795. }
  95796. declare module BABYLON {
  95797. /** @hidden */
  95798. export var defaultPixelShader: {
  95799. name: string;
  95800. shader: string;
  95801. };
  95802. }
  95803. declare module BABYLON {
  95804. /** @hidden */
  95805. export var defaultVertexDeclaration: {
  95806. name: string;
  95807. shader: string;
  95808. };
  95809. }
  95810. declare module BABYLON {
  95811. /** @hidden */
  95812. export var bumpVertexDeclaration: {
  95813. name: string;
  95814. shader: string;
  95815. };
  95816. }
  95817. declare module BABYLON {
  95818. /** @hidden */
  95819. export var bumpVertex: {
  95820. name: string;
  95821. shader: string;
  95822. };
  95823. }
  95824. declare module BABYLON {
  95825. /** @hidden */
  95826. export var fogVertex: {
  95827. name: string;
  95828. shader: string;
  95829. };
  95830. }
  95831. declare module BABYLON {
  95832. /** @hidden */
  95833. export var shadowsVertex: {
  95834. name: string;
  95835. shader: string;
  95836. };
  95837. }
  95838. declare module BABYLON {
  95839. /** @hidden */
  95840. export var pointCloudVertex: {
  95841. name: string;
  95842. shader: string;
  95843. };
  95844. }
  95845. declare module BABYLON {
  95846. /** @hidden */
  95847. export var logDepthVertex: {
  95848. name: string;
  95849. shader: string;
  95850. };
  95851. }
  95852. declare module BABYLON {
  95853. /** @hidden */
  95854. export var defaultVertexShader: {
  95855. name: string;
  95856. shader: string;
  95857. };
  95858. }
  95859. declare module BABYLON {
  95860. /** @hidden */
  95861. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95862. MAINUV1: boolean;
  95863. MAINUV2: boolean;
  95864. DIFFUSE: boolean;
  95865. DIFFUSEDIRECTUV: number;
  95866. AMBIENT: boolean;
  95867. AMBIENTDIRECTUV: number;
  95868. OPACITY: boolean;
  95869. OPACITYDIRECTUV: number;
  95870. OPACITYRGB: boolean;
  95871. REFLECTION: boolean;
  95872. EMISSIVE: boolean;
  95873. EMISSIVEDIRECTUV: number;
  95874. SPECULAR: boolean;
  95875. SPECULARDIRECTUV: number;
  95876. BUMP: boolean;
  95877. BUMPDIRECTUV: number;
  95878. PARALLAX: boolean;
  95879. PARALLAXOCCLUSION: boolean;
  95880. SPECULAROVERALPHA: boolean;
  95881. CLIPPLANE: boolean;
  95882. CLIPPLANE2: boolean;
  95883. CLIPPLANE3: boolean;
  95884. CLIPPLANE4: boolean;
  95885. ALPHATEST: boolean;
  95886. DEPTHPREPASS: boolean;
  95887. ALPHAFROMDIFFUSE: boolean;
  95888. POINTSIZE: boolean;
  95889. FOG: boolean;
  95890. SPECULARTERM: boolean;
  95891. DIFFUSEFRESNEL: boolean;
  95892. OPACITYFRESNEL: boolean;
  95893. REFLECTIONFRESNEL: boolean;
  95894. REFRACTIONFRESNEL: boolean;
  95895. EMISSIVEFRESNEL: boolean;
  95896. FRESNEL: boolean;
  95897. NORMAL: boolean;
  95898. UV1: boolean;
  95899. UV2: boolean;
  95900. VERTEXCOLOR: boolean;
  95901. VERTEXALPHA: boolean;
  95902. NUM_BONE_INFLUENCERS: number;
  95903. BonesPerMesh: number;
  95904. BONETEXTURE: boolean;
  95905. INSTANCES: boolean;
  95906. GLOSSINESS: boolean;
  95907. ROUGHNESS: boolean;
  95908. EMISSIVEASILLUMINATION: boolean;
  95909. LINKEMISSIVEWITHDIFFUSE: boolean;
  95910. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95911. LIGHTMAP: boolean;
  95912. LIGHTMAPDIRECTUV: number;
  95913. OBJECTSPACE_NORMALMAP: boolean;
  95914. USELIGHTMAPASSHADOWMAP: boolean;
  95915. REFLECTIONMAP_3D: boolean;
  95916. REFLECTIONMAP_SPHERICAL: boolean;
  95917. REFLECTIONMAP_PLANAR: boolean;
  95918. REFLECTIONMAP_CUBIC: boolean;
  95919. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95920. REFLECTIONMAP_PROJECTION: boolean;
  95921. REFLECTIONMAP_SKYBOX: boolean;
  95922. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95923. REFLECTIONMAP_EXPLICIT: boolean;
  95924. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95925. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95926. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95927. INVERTCUBICMAP: boolean;
  95928. LOGARITHMICDEPTH: boolean;
  95929. REFRACTION: boolean;
  95930. REFRACTIONMAP_3D: boolean;
  95931. REFLECTIONOVERALPHA: boolean;
  95932. TWOSIDEDLIGHTING: boolean;
  95933. SHADOWFLOAT: boolean;
  95934. MORPHTARGETS: boolean;
  95935. MORPHTARGETS_NORMAL: boolean;
  95936. MORPHTARGETS_TANGENT: boolean;
  95937. MORPHTARGETS_UV: boolean;
  95938. NUM_MORPH_INFLUENCERS: number;
  95939. NONUNIFORMSCALING: boolean;
  95940. PREMULTIPLYALPHA: boolean;
  95941. IMAGEPROCESSING: boolean;
  95942. VIGNETTE: boolean;
  95943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95944. VIGNETTEBLENDMODEOPAQUE: boolean;
  95945. TONEMAPPING: boolean;
  95946. TONEMAPPING_ACES: boolean;
  95947. CONTRAST: boolean;
  95948. COLORCURVES: boolean;
  95949. COLORGRADING: boolean;
  95950. COLORGRADING3D: boolean;
  95951. SAMPLER3DGREENDEPTH: boolean;
  95952. SAMPLER3DBGRMAP: boolean;
  95953. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95954. MULTIVIEW: boolean;
  95955. /**
  95956. * If the reflection texture on this material is in linear color space
  95957. * @hidden
  95958. */
  95959. IS_REFLECTION_LINEAR: boolean;
  95960. /**
  95961. * If the refraction texture on this material is in linear color space
  95962. * @hidden
  95963. */
  95964. IS_REFRACTION_LINEAR: boolean;
  95965. EXPOSURE: boolean;
  95966. constructor();
  95967. setReflectionMode(modeToEnable: string): void;
  95968. }
  95969. /**
  95970. * This is the default material used in Babylon. It is the best trade off between quality
  95971. * and performances.
  95972. * @see http://doc.babylonjs.com/babylon101/materials
  95973. */
  95974. export class StandardMaterial extends PushMaterial {
  95975. private _diffuseTexture;
  95976. /**
  95977. * The basic texture of the material as viewed under a light.
  95978. */
  95979. diffuseTexture: Nullable<BaseTexture>;
  95980. private _ambientTexture;
  95981. /**
  95982. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95983. */
  95984. ambientTexture: Nullable<BaseTexture>;
  95985. private _opacityTexture;
  95986. /**
  95987. * Define the transparency of the material from a texture.
  95988. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95989. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95990. */
  95991. opacityTexture: Nullable<BaseTexture>;
  95992. private _reflectionTexture;
  95993. /**
  95994. * Define the texture used to display the reflection.
  95995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95996. */
  95997. reflectionTexture: Nullable<BaseTexture>;
  95998. private _emissiveTexture;
  95999. /**
  96000. * Define texture of the material as if self lit.
  96001. * This will be mixed in the final result even in the absence of light.
  96002. */
  96003. emissiveTexture: Nullable<BaseTexture>;
  96004. private _specularTexture;
  96005. /**
  96006. * Define how the color and intensity of the highlight given by the light in the material.
  96007. */
  96008. specularTexture: Nullable<BaseTexture>;
  96009. private _bumpTexture;
  96010. /**
  96011. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96012. * 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.
  96013. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96014. */
  96015. bumpTexture: Nullable<BaseTexture>;
  96016. private _lightmapTexture;
  96017. /**
  96018. * Complex lighting can be computationally expensive to compute at runtime.
  96019. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96020. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96021. */
  96022. lightmapTexture: Nullable<BaseTexture>;
  96023. private _refractionTexture;
  96024. /**
  96025. * Define the texture used to display the refraction.
  96026. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96027. */
  96028. refractionTexture: Nullable<BaseTexture>;
  96029. /**
  96030. * The color of the material lit by the environmental background lighting.
  96031. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96032. */
  96033. ambientColor: Color3;
  96034. /**
  96035. * The basic color of the material as viewed under a light.
  96036. */
  96037. diffuseColor: Color3;
  96038. /**
  96039. * Define how the color and intensity of the highlight given by the light in the material.
  96040. */
  96041. specularColor: Color3;
  96042. /**
  96043. * Define the color of the material as if self lit.
  96044. * This will be mixed in the final result even in the absence of light.
  96045. */
  96046. emissiveColor: Color3;
  96047. /**
  96048. * Defines how sharp are the highlights in the material.
  96049. * The bigger the value the sharper giving a more glossy feeling to the result.
  96050. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96051. */
  96052. specularPower: number;
  96053. private _useAlphaFromDiffuseTexture;
  96054. /**
  96055. * Does the transparency come from the diffuse texture alpha channel.
  96056. */
  96057. useAlphaFromDiffuseTexture: boolean;
  96058. private _useEmissiveAsIllumination;
  96059. /**
  96060. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96061. */
  96062. useEmissiveAsIllumination: boolean;
  96063. private _linkEmissiveWithDiffuse;
  96064. /**
  96065. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96066. * the emissive level when the final color is close to one.
  96067. */
  96068. linkEmissiveWithDiffuse: boolean;
  96069. private _useSpecularOverAlpha;
  96070. /**
  96071. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96073. */
  96074. useSpecularOverAlpha: boolean;
  96075. private _useReflectionOverAlpha;
  96076. /**
  96077. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96078. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96079. */
  96080. useReflectionOverAlpha: boolean;
  96081. private _disableLighting;
  96082. /**
  96083. * Does lights from the scene impacts this material.
  96084. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96085. */
  96086. disableLighting: boolean;
  96087. private _useObjectSpaceNormalMap;
  96088. /**
  96089. * Allows using an object space normal map (instead of tangent space).
  96090. */
  96091. useObjectSpaceNormalMap: boolean;
  96092. private _useParallax;
  96093. /**
  96094. * Is parallax enabled or not.
  96095. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96096. */
  96097. useParallax: boolean;
  96098. private _useParallaxOcclusion;
  96099. /**
  96100. * Is parallax occlusion enabled or not.
  96101. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96102. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96103. */
  96104. useParallaxOcclusion: boolean;
  96105. /**
  96106. * 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.
  96107. */
  96108. parallaxScaleBias: number;
  96109. private _roughness;
  96110. /**
  96111. * Helps to define how blurry the reflections should appears in the material.
  96112. */
  96113. roughness: number;
  96114. /**
  96115. * In case of refraction, define the value of the index of refraction.
  96116. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96117. */
  96118. indexOfRefraction: number;
  96119. /**
  96120. * Invert the refraction texture alongside the y axis.
  96121. * It can be useful with procedural textures or probe for instance.
  96122. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96123. */
  96124. invertRefractionY: boolean;
  96125. /**
  96126. * Defines the alpha limits in alpha test mode.
  96127. */
  96128. alphaCutOff: number;
  96129. private _useLightmapAsShadowmap;
  96130. /**
  96131. * In case of light mapping, define whether the map contains light or shadow informations.
  96132. */
  96133. useLightmapAsShadowmap: boolean;
  96134. private _diffuseFresnelParameters;
  96135. /**
  96136. * Define the diffuse fresnel parameters of the material.
  96137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96138. */
  96139. diffuseFresnelParameters: FresnelParameters;
  96140. private _opacityFresnelParameters;
  96141. /**
  96142. * Define the opacity fresnel parameters of the material.
  96143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96144. */
  96145. opacityFresnelParameters: FresnelParameters;
  96146. private _reflectionFresnelParameters;
  96147. /**
  96148. * Define the reflection fresnel parameters of the material.
  96149. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96150. */
  96151. reflectionFresnelParameters: FresnelParameters;
  96152. private _refractionFresnelParameters;
  96153. /**
  96154. * Define the refraction fresnel parameters of the material.
  96155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96156. */
  96157. refractionFresnelParameters: FresnelParameters;
  96158. private _emissiveFresnelParameters;
  96159. /**
  96160. * Define the emissive fresnel parameters of the material.
  96161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96162. */
  96163. emissiveFresnelParameters: FresnelParameters;
  96164. private _useReflectionFresnelFromSpecular;
  96165. /**
  96166. * If true automatically deducts the fresnels values from the material specularity.
  96167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96168. */
  96169. useReflectionFresnelFromSpecular: boolean;
  96170. private _useGlossinessFromSpecularMapAlpha;
  96171. /**
  96172. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96173. */
  96174. useGlossinessFromSpecularMapAlpha: boolean;
  96175. private _maxSimultaneousLights;
  96176. /**
  96177. * Defines the maximum number of lights that can be used in the material
  96178. */
  96179. maxSimultaneousLights: number;
  96180. private _invertNormalMapX;
  96181. /**
  96182. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96183. */
  96184. invertNormalMapX: boolean;
  96185. private _invertNormalMapY;
  96186. /**
  96187. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96188. */
  96189. invertNormalMapY: boolean;
  96190. private _twoSidedLighting;
  96191. /**
  96192. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96193. */
  96194. twoSidedLighting: boolean;
  96195. /**
  96196. * Default configuration related to image processing available in the standard Material.
  96197. */
  96198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96199. /**
  96200. * Gets the image processing configuration used either in this material.
  96201. */
  96202. /**
  96203. * Sets the Default image processing configuration used either in the this material.
  96204. *
  96205. * If sets to null, the scene one is in use.
  96206. */
  96207. imageProcessingConfiguration: ImageProcessingConfiguration;
  96208. /**
  96209. * Keep track of the image processing observer to allow dispose and replace.
  96210. */
  96211. private _imageProcessingObserver;
  96212. /**
  96213. * Attaches a new image processing configuration to the Standard Material.
  96214. * @param configuration
  96215. */
  96216. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96217. /**
  96218. * Gets wether the color curves effect is enabled.
  96219. */
  96220. /**
  96221. * Sets wether the color curves effect is enabled.
  96222. */
  96223. cameraColorCurvesEnabled: boolean;
  96224. /**
  96225. * Gets wether the color grading effect is enabled.
  96226. */
  96227. /**
  96228. * Gets wether the color grading effect is enabled.
  96229. */
  96230. cameraColorGradingEnabled: boolean;
  96231. /**
  96232. * Gets wether tonemapping is enabled or not.
  96233. */
  96234. /**
  96235. * Sets wether tonemapping is enabled or not
  96236. */
  96237. cameraToneMappingEnabled: boolean;
  96238. /**
  96239. * The camera exposure used on this material.
  96240. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96241. * This corresponds to a photographic exposure.
  96242. */
  96243. /**
  96244. * The camera exposure used on this material.
  96245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96246. * This corresponds to a photographic exposure.
  96247. */
  96248. cameraExposure: number;
  96249. /**
  96250. * Gets The camera contrast used on this material.
  96251. */
  96252. /**
  96253. * Sets The camera contrast used on this material.
  96254. */
  96255. cameraContrast: number;
  96256. /**
  96257. * Gets the Color Grading 2D Lookup Texture.
  96258. */
  96259. /**
  96260. * Sets the Color Grading 2D Lookup Texture.
  96261. */
  96262. cameraColorGradingTexture: Nullable<BaseTexture>;
  96263. /**
  96264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96266. * 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;
  96267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96268. */
  96269. /**
  96270. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96271. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96272. * 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;
  96273. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96274. */
  96275. cameraColorCurves: Nullable<ColorCurves>;
  96276. /**
  96277. * Custom callback helping to override the default shader used in the material.
  96278. */
  96279. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96280. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96281. protected _worldViewProjectionMatrix: Matrix;
  96282. protected _globalAmbientColor: Color3;
  96283. protected _useLogarithmicDepth: boolean;
  96284. protected _rebuildInParallel: boolean;
  96285. /**
  96286. * Instantiates a new standard material.
  96287. * This is the default material used in Babylon. It is the best trade off between quality
  96288. * and performances.
  96289. * @see http://doc.babylonjs.com/babylon101/materials
  96290. * @param name Define the name of the material in the scene
  96291. * @param scene Define the scene the material belong to
  96292. */
  96293. constructor(name: string, scene: Scene);
  96294. /**
  96295. * Gets a boolean indicating that current material needs to register RTT
  96296. */
  96297. readonly hasRenderTargetTextures: boolean;
  96298. /**
  96299. * Gets the current class name of the material e.g. "StandardMaterial"
  96300. * Mainly use in serialization.
  96301. * @returns the class name
  96302. */
  96303. getClassName(): string;
  96304. /**
  96305. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96306. * You can try switching to logarithmic depth.
  96307. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96308. */
  96309. useLogarithmicDepth: boolean;
  96310. /**
  96311. * Specifies if the material will require alpha blending
  96312. * @returns a boolean specifying if alpha blending is needed
  96313. */
  96314. needAlphaBlending(): boolean;
  96315. /**
  96316. * Specifies if this material should be rendered in alpha test mode
  96317. * @returns a boolean specifying if an alpha test is needed.
  96318. */
  96319. needAlphaTesting(): boolean;
  96320. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96321. /**
  96322. * Get the texture used for alpha test purpose.
  96323. * @returns the diffuse texture in case of the standard material.
  96324. */
  96325. getAlphaTestTexture(): Nullable<BaseTexture>;
  96326. /**
  96327. * Get if the submesh is ready to be used and all its information available.
  96328. * Child classes can use it to update shaders
  96329. * @param mesh defines the mesh to check
  96330. * @param subMesh defines which submesh to check
  96331. * @param useInstances specifies that instances should be used
  96332. * @returns a boolean indicating that the submesh is ready or not
  96333. */
  96334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96335. /**
  96336. * Builds the material UBO layouts.
  96337. * Used internally during the effect preparation.
  96338. */
  96339. buildUniformLayout(): void;
  96340. /**
  96341. * Unbinds the material from the mesh
  96342. */
  96343. unbind(): void;
  96344. /**
  96345. * Binds the submesh to this material by preparing the effect and shader to draw
  96346. * @param world defines the world transformation matrix
  96347. * @param mesh defines the mesh containing the submesh
  96348. * @param subMesh defines the submesh to bind the material to
  96349. */
  96350. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96351. /**
  96352. * Get the list of animatables in the material.
  96353. * @returns the list of animatables object used in the material
  96354. */
  96355. getAnimatables(): IAnimatable[];
  96356. /**
  96357. * Gets the active textures from the material
  96358. * @returns an array of textures
  96359. */
  96360. getActiveTextures(): BaseTexture[];
  96361. /**
  96362. * Specifies if the material uses a texture
  96363. * @param texture defines the texture to check against the material
  96364. * @returns a boolean specifying if the material uses the texture
  96365. */
  96366. hasTexture(texture: BaseTexture): boolean;
  96367. /**
  96368. * Disposes the material
  96369. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96370. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96371. */
  96372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96373. /**
  96374. * Makes a duplicate of the material, and gives it a new name
  96375. * @param name defines the new name for the duplicated material
  96376. * @returns the cloned material
  96377. */
  96378. clone(name: string): StandardMaterial;
  96379. /**
  96380. * Serializes this material in a JSON representation
  96381. * @returns the serialized material object
  96382. */
  96383. serialize(): any;
  96384. /**
  96385. * Creates a standard material from parsed material data
  96386. * @param source defines the JSON representation of the material
  96387. * @param scene defines the hosting scene
  96388. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96389. * @returns a new standard material
  96390. */
  96391. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96392. /**
  96393. * Are diffuse textures enabled in the application.
  96394. */
  96395. static DiffuseTextureEnabled: boolean;
  96396. /**
  96397. * Are ambient textures enabled in the application.
  96398. */
  96399. static AmbientTextureEnabled: boolean;
  96400. /**
  96401. * Are opacity textures enabled in the application.
  96402. */
  96403. static OpacityTextureEnabled: boolean;
  96404. /**
  96405. * Are reflection textures enabled in the application.
  96406. */
  96407. static ReflectionTextureEnabled: boolean;
  96408. /**
  96409. * Are emissive textures enabled in the application.
  96410. */
  96411. static EmissiveTextureEnabled: boolean;
  96412. /**
  96413. * Are specular textures enabled in the application.
  96414. */
  96415. static SpecularTextureEnabled: boolean;
  96416. /**
  96417. * Are bump textures enabled in the application.
  96418. */
  96419. static BumpTextureEnabled: boolean;
  96420. /**
  96421. * Are lightmap textures enabled in the application.
  96422. */
  96423. static LightmapTextureEnabled: boolean;
  96424. /**
  96425. * Are refraction textures enabled in the application.
  96426. */
  96427. static RefractionTextureEnabled: boolean;
  96428. /**
  96429. * Are color grading textures enabled in the application.
  96430. */
  96431. static ColorGradingTextureEnabled: boolean;
  96432. /**
  96433. * Are fresnels enabled in the application.
  96434. */
  96435. static FresnelEnabled: boolean;
  96436. }
  96437. }
  96438. declare module BABYLON {
  96439. /**
  96440. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  96441. *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.
  96442. * The SPS is also a particle system. It provides some methods to manage the particles.
  96443. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  96444. *
  96445. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  96446. */
  96447. export class SolidParticleSystem implements IDisposable {
  96448. /**
  96449. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  96450. * Example : var p = SPS.particles[i];
  96451. */
  96452. particles: SolidParticle[];
  96453. /**
  96454. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  96455. */
  96456. nbParticles: number;
  96457. /**
  96458. * If the particles must ever face the camera (default false). Useful for planar particles.
  96459. */
  96460. billboard: boolean;
  96461. /**
  96462. * Recompute normals when adding a shape
  96463. */
  96464. recomputeNormals: boolean;
  96465. /**
  96466. * This a counter ofr your own usage. It's not set by any SPS functions.
  96467. */
  96468. counter: number;
  96469. /**
  96470. * The SPS name. This name is also given to the underlying mesh.
  96471. */
  96472. name: string;
  96473. /**
  96474. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  96475. */
  96476. mesh: Mesh;
  96477. /**
  96478. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  96479. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  96480. */
  96481. vars: any;
  96482. /**
  96483. * This array is populated when the SPS is set as 'pickable'.
  96484. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  96485. * Each element of this array is an object `{idx: int, faceId: int}`.
  96486. * `idx` is the picked particle index in the `SPS.particles` array
  96487. * `faceId` is the picked face index counted within this particle.
  96488. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  96489. */
  96490. pickedParticles: {
  96491. idx: number;
  96492. faceId: number;
  96493. }[];
  96494. /**
  96495. * This array is populated when `enableDepthSort` is set to true.
  96496. * Each element of this array is an instance of the class DepthSortedParticle.
  96497. */
  96498. depthSortedParticles: DepthSortedParticle[];
  96499. /**
  96500. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  96501. * @hidden
  96502. */
  96503. _bSphereOnly: boolean;
  96504. /**
  96505. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  96506. * @hidden
  96507. */
  96508. _bSphereRadiusFactor: number;
  96509. private _scene;
  96510. private _positions;
  96511. private _indices;
  96512. private _normals;
  96513. private _colors;
  96514. private _uvs;
  96515. private _indices32;
  96516. private _positions32;
  96517. private _normals32;
  96518. private _fixedNormal32;
  96519. private _colors32;
  96520. private _uvs32;
  96521. private _index;
  96522. private _updatable;
  96523. private _pickable;
  96524. private _isVisibilityBoxLocked;
  96525. private _alwaysVisible;
  96526. private _depthSort;
  96527. private _expandable;
  96528. private _shapeCounter;
  96529. private _copy;
  96530. private _color;
  96531. private _computeParticleColor;
  96532. private _computeParticleTexture;
  96533. private _computeParticleRotation;
  96534. private _computeParticleVertex;
  96535. private _computeBoundingBox;
  96536. private _depthSortParticles;
  96537. private _camera;
  96538. private _mustUnrotateFixedNormals;
  96539. private _particlesIntersect;
  96540. private _needs32Bits;
  96541. private _isNotBuilt;
  96542. private _lastParticleId;
  96543. private _idxOfId;
  96544. private _multimaterialEnabled;
  96545. private _useModelMaterial;
  96546. private _indicesByMaterial;
  96547. private _materialIndexes;
  96548. private _depthSortFunction;
  96549. private _materialSortFunction;
  96550. private _materials;
  96551. private _multimaterial;
  96552. private _materialIndexesById;
  96553. private _defaultMaterial;
  96554. private _autoUpdateSubMeshes;
  96555. /**
  96556. * Creates a SPS (Solid Particle System) object.
  96557. * @param name (String) is the SPS name, this will be the underlying mesh name.
  96558. * @param scene (Scene) is the scene in which the SPS is added.
  96559. * @param options defines the options of the sps e.g.
  96560. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  96561. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  96562. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  96563. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  96564. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  96565. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  96566. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  96567. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  96568. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  96569. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  96570. */
  96571. constructor(name: string, scene: Scene, options?: {
  96572. updatable?: boolean;
  96573. isPickable?: boolean;
  96574. enableDepthSort?: boolean;
  96575. particleIntersection?: boolean;
  96576. boundingSphereOnly?: boolean;
  96577. bSphereRadiusFactor?: number;
  96578. expandable?: boolean;
  96579. useModelMaterial?: boolean;
  96580. enableMultiMaterial?: boolean;
  96581. });
  96582. /**
  96583. * Builds the SPS underlying mesh. Returns a standard Mesh.
  96584. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  96585. * @returns the created mesh
  96586. */
  96587. buildMesh(): Mesh;
  96588. /**
  96589. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  96590. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  96591. * Thus the particles generated from `digest()` have their property `position` set yet.
  96592. * @param mesh ( Mesh ) is the mesh to be digested
  96593. * @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
  96594. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  96595. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  96596. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  96597. * @returns the current SPS
  96598. */
  96599. digest(mesh: Mesh, options?: {
  96600. facetNb?: number;
  96601. number?: number;
  96602. delta?: number;
  96603. storage?: [];
  96604. }): SolidParticleSystem;
  96605. /**
  96606. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  96607. * @hidden
  96608. */
  96609. private _unrotateFixedNormals;
  96610. /**
  96611. * Resets the temporary working copy particle
  96612. * @hidden
  96613. */
  96614. private _resetCopy;
  96615. /**
  96616. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  96617. * @param p the current index in the positions array to be updated
  96618. * @param ind the current index in the indices array
  96619. * @param shape a Vector3 array, the shape geometry
  96620. * @param positions the positions array to be updated
  96621. * @param meshInd the shape indices array
  96622. * @param indices the indices array to be updated
  96623. * @param meshUV the shape uv array
  96624. * @param uvs the uv array to be updated
  96625. * @param meshCol the shape color array
  96626. * @param colors the color array to be updated
  96627. * @param meshNor the shape normals array
  96628. * @param normals the normals array to be updated
  96629. * @param idx the particle index
  96630. * @param idxInShape the particle index in its shape
  96631. * @param options the addShape() method passed options
  96632. * @model the particle model
  96633. * @hidden
  96634. */
  96635. private _meshBuilder;
  96636. /**
  96637. * Returns a shape Vector3 array from positions float array
  96638. * @param positions float array
  96639. * @returns a vector3 array
  96640. * @hidden
  96641. */
  96642. private _posToShape;
  96643. /**
  96644. * Returns a shapeUV array from a float uvs (array deep copy)
  96645. * @param uvs as a float array
  96646. * @returns a shapeUV array
  96647. * @hidden
  96648. */
  96649. private _uvsToShapeUV;
  96650. /**
  96651. * Adds a new particle object in the particles array
  96652. * @param idx particle index in particles array
  96653. * @param id particle id
  96654. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  96655. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  96656. * @param model particle ModelShape object
  96657. * @param shapeId model shape identifier
  96658. * @param idxInShape index of the particle in the current model
  96659. * @param bInfo model bounding info object
  96660. * @param storage target storage array, if any
  96661. * @hidden
  96662. */
  96663. private _addParticle;
  96664. /**
  96665. * Adds some particles to the SPS from the model shape. Returns the shape id.
  96666. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  96667. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  96668. * @param nb (positive integer) the number of particles to be created from this model
  96669. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  96670. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  96671. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  96672. * @returns the number of shapes in the system
  96673. */
  96674. addShape(mesh: Mesh, nb: number, options?: {
  96675. positionFunction?: any;
  96676. vertexFunction?: any;
  96677. storage?: [];
  96678. }): number;
  96679. /**
  96680. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  96681. * @hidden
  96682. */
  96683. private _rebuildParticle;
  96684. /**
  96685. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  96686. * @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.
  96687. * @returns the SPS.
  96688. */
  96689. rebuildMesh(reset?: boolean): SolidParticleSystem;
  96690. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  96691. * Returns an array with the removed particles.
  96692. * 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.
  96693. * The SPS can't be empty so at least one particle needs to remain in place.
  96694. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  96695. * @param start index of the first particle to remove
  96696. * @param end index of the last particle to remove (included)
  96697. * @returns an array populated with the removed particles
  96698. */
  96699. removeParticles(start: number, end: number): SolidParticle[];
  96700. /**
  96701. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  96702. * @param solidParticleArray an array populated with Solid Particles objects
  96703. * @returns the SPS
  96704. */
  96705. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  96706. /**
  96707. * Creates a new particle and modifies the SPS mesh geometry :
  96708. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  96709. * - calls _addParticle() to populate the particle array
  96710. * factorized code from addShape() and insertParticlesFromArray()
  96711. * @param idx particle index in the particles array
  96712. * @param i particle index in its shape
  96713. * @param modelShape particle ModelShape object
  96714. * @param shape shape vertex array
  96715. * @param meshInd shape indices array
  96716. * @param meshUV shape uv array
  96717. * @param meshCol shape color array
  96718. * @param meshNor shape normals array
  96719. * @param bbInfo shape bounding info
  96720. * @param storage target particle storage
  96721. * @options addShape() passed options
  96722. * @hidden
  96723. */
  96724. private _insertNewParticle;
  96725. /**
  96726. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  96727. * This method calls `updateParticle()` for each particle of the SPS.
  96728. * For an animated SPS, it is usually called within the render loop.
  96729. * 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.
  96730. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  96731. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  96732. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  96733. * @returns the SPS.
  96734. */
  96735. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  96736. /**
  96737. * Disposes the SPS.
  96738. */
  96739. dispose(): void;
  96740. /**
  96741. * Returns a SolidParticle object from its identifier : particle.id
  96742. * @param id (integer) the particle Id
  96743. * @returns the searched particle or null if not found in the SPS.
  96744. */
  96745. getParticleById(id: number): Nullable<SolidParticle>;
  96746. /**
  96747. * Returns a new array populated with the particles having the passed shapeId.
  96748. * @param shapeId (integer) the shape identifier
  96749. * @returns a new solid particle array
  96750. */
  96751. getParticlesByShapeId(shapeId: number): SolidParticle[];
  96752. /**
  96753. * Populates the passed array "ref" with the particles having the passed shapeId.
  96754. * @param shapeId the shape identifier
  96755. * @returns the SPS
  96756. * @param ref
  96757. */
  96758. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  96759. /**
  96760. * Computes the required SubMeshes according the materials assigned to the particles.
  96761. * @returns the solid particle system.
  96762. * Does nothing if called before the SPS mesh is built.
  96763. */
  96764. computeSubMeshes(): SolidParticleSystem;
  96765. /**
  96766. * Sorts the solid particles by material when MultiMaterial is enabled.
  96767. * Updates the indices32 array.
  96768. * Updates the indicesByMaterial array.
  96769. * Updates the mesh indices array.
  96770. * @returns the SPS
  96771. * @hidden
  96772. */
  96773. private _sortParticlesByMaterial;
  96774. /**
  96775. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  96776. * @hidden
  96777. */
  96778. private _setMaterialIndexesById;
  96779. /**
  96780. * Returns an array with unique values of Materials from the passed array
  96781. * @param array the material array to be checked and filtered
  96782. * @hidden
  96783. */
  96784. private _filterUniqueMaterialId;
  96785. /**
  96786. * Sets a new Standard Material as _defaultMaterial if not already set.
  96787. * @hidden
  96788. */
  96789. private _setDefaultMaterial;
  96790. /**
  96791. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  96792. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96793. * @returns the SPS.
  96794. */
  96795. refreshVisibleSize(): SolidParticleSystem;
  96796. /**
  96797. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  96798. * @param size the size (float) of the visibility box
  96799. * note : this doesn't lock the SPS mesh bounding box.
  96800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96801. */
  96802. setVisibilityBox(size: number): void;
  96803. /**
  96804. * Gets whether the SPS as always visible or not
  96805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96806. */
  96807. /**
  96808. * Sets the SPS as always visible or not
  96809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96810. */
  96811. isAlwaysVisible: boolean;
  96812. /**
  96813. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96815. */
  96816. /**
  96817. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96819. */
  96820. isVisibilityBoxLocked: boolean;
  96821. /**
  96822. * Tells to `setParticles()` to compute the particle rotations or not.
  96823. * Default value : true. The SPS is faster when it's set to false.
  96824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96825. */
  96826. /**
  96827. * Gets if `setParticles()` computes the particle rotations or not.
  96828. * Default value : true. The SPS is faster when it's set to false.
  96829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96830. */
  96831. computeParticleRotation: boolean;
  96832. /**
  96833. * Tells to `setParticles()` to compute the particle colors or not.
  96834. * Default value : true. The SPS is faster when it's set to false.
  96835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96836. */
  96837. /**
  96838. * Gets if `setParticles()` computes the particle colors or not.
  96839. * Default value : true. The SPS is faster when it's set to false.
  96840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96841. */
  96842. computeParticleColor: boolean;
  96843. /**
  96844. * Gets if `setParticles()` computes the particle textures or not.
  96845. * Default value : true. The SPS is faster when it's set to false.
  96846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  96847. */
  96848. computeParticleTexture: boolean;
  96849. /**
  96850. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  96851. * Default value : false. The SPS is faster when it's set to false.
  96852. * Note : the particle custom vertex positions aren't stored values.
  96853. */
  96854. /**
  96855. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  96856. * Default value : false. The SPS is faster when it's set to false.
  96857. * Note : the particle custom vertex positions aren't stored values.
  96858. */
  96859. computeParticleVertex: boolean;
  96860. /**
  96861. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  96862. */
  96863. /**
  96864. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  96865. */
  96866. computeBoundingBox: boolean;
  96867. /**
  96868. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  96869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96870. * Default : `true`
  96871. */
  96872. /**
  96873. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  96874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96875. * Default : `true`
  96876. */
  96877. depthSortParticles: boolean;
  96878. /**
  96879. * Gets if the SPS is created as expandable at construction time.
  96880. * Default : `false`
  96881. */
  96882. readonly expandable: boolean;
  96883. /**
  96884. * Gets if the SPS supports the Multi Materials
  96885. */
  96886. readonly multimaterialEnabled: boolean;
  96887. /**
  96888. * Gets if the SPS uses the model materials for its own multimaterial.
  96889. */
  96890. readonly useModelMaterial: boolean;
  96891. /**
  96892. * The SPS used material array.
  96893. */
  96894. readonly materials: Material[];
  96895. /**
  96896. * Sets the SPS MultiMaterial from the passed materials.
  96897. * Note : the passed array is internally copied and not used then by reference.
  96898. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  96899. */
  96900. setMultiMaterial(materials: Material[]): void;
  96901. /**
  96902. * The SPS computed multimaterial object
  96903. */
  96904. multimaterial: MultiMaterial;
  96905. /**
  96906. * If the subMeshes must be updated on the next call to setParticles()
  96907. */
  96908. autoUpdateSubMeshes: boolean;
  96909. /**
  96910. * This function does nothing. It may be overwritten to set all the particle first values.
  96911. * The SPS doesn't call this function, you may have to call it by your own.
  96912. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96913. */
  96914. initParticles(): void;
  96915. /**
  96916. * This function does nothing. It may be overwritten to recycle a particle.
  96917. * The SPS doesn't call this function, you may have to call it by your own.
  96918. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96919. * @param particle The particle to recycle
  96920. * @returns the recycled particle
  96921. */
  96922. recycleParticle(particle: SolidParticle): SolidParticle;
  96923. /**
  96924. * Updates a particle : this function should be overwritten by the user.
  96925. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  96926. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96927. * @example : just set a particle position or velocity and recycle conditions
  96928. * @param particle The particle to update
  96929. * @returns the updated particle
  96930. */
  96931. updateParticle(particle: SolidParticle): SolidParticle;
  96932. /**
  96933. * Updates a vertex of a particle : it can be overwritten by the user.
  96934. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  96935. * @param particle the current particle
  96936. * @param vertex the current index of the current particle
  96937. * @param pt the index of the current vertex in the particle shape
  96938. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  96939. * @example : just set a vertex particle position
  96940. * @returns the updated vertex
  96941. */
  96942. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  96943. /**
  96944. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  96945. * This does nothing and may be overwritten by the user.
  96946. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96947. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96948. * @param update the boolean update value actually passed to setParticles()
  96949. */
  96950. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96951. /**
  96952. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  96953. * This will be passed three parameters.
  96954. * This does nothing and may be overwritten by the user.
  96955. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96956. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96957. * @param update the boolean update value actually passed to setParticles()
  96958. */
  96959. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96960. }
  96961. }
  96962. declare module BABYLON {
  96963. /**
  96964. * Represents one particle of a solid particle system.
  96965. */
  96966. export class SolidParticle {
  96967. /**
  96968. * particle global index
  96969. */
  96970. idx: number;
  96971. /**
  96972. * particle identifier
  96973. */
  96974. id: number;
  96975. /**
  96976. * The color of the particle
  96977. */
  96978. color: Nullable<Color4>;
  96979. /**
  96980. * The world space position of the particle.
  96981. */
  96982. position: Vector3;
  96983. /**
  96984. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  96985. */
  96986. rotation: Vector3;
  96987. /**
  96988. * The world space rotation quaternion of the particle.
  96989. */
  96990. rotationQuaternion: Nullable<Quaternion>;
  96991. /**
  96992. * The scaling of the particle.
  96993. */
  96994. scaling: Vector3;
  96995. /**
  96996. * The uvs of the particle.
  96997. */
  96998. uvs: Vector4;
  96999. /**
  97000. * The current speed of the particle.
  97001. */
  97002. velocity: Vector3;
  97003. /**
  97004. * The pivot point in the particle local space.
  97005. */
  97006. pivot: Vector3;
  97007. /**
  97008. * Must the particle be translated from its pivot point in its local space ?
  97009. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97010. * Default : false
  97011. */
  97012. translateFromPivot: boolean;
  97013. /**
  97014. * Is the particle active or not ?
  97015. */
  97016. alive: boolean;
  97017. /**
  97018. * Is the particle visible or not ?
  97019. */
  97020. isVisible: boolean;
  97021. /**
  97022. * Index of this particle in the global "positions" array (Internal use)
  97023. * @hidden
  97024. */
  97025. _pos: number;
  97026. /**
  97027. * @hidden Index of this particle in the global "indices" array (Internal use)
  97028. */
  97029. _ind: number;
  97030. /**
  97031. * @hidden ModelShape of this particle (Internal use)
  97032. */
  97033. _model: ModelShape;
  97034. /**
  97035. * ModelShape id of this particle
  97036. */
  97037. shapeId: number;
  97038. /**
  97039. * Index of the particle in its shape id
  97040. */
  97041. idxInShape: number;
  97042. /**
  97043. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97044. */
  97045. _modelBoundingInfo: BoundingInfo;
  97046. /**
  97047. * @hidden Particle BoundingInfo object (Internal use)
  97048. */
  97049. _boundingInfo: BoundingInfo;
  97050. /**
  97051. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97052. */
  97053. _sps: SolidParticleSystem;
  97054. /**
  97055. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97056. */
  97057. _stillInvisible: boolean;
  97058. /**
  97059. * @hidden Last computed particle rotation matrix
  97060. */
  97061. _rotationMatrix: number[];
  97062. /**
  97063. * Parent particle Id, if any.
  97064. * Default null.
  97065. */
  97066. parentId: Nullable<number>;
  97067. /**
  97068. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97069. */
  97070. materialIndex: Nullable<number>;
  97071. /**
  97072. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97073. * The possible values are :
  97074. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97075. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97077. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97078. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97079. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97080. * */
  97081. cullingStrategy: number;
  97082. /**
  97083. * @hidden Internal global position in the SPS.
  97084. */
  97085. _globalPosition: Vector3;
  97086. /**
  97087. * Creates a Solid Particle object.
  97088. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97089. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97090. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97091. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97092. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97093. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97094. * @param shapeId (integer) is the model shape identifier in the SPS.
  97095. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97096. * @param sps defines the sps it is associated to
  97097. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97098. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97099. */
  97100. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97101. /**
  97102. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97103. * @param target the particle target
  97104. * @returns the current particle
  97105. */
  97106. copyToRef(target: SolidParticle): SolidParticle;
  97107. /**
  97108. * Legacy support, changed scale to scaling
  97109. */
  97110. /**
  97111. * Legacy support, changed scale to scaling
  97112. */
  97113. scale: Vector3;
  97114. /**
  97115. * Legacy support, changed quaternion to rotationQuaternion
  97116. */
  97117. /**
  97118. * Legacy support, changed quaternion to rotationQuaternion
  97119. */
  97120. quaternion: Nullable<Quaternion>;
  97121. /**
  97122. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  97123. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  97124. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  97125. * @returns true if it intersects
  97126. */
  97127. intersectsMesh(target: Mesh | SolidParticle): boolean;
  97128. /**
  97129. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  97130. * A particle is in the frustum if its bounding box intersects the frustum
  97131. * @param frustumPlanes defines the frustum to test
  97132. * @returns true if the particle is in the frustum planes
  97133. */
  97134. isInFrustum(frustumPlanes: Plane[]): boolean;
  97135. /**
  97136. * get the rotation matrix of the particle
  97137. * @hidden
  97138. */
  97139. getRotationMatrix(m: Matrix): void;
  97140. }
  97141. /**
  97142. * Represents the shape of the model used by one particle of a solid particle system.
  97143. * SPS internal tool, don't use it manually.
  97144. */
  97145. export class ModelShape {
  97146. /**
  97147. * The shape id
  97148. * @hidden
  97149. */
  97150. shapeID: number;
  97151. /**
  97152. * flat array of model positions (internal use)
  97153. * @hidden
  97154. */
  97155. _shape: Vector3[];
  97156. /**
  97157. * flat array of model UVs (internal use)
  97158. * @hidden
  97159. */
  97160. _shapeUV: number[];
  97161. /**
  97162. * color array of the model
  97163. * @hidden
  97164. */
  97165. _shapeColors: number[];
  97166. /**
  97167. * indices array of the model
  97168. * @hidden
  97169. */
  97170. _indices: number[];
  97171. /**
  97172. * normals array of the model
  97173. * @hidden
  97174. */
  97175. _normals: number[];
  97176. /**
  97177. * length of the shape in the model indices array (internal use)
  97178. * @hidden
  97179. */
  97180. _indicesLength: number;
  97181. /**
  97182. * Custom position function (internal use)
  97183. * @hidden
  97184. */
  97185. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  97186. /**
  97187. * Custom vertex function (internal use)
  97188. * @hidden
  97189. */
  97190. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  97191. /**
  97192. * Model material (internal use)
  97193. * @hidden
  97194. */
  97195. _material: Nullable<Material>;
  97196. /**
  97197. * 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.
  97198. * SPS internal tool, don't use it manually.
  97199. * @hidden
  97200. */
  97201. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  97202. }
  97203. /**
  97204. * Represents a Depth Sorted Particle in the solid particle system.
  97205. * @hidden
  97206. */
  97207. export class DepthSortedParticle {
  97208. /**
  97209. * Index of the particle in the "indices" array
  97210. */
  97211. ind: number;
  97212. /**
  97213. * Length of the particle shape in the "indices" array
  97214. */
  97215. indicesLength: number;
  97216. /**
  97217. * Squared distance from the particle to the camera
  97218. */
  97219. sqDistance: number;
  97220. /**
  97221. * Material index when used with MultiMaterials
  97222. */
  97223. materialIndex: number;
  97224. /**
  97225. * Creates a new sorted particle
  97226. * @param materialIndex
  97227. */
  97228. constructor(ind: number, indLength: number, materialIndex: number);
  97229. }
  97230. }
  97231. declare module BABYLON {
  97232. /**
  97233. * @hidden
  97234. */
  97235. export class _MeshCollisionData {
  97236. _checkCollisions: boolean;
  97237. _collisionMask: number;
  97238. _collisionGroup: number;
  97239. _collider: Nullable<Collider>;
  97240. _oldPositionForCollisions: Vector3;
  97241. _diffPositionForCollisions: Vector3;
  97242. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  97243. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  97244. }
  97245. }
  97246. declare module BABYLON {
  97247. /** @hidden */
  97248. class _FacetDataStorage {
  97249. facetPositions: Vector3[];
  97250. facetNormals: Vector3[];
  97251. facetPartitioning: number[][];
  97252. facetNb: number;
  97253. partitioningSubdivisions: number;
  97254. partitioningBBoxRatio: number;
  97255. facetDataEnabled: boolean;
  97256. facetParameters: any;
  97257. bbSize: Vector3;
  97258. subDiv: {
  97259. max: number;
  97260. X: number;
  97261. Y: number;
  97262. Z: number;
  97263. };
  97264. facetDepthSort: boolean;
  97265. facetDepthSortEnabled: boolean;
  97266. depthSortedIndices: IndicesArray;
  97267. depthSortedFacets: {
  97268. ind: number;
  97269. sqDistance: number;
  97270. }[];
  97271. facetDepthSortFunction: (f1: {
  97272. ind: number;
  97273. sqDistance: number;
  97274. }, f2: {
  97275. ind: number;
  97276. sqDistance: number;
  97277. }) => number;
  97278. facetDepthSortFrom: Vector3;
  97279. facetDepthSortOrigin: Vector3;
  97280. invertedMatrix: Matrix;
  97281. }
  97282. /**
  97283. * @hidden
  97284. **/
  97285. class _InternalAbstractMeshDataInfo {
  97286. _hasVertexAlpha: boolean;
  97287. _useVertexColors: boolean;
  97288. _numBoneInfluencers: number;
  97289. _applyFog: boolean;
  97290. _receiveShadows: boolean;
  97291. _facetData: _FacetDataStorage;
  97292. _visibility: number;
  97293. _skeleton: Nullable<Skeleton>;
  97294. _layerMask: number;
  97295. _computeBonesUsingShaders: boolean;
  97296. _isActive: boolean;
  97297. _onlyForInstances: boolean;
  97298. _isActiveIntermediate: boolean;
  97299. _onlyForInstancesIntermediate: boolean;
  97300. _actAsRegularMesh: boolean;
  97301. }
  97302. /**
  97303. * Class used to store all common mesh properties
  97304. */
  97305. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  97306. /** No occlusion */
  97307. static OCCLUSION_TYPE_NONE: number;
  97308. /** Occlusion set to optimisitic */
  97309. static OCCLUSION_TYPE_OPTIMISTIC: number;
  97310. /** Occlusion set to strict */
  97311. static OCCLUSION_TYPE_STRICT: number;
  97312. /** Use an accurante occlusion algorithm */
  97313. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  97314. /** Use a conservative occlusion algorithm */
  97315. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  97316. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  97317. * Test order :
  97318. * Is the bounding sphere outside the frustum ?
  97319. * If not, are the bounding box vertices outside the frustum ?
  97320. * It not, then the cullable object is in the frustum.
  97321. */
  97322. static readonly CULLINGSTRATEGY_STANDARD: number;
  97323. /** Culling strategy : Bounding Sphere Only.
  97324. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  97325. * It's also less accurate than the standard because some not visible objects can still be selected.
  97326. * Test : is the bounding sphere outside the frustum ?
  97327. * If not, then the cullable object is in the frustum.
  97328. */
  97329. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  97330. /** Culling strategy : Optimistic Inclusion.
  97331. * This in an inclusion test first, then the standard exclusion test.
  97332. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  97333. * 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.
  97334. * Anyway, it's as accurate as the standard strategy.
  97335. * Test :
  97336. * Is the cullable object bounding sphere center in the frustum ?
  97337. * If not, apply the default culling strategy.
  97338. */
  97339. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  97340. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  97341. * This in an inclusion test first, then the bounding sphere only exclusion test.
  97342. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  97343. * 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.
  97344. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  97345. * Test :
  97346. * Is the cullable object bounding sphere center in the frustum ?
  97347. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  97348. */
  97349. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  97350. /**
  97351. * No billboard
  97352. */
  97353. static readonly BILLBOARDMODE_NONE: number;
  97354. /** Billboard on X axis */
  97355. static readonly BILLBOARDMODE_X: number;
  97356. /** Billboard on Y axis */
  97357. static readonly BILLBOARDMODE_Y: number;
  97358. /** Billboard on Z axis */
  97359. static readonly BILLBOARDMODE_Z: number;
  97360. /** Billboard on all axes */
  97361. static readonly BILLBOARDMODE_ALL: number;
  97362. /** Billboard on using position instead of orientation */
  97363. static readonly BILLBOARDMODE_USE_POSITION: number;
  97364. /** @hidden */
  97365. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  97366. /**
  97367. * The culling strategy to use to check whether the mesh must be rendered or not.
  97368. * This value can be changed at any time and will be used on the next render mesh selection.
  97369. * The possible values are :
  97370. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97371. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97372. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97373. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97374. * Please read each static variable documentation to get details about the culling process.
  97375. * */
  97376. cullingStrategy: number;
  97377. /**
  97378. * Gets the number of facets in the mesh
  97379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  97380. */
  97381. readonly facetNb: number;
  97382. /**
  97383. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  97384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  97385. */
  97386. partitioningSubdivisions: number;
  97387. /**
  97388. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  97389. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  97390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  97391. */
  97392. partitioningBBoxRatio: number;
  97393. /**
  97394. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  97395. * Works only for updatable meshes.
  97396. * Doesn't work with multi-materials
  97397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  97398. */
  97399. mustDepthSortFacets: boolean;
  97400. /**
  97401. * The location (Vector3) where the facet depth sort must be computed from.
  97402. * By default, the active camera position.
  97403. * Used only when facet depth sort is enabled
  97404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  97405. */
  97406. facetDepthSortFrom: Vector3;
  97407. /**
  97408. * gets a boolean indicating if facetData is enabled
  97409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  97410. */
  97411. readonly isFacetDataEnabled: boolean;
  97412. /** @hidden */
  97413. _updateNonUniformScalingState(value: boolean): boolean;
  97414. /**
  97415. * An event triggered when this mesh collides with another one
  97416. */
  97417. onCollideObservable: Observable<AbstractMesh>;
  97418. /** Set a function to call when this mesh collides with another one */
  97419. onCollide: () => void;
  97420. /**
  97421. * An event triggered when the collision's position changes
  97422. */
  97423. onCollisionPositionChangeObservable: Observable<Vector3>;
  97424. /** Set a function to call when the collision's position changes */
  97425. onCollisionPositionChange: () => void;
  97426. /**
  97427. * An event triggered when material is changed
  97428. */
  97429. onMaterialChangedObservable: Observable<AbstractMesh>;
  97430. /**
  97431. * Gets or sets the orientation for POV movement & rotation
  97432. */
  97433. definedFacingForward: boolean;
  97434. /** @hidden */
  97435. _occlusionQuery: Nullable<WebGLQuery>;
  97436. /** @hidden */
  97437. _renderingGroup: Nullable<RenderingGroup>;
  97438. /**
  97439. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  97440. */
  97441. /**
  97442. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  97443. */
  97444. visibility: number;
  97445. /** Gets or sets the alpha index used to sort transparent meshes
  97446. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  97447. */
  97448. alphaIndex: number;
  97449. /**
  97450. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  97451. */
  97452. isVisible: boolean;
  97453. /**
  97454. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  97455. */
  97456. isPickable: boolean;
  97457. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  97458. showSubMeshesBoundingBox: boolean;
  97459. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  97460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  97461. */
  97462. isBlocker: boolean;
  97463. /**
  97464. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  97465. */
  97466. enablePointerMoveEvents: boolean;
  97467. /**
  97468. * Specifies the rendering group id for this mesh (0 by default)
  97469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  97470. */
  97471. renderingGroupId: number;
  97472. private _material;
  97473. /** Gets or sets current material */
  97474. material: Nullable<Material>;
  97475. /**
  97476. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  97477. * @see http://doc.babylonjs.com/babylon101/shadows
  97478. */
  97479. receiveShadows: boolean;
  97480. /** Defines color to use when rendering outline */
  97481. outlineColor: Color3;
  97482. /** Define width to use when rendering outline */
  97483. outlineWidth: number;
  97484. /** Defines color to use when rendering overlay */
  97485. overlayColor: Color3;
  97486. /** Defines alpha to use when rendering overlay */
  97487. overlayAlpha: number;
  97488. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  97489. hasVertexAlpha: boolean;
  97490. /** 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) */
  97491. useVertexColors: boolean;
  97492. /**
  97493. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  97494. */
  97495. computeBonesUsingShaders: boolean;
  97496. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  97497. numBoneInfluencers: number;
  97498. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  97499. applyFog: boolean;
  97500. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  97501. useOctreeForRenderingSelection: boolean;
  97502. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  97503. useOctreeForPicking: boolean;
  97504. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  97505. useOctreeForCollisions: boolean;
  97506. /**
  97507. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  97508. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  97509. */
  97510. layerMask: number;
  97511. /**
  97512. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  97513. */
  97514. alwaysSelectAsActiveMesh: boolean;
  97515. /**
  97516. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  97517. */
  97518. doNotSyncBoundingInfo: boolean;
  97519. /**
  97520. * Gets or sets the current action manager
  97521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97522. */
  97523. actionManager: Nullable<AbstractActionManager>;
  97524. private _meshCollisionData;
  97525. /**
  97526. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  97527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97528. */
  97529. ellipsoid: Vector3;
  97530. /**
  97531. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  97532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97533. */
  97534. ellipsoidOffset: Vector3;
  97535. /**
  97536. * Gets or sets a collision mask used to mask collisions (default is -1).
  97537. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  97538. */
  97539. collisionMask: number;
  97540. /**
  97541. * Gets or sets the current collision group mask (-1 by default).
  97542. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  97543. */
  97544. collisionGroup: number;
  97545. /**
  97546. * Defines edge width used when edgesRenderer is enabled
  97547. * @see https://www.babylonjs-playground.com/#10OJSG#13
  97548. */
  97549. edgesWidth: number;
  97550. /**
  97551. * Defines edge color used when edgesRenderer is enabled
  97552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  97553. */
  97554. edgesColor: Color4;
  97555. /** @hidden */
  97556. _edgesRenderer: Nullable<IEdgesRenderer>;
  97557. /** @hidden */
  97558. _masterMesh: Nullable<AbstractMesh>;
  97559. /** @hidden */
  97560. _boundingInfo: Nullable<BoundingInfo>;
  97561. /** @hidden */
  97562. _renderId: number;
  97563. /**
  97564. * Gets or sets the list of subMeshes
  97565. * @see http://doc.babylonjs.com/how_to/multi_materials
  97566. */
  97567. subMeshes: SubMesh[];
  97568. /** @hidden */
  97569. _intersectionsInProgress: AbstractMesh[];
  97570. /** @hidden */
  97571. _unIndexed: boolean;
  97572. /** @hidden */
  97573. _lightSources: Light[];
  97574. /** Gets the list of lights affecting that mesh */
  97575. readonly lightSources: Light[];
  97576. /** @hidden */
  97577. readonly _positions: Nullable<Vector3[]>;
  97578. /** @hidden */
  97579. _waitingData: {
  97580. lods: Nullable<any>;
  97581. actions: Nullable<any>;
  97582. freezeWorldMatrix: Nullable<boolean>;
  97583. };
  97584. /** @hidden */
  97585. _bonesTransformMatrices: Nullable<Float32Array>;
  97586. /** @hidden */
  97587. _transformMatrixTexture: Nullable<RawTexture>;
  97588. /**
  97589. * Gets or sets a skeleton to apply skining transformations
  97590. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97591. */
  97592. skeleton: Nullable<Skeleton>;
  97593. /**
  97594. * An event triggered when the mesh is rebuilt.
  97595. */
  97596. onRebuildObservable: Observable<AbstractMesh>;
  97597. /**
  97598. * Creates a new AbstractMesh
  97599. * @param name defines the name of the mesh
  97600. * @param scene defines the hosting scene
  97601. */
  97602. constructor(name: string, scene?: Nullable<Scene>);
  97603. /**
  97604. * Returns the string "AbstractMesh"
  97605. * @returns "AbstractMesh"
  97606. */
  97607. getClassName(): string;
  97608. /**
  97609. * Gets a string representation of the current mesh
  97610. * @param fullDetails defines a boolean indicating if full details must be included
  97611. * @returns a string representation of the current mesh
  97612. */
  97613. toString(fullDetails?: boolean): string;
  97614. /**
  97615. * @hidden
  97616. */
  97617. protected _getEffectiveParent(): Nullable<Node>;
  97618. /** @hidden */
  97619. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97620. /** @hidden */
  97621. _rebuild(): void;
  97622. /** @hidden */
  97623. _resyncLightSources(): void;
  97624. /** @hidden */
  97625. _resyncLightSource(light: Light): void;
  97626. /** @hidden */
  97627. _unBindEffect(): void;
  97628. /** @hidden */
  97629. _removeLightSource(light: Light, dispose: boolean): void;
  97630. private _markSubMeshesAsDirty;
  97631. /** @hidden */
  97632. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  97633. /** @hidden */
  97634. _markSubMeshesAsAttributesDirty(): void;
  97635. /** @hidden */
  97636. _markSubMeshesAsMiscDirty(): void;
  97637. /**
  97638. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  97639. */
  97640. scaling: Vector3;
  97641. /**
  97642. * Returns true if the mesh is blocked. Implemented by child classes
  97643. */
  97644. readonly isBlocked: boolean;
  97645. /**
  97646. * Returns the mesh itself by default. Implemented by child classes
  97647. * @param camera defines the camera to use to pick the right LOD level
  97648. * @returns the currentAbstractMesh
  97649. */
  97650. getLOD(camera: Camera): Nullable<AbstractMesh>;
  97651. /**
  97652. * Returns 0 by default. Implemented by child classes
  97653. * @returns an integer
  97654. */
  97655. getTotalVertices(): number;
  97656. /**
  97657. * Returns a positive integer : the total number of indices in this mesh geometry.
  97658. * @returns the numner of indices or zero if the mesh has no geometry.
  97659. */
  97660. getTotalIndices(): number;
  97661. /**
  97662. * Returns null by default. Implemented by child classes
  97663. * @returns null
  97664. */
  97665. getIndices(): Nullable<IndicesArray>;
  97666. /**
  97667. * Returns the array of the requested vertex data kind. Implemented by child classes
  97668. * @param kind defines the vertex data kind to use
  97669. * @returns null
  97670. */
  97671. getVerticesData(kind: string): Nullable<FloatArray>;
  97672. /**
  97673. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97674. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97675. * Note that a new underlying VertexBuffer object is created each call.
  97676. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97677. * @param kind defines vertex data kind:
  97678. * * VertexBuffer.PositionKind
  97679. * * VertexBuffer.UVKind
  97680. * * VertexBuffer.UV2Kind
  97681. * * VertexBuffer.UV3Kind
  97682. * * VertexBuffer.UV4Kind
  97683. * * VertexBuffer.UV5Kind
  97684. * * VertexBuffer.UV6Kind
  97685. * * VertexBuffer.ColorKind
  97686. * * VertexBuffer.MatricesIndicesKind
  97687. * * VertexBuffer.MatricesIndicesExtraKind
  97688. * * VertexBuffer.MatricesWeightsKind
  97689. * * VertexBuffer.MatricesWeightsExtraKind
  97690. * @param data defines the data source
  97691. * @param updatable defines if the data must be flagged as updatable (or static)
  97692. * @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
  97693. * @returns the current mesh
  97694. */
  97695. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97696. /**
  97697. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97698. * If the mesh has no geometry, it is simply returned as it is.
  97699. * @param kind defines vertex data kind:
  97700. * * VertexBuffer.PositionKind
  97701. * * VertexBuffer.UVKind
  97702. * * VertexBuffer.UV2Kind
  97703. * * VertexBuffer.UV3Kind
  97704. * * VertexBuffer.UV4Kind
  97705. * * VertexBuffer.UV5Kind
  97706. * * VertexBuffer.UV6Kind
  97707. * * VertexBuffer.ColorKind
  97708. * * VertexBuffer.MatricesIndicesKind
  97709. * * VertexBuffer.MatricesIndicesExtraKind
  97710. * * VertexBuffer.MatricesWeightsKind
  97711. * * VertexBuffer.MatricesWeightsExtraKind
  97712. * @param data defines the data source
  97713. * @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
  97714. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  97715. * @returns the current mesh
  97716. */
  97717. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97718. /**
  97719. * Sets the mesh indices,
  97720. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97721. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  97722. * @param totalVertices Defines the total number of vertices
  97723. * @returns the current mesh
  97724. */
  97725. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  97726. /**
  97727. * Gets a boolean indicating if specific vertex data is present
  97728. * @param kind defines the vertex data kind to use
  97729. * @returns true is data kind is present
  97730. */
  97731. isVerticesDataPresent(kind: string): boolean;
  97732. /**
  97733. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  97734. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  97735. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  97736. * @returns a BoundingInfo
  97737. */
  97738. getBoundingInfo(): BoundingInfo;
  97739. /**
  97740. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  97741. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  97742. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  97743. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  97744. * @returns the current mesh
  97745. */
  97746. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  97747. /**
  97748. * Overwrite the current bounding info
  97749. * @param boundingInfo defines the new bounding info
  97750. * @returns the current mesh
  97751. */
  97752. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  97753. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  97754. readonly useBones: boolean;
  97755. /** @hidden */
  97756. _preActivate(): void;
  97757. /** @hidden */
  97758. _preActivateForIntermediateRendering(renderId: number): void;
  97759. /** @hidden */
  97760. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97761. /** @hidden */
  97762. _postActivate(): void;
  97763. /** @hidden */
  97764. _freeze(): void;
  97765. /** @hidden */
  97766. _unFreeze(): void;
  97767. /**
  97768. * Gets the current world matrix
  97769. * @returns a Matrix
  97770. */
  97771. getWorldMatrix(): Matrix;
  97772. /** @hidden */
  97773. _getWorldMatrixDeterminant(): number;
  97774. /**
  97775. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  97776. */
  97777. readonly isAnInstance: boolean;
  97778. /**
  97779. * Gets a boolean indicating if this mesh has instances
  97780. */
  97781. readonly hasInstances: boolean;
  97782. /**
  97783. * Perform relative position change from the point of view of behind the front of the mesh.
  97784. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97785. * Supports definition of mesh facing forward or backward
  97786. * @param amountRight defines the distance on the right axis
  97787. * @param amountUp defines the distance on the up axis
  97788. * @param amountForward defines the distance on the forward axis
  97789. * @returns the current mesh
  97790. */
  97791. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  97792. /**
  97793. * Calculate relative position change from the point of view of behind the front of the mesh.
  97794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97795. * Supports definition of mesh facing forward or backward
  97796. * @param amountRight defines the distance on the right axis
  97797. * @param amountUp defines the distance on the up axis
  97798. * @param amountForward defines the distance on the forward axis
  97799. * @returns the new displacement vector
  97800. */
  97801. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  97802. /**
  97803. * Perform relative rotation change from the point of view of behind the front of the mesh.
  97804. * Supports definition of mesh facing forward or backward
  97805. * @param flipBack defines the flip
  97806. * @param twirlClockwise defines the twirl
  97807. * @param tiltRight defines the tilt
  97808. * @returns the current mesh
  97809. */
  97810. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  97811. /**
  97812. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  97813. * Supports definition of mesh facing forward or backward.
  97814. * @param flipBack defines the flip
  97815. * @param twirlClockwise defines the twirl
  97816. * @param tiltRight defines the tilt
  97817. * @returns the new rotation vector
  97818. */
  97819. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  97820. /**
  97821. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97822. * This means the mesh underlying bounding box and sphere are recomputed.
  97823. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97824. * @returns the current mesh
  97825. */
  97826. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  97827. /** @hidden */
  97828. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  97829. /** @hidden */
  97830. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  97831. /** @hidden */
  97832. _updateBoundingInfo(): AbstractMesh;
  97833. /** @hidden */
  97834. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  97835. /** @hidden */
  97836. protected _afterComputeWorldMatrix(): void;
  97837. /** @hidden */
  97838. readonly _effectiveMesh: AbstractMesh;
  97839. /**
  97840. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97841. * A mesh is in the frustum if its bounding box intersects the frustum
  97842. * @param frustumPlanes defines the frustum to test
  97843. * @returns true if the mesh is in the frustum planes
  97844. */
  97845. isInFrustum(frustumPlanes: Plane[]): boolean;
  97846. /**
  97847. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  97848. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  97849. * @param frustumPlanes defines the frustum to test
  97850. * @returns true if the mesh is completely in the frustum planes
  97851. */
  97852. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97853. /**
  97854. * True if the mesh intersects another mesh or a SolidParticle object
  97855. * @param mesh defines a target mesh or SolidParticle to test
  97856. * @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)
  97857. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  97858. * @returns true if there is an intersection
  97859. */
  97860. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  97861. /**
  97862. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  97863. * @param point defines the point to test
  97864. * @returns true if there is an intersection
  97865. */
  97866. intersectsPoint(point: Vector3): boolean;
  97867. /**
  97868. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  97869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97870. */
  97871. checkCollisions: boolean;
  97872. /**
  97873. * Gets Collider object used to compute collisions (not physics)
  97874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97875. */
  97876. readonly collider: Nullable<Collider>;
  97877. /**
  97878. * Move the mesh using collision engine
  97879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97880. * @param displacement defines the requested displacement vector
  97881. * @returns the current mesh
  97882. */
  97883. moveWithCollisions(displacement: Vector3): AbstractMesh;
  97884. private _onCollisionPositionChange;
  97885. /** @hidden */
  97886. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  97887. /** @hidden */
  97888. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  97889. /** @hidden */
  97890. _checkCollision(collider: Collider): AbstractMesh;
  97891. /** @hidden */
  97892. _generatePointsArray(): boolean;
  97893. /**
  97894. * Checks if the passed Ray intersects with the mesh
  97895. * @param ray defines the ray to use
  97896. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  97897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97898. * @returns the picking info
  97899. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  97900. */
  97901. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  97902. /**
  97903. * Clones the current mesh
  97904. * @param name defines the mesh name
  97905. * @param newParent defines the new mesh parent
  97906. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  97907. * @returns the new mesh
  97908. */
  97909. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  97910. /**
  97911. * Disposes all the submeshes of the current meshnp
  97912. * @returns the current mesh
  97913. */
  97914. releaseSubMeshes(): AbstractMesh;
  97915. /**
  97916. * Releases resources associated with this abstract mesh.
  97917. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97918. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97919. */
  97920. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97921. /**
  97922. * Adds the passed mesh as a child to the current mesh
  97923. * @param mesh defines the child mesh
  97924. * @returns the current mesh
  97925. */
  97926. addChild(mesh: AbstractMesh): AbstractMesh;
  97927. /**
  97928. * Removes the passed mesh from the current mesh children list
  97929. * @param mesh defines the child mesh
  97930. * @returns the current mesh
  97931. */
  97932. removeChild(mesh: AbstractMesh): AbstractMesh;
  97933. /** @hidden */
  97934. private _initFacetData;
  97935. /**
  97936. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  97937. * This method can be called within the render loop.
  97938. * 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
  97939. * @returns the current mesh
  97940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97941. */
  97942. updateFacetData(): AbstractMesh;
  97943. /**
  97944. * Returns the facetLocalNormals array.
  97945. * The normals are expressed in the mesh local spac
  97946. * @returns an array of Vector3
  97947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97948. */
  97949. getFacetLocalNormals(): Vector3[];
  97950. /**
  97951. * Returns the facetLocalPositions array.
  97952. * The facet positions are expressed in the mesh local space
  97953. * @returns an array of Vector3
  97954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97955. */
  97956. getFacetLocalPositions(): Vector3[];
  97957. /**
  97958. * Returns the facetLocalPartioning array
  97959. * @returns an array of array of numbers
  97960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97961. */
  97962. getFacetLocalPartitioning(): number[][];
  97963. /**
  97964. * Returns the i-th facet position in the world system.
  97965. * This method allocates a new Vector3 per call
  97966. * @param i defines the facet index
  97967. * @returns a new Vector3
  97968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97969. */
  97970. getFacetPosition(i: number): Vector3;
  97971. /**
  97972. * Sets the reference Vector3 with the i-th facet position in the world system
  97973. * @param i defines the facet index
  97974. * @param ref defines the target vector
  97975. * @returns the current mesh
  97976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97977. */
  97978. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  97979. /**
  97980. * Returns the i-th facet normal in the world system.
  97981. * This method allocates a new Vector3 per call
  97982. * @param i defines the facet index
  97983. * @returns a new Vector3
  97984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97985. */
  97986. getFacetNormal(i: number): Vector3;
  97987. /**
  97988. * Sets the reference Vector3 with the i-th facet normal in the world system
  97989. * @param i defines the facet index
  97990. * @param ref defines the target vector
  97991. * @returns the current mesh
  97992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97993. */
  97994. getFacetNormalToRef(i: number, ref: Vector3): this;
  97995. /**
  97996. * 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)
  97997. * @param x defines x coordinate
  97998. * @param y defines y coordinate
  97999. * @param z defines z coordinate
  98000. * @returns the array of facet indexes
  98001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98002. */
  98003. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98004. /**
  98005. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98006. * @param projected sets as the (x,y,z) world projection on the facet
  98007. * @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
  98008. * @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
  98009. * @param x defines x coordinate
  98010. * @param y defines y coordinate
  98011. * @param z defines z coordinate
  98012. * @returns the face index if found (or null instead)
  98013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98014. */
  98015. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98016. /**
  98017. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98018. * @param projected sets as the (x,y,z) local projection on the facet
  98019. * @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
  98020. * @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
  98021. * @param x defines x coordinate
  98022. * @param y defines y coordinate
  98023. * @param z defines z coordinate
  98024. * @returns the face index if found (or null instead)
  98025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98026. */
  98027. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98028. /**
  98029. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98030. * @returns the parameters
  98031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98032. */
  98033. getFacetDataParameters(): any;
  98034. /**
  98035. * Disables the feature FacetData and frees the related memory
  98036. * @returns the current mesh
  98037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98038. */
  98039. disableFacetData(): AbstractMesh;
  98040. /**
  98041. * Updates the AbstractMesh indices array
  98042. * @param indices defines the data source
  98043. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98044. * @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)
  98045. * @returns the current mesh
  98046. */
  98047. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98048. /**
  98049. * Creates new normals data for the mesh
  98050. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98051. * @returns the current mesh
  98052. */
  98053. createNormals(updatable: boolean): AbstractMesh;
  98054. /**
  98055. * Align the mesh with a normal
  98056. * @param normal defines the normal to use
  98057. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98058. * @returns the current mesh
  98059. */
  98060. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98061. /** @hidden */
  98062. _checkOcclusionQuery(): boolean;
  98063. /**
  98064. * Disables the mesh edge rendering mode
  98065. * @returns the currentAbstractMesh
  98066. */
  98067. disableEdgesRendering(): AbstractMesh;
  98068. /**
  98069. * Enables the edge rendering mode on the mesh.
  98070. * This mode makes the mesh edges visible
  98071. * @param epsilon defines the maximal distance between two angles to detect a face
  98072. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98073. * @returns the currentAbstractMesh
  98074. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98075. */
  98076. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98077. }
  98078. }
  98079. declare module BABYLON {
  98080. /**
  98081. * Interface used to define ActionEvent
  98082. */
  98083. export interface IActionEvent {
  98084. /** The mesh or sprite that triggered the action */
  98085. source: any;
  98086. /** The X mouse cursor position at the time of the event */
  98087. pointerX: number;
  98088. /** The Y mouse cursor position at the time of the event */
  98089. pointerY: number;
  98090. /** The mesh that is currently pointed at (can be null) */
  98091. meshUnderPointer: Nullable<AbstractMesh>;
  98092. /** the original (browser) event that triggered the ActionEvent */
  98093. sourceEvent?: any;
  98094. /** additional data for the event */
  98095. additionalData?: any;
  98096. }
  98097. /**
  98098. * ActionEvent is the event being sent when an action is triggered.
  98099. */
  98100. export class ActionEvent implements IActionEvent {
  98101. /** The mesh or sprite that triggered the action */
  98102. source: any;
  98103. /** The X mouse cursor position at the time of the event */
  98104. pointerX: number;
  98105. /** The Y mouse cursor position at the time of the event */
  98106. pointerY: number;
  98107. /** The mesh that is currently pointed at (can be null) */
  98108. meshUnderPointer: Nullable<AbstractMesh>;
  98109. /** the original (browser) event that triggered the ActionEvent */
  98110. sourceEvent?: any;
  98111. /** additional data for the event */
  98112. additionalData?: any;
  98113. /**
  98114. * Creates a new ActionEvent
  98115. * @param source The mesh or sprite that triggered the action
  98116. * @param pointerX The X mouse cursor position at the time of the event
  98117. * @param pointerY The Y mouse cursor position at the time of the event
  98118. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  98119. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  98120. * @param additionalData additional data for the event
  98121. */
  98122. constructor(
  98123. /** The mesh or sprite that triggered the action */
  98124. source: any,
  98125. /** The X mouse cursor position at the time of the event */
  98126. pointerX: number,
  98127. /** The Y mouse cursor position at the time of the event */
  98128. pointerY: number,
  98129. /** The mesh that is currently pointed at (can be null) */
  98130. meshUnderPointer: Nullable<AbstractMesh>,
  98131. /** the original (browser) event that triggered the ActionEvent */
  98132. sourceEvent?: any,
  98133. /** additional data for the event */
  98134. additionalData?: any);
  98135. /**
  98136. * Helper function to auto-create an ActionEvent from a source mesh.
  98137. * @param source The source mesh that triggered the event
  98138. * @param evt The original (browser) event
  98139. * @param additionalData additional data for the event
  98140. * @returns the new ActionEvent
  98141. */
  98142. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  98143. /**
  98144. * Helper function to auto-create an ActionEvent from a source sprite
  98145. * @param source The source sprite that triggered the event
  98146. * @param scene Scene associated with the sprite
  98147. * @param evt The original (browser) event
  98148. * @param additionalData additional data for the event
  98149. * @returns the new ActionEvent
  98150. */
  98151. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  98152. /**
  98153. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  98154. * @param scene the scene where the event occurred
  98155. * @param evt The original (browser) event
  98156. * @returns the new ActionEvent
  98157. */
  98158. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  98159. /**
  98160. * Helper function to auto-create an ActionEvent from a primitive
  98161. * @param prim defines the target primitive
  98162. * @param pointerPos defines the pointer position
  98163. * @param evt The original (browser) event
  98164. * @param additionalData additional data for the event
  98165. * @returns the new ActionEvent
  98166. */
  98167. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  98168. }
  98169. }
  98170. declare module BABYLON {
  98171. /**
  98172. * Abstract class used to decouple action Manager from scene and meshes.
  98173. * Do not instantiate.
  98174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98175. */
  98176. export abstract class AbstractActionManager implements IDisposable {
  98177. /** Gets the list of active triggers */
  98178. static Triggers: {
  98179. [key: string]: number;
  98180. };
  98181. /** Gets the cursor to use when hovering items */
  98182. hoverCursor: string;
  98183. /** Gets the list of actions */
  98184. actions: IAction[];
  98185. /**
  98186. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  98187. */
  98188. isRecursive: boolean;
  98189. /**
  98190. * Releases all associated resources
  98191. */
  98192. abstract dispose(): void;
  98193. /**
  98194. * Does this action manager has pointer triggers
  98195. */
  98196. abstract readonly hasPointerTriggers: boolean;
  98197. /**
  98198. * Does this action manager has pick triggers
  98199. */
  98200. abstract readonly hasPickTriggers: boolean;
  98201. /**
  98202. * Process a specific trigger
  98203. * @param trigger defines the trigger to process
  98204. * @param evt defines the event details to be processed
  98205. */
  98206. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  98207. /**
  98208. * Does this action manager handles actions of any of the given triggers
  98209. * @param triggers defines the triggers to be tested
  98210. * @return a boolean indicating whether one (or more) of the triggers is handled
  98211. */
  98212. abstract hasSpecificTriggers(triggers: number[]): boolean;
  98213. /**
  98214. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  98215. * speed.
  98216. * @param triggerA defines the trigger to be tested
  98217. * @param triggerB defines the trigger to be tested
  98218. * @return a boolean indicating whether one (or more) of the triggers is handled
  98219. */
  98220. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  98221. /**
  98222. * Does this action manager handles actions of a given trigger
  98223. * @param trigger defines the trigger to be tested
  98224. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  98225. * @return whether the trigger is handled
  98226. */
  98227. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  98228. /**
  98229. * Serialize this manager to a JSON object
  98230. * @param name defines the property name to store this manager
  98231. * @returns a JSON representation of this manager
  98232. */
  98233. abstract serialize(name: string): any;
  98234. /**
  98235. * Registers an action to this action manager
  98236. * @param action defines the action to be registered
  98237. * @return the action amended (prepared) after registration
  98238. */
  98239. abstract registerAction(action: IAction): Nullable<IAction>;
  98240. /**
  98241. * Unregisters an action to this action manager
  98242. * @param action defines the action to be unregistered
  98243. * @return a boolean indicating whether the action has been unregistered
  98244. */
  98245. abstract unregisterAction(action: IAction): Boolean;
  98246. /**
  98247. * Does exist one action manager with at least one trigger
  98248. **/
  98249. static readonly HasTriggers: boolean;
  98250. /**
  98251. * Does exist one action manager with at least one pick trigger
  98252. **/
  98253. static readonly HasPickTriggers: boolean;
  98254. /**
  98255. * Does exist one action manager that handles actions of a given trigger
  98256. * @param trigger defines the trigger to be tested
  98257. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  98258. **/
  98259. static HasSpecificTrigger(trigger: number): boolean;
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * Defines how a node can be built from a string name.
  98265. */
  98266. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  98267. /**
  98268. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  98269. */
  98270. export class Node implements IBehaviorAware<Node> {
  98271. /** @hidden */
  98272. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  98273. private static _NodeConstructors;
  98274. /**
  98275. * Add a new node constructor
  98276. * @param type defines the type name of the node to construct
  98277. * @param constructorFunc defines the constructor function
  98278. */
  98279. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  98280. /**
  98281. * Returns a node constructor based on type name
  98282. * @param type defines the type name
  98283. * @param name defines the new node name
  98284. * @param scene defines the hosting scene
  98285. * @param options defines optional options to transmit to constructors
  98286. * @returns the new constructor or null
  98287. */
  98288. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  98289. /**
  98290. * Gets or sets the name of the node
  98291. */
  98292. name: string;
  98293. /**
  98294. * Gets or sets the id of the node
  98295. */
  98296. id: string;
  98297. /**
  98298. * Gets or sets the unique id of the node
  98299. */
  98300. uniqueId: number;
  98301. /**
  98302. * Gets or sets a string used to store user defined state for the node
  98303. */
  98304. state: string;
  98305. /**
  98306. * Gets or sets an object used to store user defined information for the node
  98307. */
  98308. metadata: any;
  98309. /**
  98310. * For internal use only. Please do not use.
  98311. */
  98312. reservedDataStore: any;
  98313. /**
  98314. * List of inspectable custom properties (used by the Inspector)
  98315. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  98316. */
  98317. inspectableCustomProperties: IInspectable[];
  98318. private _doNotSerialize;
  98319. /**
  98320. * Gets or sets a boolean used to define if the node must be serialized
  98321. */
  98322. doNotSerialize: boolean;
  98323. /** @hidden */
  98324. _isDisposed: boolean;
  98325. /**
  98326. * Gets a list of Animations associated with the node
  98327. */
  98328. animations: Animation[];
  98329. protected _ranges: {
  98330. [name: string]: Nullable<AnimationRange>;
  98331. };
  98332. /**
  98333. * Callback raised when the node is ready to be used
  98334. */
  98335. onReady: Nullable<(node: Node) => void>;
  98336. private _isEnabled;
  98337. private _isParentEnabled;
  98338. private _isReady;
  98339. /** @hidden */
  98340. _currentRenderId: number;
  98341. private _parentUpdateId;
  98342. /** @hidden */
  98343. _childUpdateId: number;
  98344. /** @hidden */
  98345. _waitingParentId: Nullable<string>;
  98346. /** @hidden */
  98347. _scene: Scene;
  98348. /** @hidden */
  98349. _cache: any;
  98350. private _parentNode;
  98351. private _children;
  98352. /** @hidden */
  98353. _worldMatrix: Matrix;
  98354. /** @hidden */
  98355. _worldMatrixDeterminant: number;
  98356. /** @hidden */
  98357. _worldMatrixDeterminantIsDirty: boolean;
  98358. /** @hidden */
  98359. private _sceneRootNodesIndex;
  98360. /**
  98361. * Gets a boolean indicating if the node has been disposed
  98362. * @returns true if the node was disposed
  98363. */
  98364. isDisposed(): boolean;
  98365. /**
  98366. * Gets or sets the parent of the node (without keeping the current position in the scene)
  98367. * @see https://doc.babylonjs.com/how_to/parenting
  98368. */
  98369. parent: Nullable<Node>;
  98370. /** @hidden */
  98371. _addToSceneRootNodes(): void;
  98372. /** @hidden */
  98373. _removeFromSceneRootNodes(): void;
  98374. private _animationPropertiesOverride;
  98375. /**
  98376. * Gets or sets the animation properties override
  98377. */
  98378. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98379. /**
  98380. * Gets a string idenfifying the name of the class
  98381. * @returns "Node" string
  98382. */
  98383. getClassName(): string;
  98384. /** @hidden */
  98385. readonly _isNode: boolean;
  98386. /**
  98387. * An event triggered when the mesh is disposed
  98388. */
  98389. onDisposeObservable: Observable<Node>;
  98390. private _onDisposeObserver;
  98391. /**
  98392. * Sets a callback that will be raised when the node will be disposed
  98393. */
  98394. onDispose: () => void;
  98395. /**
  98396. * Creates a new Node
  98397. * @param name the name and id to be given to this node
  98398. * @param scene the scene this node will be added to
  98399. */
  98400. constructor(name: string, scene?: Nullable<Scene>);
  98401. /**
  98402. * Gets the scene of the node
  98403. * @returns a scene
  98404. */
  98405. getScene(): Scene;
  98406. /**
  98407. * Gets the engine of the node
  98408. * @returns a Engine
  98409. */
  98410. getEngine(): Engine;
  98411. private _behaviors;
  98412. /**
  98413. * Attach a behavior to the node
  98414. * @see http://doc.babylonjs.com/features/behaviour
  98415. * @param behavior defines the behavior to attach
  98416. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  98417. * @returns the current Node
  98418. */
  98419. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  98420. /**
  98421. * Remove an attached behavior
  98422. * @see http://doc.babylonjs.com/features/behaviour
  98423. * @param behavior defines the behavior to attach
  98424. * @returns the current Node
  98425. */
  98426. removeBehavior(behavior: Behavior<Node>): Node;
  98427. /**
  98428. * Gets the list of attached behaviors
  98429. * @see http://doc.babylonjs.com/features/behaviour
  98430. */
  98431. readonly behaviors: Behavior<Node>[];
  98432. /**
  98433. * Gets an attached behavior by name
  98434. * @param name defines the name of the behavior to look for
  98435. * @see http://doc.babylonjs.com/features/behaviour
  98436. * @returns null if behavior was not found else the requested behavior
  98437. */
  98438. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  98439. /**
  98440. * Returns the latest update of the World matrix
  98441. * @returns a Matrix
  98442. */
  98443. getWorldMatrix(): Matrix;
  98444. /** @hidden */
  98445. _getWorldMatrixDeterminant(): number;
  98446. /**
  98447. * Returns directly the latest state of the mesh World matrix.
  98448. * A Matrix is returned.
  98449. */
  98450. readonly worldMatrixFromCache: Matrix;
  98451. /** @hidden */
  98452. _initCache(): void;
  98453. /** @hidden */
  98454. updateCache(force?: boolean): void;
  98455. /** @hidden */
  98456. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98457. /** @hidden */
  98458. _updateCache(ignoreParentClass?: boolean): void;
  98459. /** @hidden */
  98460. _isSynchronized(): boolean;
  98461. /** @hidden */
  98462. _markSyncedWithParent(): void;
  98463. /** @hidden */
  98464. isSynchronizedWithParent(): boolean;
  98465. /** @hidden */
  98466. isSynchronized(): boolean;
  98467. /**
  98468. * Is this node ready to be used/rendered
  98469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98470. * @return true if the node is ready
  98471. */
  98472. isReady(completeCheck?: boolean): boolean;
  98473. /**
  98474. * Is this node enabled?
  98475. * 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
  98476. * @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
  98477. * @return whether this node (and its parent) is enabled
  98478. */
  98479. isEnabled(checkAncestors?: boolean): boolean;
  98480. /** @hidden */
  98481. protected _syncParentEnabledState(): void;
  98482. /**
  98483. * Set the enabled state of this node
  98484. * @param value defines the new enabled state
  98485. */
  98486. setEnabled(value: boolean): void;
  98487. /**
  98488. * Is this node a descendant of the given node?
  98489. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  98490. * @param ancestor defines the parent node to inspect
  98491. * @returns a boolean indicating if this node is a descendant of the given node
  98492. */
  98493. isDescendantOf(ancestor: Node): boolean;
  98494. /** @hidden */
  98495. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  98496. /**
  98497. * Will return all nodes that have this node as ascendant
  98498. * @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
  98499. * @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
  98500. * @return all children nodes of all types
  98501. */
  98502. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  98503. /**
  98504. * Get all child-meshes of this node
  98505. * @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)
  98506. * @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
  98507. * @returns an array of AbstractMesh
  98508. */
  98509. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  98510. /**
  98511. * Get all direct children of this node
  98512. * @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
  98513. * @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)
  98514. * @returns an array of Node
  98515. */
  98516. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  98517. /** @hidden */
  98518. _setReady(state: boolean): void;
  98519. /**
  98520. * Get an animation by name
  98521. * @param name defines the name of the animation to look for
  98522. * @returns null if not found else the requested animation
  98523. */
  98524. getAnimationByName(name: string): Nullable<Animation>;
  98525. /**
  98526. * Creates an animation range for this node
  98527. * @param name defines the name of the range
  98528. * @param from defines the starting key
  98529. * @param to defines the end key
  98530. */
  98531. createAnimationRange(name: string, from: number, to: number): void;
  98532. /**
  98533. * Delete a specific animation range
  98534. * @param name defines the name of the range to delete
  98535. * @param deleteFrames defines if animation frames from the range must be deleted as well
  98536. */
  98537. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  98538. /**
  98539. * Get an animation range by name
  98540. * @param name defines the name of the animation range to look for
  98541. * @returns null if not found else the requested animation range
  98542. */
  98543. getAnimationRange(name: string): Nullable<AnimationRange>;
  98544. /**
  98545. * Gets the list of all animation ranges defined on this node
  98546. * @returns an array
  98547. */
  98548. getAnimationRanges(): Nullable<AnimationRange>[];
  98549. /**
  98550. * Will start the animation sequence
  98551. * @param name defines the range frames for animation sequence
  98552. * @param loop defines if the animation should loop (false by default)
  98553. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  98554. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  98555. * @returns the object created for this animation. If range does not exist, it will return null
  98556. */
  98557. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  98558. /**
  98559. * Serialize animation ranges into a JSON compatible object
  98560. * @returns serialization object
  98561. */
  98562. serializeAnimationRanges(): any;
  98563. /**
  98564. * Computes the world matrix of the node
  98565. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98566. * @returns the world matrix
  98567. */
  98568. computeWorldMatrix(force?: boolean): Matrix;
  98569. /**
  98570. * Releases resources associated with this node.
  98571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98573. */
  98574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98575. /**
  98576. * Parse animation range data from a serialization object and store them into a given node
  98577. * @param node defines where to store the animation ranges
  98578. * @param parsedNode defines the serialization object to read data from
  98579. * @param scene defines the hosting scene
  98580. */
  98581. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  98582. /**
  98583. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  98584. * @param includeDescendants Include bounding info from descendants as well (true by default)
  98585. * @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
  98586. * @returns the new bounding vectors
  98587. */
  98588. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  98589. min: Vector3;
  98590. max: Vector3;
  98591. };
  98592. }
  98593. }
  98594. declare module BABYLON {
  98595. /**
  98596. * @hidden
  98597. */
  98598. export class _IAnimationState {
  98599. key: number;
  98600. repeatCount: number;
  98601. workValue?: any;
  98602. loopMode?: number;
  98603. offsetValue?: any;
  98604. highLimitValue?: any;
  98605. }
  98606. /**
  98607. * Class used to store any kind of animation
  98608. */
  98609. export class Animation {
  98610. /**Name of the animation */
  98611. name: string;
  98612. /**Property to animate */
  98613. targetProperty: string;
  98614. /**The frames per second of the animation */
  98615. framePerSecond: number;
  98616. /**The data type of the animation */
  98617. dataType: number;
  98618. /**The loop mode of the animation */
  98619. loopMode?: number | undefined;
  98620. /**Specifies if blending should be enabled */
  98621. enableBlending?: boolean | undefined;
  98622. /**
  98623. * Use matrix interpolation instead of using direct key value when animating matrices
  98624. */
  98625. static AllowMatricesInterpolation: boolean;
  98626. /**
  98627. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  98628. */
  98629. static AllowMatrixDecomposeForInterpolation: boolean;
  98630. /**
  98631. * Stores the key frames of the animation
  98632. */
  98633. private _keys;
  98634. /**
  98635. * Stores the easing function of the animation
  98636. */
  98637. private _easingFunction;
  98638. /**
  98639. * @hidden Internal use only
  98640. */
  98641. _runtimeAnimations: RuntimeAnimation[];
  98642. /**
  98643. * The set of event that will be linked to this animation
  98644. */
  98645. private _events;
  98646. /**
  98647. * Stores an array of target property paths
  98648. */
  98649. targetPropertyPath: string[];
  98650. /**
  98651. * Stores the blending speed of the animation
  98652. */
  98653. blendingSpeed: number;
  98654. /**
  98655. * Stores the animation ranges for the animation
  98656. */
  98657. private _ranges;
  98658. /**
  98659. * @hidden Internal use
  98660. */
  98661. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  98662. /**
  98663. * Sets up an animation
  98664. * @param property The property to animate
  98665. * @param animationType The animation type to apply
  98666. * @param framePerSecond The frames per second of the animation
  98667. * @param easingFunction The easing function used in the animation
  98668. * @returns The created animation
  98669. */
  98670. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  98671. /**
  98672. * Create and start an animation on a node
  98673. * @param name defines the name of the global animation that will be run on all nodes
  98674. * @param node defines the root node where the animation will take place
  98675. * @param targetProperty defines property to animate
  98676. * @param framePerSecond defines the number of frame per second yo use
  98677. * @param totalFrame defines the number of frames in total
  98678. * @param from defines the initial value
  98679. * @param to defines the final value
  98680. * @param loopMode defines which loop mode you want to use (off by default)
  98681. * @param easingFunction defines the easing function to use (linear by default)
  98682. * @param onAnimationEnd defines the callback to call when animation end
  98683. * @returns the animatable created for this animation
  98684. */
  98685. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98686. /**
  98687. * Create and start an animation on a node and its descendants
  98688. * @param name defines the name of the global animation that will be run on all nodes
  98689. * @param node defines the root node where the animation will take place
  98690. * @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
  98691. * @param targetProperty defines property to animate
  98692. * @param framePerSecond defines the number of frame per second to use
  98693. * @param totalFrame defines the number of frames in total
  98694. * @param from defines the initial value
  98695. * @param to defines the final value
  98696. * @param loopMode defines which loop mode you want to use (off by default)
  98697. * @param easingFunction defines the easing function to use (linear by default)
  98698. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  98699. * @returns the list of animatables created for all nodes
  98700. * @example https://www.babylonjs-playground.com/#MH0VLI
  98701. */
  98702. 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[]>;
  98703. /**
  98704. * Creates a new animation, merges it with the existing animations and starts it
  98705. * @param name Name of the animation
  98706. * @param node Node which contains the scene that begins the animations
  98707. * @param targetProperty Specifies which property to animate
  98708. * @param framePerSecond The frames per second of the animation
  98709. * @param totalFrame The total number of frames
  98710. * @param from The frame at the beginning of the animation
  98711. * @param to The frame at the end of the animation
  98712. * @param loopMode Specifies the loop mode of the animation
  98713. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  98714. * @param onAnimationEnd Callback to run once the animation is complete
  98715. * @returns Nullable animation
  98716. */
  98717. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98718. /**
  98719. * Transition property of an host to the target Value
  98720. * @param property The property to transition
  98721. * @param targetValue The target Value of the property
  98722. * @param host The object where the property to animate belongs
  98723. * @param scene Scene used to run the animation
  98724. * @param frameRate Framerate (in frame/s) to use
  98725. * @param transition The transition type we want to use
  98726. * @param duration The duration of the animation, in milliseconds
  98727. * @param onAnimationEnd Callback trigger at the end of the animation
  98728. * @returns Nullable animation
  98729. */
  98730. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  98731. /**
  98732. * Return the array of runtime animations currently using this animation
  98733. */
  98734. readonly runtimeAnimations: RuntimeAnimation[];
  98735. /**
  98736. * Specifies if any of the runtime animations are currently running
  98737. */
  98738. readonly hasRunningRuntimeAnimations: boolean;
  98739. /**
  98740. * Initializes the animation
  98741. * @param name Name of the animation
  98742. * @param targetProperty Property to animate
  98743. * @param framePerSecond The frames per second of the animation
  98744. * @param dataType The data type of the animation
  98745. * @param loopMode The loop mode of the animation
  98746. * @param enableBlending Specifies if blending should be enabled
  98747. */
  98748. constructor(
  98749. /**Name of the animation */
  98750. name: string,
  98751. /**Property to animate */
  98752. targetProperty: string,
  98753. /**The frames per second of the animation */
  98754. framePerSecond: number,
  98755. /**The data type of the animation */
  98756. dataType: number,
  98757. /**The loop mode of the animation */
  98758. loopMode?: number | undefined,
  98759. /**Specifies if blending should be enabled */
  98760. enableBlending?: boolean | undefined);
  98761. /**
  98762. * Converts the animation to a string
  98763. * @param fullDetails support for multiple levels of logging within scene loading
  98764. * @returns String form of the animation
  98765. */
  98766. toString(fullDetails?: boolean): string;
  98767. /**
  98768. * Add an event to this animation
  98769. * @param event Event to add
  98770. */
  98771. addEvent(event: AnimationEvent): void;
  98772. /**
  98773. * Remove all events found at the given frame
  98774. * @param frame The frame to remove events from
  98775. */
  98776. removeEvents(frame: number): void;
  98777. /**
  98778. * Retrieves all the events from the animation
  98779. * @returns Events from the animation
  98780. */
  98781. getEvents(): AnimationEvent[];
  98782. /**
  98783. * Creates an animation range
  98784. * @param name Name of the animation range
  98785. * @param from Starting frame of the animation range
  98786. * @param to Ending frame of the animation
  98787. */
  98788. createRange(name: string, from: number, to: number): void;
  98789. /**
  98790. * Deletes an animation range by name
  98791. * @param name Name of the animation range to delete
  98792. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  98793. */
  98794. deleteRange(name: string, deleteFrames?: boolean): void;
  98795. /**
  98796. * Gets the animation range by name, or null if not defined
  98797. * @param name Name of the animation range
  98798. * @returns Nullable animation range
  98799. */
  98800. getRange(name: string): Nullable<AnimationRange>;
  98801. /**
  98802. * Gets the key frames from the animation
  98803. * @returns The key frames of the animation
  98804. */
  98805. getKeys(): Array<IAnimationKey>;
  98806. /**
  98807. * Gets the highest frame rate of the animation
  98808. * @returns Highest frame rate of the animation
  98809. */
  98810. getHighestFrame(): number;
  98811. /**
  98812. * Gets the easing function of the animation
  98813. * @returns Easing function of the animation
  98814. */
  98815. getEasingFunction(): IEasingFunction;
  98816. /**
  98817. * Sets the easing function of the animation
  98818. * @param easingFunction A custom mathematical formula for animation
  98819. */
  98820. setEasingFunction(easingFunction: EasingFunction): void;
  98821. /**
  98822. * Interpolates a scalar linearly
  98823. * @param startValue Start value of the animation curve
  98824. * @param endValue End value of the animation curve
  98825. * @param gradient Scalar amount to interpolate
  98826. * @returns Interpolated scalar value
  98827. */
  98828. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  98829. /**
  98830. * Interpolates a scalar cubically
  98831. * @param startValue Start value of the animation curve
  98832. * @param outTangent End tangent of the animation
  98833. * @param endValue End value of the animation curve
  98834. * @param inTangent Start tangent of the animation curve
  98835. * @param gradient Scalar amount to interpolate
  98836. * @returns Interpolated scalar value
  98837. */
  98838. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  98839. /**
  98840. * Interpolates a quaternion using a spherical linear interpolation
  98841. * @param startValue Start value of the animation curve
  98842. * @param endValue End value of the animation curve
  98843. * @param gradient Scalar amount to interpolate
  98844. * @returns Interpolated quaternion value
  98845. */
  98846. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  98847. /**
  98848. * Interpolates a quaternion cubically
  98849. * @param startValue Start value of the animation curve
  98850. * @param outTangent End tangent of the animation curve
  98851. * @param endValue End value of the animation curve
  98852. * @param inTangent Start tangent of the animation curve
  98853. * @param gradient Scalar amount to interpolate
  98854. * @returns Interpolated quaternion value
  98855. */
  98856. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  98857. /**
  98858. * Interpolates a Vector3 linearl
  98859. * @param startValue Start value of the animation curve
  98860. * @param endValue End value of the animation curve
  98861. * @param gradient Scalar amount to interpolate
  98862. * @returns Interpolated scalar value
  98863. */
  98864. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  98865. /**
  98866. * Interpolates a Vector3 cubically
  98867. * @param startValue Start value of the animation curve
  98868. * @param outTangent End tangent of the animation
  98869. * @param endValue End value of the animation curve
  98870. * @param inTangent Start tangent of the animation curve
  98871. * @param gradient Scalar amount to interpolate
  98872. * @returns InterpolatedVector3 value
  98873. */
  98874. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  98875. /**
  98876. * Interpolates a Vector2 linearly
  98877. * @param startValue Start value of the animation curve
  98878. * @param endValue End value of the animation curve
  98879. * @param gradient Scalar amount to interpolate
  98880. * @returns Interpolated Vector2 value
  98881. */
  98882. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  98883. /**
  98884. * Interpolates a Vector2 cubically
  98885. * @param startValue Start value of the animation curve
  98886. * @param outTangent End tangent of the animation
  98887. * @param endValue End value of the animation curve
  98888. * @param inTangent Start tangent of the animation curve
  98889. * @param gradient Scalar amount to interpolate
  98890. * @returns Interpolated Vector2 value
  98891. */
  98892. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  98893. /**
  98894. * Interpolates a size linearly
  98895. * @param startValue Start value of the animation curve
  98896. * @param endValue End value of the animation curve
  98897. * @param gradient Scalar amount to interpolate
  98898. * @returns Interpolated Size value
  98899. */
  98900. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  98901. /**
  98902. * Interpolates a Color3 linearly
  98903. * @param startValue Start value of the animation curve
  98904. * @param endValue End value of the animation curve
  98905. * @param gradient Scalar amount to interpolate
  98906. * @returns Interpolated Color3 value
  98907. */
  98908. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  98909. /**
  98910. * Interpolates a Color4 linearly
  98911. * @param startValue Start value of the animation curve
  98912. * @param endValue End value of the animation curve
  98913. * @param gradient Scalar amount to interpolate
  98914. * @returns Interpolated Color3 value
  98915. */
  98916. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  98917. /**
  98918. * @hidden Internal use only
  98919. */
  98920. _getKeyValue(value: any): any;
  98921. /**
  98922. * @hidden Internal use only
  98923. */
  98924. _interpolate(currentFrame: number, state: _IAnimationState): any;
  98925. /**
  98926. * Defines the function to use to interpolate matrices
  98927. * @param startValue defines the start matrix
  98928. * @param endValue defines the end matrix
  98929. * @param gradient defines the gradient between both matrices
  98930. * @param result defines an optional target matrix where to store the interpolation
  98931. * @returns the interpolated matrix
  98932. */
  98933. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  98934. /**
  98935. * Makes a copy of the animation
  98936. * @returns Cloned animation
  98937. */
  98938. clone(): Animation;
  98939. /**
  98940. * Sets the key frames of the animation
  98941. * @param values The animation key frames to set
  98942. */
  98943. setKeys(values: Array<IAnimationKey>): void;
  98944. /**
  98945. * Serializes the animation to an object
  98946. * @returns Serialized object
  98947. */
  98948. serialize(): any;
  98949. /**
  98950. * Float animation type
  98951. */
  98952. static readonly ANIMATIONTYPE_FLOAT: number;
  98953. /**
  98954. * Vector3 animation type
  98955. */
  98956. static readonly ANIMATIONTYPE_VECTOR3: number;
  98957. /**
  98958. * Quaternion animation type
  98959. */
  98960. static readonly ANIMATIONTYPE_QUATERNION: number;
  98961. /**
  98962. * Matrix animation type
  98963. */
  98964. static readonly ANIMATIONTYPE_MATRIX: number;
  98965. /**
  98966. * Color3 animation type
  98967. */
  98968. static readonly ANIMATIONTYPE_COLOR3: number;
  98969. /**
  98970. * Color3 animation type
  98971. */
  98972. static readonly ANIMATIONTYPE_COLOR4: number;
  98973. /**
  98974. * Vector2 animation type
  98975. */
  98976. static readonly ANIMATIONTYPE_VECTOR2: number;
  98977. /**
  98978. * Size animation type
  98979. */
  98980. static readonly ANIMATIONTYPE_SIZE: number;
  98981. /**
  98982. * Relative Loop Mode
  98983. */
  98984. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  98985. /**
  98986. * Cycle Loop Mode
  98987. */
  98988. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  98989. /**
  98990. * Constant Loop Mode
  98991. */
  98992. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  98993. /** @hidden */
  98994. static _UniversalLerp(left: any, right: any, amount: number): any;
  98995. /**
  98996. * Parses an animation object and creates an animation
  98997. * @param parsedAnimation Parsed animation object
  98998. * @returns Animation object
  98999. */
  99000. static Parse(parsedAnimation: any): Animation;
  99001. /**
  99002. * Appends the serialized animations from the source animations
  99003. * @param source Source containing the animations
  99004. * @param destination Target to store the animations
  99005. */
  99006. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99007. }
  99008. }
  99009. declare module BABYLON {
  99010. /**
  99011. * Interface containing an array of animations
  99012. */
  99013. export interface IAnimatable {
  99014. /**
  99015. * Array of animations
  99016. */
  99017. animations: Nullable<Array<Animation>>;
  99018. }
  99019. }
  99020. declare module BABYLON {
  99021. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99022. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99023. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99024. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99025. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99026. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99027. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99028. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99029. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99030. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99031. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99032. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99033. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99034. /**
  99035. * Decorator used to define property that can be serialized as reference to a camera
  99036. * @param sourceName defines the name of the property to decorate
  99037. */
  99038. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99039. /**
  99040. * Class used to help serialization objects
  99041. */
  99042. export class SerializationHelper {
  99043. /** @hidden */
  99044. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99045. /** @hidden */
  99046. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99047. /** @hidden */
  99048. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99049. /** @hidden */
  99050. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99051. /**
  99052. * Appends the serialized animations from the source animations
  99053. * @param source Source containing the animations
  99054. * @param destination Target to store the animations
  99055. */
  99056. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99057. /**
  99058. * Static function used to serialized a specific entity
  99059. * @param entity defines the entity to serialize
  99060. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99061. * @returns a JSON compatible object representing the serialization of the entity
  99062. */
  99063. static Serialize<T>(entity: T, serializationObject?: any): any;
  99064. /**
  99065. * Creates a new entity from a serialization data object
  99066. * @param creationFunction defines a function used to instanciated the new entity
  99067. * @param source defines the source serialization data
  99068. * @param scene defines the hosting scene
  99069. * @param rootUrl defines the root url for resources
  99070. * @returns a new entity
  99071. */
  99072. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99073. /**
  99074. * Clones an object
  99075. * @param creationFunction defines the function used to instanciate the new object
  99076. * @param source defines the source object
  99077. * @returns the cloned object
  99078. */
  99079. static Clone<T>(creationFunction: () => T, source: T): T;
  99080. /**
  99081. * Instanciates a new object based on a source one (some data will be shared between both object)
  99082. * @param creationFunction defines the function used to instanciate the new object
  99083. * @param source defines the source object
  99084. * @returns the new object
  99085. */
  99086. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99087. }
  99088. }
  99089. declare module BABYLON {
  99090. /**
  99091. * Class used to manipulate GUIDs
  99092. */
  99093. export class GUID {
  99094. /**
  99095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99096. * Be aware Math.random() could cause collisions, but:
  99097. * "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"
  99098. * @returns a pseudo random id
  99099. */
  99100. static RandomId(): string;
  99101. }
  99102. }
  99103. declare module BABYLON {
  99104. /**
  99105. * Base class of all the textures in babylon.
  99106. * It groups all the common properties the materials, post process, lights... might need
  99107. * in order to make a correct use of the texture.
  99108. */
  99109. export class BaseTexture implements IAnimatable {
  99110. /**
  99111. * Default anisotropic filtering level for the application.
  99112. * It is set to 4 as a good tradeoff between perf and quality.
  99113. */
  99114. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  99115. /**
  99116. * Gets or sets the unique id of the texture
  99117. */
  99118. uniqueId: number;
  99119. /**
  99120. * Define the name of the texture.
  99121. */
  99122. name: string;
  99123. /**
  99124. * Gets or sets an object used to store user defined information.
  99125. */
  99126. metadata: any;
  99127. /**
  99128. * For internal use only. Please do not use.
  99129. */
  99130. reservedDataStore: any;
  99131. private _hasAlpha;
  99132. /**
  99133. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  99134. */
  99135. hasAlpha: boolean;
  99136. /**
  99137. * Defines if the alpha value should be determined via the rgb values.
  99138. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  99139. */
  99140. getAlphaFromRGB: boolean;
  99141. /**
  99142. * Intensity or strength of the texture.
  99143. * It is commonly used by materials to fine tune the intensity of the texture
  99144. */
  99145. level: number;
  99146. /**
  99147. * Define the UV chanel to use starting from 0 and defaulting to 0.
  99148. * This is part of the texture as textures usually maps to one uv set.
  99149. */
  99150. coordinatesIndex: number;
  99151. private _coordinatesMode;
  99152. /**
  99153. * How a texture is mapped.
  99154. *
  99155. * | Value | Type | Description |
  99156. * | ----- | ----------------------------------- | ----------- |
  99157. * | 0 | EXPLICIT_MODE | |
  99158. * | 1 | SPHERICAL_MODE | |
  99159. * | 2 | PLANAR_MODE | |
  99160. * | 3 | CUBIC_MODE | |
  99161. * | 4 | PROJECTION_MODE | |
  99162. * | 5 | SKYBOX_MODE | |
  99163. * | 6 | INVCUBIC_MODE | |
  99164. * | 7 | EQUIRECTANGULAR_MODE | |
  99165. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  99166. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  99167. */
  99168. coordinatesMode: number;
  99169. /**
  99170. * | Value | Type | Description |
  99171. * | ----- | ------------------ | ----------- |
  99172. * | 0 | CLAMP_ADDRESSMODE | |
  99173. * | 1 | WRAP_ADDRESSMODE | |
  99174. * | 2 | MIRROR_ADDRESSMODE | |
  99175. */
  99176. wrapU: number;
  99177. /**
  99178. * | Value | Type | Description |
  99179. * | ----- | ------------------ | ----------- |
  99180. * | 0 | CLAMP_ADDRESSMODE | |
  99181. * | 1 | WRAP_ADDRESSMODE | |
  99182. * | 2 | MIRROR_ADDRESSMODE | |
  99183. */
  99184. wrapV: number;
  99185. /**
  99186. * | Value | Type | Description |
  99187. * | ----- | ------------------ | ----------- |
  99188. * | 0 | CLAMP_ADDRESSMODE | |
  99189. * | 1 | WRAP_ADDRESSMODE | |
  99190. * | 2 | MIRROR_ADDRESSMODE | |
  99191. */
  99192. wrapR: number;
  99193. /**
  99194. * With compliant hardware and browser (supporting anisotropic filtering)
  99195. * this defines the level of anisotropic filtering in the texture.
  99196. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  99197. */
  99198. anisotropicFilteringLevel: number;
  99199. /**
  99200. * Define if the texture is a cube texture or if false a 2d texture.
  99201. */
  99202. isCube: boolean;
  99203. /**
  99204. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  99205. */
  99206. is3D: boolean;
  99207. /**
  99208. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  99209. */
  99210. is2DArray: boolean;
  99211. /**
  99212. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  99213. * HDR texture are usually stored in linear space.
  99214. * This only impacts the PBR and Background materials
  99215. */
  99216. gammaSpace: boolean;
  99217. /**
  99218. * Gets or sets whether or not the texture contains RGBD data.
  99219. */
  99220. isRGBD: boolean;
  99221. /**
  99222. * Is Z inverted in the texture (useful in a cube texture).
  99223. */
  99224. invertZ: boolean;
  99225. /**
  99226. * Are mip maps generated for this texture or not.
  99227. */
  99228. readonly noMipmap: boolean;
  99229. /**
  99230. * @hidden
  99231. */
  99232. lodLevelInAlpha: boolean;
  99233. /**
  99234. * With prefiltered texture, defined the offset used during the prefiltering steps.
  99235. */
  99236. lodGenerationOffset: number;
  99237. /**
  99238. * With prefiltered texture, defined the scale used during the prefiltering steps.
  99239. */
  99240. lodGenerationScale: number;
  99241. /**
  99242. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  99243. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  99244. * average roughness values.
  99245. */
  99246. linearSpecularLOD: boolean;
  99247. /**
  99248. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  99249. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  99250. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  99251. */
  99252. irradianceTexture: Nullable<BaseTexture>;
  99253. /**
  99254. * Define if the texture is a render target.
  99255. */
  99256. isRenderTarget: boolean;
  99257. /**
  99258. * Define the unique id of the texture in the scene.
  99259. */
  99260. readonly uid: string;
  99261. /**
  99262. * Return a string representation of the texture.
  99263. * @returns the texture as a string
  99264. */
  99265. toString(): string;
  99266. /**
  99267. * Get the class name of the texture.
  99268. * @returns "BaseTexture"
  99269. */
  99270. getClassName(): string;
  99271. /**
  99272. * Define the list of animation attached to the texture.
  99273. */
  99274. animations: Animation[];
  99275. /**
  99276. * An event triggered when the texture is disposed.
  99277. */
  99278. onDisposeObservable: Observable<BaseTexture>;
  99279. private _onDisposeObserver;
  99280. /**
  99281. * Callback triggered when the texture has been disposed.
  99282. * Kept for back compatibility, you can use the onDisposeObservable instead.
  99283. */
  99284. onDispose: () => void;
  99285. /**
  99286. * Define the current state of the loading sequence when in delayed load mode.
  99287. */
  99288. delayLoadState: number;
  99289. private _scene;
  99290. /** @hidden */
  99291. _texture: Nullable<InternalTexture>;
  99292. private _uid;
  99293. /**
  99294. * Define if the texture is preventinga material to render or not.
  99295. * If not and the texture is not ready, the engine will use a default black texture instead.
  99296. */
  99297. readonly isBlocking: boolean;
  99298. /**
  99299. * Instantiates a new BaseTexture.
  99300. * Base class of all the textures in babylon.
  99301. * It groups all the common properties the materials, post process, lights... might need
  99302. * in order to make a correct use of the texture.
  99303. * @param scene Define the scene the texture blongs to
  99304. */
  99305. constructor(scene: Nullable<Scene>);
  99306. /**
  99307. * Get the scene the texture belongs to.
  99308. * @returns the scene or null if undefined
  99309. */
  99310. getScene(): Nullable<Scene>;
  99311. /**
  99312. * Get the texture transform matrix used to offset tile the texture for istance.
  99313. * @returns the transformation matrix
  99314. */
  99315. getTextureMatrix(): Matrix;
  99316. /**
  99317. * Get the texture reflection matrix used to rotate/transform the reflection.
  99318. * @returns the reflection matrix
  99319. */
  99320. getReflectionTextureMatrix(): Matrix;
  99321. /**
  99322. * Get the underlying lower level texture from Babylon.
  99323. * @returns the insternal texture
  99324. */
  99325. getInternalTexture(): Nullable<InternalTexture>;
  99326. /**
  99327. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  99328. * @returns true if ready or not blocking
  99329. */
  99330. isReadyOrNotBlocking(): boolean;
  99331. /**
  99332. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  99333. * @returns true if fully ready
  99334. */
  99335. isReady(): boolean;
  99336. private _cachedSize;
  99337. /**
  99338. * Get the size of the texture.
  99339. * @returns the texture size.
  99340. */
  99341. getSize(): ISize;
  99342. /**
  99343. * Get the base size of the texture.
  99344. * It can be different from the size if the texture has been resized for POT for instance
  99345. * @returns the base size
  99346. */
  99347. getBaseSize(): ISize;
  99348. /**
  99349. * Update the sampling mode of the texture.
  99350. * Default is Trilinear mode.
  99351. *
  99352. * | Value | Type | Description |
  99353. * | ----- | ------------------ | ----------- |
  99354. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  99355. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  99356. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  99357. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  99358. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  99359. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  99360. * | 7 | NEAREST_LINEAR | |
  99361. * | 8 | NEAREST_NEAREST | |
  99362. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  99363. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  99364. * | 11 | LINEAR_LINEAR | |
  99365. * | 12 | LINEAR_NEAREST | |
  99366. *
  99367. * > _mag_: magnification filter (close to the viewer)
  99368. * > _min_: minification filter (far from the viewer)
  99369. * > _mip_: filter used between mip map levels
  99370. *@param samplingMode Define the new sampling mode of the texture
  99371. */
  99372. updateSamplingMode(samplingMode: number): void;
  99373. /**
  99374. * Scales the texture if is `canRescale()`
  99375. * @param ratio the resize factor we want to use to rescale
  99376. */
  99377. scale(ratio: number): void;
  99378. /**
  99379. * Get if the texture can rescale.
  99380. */
  99381. readonly canRescale: boolean;
  99382. /** @hidden */
  99383. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  99384. /** @hidden */
  99385. _rebuild(): void;
  99386. /**
  99387. * Triggers the load sequence in delayed load mode.
  99388. */
  99389. delayLoad(): void;
  99390. /**
  99391. * Clones the texture.
  99392. * @returns the cloned texture
  99393. */
  99394. clone(): Nullable<BaseTexture>;
  99395. /**
  99396. * Get the texture underlying type (INT, FLOAT...)
  99397. */
  99398. readonly textureType: number;
  99399. /**
  99400. * Get the texture underlying format (RGB, RGBA...)
  99401. */
  99402. readonly textureFormat: number;
  99403. /**
  99404. * Indicates that textures need to be re-calculated for all materials
  99405. */
  99406. protected _markAllSubMeshesAsTexturesDirty(): void;
  99407. /**
  99408. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  99409. * This will returns an RGBA array buffer containing either in values (0-255) or
  99410. * float values (0-1) depending of the underlying buffer type.
  99411. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  99412. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  99413. * @param buffer defines a user defined buffer to fill with data (can be null)
  99414. * @returns The Array buffer containing the pixels data.
  99415. */
  99416. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  99417. /**
  99418. * Release and destroy the underlying lower level texture aka internalTexture.
  99419. */
  99420. releaseInternalTexture(): void;
  99421. /** @hidden */
  99422. readonly _lodTextureHigh: Nullable<BaseTexture>;
  99423. /** @hidden */
  99424. readonly _lodTextureMid: Nullable<BaseTexture>;
  99425. /** @hidden */
  99426. readonly _lodTextureLow: Nullable<BaseTexture>;
  99427. /**
  99428. * Dispose the texture and release its associated resources.
  99429. */
  99430. dispose(): void;
  99431. /**
  99432. * Serialize the texture into a JSON representation that can be parsed later on.
  99433. * @returns the JSON representation of the texture
  99434. */
  99435. serialize(): any;
  99436. /**
  99437. * Helper function to be called back once a list of texture contains only ready textures.
  99438. * @param textures Define the list of textures to wait for
  99439. * @param callback Define the callback triggered once the entire list will be ready
  99440. */
  99441. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  99442. }
  99443. }
  99444. declare module BABYLON {
  99445. /**
  99446. * Options to be used when creating an effect.
  99447. */
  99448. export interface IEffectCreationOptions {
  99449. /**
  99450. * Atrributes that will be used in the shader.
  99451. */
  99452. attributes: string[];
  99453. /**
  99454. * Uniform varible names that will be set in the shader.
  99455. */
  99456. uniformsNames: string[];
  99457. /**
  99458. * Uniform buffer variable names that will be set in the shader.
  99459. */
  99460. uniformBuffersNames: string[];
  99461. /**
  99462. * Sampler texture variable names that will be set in the shader.
  99463. */
  99464. samplers: string[];
  99465. /**
  99466. * Define statements that will be set in the shader.
  99467. */
  99468. defines: any;
  99469. /**
  99470. * Possible fallbacks for this effect to improve performance when needed.
  99471. */
  99472. fallbacks: Nullable<IEffectFallbacks>;
  99473. /**
  99474. * Callback that will be called when the shader is compiled.
  99475. */
  99476. onCompiled: Nullable<(effect: Effect) => void>;
  99477. /**
  99478. * Callback that will be called if an error occurs during shader compilation.
  99479. */
  99480. onError: Nullable<(effect: Effect, errors: string) => void>;
  99481. /**
  99482. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  99483. */
  99484. indexParameters?: any;
  99485. /**
  99486. * Max number of lights that can be used in the shader.
  99487. */
  99488. maxSimultaneousLights?: number;
  99489. /**
  99490. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  99491. */
  99492. transformFeedbackVaryings?: Nullable<string[]>;
  99493. }
  99494. /**
  99495. * Effect containing vertex and fragment shader that can be executed on an object.
  99496. */
  99497. export class Effect implements IDisposable {
  99498. /**
  99499. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99500. */
  99501. static ShadersRepository: string;
  99502. /**
  99503. * Name of the effect.
  99504. */
  99505. name: any;
  99506. /**
  99507. * String container all the define statements that should be set on the shader.
  99508. */
  99509. defines: string;
  99510. /**
  99511. * Callback that will be called when the shader is compiled.
  99512. */
  99513. onCompiled: Nullable<(effect: Effect) => void>;
  99514. /**
  99515. * Callback that will be called if an error occurs during shader compilation.
  99516. */
  99517. onError: Nullable<(effect: Effect, errors: string) => void>;
  99518. /**
  99519. * Callback that will be called when effect is bound.
  99520. */
  99521. onBind: Nullable<(effect: Effect) => void>;
  99522. /**
  99523. * Unique ID of the effect.
  99524. */
  99525. uniqueId: number;
  99526. /**
  99527. * Observable that will be called when the shader is compiled.
  99528. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  99529. */
  99530. onCompileObservable: Observable<Effect>;
  99531. /**
  99532. * Observable that will be called if an error occurs during shader compilation.
  99533. */
  99534. onErrorObservable: Observable<Effect>;
  99535. /** @hidden */
  99536. _onBindObservable: Nullable<Observable<Effect>>;
  99537. /**
  99538. * Observable that will be called when effect is bound.
  99539. */
  99540. readonly onBindObservable: Observable<Effect>;
  99541. /** @hidden */
  99542. _bonesComputationForcedToCPU: boolean;
  99543. private static _uniqueIdSeed;
  99544. private _engine;
  99545. private _uniformBuffersNames;
  99546. private _uniformsNames;
  99547. private _samplerList;
  99548. private _samplers;
  99549. private _isReady;
  99550. private _compilationError;
  99551. private _allFallbacksProcessed;
  99552. private _attributesNames;
  99553. private _attributes;
  99554. private _attributeLocationByName;
  99555. private _uniforms;
  99556. /**
  99557. * Key for the effect.
  99558. * @hidden
  99559. */
  99560. _key: string;
  99561. private _indexParameters;
  99562. private _fallbacks;
  99563. private _vertexSourceCode;
  99564. private _fragmentSourceCode;
  99565. private _vertexSourceCodeOverride;
  99566. private _fragmentSourceCodeOverride;
  99567. private _transformFeedbackVaryings;
  99568. /**
  99569. * Compiled shader to webGL program.
  99570. * @hidden
  99571. */
  99572. _pipelineContext: Nullable<IPipelineContext>;
  99573. private _valueCache;
  99574. private static _baseCache;
  99575. /**
  99576. * Instantiates an effect.
  99577. * An effect can be used to create/manage/execute vertex and fragment shaders.
  99578. * @param baseName Name of the effect.
  99579. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  99580. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  99581. * @param samplers List of sampler variables that will be passed to the shader.
  99582. * @param engine Engine to be used to render the effect
  99583. * @param defines Define statements to be added to the shader.
  99584. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  99585. * @param onCompiled Callback that will be called when the shader is compiled.
  99586. * @param onError Callback that will be called if an error occurs during shader compilation.
  99587. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  99588. */
  99589. 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);
  99590. private _useFinalCode;
  99591. /**
  99592. * Unique key for this effect
  99593. */
  99594. readonly key: string;
  99595. /**
  99596. * If the effect has been compiled and prepared.
  99597. * @returns if the effect is compiled and prepared.
  99598. */
  99599. isReady(): boolean;
  99600. private _isReadyInternal;
  99601. /**
  99602. * The engine the effect was initialized with.
  99603. * @returns the engine.
  99604. */
  99605. getEngine(): Engine;
  99606. /**
  99607. * The pipeline context for this effect
  99608. * @returns the associated pipeline context
  99609. */
  99610. getPipelineContext(): Nullable<IPipelineContext>;
  99611. /**
  99612. * The set of names of attribute variables for the shader.
  99613. * @returns An array of attribute names.
  99614. */
  99615. getAttributesNames(): string[];
  99616. /**
  99617. * Returns the attribute at the given index.
  99618. * @param index The index of the attribute.
  99619. * @returns The location of the attribute.
  99620. */
  99621. getAttributeLocation(index: number): number;
  99622. /**
  99623. * Returns the attribute based on the name of the variable.
  99624. * @param name of the attribute to look up.
  99625. * @returns the attribute location.
  99626. */
  99627. getAttributeLocationByName(name: string): number;
  99628. /**
  99629. * The number of attributes.
  99630. * @returns the numnber of attributes.
  99631. */
  99632. getAttributesCount(): number;
  99633. /**
  99634. * Gets the index of a uniform variable.
  99635. * @param uniformName of the uniform to look up.
  99636. * @returns the index.
  99637. */
  99638. getUniformIndex(uniformName: string): number;
  99639. /**
  99640. * Returns the attribute based on the name of the variable.
  99641. * @param uniformName of the uniform to look up.
  99642. * @returns the location of the uniform.
  99643. */
  99644. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  99645. /**
  99646. * Returns an array of sampler variable names
  99647. * @returns The array of sampler variable neames.
  99648. */
  99649. getSamplers(): string[];
  99650. /**
  99651. * The error from the last compilation.
  99652. * @returns the error string.
  99653. */
  99654. getCompilationError(): string;
  99655. /**
  99656. * Gets a boolean indicating that all fallbacks were used during compilation
  99657. * @returns true if all fallbacks were used
  99658. */
  99659. allFallbacksProcessed(): boolean;
  99660. /**
  99661. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  99662. * @param func The callback to be used.
  99663. */
  99664. executeWhenCompiled(func: (effect: Effect) => void): void;
  99665. private _checkIsReady;
  99666. private _loadShader;
  99667. /**
  99668. * Recompiles the webGL program
  99669. * @param vertexSourceCode The source code for the vertex shader.
  99670. * @param fragmentSourceCode The source code for the fragment shader.
  99671. * @param onCompiled Callback called when completed.
  99672. * @param onError Callback called on error.
  99673. * @hidden
  99674. */
  99675. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  99676. /**
  99677. * Prepares the effect
  99678. * @hidden
  99679. */
  99680. _prepareEffect(): void;
  99681. private _processCompilationErrors;
  99682. /**
  99683. * Checks if the effect is supported. (Must be called after compilation)
  99684. */
  99685. readonly isSupported: boolean;
  99686. /**
  99687. * Binds a texture to the engine to be used as output of the shader.
  99688. * @param channel Name of the output variable.
  99689. * @param texture Texture to bind.
  99690. * @hidden
  99691. */
  99692. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  99693. /**
  99694. * Sets a texture on the engine to be used in the shader.
  99695. * @param channel Name of the sampler variable.
  99696. * @param texture Texture to set.
  99697. */
  99698. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  99699. /**
  99700. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  99701. * @param channel Name of the sampler variable.
  99702. * @param texture Texture to set.
  99703. */
  99704. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  99705. /**
  99706. * Sets an array of textures on the engine to be used in the shader.
  99707. * @param channel Name of the variable.
  99708. * @param textures Textures to set.
  99709. */
  99710. setTextureArray(channel: string, textures: BaseTexture[]): void;
  99711. /**
  99712. * 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)
  99713. * @param channel Name of the sampler variable.
  99714. * @param postProcess Post process to get the input texture from.
  99715. */
  99716. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  99717. /**
  99718. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  99719. * 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)
  99720. * @param channel Name of the sampler variable.
  99721. * @param postProcess Post process to get the output texture from.
  99722. */
  99723. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  99724. /** @hidden */
  99725. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  99726. /** @hidden */
  99727. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  99728. /** @hidden */
  99729. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  99730. /** @hidden */
  99731. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  99732. /**
  99733. * Binds a buffer to a uniform.
  99734. * @param buffer Buffer to bind.
  99735. * @param name Name of the uniform variable to bind to.
  99736. */
  99737. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  99738. /**
  99739. * Binds block to a uniform.
  99740. * @param blockName Name of the block to bind.
  99741. * @param index Index to bind.
  99742. */
  99743. bindUniformBlock(blockName: string, index: number): void;
  99744. /**
  99745. * Sets an interger value on a uniform variable.
  99746. * @param uniformName Name of the variable.
  99747. * @param value Value to be set.
  99748. * @returns this effect.
  99749. */
  99750. setInt(uniformName: string, value: number): Effect;
  99751. /**
  99752. * Sets an int array on a uniform variable.
  99753. * @param uniformName Name of the variable.
  99754. * @param array array to be set.
  99755. * @returns this effect.
  99756. */
  99757. setIntArray(uniformName: string, array: Int32Array): Effect;
  99758. /**
  99759. * 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)
  99760. * @param uniformName Name of the variable.
  99761. * @param array array to be set.
  99762. * @returns this effect.
  99763. */
  99764. setIntArray2(uniformName: string, array: Int32Array): Effect;
  99765. /**
  99766. * 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)
  99767. * @param uniformName Name of the variable.
  99768. * @param array array to be set.
  99769. * @returns this effect.
  99770. */
  99771. setIntArray3(uniformName: string, array: Int32Array): Effect;
  99772. /**
  99773. * 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)
  99774. * @param uniformName Name of the variable.
  99775. * @param array array to be set.
  99776. * @returns this effect.
  99777. */
  99778. setIntArray4(uniformName: string, array: Int32Array): Effect;
  99779. /**
  99780. * Sets an float array on a uniform variable.
  99781. * @param uniformName Name of the variable.
  99782. * @param array array to be set.
  99783. * @returns this effect.
  99784. */
  99785. setFloatArray(uniformName: string, array: Float32Array): Effect;
  99786. /**
  99787. * 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)
  99788. * @param uniformName Name of the variable.
  99789. * @param array array to be set.
  99790. * @returns this effect.
  99791. */
  99792. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  99793. /**
  99794. * 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)
  99795. * @param uniformName Name of the variable.
  99796. * @param array array to be set.
  99797. * @returns this effect.
  99798. */
  99799. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  99800. /**
  99801. * 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)
  99802. * @param uniformName Name of the variable.
  99803. * @param array array to be set.
  99804. * @returns this effect.
  99805. */
  99806. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  99807. /**
  99808. * Sets an array on a uniform variable.
  99809. * @param uniformName Name of the variable.
  99810. * @param array array to be set.
  99811. * @returns this effect.
  99812. */
  99813. setArray(uniformName: string, array: number[]): Effect;
  99814. /**
  99815. * 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)
  99816. * @param uniformName Name of the variable.
  99817. * @param array array to be set.
  99818. * @returns this effect.
  99819. */
  99820. setArray2(uniformName: string, array: number[]): Effect;
  99821. /**
  99822. * 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)
  99823. * @param uniformName Name of the variable.
  99824. * @param array array to be set.
  99825. * @returns this effect.
  99826. */
  99827. setArray3(uniformName: string, array: number[]): Effect;
  99828. /**
  99829. * 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)
  99830. * @param uniformName Name of the variable.
  99831. * @param array array to be set.
  99832. * @returns this effect.
  99833. */
  99834. setArray4(uniformName: string, array: number[]): Effect;
  99835. /**
  99836. * Sets matrices on a uniform variable.
  99837. * @param uniformName Name of the variable.
  99838. * @param matrices matrices to be set.
  99839. * @returns this effect.
  99840. */
  99841. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  99842. /**
  99843. * Sets matrix on a uniform variable.
  99844. * @param uniformName Name of the variable.
  99845. * @param matrix matrix to be set.
  99846. * @returns this effect.
  99847. */
  99848. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  99849. /**
  99850. * 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)
  99851. * @param uniformName Name of the variable.
  99852. * @param matrix matrix to be set.
  99853. * @returns this effect.
  99854. */
  99855. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  99856. /**
  99857. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  99858. * @param uniformName Name of the variable.
  99859. * @param matrix matrix to be set.
  99860. * @returns this effect.
  99861. */
  99862. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  99863. /**
  99864. * Sets a float on a uniform variable.
  99865. * @param uniformName Name of the variable.
  99866. * @param value value to be set.
  99867. * @returns this effect.
  99868. */
  99869. setFloat(uniformName: string, value: number): Effect;
  99870. /**
  99871. * Sets a boolean on a uniform variable.
  99872. * @param uniformName Name of the variable.
  99873. * @param bool value to be set.
  99874. * @returns this effect.
  99875. */
  99876. setBool(uniformName: string, bool: boolean): Effect;
  99877. /**
  99878. * Sets a Vector2 on a uniform variable.
  99879. * @param uniformName Name of the variable.
  99880. * @param vector2 vector2 to be set.
  99881. * @returns this effect.
  99882. */
  99883. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  99884. /**
  99885. * Sets a float2 on a uniform variable.
  99886. * @param uniformName Name of the variable.
  99887. * @param x First float in float2.
  99888. * @param y Second float in float2.
  99889. * @returns this effect.
  99890. */
  99891. setFloat2(uniformName: string, x: number, y: number): Effect;
  99892. /**
  99893. * Sets a Vector3 on a uniform variable.
  99894. * @param uniformName Name of the variable.
  99895. * @param vector3 Value to be set.
  99896. * @returns this effect.
  99897. */
  99898. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  99899. /**
  99900. * Sets a float3 on a uniform variable.
  99901. * @param uniformName Name of the variable.
  99902. * @param x First float in float3.
  99903. * @param y Second float in float3.
  99904. * @param z Third float in float3.
  99905. * @returns this effect.
  99906. */
  99907. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  99908. /**
  99909. * Sets a Vector4 on a uniform variable.
  99910. * @param uniformName Name of the variable.
  99911. * @param vector4 Value to be set.
  99912. * @returns this effect.
  99913. */
  99914. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  99915. /**
  99916. * Sets a float4 on a uniform variable.
  99917. * @param uniformName Name of the variable.
  99918. * @param x First float in float4.
  99919. * @param y Second float in float4.
  99920. * @param z Third float in float4.
  99921. * @param w Fourth float in float4.
  99922. * @returns this effect.
  99923. */
  99924. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  99925. /**
  99926. * Sets a Color3 on a uniform variable.
  99927. * @param uniformName Name of the variable.
  99928. * @param color3 Value to be set.
  99929. * @returns this effect.
  99930. */
  99931. setColor3(uniformName: string, color3: IColor3Like): Effect;
  99932. /**
  99933. * Sets a Color4 on a uniform variable.
  99934. * @param uniformName Name of the variable.
  99935. * @param color3 Value to be set.
  99936. * @param alpha Alpha value to be set.
  99937. * @returns this effect.
  99938. */
  99939. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  99940. /**
  99941. * Sets a Color4 on a uniform variable
  99942. * @param uniformName defines the name of the variable
  99943. * @param color4 defines the value to be set
  99944. * @returns this effect.
  99945. */
  99946. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  99947. /** Release all associated resources */
  99948. dispose(): void;
  99949. /**
  99950. * This function will add a new shader to the shader store
  99951. * @param name the name of the shader
  99952. * @param pixelShader optional pixel shader content
  99953. * @param vertexShader optional vertex shader content
  99954. */
  99955. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  99956. /**
  99957. * Store of each shader (The can be looked up using effect.key)
  99958. */
  99959. static ShadersStore: {
  99960. [key: string]: string;
  99961. };
  99962. /**
  99963. * Store of each included file for a shader (The can be looked up using effect.key)
  99964. */
  99965. static IncludesShadersStore: {
  99966. [key: string]: string;
  99967. };
  99968. /**
  99969. * Resets the cache of effects.
  99970. */
  99971. static ResetCache(): void;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * Interface used to describe the capabilities of the engine relatively to the current browser
  99977. */
  99978. export interface EngineCapabilities {
  99979. /** Maximum textures units per fragment shader */
  99980. maxTexturesImageUnits: number;
  99981. /** Maximum texture units per vertex shader */
  99982. maxVertexTextureImageUnits: number;
  99983. /** Maximum textures units in the entire pipeline */
  99984. maxCombinedTexturesImageUnits: number;
  99985. /** Maximum texture size */
  99986. maxTextureSize: number;
  99987. /** Maximum texture samples */
  99988. maxSamples?: number;
  99989. /** Maximum cube texture size */
  99990. maxCubemapTextureSize: number;
  99991. /** Maximum render texture size */
  99992. maxRenderTextureSize: number;
  99993. /** Maximum number of vertex attributes */
  99994. maxVertexAttribs: number;
  99995. /** Maximum number of varyings */
  99996. maxVaryingVectors: number;
  99997. /** Maximum number of uniforms per vertex shader */
  99998. maxVertexUniformVectors: number;
  99999. /** Maximum number of uniforms per fragment shader */
  100000. maxFragmentUniformVectors: number;
  100001. /** Defines if standard derivates (dx/dy) are supported */
  100002. standardDerivatives: boolean;
  100003. /** Defines if s3tc texture compression is supported */
  100004. s3tc?: WEBGL_compressed_texture_s3tc;
  100005. /** Defines if pvrtc texture compression is supported */
  100006. pvrtc: any;
  100007. /** Defines if etc1 texture compression is supported */
  100008. etc1: any;
  100009. /** Defines if etc2 texture compression is supported */
  100010. etc2: any;
  100011. /** Defines if astc texture compression is supported */
  100012. astc: any;
  100013. /** Defines if float textures are supported */
  100014. textureFloat: boolean;
  100015. /** Defines if vertex array objects are supported */
  100016. vertexArrayObject: boolean;
  100017. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100018. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100019. /** Gets the maximum level of anisotropy supported */
  100020. maxAnisotropy: number;
  100021. /** Defines if instancing is supported */
  100022. instancedArrays: boolean;
  100023. /** Defines if 32 bits indices are supported */
  100024. uintIndices: boolean;
  100025. /** Defines if high precision shaders are supported */
  100026. highPrecisionShaderSupported: boolean;
  100027. /** Defines if depth reading in the fragment shader is supported */
  100028. fragmentDepthSupported: boolean;
  100029. /** Defines if float texture linear filtering is supported*/
  100030. textureFloatLinearFiltering: boolean;
  100031. /** Defines if rendering to float textures is supported */
  100032. textureFloatRender: boolean;
  100033. /** Defines if half float textures are supported*/
  100034. textureHalfFloat: boolean;
  100035. /** Defines if half float texture linear filtering is supported*/
  100036. textureHalfFloatLinearFiltering: boolean;
  100037. /** Defines if rendering to half float textures is supported */
  100038. textureHalfFloatRender: boolean;
  100039. /** Defines if textureLOD shader command is supported */
  100040. textureLOD: boolean;
  100041. /** Defines if draw buffers extension is supported */
  100042. drawBuffersExtension: boolean;
  100043. /** Defines if depth textures are supported */
  100044. depthTextureExtension: boolean;
  100045. /** Defines if float color buffer are supported */
  100046. colorBufferFloat: boolean;
  100047. /** Gets disjoint timer query extension (null if not supported) */
  100048. timerQuery?: EXT_disjoint_timer_query;
  100049. /** Defines if timestamp can be used with timer query */
  100050. canUseTimestampForTimerQuery: boolean;
  100051. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100052. multiview?: any;
  100053. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100054. oculusMultiview?: any;
  100055. /** Function used to let the system compiles shaders in background */
  100056. parallelShaderCompile?: {
  100057. COMPLETION_STATUS_KHR: number;
  100058. };
  100059. /** Max number of texture samples for MSAA */
  100060. maxMSAASamples: number;
  100061. /** Defines if the blend min max extension is supported */
  100062. blendMinMax: boolean;
  100063. }
  100064. }
  100065. declare module BABYLON {
  100066. /**
  100067. * @hidden
  100068. **/
  100069. export class DepthCullingState {
  100070. private _isDepthTestDirty;
  100071. private _isDepthMaskDirty;
  100072. private _isDepthFuncDirty;
  100073. private _isCullFaceDirty;
  100074. private _isCullDirty;
  100075. private _isZOffsetDirty;
  100076. private _isFrontFaceDirty;
  100077. private _depthTest;
  100078. private _depthMask;
  100079. private _depthFunc;
  100080. private _cull;
  100081. private _cullFace;
  100082. private _zOffset;
  100083. private _frontFace;
  100084. /**
  100085. * Initializes the state.
  100086. */
  100087. constructor();
  100088. readonly isDirty: boolean;
  100089. zOffset: number;
  100090. cullFace: Nullable<number>;
  100091. cull: Nullable<boolean>;
  100092. depthFunc: Nullable<number>;
  100093. depthMask: boolean;
  100094. depthTest: boolean;
  100095. frontFace: Nullable<number>;
  100096. reset(): void;
  100097. apply(gl: WebGLRenderingContext): void;
  100098. }
  100099. }
  100100. declare module BABYLON {
  100101. /**
  100102. * @hidden
  100103. **/
  100104. export class StencilState {
  100105. /** 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 */
  100106. static readonly ALWAYS: number;
  100107. /** Passed to stencilOperation to specify that stencil value must be kept */
  100108. static readonly KEEP: number;
  100109. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100110. static readonly REPLACE: number;
  100111. private _isStencilTestDirty;
  100112. private _isStencilMaskDirty;
  100113. private _isStencilFuncDirty;
  100114. private _isStencilOpDirty;
  100115. private _stencilTest;
  100116. private _stencilMask;
  100117. private _stencilFunc;
  100118. private _stencilFuncRef;
  100119. private _stencilFuncMask;
  100120. private _stencilOpStencilFail;
  100121. private _stencilOpDepthFail;
  100122. private _stencilOpStencilDepthPass;
  100123. readonly isDirty: boolean;
  100124. stencilFunc: number;
  100125. stencilFuncRef: number;
  100126. stencilFuncMask: number;
  100127. stencilOpStencilFail: number;
  100128. stencilOpDepthFail: number;
  100129. stencilOpStencilDepthPass: number;
  100130. stencilMask: number;
  100131. stencilTest: boolean;
  100132. constructor();
  100133. reset(): void;
  100134. apply(gl: WebGLRenderingContext): void;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * @hidden
  100140. **/
  100141. export class AlphaState {
  100142. private _isAlphaBlendDirty;
  100143. private _isBlendFunctionParametersDirty;
  100144. private _isBlendEquationParametersDirty;
  100145. private _isBlendConstantsDirty;
  100146. private _alphaBlend;
  100147. private _blendFunctionParameters;
  100148. private _blendEquationParameters;
  100149. private _blendConstants;
  100150. /**
  100151. * Initializes the state.
  100152. */
  100153. constructor();
  100154. readonly isDirty: boolean;
  100155. alphaBlend: boolean;
  100156. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  100157. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  100158. setAlphaEquationParameters(rgb: number, alpha: number): void;
  100159. reset(): void;
  100160. apply(gl: WebGLRenderingContext): void;
  100161. }
  100162. }
  100163. declare module BABYLON {
  100164. /** @hidden */
  100165. export class WebGL2ShaderProcessor implements IShaderProcessor {
  100166. attributeProcessor(attribute: string): string;
  100167. varyingProcessor(varying: string, isFragment: boolean): string;
  100168. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  100169. }
  100170. }
  100171. declare module BABYLON {
  100172. /**
  100173. * Interface for attribute information associated with buffer instanciation
  100174. */
  100175. export interface InstancingAttributeInfo {
  100176. /**
  100177. * Name of the GLSL attribute
  100178. * if attribute index is not specified, this is used to retrieve the index from the effect
  100179. */
  100180. attributeName: string;
  100181. /**
  100182. * Index/offset of the attribute in the vertex shader
  100183. * if not specified, this will be computes from the name.
  100184. */
  100185. index?: number;
  100186. /**
  100187. * size of the attribute, 1, 2, 3 or 4
  100188. */
  100189. attributeSize: number;
  100190. /**
  100191. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  100192. */
  100193. offset: number;
  100194. /**
  100195. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  100196. * default to 1
  100197. */
  100198. divisor?: number;
  100199. /**
  100200. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  100201. * default is FLOAT
  100202. */
  100203. attributeType?: number;
  100204. /**
  100205. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  100206. */
  100207. normalized?: boolean;
  100208. }
  100209. }
  100210. declare module BABYLON {
  100211. interface ThinEngine {
  100212. /**
  100213. * Update a video texture
  100214. * @param texture defines the texture to update
  100215. * @param video defines the video element to use
  100216. * @param invertY defines if data must be stored with Y axis inverted
  100217. */
  100218. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  100219. }
  100220. }
  100221. declare module BABYLON {
  100222. /**
  100223. * Settings for finer control over video usage
  100224. */
  100225. export interface VideoTextureSettings {
  100226. /**
  100227. * Applies `autoplay` to video, if specified
  100228. */
  100229. autoPlay?: boolean;
  100230. /**
  100231. * Applies `loop` to video, if specified
  100232. */
  100233. loop?: boolean;
  100234. /**
  100235. * Automatically updates internal texture from video at every frame in the render loop
  100236. */
  100237. autoUpdateTexture: boolean;
  100238. /**
  100239. * Image src displayed during the video loading or until the user interacts with the video.
  100240. */
  100241. poster?: string;
  100242. }
  100243. /**
  100244. * If you want to display a video in your scene, this is the special texture for that.
  100245. * This special texture works similar to other textures, with the exception of a few parameters.
  100246. * @see https://doc.babylonjs.com/how_to/video_texture
  100247. */
  100248. export class VideoTexture extends Texture {
  100249. /**
  100250. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  100251. */
  100252. readonly autoUpdateTexture: boolean;
  100253. /**
  100254. * The video instance used by the texture internally
  100255. */
  100256. readonly video: HTMLVideoElement;
  100257. private _onUserActionRequestedObservable;
  100258. /**
  100259. * Event triggerd when a dom action is required by the user to play the video.
  100260. * This happens due to recent changes in browser policies preventing video to auto start.
  100261. */
  100262. readonly onUserActionRequestedObservable: Observable<Texture>;
  100263. private _generateMipMaps;
  100264. private _engine;
  100265. private _stillImageCaptured;
  100266. private _displayingPosterTexture;
  100267. private _settings;
  100268. private _createInternalTextureOnEvent;
  100269. private _frameId;
  100270. /**
  100271. * Creates a video texture.
  100272. * If you want to display a video in your scene, this is the special texture for that.
  100273. * This special texture works similar to other textures, with the exception of a few parameters.
  100274. * @see https://doc.babylonjs.com/how_to/video_texture
  100275. * @param name optional name, will detect from video source, if not defined
  100276. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  100277. * @param scene is obviously the current scene.
  100278. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  100279. * @param invertY is false by default but can be used to invert video on Y axis
  100280. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  100281. * @param settings allows finer control over video usage
  100282. */
  100283. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  100284. private _getName;
  100285. private _getVideo;
  100286. private _createInternalTexture;
  100287. private reset;
  100288. /**
  100289. * @hidden Internal method to initiate `update`.
  100290. */
  100291. _rebuild(): void;
  100292. /**
  100293. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  100294. */
  100295. update(): void;
  100296. /**
  100297. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  100298. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  100299. */
  100300. updateTexture(isVisible: boolean): void;
  100301. protected _updateInternalTexture: () => void;
  100302. /**
  100303. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  100304. * @param url New url.
  100305. */
  100306. updateURL(url: string): void;
  100307. /**
  100308. * Dispose the texture and release its associated resources.
  100309. */
  100310. dispose(): void;
  100311. /**
  100312. * Creates a video texture straight from a stream.
  100313. * @param scene Define the scene the texture should be created in
  100314. * @param stream Define the stream the texture should be created from
  100315. * @returns The created video texture as a promise
  100316. */
  100317. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  100318. /**
  100319. * Creates a video texture straight from your WebCam video feed.
  100320. * @param scene Define the scene the texture should be created in
  100321. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  100322. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  100323. * @returns The created video texture as a promise
  100324. */
  100325. static CreateFromWebCamAsync(scene: Scene, constraints: {
  100326. minWidth: number;
  100327. maxWidth: number;
  100328. minHeight: number;
  100329. maxHeight: number;
  100330. deviceId: string;
  100331. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  100332. /**
  100333. * Creates a video texture straight from your WebCam video feed.
  100334. * @param scene Define the scene the texture should be created in
  100335. * @param onReady Define a callback to triggered once the texture will be ready
  100336. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  100337. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  100338. */
  100339. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  100340. minWidth: number;
  100341. maxWidth: number;
  100342. minHeight: number;
  100343. maxHeight: number;
  100344. deviceId: string;
  100345. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  100346. }
  100347. }
  100348. declare module BABYLON {
  100349. /**
  100350. * Defines the interface used by objects working like Scene
  100351. * @hidden
  100352. */
  100353. interface ISceneLike {
  100354. _addPendingData(data: any): void;
  100355. _removePendingData(data: any): void;
  100356. offlineProvider: IOfflineProvider;
  100357. }
  100358. /** Interface defining initialization parameters for Engine class */
  100359. export interface EngineOptions extends WebGLContextAttributes {
  100360. /**
  100361. * Defines if the engine should no exceed a specified device ratio
  100362. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  100363. */
  100364. limitDeviceRatio?: number;
  100365. /**
  100366. * Defines if webvr should be enabled automatically
  100367. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100368. */
  100369. autoEnableWebVR?: boolean;
  100370. /**
  100371. * Defines if webgl2 should be turned off even if supported
  100372. * @see http://doc.babylonjs.com/features/webgl2
  100373. */
  100374. disableWebGL2Support?: boolean;
  100375. /**
  100376. * Defines if webaudio should be initialized as well
  100377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100378. */
  100379. audioEngine?: boolean;
  100380. /**
  100381. * Defines if animations should run using a deterministic lock step
  100382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100383. */
  100384. deterministicLockstep?: boolean;
  100385. /** Defines the maximum steps to use with deterministic lock step mode */
  100386. lockstepMaxSteps?: number;
  100387. /** Defines the seconds between each deterministic lock step */
  100388. timeStep?: number;
  100389. /**
  100390. * Defines that engine should ignore context lost events
  100391. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  100392. */
  100393. doNotHandleContextLost?: boolean;
  100394. /**
  100395. * Defines that engine should ignore modifying touch action attribute and style
  100396. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  100397. */
  100398. doNotHandleTouchAction?: boolean;
  100399. /**
  100400. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  100401. */
  100402. useHighPrecisionFloats?: boolean;
  100403. }
  100404. /**
  100405. * The base engine class (root of all engines)
  100406. */
  100407. export class ThinEngine {
  100408. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  100409. static ExceptionList: ({
  100410. key: string;
  100411. capture: string;
  100412. captureConstraint: number;
  100413. targets: string[];
  100414. } | {
  100415. key: string;
  100416. capture: null;
  100417. captureConstraint: null;
  100418. targets: string[];
  100419. })[];
  100420. /** @hidden */
  100421. static _TextureLoaders: IInternalTextureLoader[];
  100422. /**
  100423. * Returns the current npm package of the sdk
  100424. */
  100425. static readonly NpmPackage: string;
  100426. /**
  100427. * Returns the current version of the framework
  100428. */
  100429. static readonly Version: string;
  100430. /**
  100431. * Returns a string describing the current engine
  100432. */
  100433. readonly description: string;
  100434. /**
  100435. * Gets or sets the epsilon value used by collision engine
  100436. */
  100437. static CollisionsEpsilon: number;
  100438. /**
  100439. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100440. */
  100441. static ShadersRepository: string;
  100442. /**
  100443. * Gets or sets the textures that the engine should not attempt to load as compressed
  100444. */
  100445. protected _excludedCompressedTextures: string[];
  100446. /**
  100447. * Filters the compressed texture formats to only include
  100448. * files that are not included in the skippable list
  100449. *
  100450. * @param url the current extension
  100451. * @param textureFormatInUse the current compressed texture format
  100452. * @returns "format" string
  100453. */
  100454. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  100455. /** @hidden */
  100456. _shaderProcessor: IShaderProcessor;
  100457. /**
  100458. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  100459. */
  100460. forcePOTTextures: boolean;
  100461. /**
  100462. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  100463. */
  100464. isFullscreen: boolean;
  100465. /**
  100466. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  100467. */
  100468. cullBackFaces: boolean;
  100469. /**
  100470. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  100471. */
  100472. renderEvenInBackground: boolean;
  100473. /**
  100474. * Gets or sets a boolean indicating that cache can be kept between frames
  100475. */
  100476. preventCacheWipeBetweenFrames: boolean;
  100477. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  100478. validateShaderPrograms: boolean;
  100479. /**
  100480. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  100481. * This can provide greater z depth for distant objects.
  100482. */
  100483. useReverseDepthBuffer: boolean;
  100484. /**
  100485. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  100486. */
  100487. disableUniformBuffers: boolean;
  100488. /** @hidden */
  100489. _uniformBuffers: UniformBuffer[];
  100490. /**
  100491. * Gets a boolean indicating that the engine supports uniform buffers
  100492. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  100493. */
  100494. readonly supportsUniformBuffers: boolean;
  100495. /** @hidden */
  100496. _gl: WebGLRenderingContext;
  100497. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  100498. protected _windowIsBackground: boolean;
  100499. protected _webGLVersion: number;
  100500. protected _creationOptions: EngineOptions;
  100501. protected _highPrecisionShadersAllowed: boolean;
  100502. /** @hidden */
  100503. readonly _shouldUseHighPrecisionShader: boolean;
  100504. /**
  100505. * Gets a boolean indicating that only power of 2 textures are supported
  100506. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  100507. */
  100508. readonly needPOTTextures: boolean;
  100509. /** @hidden */
  100510. _badOS: boolean;
  100511. /** @hidden */
  100512. _badDesktopOS: boolean;
  100513. private _hardwareScalingLevel;
  100514. /** @hidden */
  100515. _caps: EngineCapabilities;
  100516. private _isStencilEnable;
  100517. private _glVersion;
  100518. private _glRenderer;
  100519. private _glVendor;
  100520. /** @hidden */
  100521. _videoTextureSupported: boolean;
  100522. protected _renderingQueueLaunched: boolean;
  100523. protected _activeRenderLoops: (() => void)[];
  100524. /**
  100525. * Observable signaled when a context lost event is raised
  100526. */
  100527. onContextLostObservable: Observable<ThinEngine>;
  100528. /**
  100529. * Observable signaled when a context restored event is raised
  100530. */
  100531. onContextRestoredObservable: Observable<ThinEngine>;
  100532. private _onContextLost;
  100533. private _onContextRestored;
  100534. protected _contextWasLost: boolean;
  100535. /** @hidden */
  100536. _doNotHandleContextLost: boolean;
  100537. /**
  100538. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  100539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  100540. */
  100541. doNotHandleContextLost: boolean;
  100542. /**
  100543. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  100544. */
  100545. disableVertexArrayObjects: boolean;
  100546. /** @hidden */
  100547. protected _colorWrite: boolean;
  100548. /** @hidden */
  100549. protected _colorWriteChanged: boolean;
  100550. /** @hidden */
  100551. protected _depthCullingState: DepthCullingState;
  100552. /** @hidden */
  100553. protected _stencilState: StencilState;
  100554. /** @hidden */
  100555. _alphaState: AlphaState;
  100556. /** @hidden */
  100557. _alphaMode: number;
  100558. /** @hidden */
  100559. _alphaEquation: number;
  100560. /** @hidden */
  100561. _internalTexturesCache: InternalTexture[];
  100562. /** @hidden */
  100563. protected _activeChannel: number;
  100564. private _currentTextureChannel;
  100565. /** @hidden */
  100566. protected _boundTexturesCache: {
  100567. [key: string]: Nullable<InternalTexture>;
  100568. };
  100569. /** @hidden */
  100570. protected _currentEffect: Nullable<Effect>;
  100571. /** @hidden */
  100572. protected _currentProgram: Nullable<WebGLProgram>;
  100573. private _compiledEffects;
  100574. private _vertexAttribArraysEnabled;
  100575. /** @hidden */
  100576. protected _cachedViewport: Nullable<IViewportLike>;
  100577. private _cachedVertexArrayObject;
  100578. /** @hidden */
  100579. protected _cachedVertexBuffers: any;
  100580. /** @hidden */
  100581. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  100582. /** @hidden */
  100583. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  100584. /** @hidden */
  100585. _currentRenderTarget: Nullable<InternalTexture>;
  100586. private _uintIndicesCurrentlySet;
  100587. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  100588. /** @hidden */
  100589. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  100590. private _currentBufferPointers;
  100591. private _currentInstanceLocations;
  100592. private _currentInstanceBuffers;
  100593. private _textureUnits;
  100594. /** @hidden */
  100595. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100596. /** @hidden */
  100597. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100598. /** @hidden */
  100599. _boundRenderFunction: any;
  100600. private _vaoRecordInProgress;
  100601. private _mustWipeVertexAttributes;
  100602. private _emptyTexture;
  100603. private _emptyCubeTexture;
  100604. private _emptyTexture3D;
  100605. private _emptyTexture2DArray;
  100606. /** @hidden */
  100607. _frameHandler: number;
  100608. private _nextFreeTextureSlots;
  100609. private _maxSimultaneousTextures;
  100610. private _activeRequests;
  100611. protected _texturesSupported: string[];
  100612. /** @hidden */
  100613. _textureFormatInUse: Nullable<string>;
  100614. protected readonly _supportsHardwareTextureRescaling: boolean;
  100615. /**
  100616. * Gets the list of texture formats supported
  100617. */
  100618. readonly texturesSupported: Array<string>;
  100619. /**
  100620. * Gets the list of texture formats in use
  100621. */
  100622. readonly textureFormatInUse: Nullable<string>;
  100623. /**
  100624. * Gets the current viewport
  100625. */
  100626. readonly currentViewport: Nullable<IViewportLike>;
  100627. /**
  100628. * Gets the default empty texture
  100629. */
  100630. readonly emptyTexture: InternalTexture;
  100631. /**
  100632. * Gets the default empty 3D texture
  100633. */
  100634. readonly emptyTexture3D: InternalTexture;
  100635. /**
  100636. * Gets the default empty 2D array texture
  100637. */
  100638. readonly emptyTexture2DArray: InternalTexture;
  100639. /**
  100640. * Gets the default empty cube texture
  100641. */
  100642. readonly emptyCubeTexture: InternalTexture;
  100643. /**
  100644. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  100645. */
  100646. readonly premultipliedAlpha: boolean;
  100647. /**
  100648. * Observable event triggered before each texture is initialized
  100649. */
  100650. onBeforeTextureInitObservable: Observable<Texture>;
  100651. /**
  100652. * Creates a new engine
  100653. * @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
  100654. * @param antialias defines enable antialiasing (default: false)
  100655. * @param options defines further options to be sent to the getContext() function
  100656. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100657. */
  100658. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100659. private _rebuildInternalTextures;
  100660. private _rebuildEffects;
  100661. /**
  100662. * Gets a boolean indicating if all created effects are ready
  100663. * @returns true if all effects are ready
  100664. */
  100665. areAllEffectsReady(): boolean;
  100666. protected _rebuildBuffers(): void;
  100667. private _initGLContext;
  100668. /**
  100669. * Gets version of the current webGL context
  100670. */
  100671. readonly webGLVersion: number;
  100672. /**
  100673. * Gets a string idenfifying the name of the class
  100674. * @returns "Engine" string
  100675. */
  100676. getClassName(): string;
  100677. /**
  100678. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  100679. */
  100680. readonly isStencilEnable: boolean;
  100681. /** @hidden */
  100682. _prepareWorkingCanvas(): void;
  100683. /**
  100684. * Reset the texture cache to empty state
  100685. */
  100686. resetTextureCache(): void;
  100687. /**
  100688. * Gets an object containing information about the current webGL context
  100689. * @returns an object containing the vender, the renderer and the version of the current webGL context
  100690. */
  100691. getGlInfo(): {
  100692. vendor: string;
  100693. renderer: string;
  100694. version: string;
  100695. };
  100696. /**
  100697. * Defines the hardware scaling level.
  100698. * By default the hardware scaling level is computed from the window device ratio.
  100699. * 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.
  100700. * @param level defines the level to use
  100701. */
  100702. setHardwareScalingLevel(level: number): void;
  100703. /**
  100704. * Gets the current hardware scaling level.
  100705. * By default the hardware scaling level is computed from the window device ratio.
  100706. * 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.
  100707. * @returns a number indicating the current hardware scaling level
  100708. */
  100709. getHardwareScalingLevel(): number;
  100710. /**
  100711. * Gets the list of loaded textures
  100712. * @returns an array containing all loaded textures
  100713. */
  100714. getLoadedTexturesCache(): InternalTexture[];
  100715. /**
  100716. * Gets the object containing all engine capabilities
  100717. * @returns the EngineCapabilities object
  100718. */
  100719. getCaps(): EngineCapabilities;
  100720. /**
  100721. * stop executing a render loop function and remove it from the execution array
  100722. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  100723. */
  100724. stopRenderLoop(renderFunction?: () => void): void;
  100725. /** @hidden */
  100726. _renderLoop(): void;
  100727. /**
  100728. * Gets the HTML canvas attached with the current webGL context
  100729. * @returns a HTML canvas
  100730. */
  100731. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  100732. /**
  100733. * Gets host window
  100734. * @returns the host window object
  100735. */
  100736. getHostWindow(): Nullable<Window>;
  100737. /**
  100738. * Gets the current render width
  100739. * @param useScreen defines if screen size must be used (or the current render target if any)
  100740. * @returns a number defining the current render width
  100741. */
  100742. getRenderWidth(useScreen?: boolean): number;
  100743. /**
  100744. * Gets the current render height
  100745. * @param useScreen defines if screen size must be used (or the current render target if any)
  100746. * @returns a number defining the current render height
  100747. */
  100748. getRenderHeight(useScreen?: boolean): number;
  100749. /**
  100750. * Can be used to override the current requestAnimationFrame requester.
  100751. * @hidden
  100752. */
  100753. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  100754. /**
  100755. * Register and execute a render loop. The engine can have more than one render function
  100756. * @param renderFunction defines the function to continuously execute
  100757. */
  100758. runRenderLoop(renderFunction: () => void): void;
  100759. /**
  100760. * Clear the current render buffer or the current render target (if any is set up)
  100761. * @param color defines the color to use
  100762. * @param backBuffer defines if the back buffer must be cleared
  100763. * @param depth defines if the depth buffer must be cleared
  100764. * @param stencil defines if the stencil buffer must be cleared
  100765. */
  100766. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100767. private _viewportCached;
  100768. /** @hidden */
  100769. _viewport(x: number, y: number, width: number, height: number): void;
  100770. /**
  100771. * Set the WebGL's viewport
  100772. * @param viewport defines the viewport element to be used
  100773. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  100774. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  100775. */
  100776. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  100777. /**
  100778. * Begin a new frame
  100779. */
  100780. beginFrame(): void;
  100781. /**
  100782. * Enf the current frame
  100783. */
  100784. endFrame(): void;
  100785. /**
  100786. * Resize the view according to the canvas' size
  100787. */
  100788. resize(): void;
  100789. /**
  100790. * Force a specific size of the canvas
  100791. * @param width defines the new canvas' width
  100792. * @param height defines the new canvas' height
  100793. */
  100794. setSize(width: number, height: number): void;
  100795. /**
  100796. * Binds the frame buffer to the specified texture.
  100797. * @param texture The texture to render to or null for the default canvas
  100798. * @param faceIndex The face of the texture to render to in case of cube texture
  100799. * @param requiredWidth The width of the target to render to
  100800. * @param requiredHeight The height of the target to render to
  100801. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  100802. * @param depthStencilTexture The depth stencil texture to use to render
  100803. * @param lodLevel defines le lod level to bind to the frame buffer
  100804. */
  100805. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  100806. /** @hidden */
  100807. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  100808. /**
  100809. * Unbind the current render target texture from the webGL context
  100810. * @param texture defines the render target texture to unbind
  100811. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  100812. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  100813. */
  100814. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100815. /**
  100816. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  100817. */
  100818. flushFramebuffer(): void;
  100819. /**
  100820. * Unbind the current render target and bind the default framebuffer
  100821. */
  100822. restoreDefaultFramebuffer(): void;
  100823. /** @hidden */
  100824. protected _resetVertexBufferBinding(): void;
  100825. /**
  100826. * Creates a vertex buffer
  100827. * @param data the data for the vertex buffer
  100828. * @returns the new WebGL static buffer
  100829. */
  100830. createVertexBuffer(data: DataArray): DataBuffer;
  100831. private _createVertexBuffer;
  100832. /**
  100833. * Creates a dynamic vertex buffer
  100834. * @param data the data for the dynamic vertex buffer
  100835. * @returns the new WebGL dynamic buffer
  100836. */
  100837. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  100838. protected _resetIndexBufferBinding(): void;
  100839. /**
  100840. * Creates a new index buffer
  100841. * @param indices defines the content of the index buffer
  100842. * @param updatable defines if the index buffer must be updatable
  100843. * @returns a new webGL buffer
  100844. */
  100845. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  100846. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  100847. /**
  100848. * Bind a webGL buffer to the webGL context
  100849. * @param buffer defines the buffer to bind
  100850. */
  100851. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  100852. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  100853. private bindBuffer;
  100854. /**
  100855. * update the bound buffer with the given data
  100856. * @param data defines the data to update
  100857. */
  100858. updateArrayBuffer(data: Float32Array): void;
  100859. private _vertexAttribPointer;
  100860. private _bindIndexBufferWithCache;
  100861. private _bindVertexBuffersAttributes;
  100862. /**
  100863. * Records a vertex array object
  100864. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100865. * @param vertexBuffers defines the list of vertex buffers to store
  100866. * @param indexBuffer defines the index buffer to store
  100867. * @param effect defines the effect to store
  100868. * @returns the new vertex array object
  100869. */
  100870. recordVertexArrayObject(vertexBuffers: {
  100871. [key: string]: VertexBuffer;
  100872. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  100873. /**
  100874. * Bind a specific vertex array object
  100875. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100876. * @param vertexArrayObject defines the vertex array object to bind
  100877. * @param indexBuffer defines the index buffer to bind
  100878. */
  100879. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  100880. /**
  100881. * Bind webGl buffers directly to the webGL context
  100882. * @param vertexBuffer defines the vertex buffer to bind
  100883. * @param indexBuffer defines the index buffer to bind
  100884. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  100885. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  100886. * @param effect defines the effect associated with the vertex buffer
  100887. */
  100888. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  100889. private _unbindVertexArrayObject;
  100890. /**
  100891. * Bind a list of vertex buffers to the webGL context
  100892. * @param vertexBuffers defines the list of vertex buffers to bind
  100893. * @param indexBuffer defines the index buffer to bind
  100894. * @param effect defines the effect associated with the vertex buffers
  100895. */
  100896. bindBuffers(vertexBuffers: {
  100897. [key: string]: Nullable<VertexBuffer>;
  100898. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  100899. /**
  100900. * Unbind all instance attributes
  100901. */
  100902. unbindInstanceAttributes(): void;
  100903. /**
  100904. * Release and free the memory of a vertex array object
  100905. * @param vao defines the vertex array object to delete
  100906. */
  100907. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  100908. /** @hidden */
  100909. _releaseBuffer(buffer: DataBuffer): boolean;
  100910. protected _deleteBuffer(buffer: DataBuffer): void;
  100911. /**
  100912. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  100913. * @param instancesBuffer defines the webGL buffer to update and bind
  100914. * @param data defines the data to store in the buffer
  100915. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  100916. */
  100917. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  100918. /**
  100919. * Bind the content of a webGL buffer used with instanciation
  100920. * @param instancesBuffer defines the webGL buffer to bind
  100921. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  100922. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  100923. */
  100924. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  100925. /**
  100926. * Disable the instance attribute corresponding to the name in parameter
  100927. * @param name defines the name of the attribute to disable
  100928. */
  100929. disableInstanceAttributeByName(name: string): void;
  100930. /**
  100931. * Disable the instance attribute corresponding to the location in parameter
  100932. * @param attributeLocation defines the attribute location of the attribute to disable
  100933. */
  100934. disableInstanceAttribute(attributeLocation: number): void;
  100935. /**
  100936. * Disable the attribute corresponding to the location in parameter
  100937. * @param attributeLocation defines the attribute location of the attribute to disable
  100938. */
  100939. disableAttributeByIndex(attributeLocation: number): void;
  100940. /**
  100941. * Send a draw order
  100942. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100943. * @param indexStart defines the starting index
  100944. * @param indexCount defines the number of index to draw
  100945. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100946. */
  100947. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100948. /**
  100949. * Draw a list of points
  100950. * @param verticesStart defines the index of first vertex to draw
  100951. * @param verticesCount defines the count of vertices to draw
  100952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100953. */
  100954. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100955. /**
  100956. * Draw a list of unindexed primitives
  100957. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100958. * @param verticesStart defines the index of first vertex to draw
  100959. * @param verticesCount defines the count of vertices to draw
  100960. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100961. */
  100962. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100963. /**
  100964. * Draw a list of indexed primitives
  100965. * @param fillMode defines the primitive to use
  100966. * @param indexStart defines the starting index
  100967. * @param indexCount defines the number of index to draw
  100968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100969. */
  100970. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100971. /**
  100972. * Draw a list of unindexed primitives
  100973. * @param fillMode defines the primitive to use
  100974. * @param verticesStart defines the index of first vertex to draw
  100975. * @param verticesCount defines the count of vertices to draw
  100976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100977. */
  100978. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100979. private _drawMode;
  100980. /** @hidden */
  100981. protected _reportDrawCall(): void;
  100982. /** @hidden */
  100983. _releaseEffect(effect: Effect): void;
  100984. /** @hidden */
  100985. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100986. /**
  100987. * Create a new effect (used to store vertex/fragment shaders)
  100988. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  100989. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  100990. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  100991. * @param samplers defines an array of string used to represent textures
  100992. * @param defines defines the string containing the defines to use to compile the shaders
  100993. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  100994. * @param onCompiled defines a function to call when the effect creation is successful
  100995. * @param onError defines a function to call when the effect creation has failed
  100996. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  100997. * @returns the new Effect
  100998. */
  100999. 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;
  101000. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101001. private _compileShader;
  101002. private _compileRawShader;
  101003. /**
  101004. * Directly creates a webGL program
  101005. * @param pipelineContext defines the pipeline context to attach to
  101006. * @param vertexCode defines the vertex shader code to use
  101007. * @param fragmentCode defines the fragment shader code to use
  101008. * @param context defines the webGL context to use (if not set, the current one will be used)
  101009. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101010. * @returns the new webGL program
  101011. */
  101012. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101013. /**
  101014. * Creates a webGL program
  101015. * @param pipelineContext defines the pipeline context to attach to
  101016. * @param vertexCode defines the vertex shader code to use
  101017. * @param fragmentCode defines the fragment shader code to use
  101018. * @param defines defines the string containing the defines to use to compile the shaders
  101019. * @param context defines the webGL context to use (if not set, the current one will be used)
  101020. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101021. * @returns the new webGL program
  101022. */
  101023. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101024. /**
  101025. * Creates a new pipeline context
  101026. * @returns the new pipeline
  101027. */
  101028. createPipelineContext(): IPipelineContext;
  101029. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101030. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101031. /** @hidden */
  101032. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101033. /** @hidden */
  101034. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101035. /** @hidden */
  101036. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101037. /**
  101038. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101039. * @param pipelineContext defines the pipeline context to use
  101040. * @param uniformsNames defines the list of uniform names
  101041. * @returns an array of webGL uniform locations
  101042. */
  101043. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101044. /**
  101045. * Gets the lsit of active attributes for a given webGL program
  101046. * @param pipelineContext defines the pipeline context to use
  101047. * @param attributesNames defines the list of attribute names to get
  101048. * @returns an array of indices indicating the offset of each attribute
  101049. */
  101050. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101051. /**
  101052. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101053. * @param effect defines the effect to activate
  101054. */
  101055. enableEffect(effect: Nullable<Effect>): void;
  101056. /**
  101057. * Set the value of an uniform to a number (int)
  101058. * @param uniform defines the webGL uniform location where to store the value
  101059. * @param value defines the int number to store
  101060. */
  101061. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101062. /**
  101063. * Set the value of an uniform to an array of int32
  101064. * @param uniform defines the webGL uniform location where to store the value
  101065. * @param array defines the array of int32 to store
  101066. */
  101067. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101068. /**
  101069. * Set the value of an uniform to an array of int32 (stored as vec2)
  101070. * @param uniform defines the webGL uniform location where to store the value
  101071. * @param array defines the array of int32 to store
  101072. */
  101073. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101074. /**
  101075. * Set the value of an uniform to an array of int32 (stored as vec3)
  101076. * @param uniform defines the webGL uniform location where to store the value
  101077. * @param array defines the array of int32 to store
  101078. */
  101079. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101080. /**
  101081. * Set the value of an uniform to an array of int32 (stored as vec4)
  101082. * @param uniform defines the webGL uniform location where to store the value
  101083. * @param array defines the array of int32 to store
  101084. */
  101085. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101086. /**
  101087. * Set the value of an uniform to an array of number
  101088. * @param uniform defines the webGL uniform location where to store the value
  101089. * @param array defines the array of number to store
  101090. */
  101091. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101092. /**
  101093. * Set the value of an uniform to an array of number (stored as vec2)
  101094. * @param uniform defines the webGL uniform location where to store the value
  101095. * @param array defines the array of number to store
  101096. */
  101097. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101098. /**
  101099. * Set the value of an uniform to an array of number (stored as vec3)
  101100. * @param uniform defines the webGL uniform location where to store the value
  101101. * @param array defines the array of number to store
  101102. */
  101103. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101104. /**
  101105. * Set the value of an uniform to an array of number (stored as vec4)
  101106. * @param uniform defines the webGL uniform location where to store the value
  101107. * @param array defines the array of number to store
  101108. */
  101109. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101110. /**
  101111. * Set the value of an uniform to an array of float32 (stored as matrices)
  101112. * @param uniform defines the webGL uniform location where to store the value
  101113. * @param matrices defines the array of float32 to store
  101114. */
  101115. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  101116. /**
  101117. * Set the value of an uniform to a matrix (3x3)
  101118. * @param uniform defines the webGL uniform location where to store the value
  101119. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  101120. */
  101121. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101122. /**
  101123. * Set the value of an uniform to a matrix (2x2)
  101124. * @param uniform defines the webGL uniform location where to store the value
  101125. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  101126. */
  101127. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101128. /**
  101129. * Set the value of an uniform to a number (float)
  101130. * @param uniform defines the webGL uniform location where to store the value
  101131. * @param value defines the float number to store
  101132. */
  101133. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101134. /**
  101135. * Set the value of an uniform to a vec2
  101136. * @param uniform defines the webGL uniform location where to store the value
  101137. * @param x defines the 1st component of the value
  101138. * @param y defines the 2nd component of the value
  101139. */
  101140. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  101141. /**
  101142. * Set the value of an uniform to a vec3
  101143. * @param uniform defines the webGL uniform location where to store the value
  101144. * @param x defines the 1st component of the value
  101145. * @param y defines the 2nd component of the value
  101146. * @param z defines the 3rd component of the value
  101147. */
  101148. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  101149. /**
  101150. * Set the value of an uniform to a vec4
  101151. * @param uniform defines the webGL uniform location where to store the value
  101152. * @param x defines the 1st component of the value
  101153. * @param y defines the 2nd component of the value
  101154. * @param z defines the 3rd component of the value
  101155. * @param w defines the 4th component of the value
  101156. */
  101157. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  101158. /**
  101159. * Apply all cached states (depth, culling, stencil and alpha)
  101160. */
  101161. applyStates(): void;
  101162. /**
  101163. * Enable or disable color writing
  101164. * @param enable defines the state to set
  101165. */
  101166. setColorWrite(enable: boolean): void;
  101167. /**
  101168. * Gets a boolean indicating if color writing is enabled
  101169. * @returns the current color writing state
  101170. */
  101171. getColorWrite(): boolean;
  101172. /**
  101173. * Gets the depth culling state manager
  101174. */
  101175. readonly depthCullingState: DepthCullingState;
  101176. /**
  101177. * Gets the alpha state manager
  101178. */
  101179. readonly alphaState: AlphaState;
  101180. /**
  101181. * Gets the stencil state manager
  101182. */
  101183. readonly stencilState: StencilState;
  101184. /**
  101185. * Clears the list of texture accessible through engine.
  101186. * This can help preventing texture load conflict due to name collision.
  101187. */
  101188. clearInternalTexturesCache(): void;
  101189. /**
  101190. * Force the entire cache to be cleared
  101191. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  101192. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  101193. */
  101194. wipeCaches(bruteForce?: boolean): void;
  101195. /** @hidden */
  101196. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  101197. min: number;
  101198. mag: number;
  101199. };
  101200. /** @hidden */
  101201. _createTexture(): WebGLTexture;
  101202. /**
  101203. * Usually called from Texture.ts.
  101204. * Passed information to create a WebGLTexture
  101205. * @param urlArg defines a value which contains one of the following:
  101206. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  101207. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  101208. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  101209. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  101210. * @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)
  101211. * @param scene needed for loading to the correct scene
  101212. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  101213. * @param onLoad optional callback to be called upon successful completion
  101214. * @param onError optional callback to be called upon failure
  101215. * @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
  101216. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  101217. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  101218. * @param forcedExtension defines the extension to use to pick the right loader
  101219. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  101220. * @param mimeType defines an optional mime type
  101221. * @returns a InternalTexture for assignment back into BABYLON.Texture
  101222. */
  101223. 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;
  101224. /**
  101225. * @hidden
  101226. */
  101227. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  101228. /**
  101229. * Creates a raw texture
  101230. * @param data defines the data to store in the texture
  101231. * @param width defines the width of the texture
  101232. * @param height defines the height of the texture
  101233. * @param format defines the format of the data
  101234. * @param generateMipMaps defines if the engine should generate the mip levels
  101235. * @param invertY defines if data must be stored with Y axis inverted
  101236. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  101237. * @param compression defines the compression used (null by default)
  101238. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  101239. * @returns the raw texture inside an InternalTexture
  101240. */
  101241. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  101242. /**
  101243. * Creates a new raw cube texture
  101244. * @param data defines the array of data to use to create each face
  101245. * @param size defines the size of the textures
  101246. * @param format defines the format of the data
  101247. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  101248. * @param generateMipMaps defines if the engine should generate the mip levels
  101249. * @param invertY defines if data must be stored with Y axis inverted
  101250. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  101251. * @param compression defines the compression used (null by default)
  101252. * @returns the cube texture as an InternalTexture
  101253. */
  101254. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  101255. /**
  101256. * Creates a new raw 3D texture
  101257. * @param data defines the data used to create the texture
  101258. * @param width defines the width of the texture
  101259. * @param height defines the height of the texture
  101260. * @param depth defines the depth of the texture
  101261. * @param format defines the format of the texture
  101262. * @param generateMipMaps defines if the engine must generate mip levels
  101263. * @param invertY defines if data must be stored with Y axis inverted
  101264. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  101265. * @param compression defines the compressed used (can be null)
  101266. * @param textureType defines the compressed used (can be null)
  101267. * @returns a new raw 3D texture (stored in an InternalTexture)
  101268. */
  101269. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  101270. /**
  101271. * Creates a new raw 2D array texture
  101272. * @param data defines the data used to create the texture
  101273. * @param width defines the width of the texture
  101274. * @param height defines the height of the texture
  101275. * @param depth defines the number of layers of the texture
  101276. * @param format defines the format of the texture
  101277. * @param generateMipMaps defines if the engine must generate mip levels
  101278. * @param invertY defines if data must be stored with Y axis inverted
  101279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  101280. * @param compression defines the compressed used (can be null)
  101281. * @param textureType defines the compressed used (can be null)
  101282. * @returns a new raw 2D array texture (stored in an InternalTexture)
  101283. */
  101284. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  101285. private _unpackFlipYCached;
  101286. /**
  101287. * In case you are sharing the context with other applications, it might
  101288. * be interested to not cache the unpack flip y state to ensure a consistent
  101289. * value would be set.
  101290. */
  101291. enableUnpackFlipYCached: boolean;
  101292. /** @hidden */
  101293. _unpackFlipY(value: boolean): void;
  101294. /** @hidden */
  101295. _getUnpackAlignement(): number;
  101296. private _getTextureTarget;
  101297. /**
  101298. * Update the sampling mode of a given texture
  101299. * @param samplingMode defines the required sampling mode
  101300. * @param texture defines the texture to update
  101301. * @param generateMipMaps defines whether to generate mipmaps for the texture
  101302. */
  101303. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  101304. /**
  101305. * Update the sampling mode of a given texture
  101306. * @param texture defines the texture to update
  101307. * @param wrapU defines the texture wrap mode of the u coordinates
  101308. * @param wrapV defines the texture wrap mode of the v coordinates
  101309. * @param wrapR defines the texture wrap mode of the r coordinates
  101310. */
  101311. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  101312. /** @hidden */
  101313. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  101314. width: number;
  101315. height: number;
  101316. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  101317. /** @hidden */
  101318. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101319. /** @hidden */
  101320. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  101321. /** @hidden */
  101322. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101323. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  101324. private _prepareWebGLTexture;
  101325. /** @hidden */
  101326. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  101327. private _getDepthStencilBuffer;
  101328. /** @hidden */
  101329. _releaseFramebufferObjects(texture: InternalTexture): void;
  101330. /** @hidden */
  101331. _releaseTexture(texture: InternalTexture): void;
  101332. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  101333. protected _setProgram(program: WebGLProgram): void;
  101334. protected _boundUniforms: {
  101335. [key: number]: WebGLUniformLocation;
  101336. };
  101337. /**
  101338. * Binds an effect to the webGL context
  101339. * @param effect defines the effect to bind
  101340. */
  101341. bindSamplers(effect: Effect): void;
  101342. private _activateCurrentTexture;
  101343. /** @hidden */
  101344. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  101345. /** @hidden */
  101346. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  101347. /**
  101348. * Unbind all textures from the webGL context
  101349. */
  101350. unbindAllTextures(): void;
  101351. /**
  101352. * Sets a texture to the according uniform.
  101353. * @param channel The texture channel
  101354. * @param uniform The uniform to set
  101355. * @param texture The texture to apply
  101356. */
  101357. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  101358. private _bindSamplerUniformToChannel;
  101359. private _getTextureWrapMode;
  101360. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  101361. /**
  101362. * Sets an array of texture to the webGL context
  101363. * @param channel defines the channel where the texture array must be set
  101364. * @param uniform defines the associated uniform location
  101365. * @param textures defines the array of textures to bind
  101366. */
  101367. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  101368. /** @hidden */
  101369. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  101370. private _setTextureParameterFloat;
  101371. private _setTextureParameterInteger;
  101372. /**
  101373. * Unbind all vertex attributes from the webGL context
  101374. */
  101375. unbindAllAttributes(): void;
  101376. /**
  101377. * 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
  101378. */
  101379. releaseEffects(): void;
  101380. /**
  101381. * Dispose and release all associated resources
  101382. */
  101383. dispose(): void;
  101384. /**
  101385. * Attach a new callback raised when context lost event is fired
  101386. * @param callback defines the callback to call
  101387. */
  101388. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  101389. /**
  101390. * Attach a new callback raised when context restored event is fired
  101391. * @param callback defines the callback to call
  101392. */
  101393. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  101394. /**
  101395. * Get the current error code of the webGL context
  101396. * @returns the error code
  101397. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101398. */
  101399. getError(): number;
  101400. private _canRenderToFloatFramebuffer;
  101401. private _canRenderToHalfFloatFramebuffer;
  101402. private _canRenderToFramebuffer;
  101403. /** @hidden */
  101404. _getWebGLTextureType(type: number): number;
  101405. /** @hidden */
  101406. _getInternalFormat(format: number): number;
  101407. /** @hidden */
  101408. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  101409. /** @hidden */
  101410. _getRGBAMultiSampleBufferFormat(type: number): number;
  101411. /** @hidden */
  101412. _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;
  101413. /**
  101414. * Reads pixels from the current frame buffer. Please note that this function can be slow
  101415. * @param x defines the x coordinate of the rectangle where pixels must be read
  101416. * @param y defines the y coordinate of the rectangle where pixels must be read
  101417. * @param width defines the width of the rectangle where pixels must be read
  101418. * @param height defines the height of the rectangle where pixels must be read
  101419. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  101420. * @returns a Uint8Array containing RGBA colors
  101421. */
  101422. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  101423. /**
  101424. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  101425. * @returns true if the engine can be created
  101426. * @ignorenaming
  101427. */
  101428. static isSupported(): boolean;
  101429. /**
  101430. * Find the next highest power of two.
  101431. * @param x Number to start search from.
  101432. * @return Next highest power of two.
  101433. */
  101434. static CeilingPOT(x: number): number;
  101435. /**
  101436. * Find the next lowest power of two.
  101437. * @param x Number to start search from.
  101438. * @return Next lowest power of two.
  101439. */
  101440. static FloorPOT(x: number): number;
  101441. /**
  101442. * Find the nearest power of two.
  101443. * @param x Number to start search from.
  101444. * @return Next nearest power of two.
  101445. */
  101446. static NearestPOT(x: number): number;
  101447. /**
  101448. * Get the closest exponent of two
  101449. * @param value defines the value to approximate
  101450. * @param max defines the maximum value to return
  101451. * @param mode defines how to define the closest value
  101452. * @returns closest exponent of two of the given value
  101453. */
  101454. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  101455. /**
  101456. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  101457. * @param func - the function to be called
  101458. * @param requester - the object that will request the next frame. Falls back to window.
  101459. * @returns frame number
  101460. */
  101461. static QueueNewFrame(func: () => void, requester?: any): number;
  101462. /**
  101463. * Gets host document
  101464. * @returns the host document object
  101465. */
  101466. getHostDocument(): Nullable<Document>;
  101467. }
  101468. }
  101469. declare module BABYLON {
  101470. /**
  101471. * Class representing spherical harmonics coefficients to the 3rd degree
  101472. */
  101473. export class SphericalHarmonics {
  101474. /**
  101475. * Defines whether or not the harmonics have been prescaled for rendering.
  101476. */
  101477. preScaled: boolean;
  101478. /**
  101479. * The l0,0 coefficients of the spherical harmonics
  101480. */
  101481. l00: Vector3;
  101482. /**
  101483. * The l1,-1 coefficients of the spherical harmonics
  101484. */
  101485. l1_1: Vector3;
  101486. /**
  101487. * The l1,0 coefficients of the spherical harmonics
  101488. */
  101489. l10: Vector3;
  101490. /**
  101491. * The l1,1 coefficients of the spherical harmonics
  101492. */
  101493. l11: Vector3;
  101494. /**
  101495. * The l2,-2 coefficients of the spherical harmonics
  101496. */
  101497. l2_2: Vector3;
  101498. /**
  101499. * The l2,-1 coefficients of the spherical harmonics
  101500. */
  101501. l2_1: Vector3;
  101502. /**
  101503. * The l2,0 coefficients of the spherical harmonics
  101504. */
  101505. l20: Vector3;
  101506. /**
  101507. * The l2,1 coefficients of the spherical harmonics
  101508. */
  101509. l21: Vector3;
  101510. /**
  101511. * The l2,2 coefficients of the spherical harmonics
  101512. */
  101513. l22: Vector3;
  101514. /**
  101515. * Adds a light to the spherical harmonics
  101516. * @param direction the direction of the light
  101517. * @param color the color of the light
  101518. * @param deltaSolidAngle the delta solid angle of the light
  101519. */
  101520. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101521. /**
  101522. * Scales the spherical harmonics by the given amount
  101523. * @param scale the amount to scale
  101524. */
  101525. scaleInPlace(scale: number): void;
  101526. /**
  101527. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101528. *
  101529. * ```
  101530. * E_lm = A_l * L_lm
  101531. * ```
  101532. *
  101533. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101534. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101535. * the scaling factors are given in equation 9.
  101536. */
  101537. convertIncidentRadianceToIrradiance(): void;
  101538. /**
  101539. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101540. *
  101541. * ```
  101542. * L = (1/pi) * E * rho
  101543. * ```
  101544. *
  101545. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101546. */
  101547. convertIrradianceToLambertianRadiance(): void;
  101548. /**
  101549. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101550. * required operations at run time.
  101551. *
  101552. * This is simply done by scaling back the SH with Ylm constants parameter.
  101553. * The trigonometric part being applied by the shader at run time.
  101554. */
  101555. preScaleForRendering(): void;
  101556. /**
  101557. * Constructs a spherical harmonics from an array.
  101558. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101559. * @returns the spherical harmonics
  101560. */
  101561. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101562. /**
  101563. * Gets the spherical harmonics from polynomial
  101564. * @param polynomial the spherical polynomial
  101565. * @returns the spherical harmonics
  101566. */
  101567. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101568. }
  101569. /**
  101570. * Class representing spherical polynomial coefficients to the 3rd degree
  101571. */
  101572. export class SphericalPolynomial {
  101573. private _harmonics;
  101574. /**
  101575. * The spherical harmonics used to create the polynomials.
  101576. */
  101577. readonly preScaledHarmonics: SphericalHarmonics;
  101578. /**
  101579. * The x coefficients of the spherical polynomial
  101580. */
  101581. x: Vector3;
  101582. /**
  101583. * The y coefficients of the spherical polynomial
  101584. */
  101585. y: Vector3;
  101586. /**
  101587. * The z coefficients of the spherical polynomial
  101588. */
  101589. z: Vector3;
  101590. /**
  101591. * The xx coefficients of the spherical polynomial
  101592. */
  101593. xx: Vector3;
  101594. /**
  101595. * The yy coefficients of the spherical polynomial
  101596. */
  101597. yy: Vector3;
  101598. /**
  101599. * The zz coefficients of the spherical polynomial
  101600. */
  101601. zz: Vector3;
  101602. /**
  101603. * The xy coefficients of the spherical polynomial
  101604. */
  101605. xy: Vector3;
  101606. /**
  101607. * The yz coefficients of the spherical polynomial
  101608. */
  101609. yz: Vector3;
  101610. /**
  101611. * The zx coefficients of the spherical polynomial
  101612. */
  101613. zx: Vector3;
  101614. /**
  101615. * Adds an ambient color to the spherical polynomial
  101616. * @param color the color to add
  101617. */
  101618. addAmbient(color: Color3): void;
  101619. /**
  101620. * Scales the spherical polynomial by the given amount
  101621. * @param scale the amount to scale
  101622. */
  101623. scaleInPlace(scale: number): void;
  101624. /**
  101625. * Gets the spherical polynomial from harmonics
  101626. * @param harmonics the spherical harmonics
  101627. * @returns the spherical polynomial
  101628. */
  101629. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101630. /**
  101631. * Constructs a spherical polynomial from an array.
  101632. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101633. * @returns the spherical polynomial
  101634. */
  101635. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101636. }
  101637. }
  101638. declare module BABYLON {
  101639. /**
  101640. * Defines the source of the internal texture
  101641. */
  101642. export enum InternalTextureSource {
  101643. /**
  101644. * The source of the texture data is unknown
  101645. */
  101646. Unknown = 0,
  101647. /**
  101648. * Texture data comes from an URL
  101649. */
  101650. Url = 1,
  101651. /**
  101652. * Texture data is only used for temporary storage
  101653. */
  101654. Temp = 2,
  101655. /**
  101656. * Texture data comes from raw data (ArrayBuffer)
  101657. */
  101658. Raw = 3,
  101659. /**
  101660. * Texture content is dynamic (video or dynamic texture)
  101661. */
  101662. Dynamic = 4,
  101663. /**
  101664. * Texture content is generated by rendering to it
  101665. */
  101666. RenderTarget = 5,
  101667. /**
  101668. * Texture content is part of a multi render target process
  101669. */
  101670. MultiRenderTarget = 6,
  101671. /**
  101672. * Texture data comes from a cube data file
  101673. */
  101674. Cube = 7,
  101675. /**
  101676. * Texture data comes from a raw cube data
  101677. */
  101678. CubeRaw = 8,
  101679. /**
  101680. * Texture data come from a prefiltered cube data file
  101681. */
  101682. CubePrefiltered = 9,
  101683. /**
  101684. * Texture content is raw 3D data
  101685. */
  101686. Raw3D = 10,
  101687. /**
  101688. * Texture content is raw 2D array data
  101689. */
  101690. Raw2DArray = 11,
  101691. /**
  101692. * Texture content is a depth texture
  101693. */
  101694. Depth = 12,
  101695. /**
  101696. * Texture data comes from a raw cube data encoded with RGBD
  101697. */
  101698. CubeRawRGBD = 13
  101699. }
  101700. /**
  101701. * Class used to store data associated with WebGL texture data for the engine
  101702. * This class should not be used directly
  101703. */
  101704. export class InternalTexture {
  101705. /** @hidden */
  101706. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  101707. /**
  101708. * Defines if the texture is ready
  101709. */
  101710. isReady: boolean;
  101711. /**
  101712. * Defines if the texture is a cube texture
  101713. */
  101714. isCube: boolean;
  101715. /**
  101716. * Defines if the texture contains 3D data
  101717. */
  101718. is3D: boolean;
  101719. /**
  101720. * Defines if the texture contains 2D array data
  101721. */
  101722. is2DArray: boolean;
  101723. /**
  101724. * Defines if the texture contains multiview data
  101725. */
  101726. isMultiview: boolean;
  101727. /**
  101728. * Gets the URL used to load this texture
  101729. */
  101730. url: string;
  101731. /**
  101732. * Gets the sampling mode of the texture
  101733. */
  101734. samplingMode: number;
  101735. /**
  101736. * Gets a boolean indicating if the texture needs mipmaps generation
  101737. */
  101738. generateMipMaps: boolean;
  101739. /**
  101740. * Gets the number of samples used by the texture (WebGL2+ only)
  101741. */
  101742. samples: number;
  101743. /**
  101744. * Gets the type of the texture (int, float...)
  101745. */
  101746. type: number;
  101747. /**
  101748. * Gets the format of the texture (RGB, RGBA...)
  101749. */
  101750. format: number;
  101751. /**
  101752. * Observable called when the texture is loaded
  101753. */
  101754. onLoadedObservable: Observable<InternalTexture>;
  101755. /**
  101756. * Gets the width of the texture
  101757. */
  101758. width: number;
  101759. /**
  101760. * Gets the height of the texture
  101761. */
  101762. height: number;
  101763. /**
  101764. * Gets the depth of the texture
  101765. */
  101766. depth: number;
  101767. /**
  101768. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  101769. */
  101770. baseWidth: number;
  101771. /**
  101772. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  101773. */
  101774. baseHeight: number;
  101775. /**
  101776. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  101777. */
  101778. baseDepth: number;
  101779. /**
  101780. * Gets a boolean indicating if the texture is inverted on Y axis
  101781. */
  101782. invertY: boolean;
  101783. /** @hidden */
  101784. _invertVScale: boolean;
  101785. /** @hidden */
  101786. _associatedChannel: number;
  101787. /** @hidden */
  101788. _source: InternalTextureSource;
  101789. /** @hidden */
  101790. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101791. /** @hidden */
  101792. _bufferView: Nullable<ArrayBufferView>;
  101793. /** @hidden */
  101794. _bufferViewArray: Nullable<ArrayBufferView[]>;
  101795. /** @hidden */
  101796. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  101797. /** @hidden */
  101798. _size: number;
  101799. /** @hidden */
  101800. _extension: string;
  101801. /** @hidden */
  101802. _files: Nullable<string[]>;
  101803. /** @hidden */
  101804. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101805. /** @hidden */
  101806. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101807. /** @hidden */
  101808. _framebuffer: Nullable<WebGLFramebuffer>;
  101809. /** @hidden */
  101810. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  101811. /** @hidden */
  101812. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  101813. /** @hidden */
  101814. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  101815. /** @hidden */
  101816. _attachments: Nullable<number[]>;
  101817. /** @hidden */
  101818. _cachedCoordinatesMode: Nullable<number>;
  101819. /** @hidden */
  101820. _cachedWrapU: Nullable<number>;
  101821. /** @hidden */
  101822. _cachedWrapV: Nullable<number>;
  101823. /** @hidden */
  101824. _cachedWrapR: Nullable<number>;
  101825. /** @hidden */
  101826. _cachedAnisotropicFilteringLevel: Nullable<number>;
  101827. /** @hidden */
  101828. _isDisabled: boolean;
  101829. /** @hidden */
  101830. _compression: Nullable<string>;
  101831. /** @hidden */
  101832. _generateStencilBuffer: boolean;
  101833. /** @hidden */
  101834. _generateDepthBuffer: boolean;
  101835. /** @hidden */
  101836. _comparisonFunction: number;
  101837. /** @hidden */
  101838. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  101839. /** @hidden */
  101840. _lodGenerationScale: number;
  101841. /** @hidden */
  101842. _lodGenerationOffset: number;
  101843. /** @hidden */
  101844. _colorTextureArray: Nullable<WebGLTexture>;
  101845. /** @hidden */
  101846. _depthStencilTextureArray: Nullable<WebGLTexture>;
  101847. /** @hidden */
  101848. _lodTextureHigh: Nullable<BaseTexture>;
  101849. /** @hidden */
  101850. _lodTextureMid: Nullable<BaseTexture>;
  101851. /** @hidden */
  101852. _lodTextureLow: Nullable<BaseTexture>;
  101853. /** @hidden */
  101854. _isRGBD: boolean;
  101855. /** @hidden */
  101856. _linearSpecularLOD: boolean;
  101857. /** @hidden */
  101858. _irradianceTexture: Nullable<BaseTexture>;
  101859. /** @hidden */
  101860. _webGLTexture: Nullable<WebGLTexture>;
  101861. /** @hidden */
  101862. _references: number;
  101863. private _engine;
  101864. /**
  101865. * Gets the Engine the texture belongs to.
  101866. * @returns The babylon engine
  101867. */
  101868. getEngine(): ThinEngine;
  101869. /**
  101870. * Gets the data source type of the texture
  101871. */
  101872. readonly source: InternalTextureSource;
  101873. /**
  101874. * Creates a new InternalTexture
  101875. * @param engine defines the engine to use
  101876. * @param source defines the type of data that will be used
  101877. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101878. */
  101879. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  101880. /**
  101881. * Increments the number of references (ie. the number of Texture that point to it)
  101882. */
  101883. incrementReferences(): void;
  101884. /**
  101885. * Change the size of the texture (not the size of the content)
  101886. * @param width defines the new width
  101887. * @param height defines the new height
  101888. * @param depth defines the new depth (1 by default)
  101889. */
  101890. updateSize(width: int, height: int, depth?: int): void;
  101891. /** @hidden */
  101892. _rebuild(): void;
  101893. /** @hidden */
  101894. _swapAndDie(target: InternalTexture): void;
  101895. /**
  101896. * Dispose the current allocated resources
  101897. */
  101898. dispose(): void;
  101899. }
  101900. }
  101901. declare module BABYLON {
  101902. /**
  101903. * Class used to work with sound analyzer using fast fourier transform (FFT)
  101904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101905. */
  101906. export class Analyser {
  101907. /**
  101908. * Gets or sets the smoothing
  101909. * @ignorenaming
  101910. */
  101911. SMOOTHING: number;
  101912. /**
  101913. * Gets or sets the FFT table size
  101914. * @ignorenaming
  101915. */
  101916. FFT_SIZE: number;
  101917. /**
  101918. * Gets or sets the bar graph amplitude
  101919. * @ignorenaming
  101920. */
  101921. BARGRAPHAMPLITUDE: number;
  101922. /**
  101923. * Gets or sets the position of the debug canvas
  101924. * @ignorenaming
  101925. */
  101926. DEBUGCANVASPOS: {
  101927. x: number;
  101928. y: number;
  101929. };
  101930. /**
  101931. * Gets or sets the debug canvas size
  101932. * @ignorenaming
  101933. */
  101934. DEBUGCANVASSIZE: {
  101935. width: number;
  101936. height: number;
  101937. };
  101938. private _byteFreqs;
  101939. private _byteTime;
  101940. private _floatFreqs;
  101941. private _webAudioAnalyser;
  101942. private _debugCanvas;
  101943. private _debugCanvasContext;
  101944. private _scene;
  101945. private _registerFunc;
  101946. private _audioEngine;
  101947. /**
  101948. * Creates a new analyser
  101949. * @param scene defines hosting scene
  101950. */
  101951. constructor(scene: Scene);
  101952. /**
  101953. * Get the number of data values you will have to play with for the visualization
  101954. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  101955. * @returns a number
  101956. */
  101957. getFrequencyBinCount(): number;
  101958. /**
  101959. * Gets the current frequency data as a byte array
  101960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101961. * @returns a Uint8Array
  101962. */
  101963. getByteFrequencyData(): Uint8Array;
  101964. /**
  101965. * Gets the current waveform as a byte array
  101966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  101967. * @returns a Uint8Array
  101968. */
  101969. getByteTimeDomainData(): Uint8Array;
  101970. /**
  101971. * Gets the current frequency data as a float array
  101972. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101973. * @returns a Float32Array
  101974. */
  101975. getFloatFrequencyData(): Float32Array;
  101976. /**
  101977. * Renders the debug canvas
  101978. */
  101979. drawDebugCanvas(): void;
  101980. /**
  101981. * Stops rendering the debug canvas and removes it
  101982. */
  101983. stopDebugCanvas(): void;
  101984. /**
  101985. * Connects two audio nodes
  101986. * @param inputAudioNode defines first node to connect
  101987. * @param outputAudioNode defines second node to connect
  101988. */
  101989. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  101990. /**
  101991. * Releases all associated resources
  101992. */
  101993. dispose(): void;
  101994. }
  101995. }
  101996. declare module BABYLON {
  101997. /**
  101998. * This represents an audio engine and it is responsible
  101999. * to play, synchronize and analyse sounds throughout the application.
  102000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102001. */
  102002. export interface IAudioEngine extends IDisposable {
  102003. /**
  102004. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102005. */
  102006. readonly canUseWebAudio: boolean;
  102007. /**
  102008. * Gets the current AudioContext if available.
  102009. */
  102010. readonly audioContext: Nullable<AudioContext>;
  102011. /**
  102012. * The master gain node defines the global audio volume of your audio engine.
  102013. */
  102014. readonly masterGain: GainNode;
  102015. /**
  102016. * Gets whether or not mp3 are supported by your browser.
  102017. */
  102018. readonly isMP3supported: boolean;
  102019. /**
  102020. * Gets whether or not ogg are supported by your browser.
  102021. */
  102022. readonly isOGGsupported: boolean;
  102023. /**
  102024. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102025. * @ignoreNaming
  102026. */
  102027. WarnedWebAudioUnsupported: boolean;
  102028. /**
  102029. * Defines if the audio engine relies on a custom unlocked button.
  102030. * In this case, the embedded button will not be displayed.
  102031. */
  102032. useCustomUnlockedButton: boolean;
  102033. /**
  102034. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102035. */
  102036. readonly unlocked: boolean;
  102037. /**
  102038. * Event raised when audio has been unlocked on the browser.
  102039. */
  102040. onAudioUnlockedObservable: Observable<AudioEngine>;
  102041. /**
  102042. * Event raised when audio has been locked on the browser.
  102043. */
  102044. onAudioLockedObservable: Observable<AudioEngine>;
  102045. /**
  102046. * Flags the audio engine in Locked state.
  102047. * This happens due to new browser policies preventing audio to autoplay.
  102048. */
  102049. lock(): void;
  102050. /**
  102051. * Unlocks the audio engine once a user action has been done on the dom.
  102052. * This is helpful to resume play once browser policies have been satisfied.
  102053. */
  102054. unlock(): void;
  102055. }
  102056. /**
  102057. * This represents the default audio engine used in babylon.
  102058. * It is responsible to play, synchronize and analyse sounds throughout the application.
  102059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102060. */
  102061. export class AudioEngine implements IAudioEngine {
  102062. private _audioContext;
  102063. private _audioContextInitialized;
  102064. private _muteButton;
  102065. private _hostElement;
  102066. /**
  102067. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102068. */
  102069. canUseWebAudio: boolean;
  102070. /**
  102071. * The master gain node defines the global audio volume of your audio engine.
  102072. */
  102073. masterGain: GainNode;
  102074. /**
  102075. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102076. * @ignoreNaming
  102077. */
  102078. WarnedWebAudioUnsupported: boolean;
  102079. /**
  102080. * Gets whether or not mp3 are supported by your browser.
  102081. */
  102082. isMP3supported: boolean;
  102083. /**
  102084. * Gets whether or not ogg are supported by your browser.
  102085. */
  102086. isOGGsupported: boolean;
  102087. /**
  102088. * Gets whether audio has been unlocked on the device.
  102089. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  102090. * a user interaction has happened.
  102091. */
  102092. unlocked: boolean;
  102093. /**
  102094. * Defines if the audio engine relies on a custom unlocked button.
  102095. * In this case, the embedded button will not be displayed.
  102096. */
  102097. useCustomUnlockedButton: boolean;
  102098. /**
  102099. * Event raised when audio has been unlocked on the browser.
  102100. */
  102101. onAudioUnlockedObservable: Observable<AudioEngine>;
  102102. /**
  102103. * Event raised when audio has been locked on the browser.
  102104. */
  102105. onAudioLockedObservable: Observable<AudioEngine>;
  102106. /**
  102107. * Gets the current AudioContext if available.
  102108. */
  102109. readonly audioContext: Nullable<AudioContext>;
  102110. private _connectedAnalyser;
  102111. /**
  102112. * Instantiates a new audio engine.
  102113. *
  102114. * There should be only one per page as some browsers restrict the number
  102115. * of audio contexts you can create.
  102116. * @param hostElement defines the host element where to display the mute icon if necessary
  102117. */
  102118. constructor(hostElement?: Nullable<HTMLElement>);
  102119. /**
  102120. * Flags the audio engine in Locked state.
  102121. * This happens due to new browser policies preventing audio to autoplay.
  102122. */
  102123. lock(): void;
  102124. /**
  102125. * Unlocks the audio engine once a user action has been done on the dom.
  102126. * This is helpful to resume play once browser policies have been satisfied.
  102127. */
  102128. unlock(): void;
  102129. private _resumeAudioContext;
  102130. private _initializeAudioContext;
  102131. private _tryToRun;
  102132. private _triggerRunningState;
  102133. private _triggerSuspendedState;
  102134. private _displayMuteButton;
  102135. private _moveButtonToTopLeft;
  102136. private _onResize;
  102137. private _hideMuteButton;
  102138. /**
  102139. * Destroy and release the resources associated with the audio ccontext.
  102140. */
  102141. dispose(): void;
  102142. /**
  102143. * Gets the global volume sets on the master gain.
  102144. * @returns the global volume if set or -1 otherwise
  102145. */
  102146. getGlobalVolume(): number;
  102147. /**
  102148. * Sets the global volume of your experience (sets on the master gain).
  102149. * @param newVolume Defines the new global volume of the application
  102150. */
  102151. setGlobalVolume(newVolume: number): void;
  102152. /**
  102153. * Connect the audio engine to an audio analyser allowing some amazing
  102154. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102156. * @param analyser The analyser to connect to the engine
  102157. */
  102158. connectToAnalyser(analyser: Analyser): void;
  102159. }
  102160. }
  102161. declare module BABYLON {
  102162. /**
  102163. * Interface used to present a loading screen while loading a scene
  102164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102165. */
  102166. export interface ILoadingScreen {
  102167. /**
  102168. * Function called to display the loading screen
  102169. */
  102170. displayLoadingUI: () => void;
  102171. /**
  102172. * Function called to hide the loading screen
  102173. */
  102174. hideLoadingUI: () => void;
  102175. /**
  102176. * Gets or sets the color to use for the background
  102177. */
  102178. loadingUIBackgroundColor: string;
  102179. /**
  102180. * Gets or sets the text to display while loading
  102181. */
  102182. loadingUIText: string;
  102183. }
  102184. /**
  102185. * Class used for the default loading screen
  102186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102187. */
  102188. export class DefaultLoadingScreen implements ILoadingScreen {
  102189. private _renderingCanvas;
  102190. private _loadingText;
  102191. private _loadingDivBackgroundColor;
  102192. private _loadingDiv;
  102193. private _loadingTextDiv;
  102194. /** Gets or sets the logo url to use for the default loading screen */
  102195. static DefaultLogoUrl: string;
  102196. /** Gets or sets the spinner url to use for the default loading screen */
  102197. static DefaultSpinnerUrl: string;
  102198. /**
  102199. * Creates a new default loading screen
  102200. * @param _renderingCanvas defines the canvas used to render the scene
  102201. * @param _loadingText defines the default text to display
  102202. * @param _loadingDivBackgroundColor defines the default background color
  102203. */
  102204. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  102205. /**
  102206. * Function called to display the loading screen
  102207. */
  102208. displayLoadingUI(): void;
  102209. /**
  102210. * Function called to hide the loading screen
  102211. */
  102212. hideLoadingUI(): void;
  102213. /**
  102214. * Gets or sets the text to display while loading
  102215. */
  102216. loadingUIText: string;
  102217. /**
  102218. * Gets or sets the color to use for the background
  102219. */
  102220. loadingUIBackgroundColor: string;
  102221. private _resizeLoadingUI;
  102222. }
  102223. }
  102224. declare module BABYLON {
  102225. /**
  102226. * Interface for any object that can request an animation frame
  102227. */
  102228. export interface ICustomAnimationFrameRequester {
  102229. /**
  102230. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  102231. */
  102232. renderFunction?: Function;
  102233. /**
  102234. * Called to request the next frame to render to
  102235. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  102236. */
  102237. requestAnimationFrame: Function;
  102238. /**
  102239. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  102240. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  102241. */
  102242. requestID?: number;
  102243. }
  102244. }
  102245. declare module BABYLON {
  102246. /**
  102247. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  102248. */
  102249. export class PerformanceMonitor {
  102250. private _enabled;
  102251. private _rollingFrameTime;
  102252. private _lastFrameTimeMs;
  102253. /**
  102254. * constructor
  102255. * @param frameSampleSize The number of samples required to saturate the sliding window
  102256. */
  102257. constructor(frameSampleSize?: number);
  102258. /**
  102259. * Samples current frame
  102260. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  102261. */
  102262. sampleFrame(timeMs?: number): void;
  102263. /**
  102264. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  102265. */
  102266. readonly averageFrameTime: number;
  102267. /**
  102268. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  102269. */
  102270. readonly averageFrameTimeVariance: number;
  102271. /**
  102272. * Returns the frame time of the most recent frame
  102273. */
  102274. readonly instantaneousFrameTime: number;
  102275. /**
  102276. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  102277. */
  102278. readonly averageFPS: number;
  102279. /**
  102280. * Returns the average framerate in frames per second using the most recent frame time
  102281. */
  102282. readonly instantaneousFPS: number;
  102283. /**
  102284. * Returns true if enough samples have been taken to completely fill the sliding window
  102285. */
  102286. readonly isSaturated: boolean;
  102287. /**
  102288. * Enables contributions to the sliding window sample set
  102289. */
  102290. enable(): void;
  102291. /**
  102292. * Disables contributions to the sliding window sample set
  102293. * Samples will not be interpolated over the disabled period
  102294. */
  102295. disable(): void;
  102296. /**
  102297. * Returns true if sampling is enabled
  102298. */
  102299. readonly isEnabled: boolean;
  102300. /**
  102301. * Resets performance monitor
  102302. */
  102303. reset(): void;
  102304. }
  102305. /**
  102306. * RollingAverage
  102307. *
  102308. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  102309. */
  102310. export class RollingAverage {
  102311. /**
  102312. * Current average
  102313. */
  102314. average: number;
  102315. /**
  102316. * Current variance
  102317. */
  102318. variance: number;
  102319. protected _samples: Array<number>;
  102320. protected _sampleCount: number;
  102321. protected _pos: number;
  102322. protected _m2: number;
  102323. /**
  102324. * constructor
  102325. * @param length The number of samples required to saturate the sliding window
  102326. */
  102327. constructor(length: number);
  102328. /**
  102329. * Adds a sample to the sample set
  102330. * @param v The sample value
  102331. */
  102332. add(v: number): void;
  102333. /**
  102334. * Returns previously added values or null if outside of history or outside the sliding window domain
  102335. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  102336. * @return Value previously recorded with add() or null if outside of range
  102337. */
  102338. history(i: number): number;
  102339. /**
  102340. * Returns true if enough samples have been taken to completely fill the sliding window
  102341. * @return true if sample-set saturated
  102342. */
  102343. isSaturated(): boolean;
  102344. /**
  102345. * Resets the rolling average (equivalent to 0 samples taken so far)
  102346. */
  102347. reset(): void;
  102348. /**
  102349. * Wraps a value around the sample range boundaries
  102350. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  102351. * @return Wrapped position in sample range
  102352. */
  102353. protected _wrapPosition(i: number): number;
  102354. }
  102355. }
  102356. declare module BABYLON {
  102357. /**
  102358. * This class is used to track a performance counter which is number based.
  102359. * The user has access to many properties which give statistics of different nature.
  102360. *
  102361. * The implementer can track two kinds of Performance Counter: time and count.
  102362. * 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.
  102363. * 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.
  102364. */
  102365. export class PerfCounter {
  102366. /**
  102367. * Gets or sets a global boolean to turn on and off all the counters
  102368. */
  102369. static Enabled: boolean;
  102370. /**
  102371. * Returns the smallest value ever
  102372. */
  102373. readonly min: number;
  102374. /**
  102375. * Returns the biggest value ever
  102376. */
  102377. readonly max: number;
  102378. /**
  102379. * Returns the average value since the performance counter is running
  102380. */
  102381. readonly average: number;
  102382. /**
  102383. * Returns the average value of the last second the counter was monitored
  102384. */
  102385. readonly lastSecAverage: number;
  102386. /**
  102387. * Returns the current value
  102388. */
  102389. readonly current: number;
  102390. /**
  102391. * Gets the accumulated total
  102392. */
  102393. readonly total: number;
  102394. /**
  102395. * Gets the total value count
  102396. */
  102397. readonly count: number;
  102398. /**
  102399. * Creates a new counter
  102400. */
  102401. constructor();
  102402. /**
  102403. * Call this method to start monitoring a new frame.
  102404. * 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.
  102405. */
  102406. fetchNewFrame(): void;
  102407. /**
  102408. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  102409. * @param newCount the count value to add to the monitored count
  102410. * @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.
  102411. */
  102412. addCount(newCount: number, fetchResult: boolean): void;
  102413. /**
  102414. * Start monitoring this performance counter
  102415. */
  102416. beginMonitoring(): void;
  102417. /**
  102418. * Compute the time lapsed since the previous beginMonitoring() call.
  102419. * @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
  102420. */
  102421. endMonitoring(newFrame?: boolean): void;
  102422. private _fetchResult;
  102423. private _startMonitoringTime;
  102424. private _min;
  102425. private _max;
  102426. private _average;
  102427. private _current;
  102428. private _totalValueCount;
  102429. private _totalAccumulated;
  102430. private _lastSecAverage;
  102431. private _lastSecAccumulated;
  102432. private _lastSecTime;
  102433. private _lastSecValueCount;
  102434. }
  102435. }
  102436. declare module BABYLON {
  102437. interface ThinEngine {
  102438. /**
  102439. * Sets alpha constants used by some alpha blending modes
  102440. * @param r defines the red component
  102441. * @param g defines the green component
  102442. * @param b defines the blue component
  102443. * @param a defines the alpha component
  102444. */
  102445. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  102446. /**
  102447. * Sets the current alpha mode
  102448. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  102449. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  102450. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  102451. */
  102452. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  102453. /**
  102454. * Gets the current alpha mode
  102455. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  102456. * @returns the current alpha mode
  102457. */
  102458. getAlphaMode(): number;
  102459. /**
  102460. * Sets the current alpha equation
  102461. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  102462. */
  102463. setAlphaEquation(equation: number): void;
  102464. /**
  102465. * Gets the current alpha equation.
  102466. * @returns the current alpha equation
  102467. */
  102468. getAlphaEquation(): number;
  102469. }
  102470. }
  102471. declare module BABYLON {
  102472. /**
  102473. * Defines the interface used by display changed events
  102474. */
  102475. export interface IDisplayChangedEventArgs {
  102476. /** Gets the vrDisplay object (if any) */
  102477. vrDisplay: Nullable<any>;
  102478. /** Gets a boolean indicating if webVR is supported */
  102479. vrSupported: boolean;
  102480. }
  102481. /**
  102482. * Defines the interface used by objects containing a viewport (like a camera)
  102483. */
  102484. interface IViewportOwnerLike {
  102485. /**
  102486. * Gets or sets the viewport
  102487. */
  102488. viewport: IViewportLike;
  102489. }
  102490. /**
  102491. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  102492. */
  102493. export class Engine extends ThinEngine {
  102494. /** Defines that alpha blending is disabled */
  102495. static readonly ALPHA_DISABLE: number;
  102496. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  102497. static readonly ALPHA_ADD: number;
  102498. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  102499. static readonly ALPHA_COMBINE: number;
  102500. /** Defines that alpha blending to DEST - SRC * DEST */
  102501. static readonly ALPHA_SUBTRACT: number;
  102502. /** Defines that alpha blending to SRC * DEST */
  102503. static readonly ALPHA_MULTIPLY: number;
  102504. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  102505. static readonly ALPHA_MAXIMIZED: number;
  102506. /** Defines that alpha blending to SRC + DEST */
  102507. static readonly ALPHA_ONEONE: number;
  102508. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  102509. static readonly ALPHA_PREMULTIPLIED: number;
  102510. /**
  102511. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  102512. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  102513. */
  102514. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  102515. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  102516. static readonly ALPHA_INTERPOLATE: number;
  102517. /**
  102518. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  102519. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  102520. */
  102521. static readonly ALPHA_SCREENMODE: number;
  102522. /** Defines that the ressource is not delayed*/
  102523. static readonly DELAYLOADSTATE_NONE: number;
  102524. /** Defines that the ressource was successfully delay loaded */
  102525. static readonly DELAYLOADSTATE_LOADED: number;
  102526. /** Defines that the ressource is currently delay loading */
  102527. static readonly DELAYLOADSTATE_LOADING: number;
  102528. /** Defines that the ressource is delayed and has not started loading */
  102529. static readonly DELAYLOADSTATE_NOTLOADED: number;
  102530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  102531. static readonly NEVER: number;
  102532. /** 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 */
  102533. static readonly ALWAYS: number;
  102534. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  102535. static readonly LESS: number;
  102536. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  102537. static readonly EQUAL: number;
  102538. /** 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 */
  102539. static readonly LEQUAL: number;
  102540. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  102541. static readonly GREATER: number;
  102542. /** 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 */
  102543. static readonly GEQUAL: number;
  102544. /** 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 */
  102545. static readonly NOTEQUAL: number;
  102546. /** Passed to stencilOperation to specify that stencil value must be kept */
  102547. static readonly KEEP: number;
  102548. /** Passed to stencilOperation to specify that stencil value must be replaced */
  102549. static readonly REPLACE: number;
  102550. /** Passed to stencilOperation to specify that stencil value must be incremented */
  102551. static readonly INCR: number;
  102552. /** Passed to stencilOperation to specify that stencil value must be decremented */
  102553. static readonly DECR: number;
  102554. /** Passed to stencilOperation to specify that stencil value must be inverted */
  102555. static readonly INVERT: number;
  102556. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  102557. static readonly INCR_WRAP: number;
  102558. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  102559. static readonly DECR_WRAP: number;
  102560. /** Texture is not repeating outside of 0..1 UVs */
  102561. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  102562. /** Texture is repeating outside of 0..1 UVs */
  102563. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  102564. /** Texture is repeating and mirrored */
  102565. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  102566. /** ALPHA */
  102567. static readonly TEXTUREFORMAT_ALPHA: number;
  102568. /** LUMINANCE */
  102569. static readonly TEXTUREFORMAT_LUMINANCE: number;
  102570. /** LUMINANCE_ALPHA */
  102571. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  102572. /** RGB */
  102573. static readonly TEXTUREFORMAT_RGB: number;
  102574. /** RGBA */
  102575. static readonly TEXTUREFORMAT_RGBA: number;
  102576. /** RED */
  102577. static readonly TEXTUREFORMAT_RED: number;
  102578. /** RED (2nd reference) */
  102579. static readonly TEXTUREFORMAT_R: number;
  102580. /** RG */
  102581. static readonly TEXTUREFORMAT_RG: number;
  102582. /** RED_INTEGER */
  102583. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  102584. /** RED_INTEGER (2nd reference) */
  102585. static readonly TEXTUREFORMAT_R_INTEGER: number;
  102586. /** RG_INTEGER */
  102587. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  102588. /** RGB_INTEGER */
  102589. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  102590. /** RGBA_INTEGER */
  102591. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  102592. /** UNSIGNED_BYTE */
  102593. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  102594. /** UNSIGNED_BYTE (2nd reference) */
  102595. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  102596. /** FLOAT */
  102597. static readonly TEXTURETYPE_FLOAT: number;
  102598. /** HALF_FLOAT */
  102599. static readonly TEXTURETYPE_HALF_FLOAT: number;
  102600. /** BYTE */
  102601. static readonly TEXTURETYPE_BYTE: number;
  102602. /** SHORT */
  102603. static readonly TEXTURETYPE_SHORT: number;
  102604. /** UNSIGNED_SHORT */
  102605. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  102606. /** INT */
  102607. static readonly TEXTURETYPE_INT: number;
  102608. /** UNSIGNED_INT */
  102609. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  102610. /** UNSIGNED_SHORT_4_4_4_4 */
  102611. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  102612. /** UNSIGNED_SHORT_5_5_5_1 */
  102613. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  102614. /** UNSIGNED_SHORT_5_6_5 */
  102615. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  102616. /** UNSIGNED_INT_2_10_10_10_REV */
  102617. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  102618. /** UNSIGNED_INT_24_8 */
  102619. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  102620. /** UNSIGNED_INT_10F_11F_11F_REV */
  102621. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  102622. /** UNSIGNED_INT_5_9_9_9_REV */
  102623. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  102624. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  102625. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  102626. /** nearest is mag = nearest and min = nearest and mip = linear */
  102627. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  102628. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102629. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  102630. /** Trilinear is mag = linear and min = linear and mip = linear */
  102631. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  102632. /** nearest is mag = nearest and min = nearest and mip = linear */
  102633. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  102634. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102635. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  102636. /** Trilinear is mag = linear and min = linear and mip = linear */
  102637. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  102638. /** mag = nearest and min = nearest and mip = nearest */
  102639. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  102640. /** mag = nearest and min = linear and mip = nearest */
  102641. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  102642. /** mag = nearest and min = linear and mip = linear */
  102643. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  102644. /** mag = nearest and min = linear and mip = none */
  102645. static readonly TEXTURE_NEAREST_LINEAR: number;
  102646. /** mag = nearest and min = nearest and mip = none */
  102647. static readonly TEXTURE_NEAREST_NEAREST: number;
  102648. /** mag = linear and min = nearest and mip = nearest */
  102649. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  102650. /** mag = linear and min = nearest and mip = linear */
  102651. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  102652. /** mag = linear and min = linear and mip = none */
  102653. static readonly TEXTURE_LINEAR_LINEAR: number;
  102654. /** mag = linear and min = nearest and mip = none */
  102655. static readonly TEXTURE_LINEAR_NEAREST: number;
  102656. /** Explicit coordinates mode */
  102657. static readonly TEXTURE_EXPLICIT_MODE: number;
  102658. /** Spherical coordinates mode */
  102659. static readonly TEXTURE_SPHERICAL_MODE: number;
  102660. /** Planar coordinates mode */
  102661. static readonly TEXTURE_PLANAR_MODE: number;
  102662. /** Cubic coordinates mode */
  102663. static readonly TEXTURE_CUBIC_MODE: number;
  102664. /** Projection coordinates mode */
  102665. static readonly TEXTURE_PROJECTION_MODE: number;
  102666. /** Skybox coordinates mode */
  102667. static readonly TEXTURE_SKYBOX_MODE: number;
  102668. /** Inverse Cubic coordinates mode */
  102669. static readonly TEXTURE_INVCUBIC_MODE: number;
  102670. /** Equirectangular coordinates mode */
  102671. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  102672. /** Equirectangular Fixed coordinates mode */
  102673. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  102674. /** Equirectangular Fixed Mirrored coordinates mode */
  102675. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102676. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  102677. static readonly SCALEMODE_FLOOR: number;
  102678. /** Defines that texture rescaling will look for the nearest power of 2 size */
  102679. static readonly SCALEMODE_NEAREST: number;
  102680. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  102681. static readonly SCALEMODE_CEILING: number;
  102682. /**
  102683. * Returns the current npm package of the sdk
  102684. */
  102685. static readonly NpmPackage: string;
  102686. /**
  102687. * Returns the current version of the framework
  102688. */
  102689. static readonly Version: string;
  102690. /** Gets the list of created engines */
  102691. static readonly Instances: Engine[];
  102692. /**
  102693. * Gets the latest created engine
  102694. */
  102695. static readonly LastCreatedEngine: Nullable<Engine>;
  102696. /**
  102697. * Gets the latest created scene
  102698. */
  102699. static readonly LastCreatedScene: Nullable<Scene>;
  102700. /**
  102701. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  102702. * @param flag defines which part of the materials must be marked as dirty
  102703. * @param predicate defines a predicate used to filter which materials should be affected
  102704. */
  102705. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102706. /**
  102707. * Method called to create the default loading screen.
  102708. * This can be overriden in your own app.
  102709. * @param canvas The rendering canvas element
  102710. * @returns The loading screen
  102711. */
  102712. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  102713. /**
  102714. * Method called to create the default rescale post process on each engine.
  102715. */
  102716. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  102717. /**
  102718. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  102719. **/
  102720. enableOfflineSupport: boolean;
  102721. /**
  102722. * 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)
  102723. **/
  102724. disableManifestCheck: boolean;
  102725. /**
  102726. * Gets the list of created scenes
  102727. */
  102728. scenes: Scene[];
  102729. /**
  102730. * Event raised when a new scene is created
  102731. */
  102732. onNewSceneAddedObservable: Observable<Scene>;
  102733. /**
  102734. * Gets the list of created postprocesses
  102735. */
  102736. postProcesses: PostProcess[];
  102737. /**
  102738. * Gets a boolean indicating if the pointer is currently locked
  102739. */
  102740. isPointerLock: boolean;
  102741. /**
  102742. * Observable event triggered each time the rendering canvas is resized
  102743. */
  102744. onResizeObservable: Observable<Engine>;
  102745. /**
  102746. * Observable event triggered each time the canvas loses focus
  102747. */
  102748. onCanvasBlurObservable: Observable<Engine>;
  102749. /**
  102750. * Observable event triggered each time the canvas gains focus
  102751. */
  102752. onCanvasFocusObservable: Observable<Engine>;
  102753. /**
  102754. * Observable event triggered each time the canvas receives pointerout event
  102755. */
  102756. onCanvasPointerOutObservable: Observable<PointerEvent>;
  102757. /**
  102758. * Observable raised when the engine begins a new frame
  102759. */
  102760. onBeginFrameObservable: Observable<Engine>;
  102761. /**
  102762. * If set, will be used to request the next animation frame for the render loop
  102763. */
  102764. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  102765. /**
  102766. * Observable raised when the engine ends the current frame
  102767. */
  102768. onEndFrameObservable: Observable<Engine>;
  102769. /**
  102770. * Observable raised when the engine is about to compile a shader
  102771. */
  102772. onBeforeShaderCompilationObservable: Observable<Engine>;
  102773. /**
  102774. * Observable raised when the engine has jsut compiled a shader
  102775. */
  102776. onAfterShaderCompilationObservable: Observable<Engine>;
  102777. /**
  102778. * Gets the audio engine
  102779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102780. * @ignorenaming
  102781. */
  102782. static audioEngine: IAudioEngine;
  102783. /**
  102784. * Default AudioEngine factory responsible of creating the Audio Engine.
  102785. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  102786. */
  102787. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  102788. /**
  102789. * Default offline support factory responsible of creating a tool used to store data locally.
  102790. * By default, this will create a Database object if the workload has been embedded.
  102791. */
  102792. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  102793. private _loadingScreen;
  102794. private _pointerLockRequested;
  102795. private _dummyFramebuffer;
  102796. private _rescalePostProcess;
  102797. private _deterministicLockstep;
  102798. private _lockstepMaxSteps;
  102799. private _timeStep;
  102800. protected readonly _supportsHardwareTextureRescaling: boolean;
  102801. private _fps;
  102802. private _deltaTime;
  102803. /** @hidden */
  102804. _drawCalls: PerfCounter;
  102805. /**
  102806. * Turn this value on if you want to pause FPS computation when in background
  102807. */
  102808. disablePerformanceMonitorInBackground: boolean;
  102809. private _performanceMonitor;
  102810. /**
  102811. * Gets the performance monitor attached to this engine
  102812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102813. */
  102814. readonly performanceMonitor: PerformanceMonitor;
  102815. private _onFocus;
  102816. private _onBlur;
  102817. private _onCanvasPointerOut;
  102818. private _onCanvasBlur;
  102819. private _onCanvasFocus;
  102820. private _onFullscreenChange;
  102821. private _onPointerLockChange;
  102822. /**
  102823. * Gets the HTML element used to attach event listeners
  102824. * @returns a HTML element
  102825. */
  102826. getInputElement(): Nullable<HTMLElement>;
  102827. /**
  102828. * Creates a new engine
  102829. * @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
  102830. * @param antialias defines enable antialiasing (default: false)
  102831. * @param options defines further options to be sent to the getContext() function
  102832. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102833. */
  102834. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102835. /**
  102836. * Gets current aspect ratio
  102837. * @param viewportOwner defines the camera to use to get the aspect ratio
  102838. * @param useScreen defines if screen size must be used (or the current render target if any)
  102839. * @returns a number defining the aspect ratio
  102840. */
  102841. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  102842. /**
  102843. * Gets current screen aspect ratio
  102844. * @returns a number defining the aspect ratio
  102845. */
  102846. getScreenAspectRatio(): number;
  102847. /**
  102848. * Gets the client rect of the HTML canvas attached with the current webGL context
  102849. * @returns a client rectanglee
  102850. */
  102851. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  102852. /**
  102853. * Gets the client rect of the HTML element used for events
  102854. * @returns a client rectanglee
  102855. */
  102856. getInputElementClientRect(): Nullable<ClientRect>;
  102857. /**
  102858. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  102859. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102860. * @returns true if engine is in deterministic lock step mode
  102861. */
  102862. isDeterministicLockStep(): boolean;
  102863. /**
  102864. * Gets the max steps when engine is running in deterministic lock step
  102865. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102866. * @returns the max steps
  102867. */
  102868. getLockstepMaxSteps(): number;
  102869. /**
  102870. * Returns the time in ms between steps when using deterministic lock step.
  102871. * @returns time step in (ms)
  102872. */
  102873. getTimeStep(): number;
  102874. /**
  102875. * Force the mipmap generation for the given render target texture
  102876. * @param texture defines the render target texture to use
  102877. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  102878. */
  102879. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  102880. /** States */
  102881. /**
  102882. * Set various states to the webGL context
  102883. * @param culling defines backface culling state
  102884. * @param zOffset defines the value to apply to zOffset (0 by default)
  102885. * @param force defines if states must be applied even if cache is up to date
  102886. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  102887. */
  102888. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  102889. /**
  102890. * Set the z offset to apply to current rendering
  102891. * @param value defines the offset to apply
  102892. */
  102893. setZOffset(value: number): void;
  102894. /**
  102895. * Gets the current value of the zOffset
  102896. * @returns the current zOffset state
  102897. */
  102898. getZOffset(): number;
  102899. /**
  102900. * Enable or disable depth buffering
  102901. * @param enable defines the state to set
  102902. */
  102903. setDepthBuffer(enable: boolean): void;
  102904. /**
  102905. * Gets a boolean indicating if depth writing is enabled
  102906. * @returns the current depth writing state
  102907. */
  102908. getDepthWrite(): boolean;
  102909. /**
  102910. * Enable or disable depth writing
  102911. * @param enable defines the state to set
  102912. */
  102913. setDepthWrite(enable: boolean): void;
  102914. /**
  102915. * Gets a boolean indicating if stencil buffer is enabled
  102916. * @returns the current stencil buffer state
  102917. */
  102918. getStencilBuffer(): boolean;
  102919. /**
  102920. * Enable or disable the stencil buffer
  102921. * @param enable defines if the stencil buffer must be enabled or disabled
  102922. */
  102923. setStencilBuffer(enable: boolean): void;
  102924. /**
  102925. * Gets the current stencil mask
  102926. * @returns a number defining the new stencil mask to use
  102927. */
  102928. getStencilMask(): number;
  102929. /**
  102930. * Sets the current stencil mask
  102931. * @param mask defines the new stencil mask to use
  102932. */
  102933. setStencilMask(mask: number): void;
  102934. /**
  102935. * Gets the current stencil function
  102936. * @returns a number defining the stencil function to use
  102937. */
  102938. getStencilFunction(): number;
  102939. /**
  102940. * Gets the current stencil reference value
  102941. * @returns a number defining the stencil reference value to use
  102942. */
  102943. getStencilFunctionReference(): number;
  102944. /**
  102945. * Gets the current stencil mask
  102946. * @returns a number defining the stencil mask to use
  102947. */
  102948. getStencilFunctionMask(): number;
  102949. /**
  102950. * Sets the current stencil function
  102951. * @param stencilFunc defines the new stencil function to use
  102952. */
  102953. setStencilFunction(stencilFunc: number): void;
  102954. /**
  102955. * Sets the current stencil reference
  102956. * @param reference defines the new stencil reference to use
  102957. */
  102958. setStencilFunctionReference(reference: number): void;
  102959. /**
  102960. * Sets the current stencil mask
  102961. * @param mask defines the new stencil mask to use
  102962. */
  102963. setStencilFunctionMask(mask: number): void;
  102964. /**
  102965. * Gets the current stencil operation when stencil fails
  102966. * @returns a number defining stencil operation to use when stencil fails
  102967. */
  102968. getStencilOperationFail(): number;
  102969. /**
  102970. * Gets the current stencil operation when depth fails
  102971. * @returns a number defining stencil operation to use when depth fails
  102972. */
  102973. getStencilOperationDepthFail(): number;
  102974. /**
  102975. * Gets the current stencil operation when stencil passes
  102976. * @returns a number defining stencil operation to use when stencil passes
  102977. */
  102978. getStencilOperationPass(): number;
  102979. /**
  102980. * Sets the stencil operation to use when stencil fails
  102981. * @param operation defines the stencil operation to use when stencil fails
  102982. */
  102983. setStencilOperationFail(operation: number): void;
  102984. /**
  102985. * Sets the stencil operation to use when depth fails
  102986. * @param operation defines the stencil operation to use when depth fails
  102987. */
  102988. setStencilOperationDepthFail(operation: number): void;
  102989. /**
  102990. * Sets the stencil operation to use when stencil passes
  102991. * @param operation defines the stencil operation to use when stencil passes
  102992. */
  102993. setStencilOperationPass(operation: number): void;
  102994. /**
  102995. * Sets a boolean indicating if the dithering state is enabled or disabled
  102996. * @param value defines the dithering state
  102997. */
  102998. setDitheringState(value: boolean): void;
  102999. /**
  103000. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103001. * @param value defines the rasterizer state
  103002. */
  103003. setRasterizerState(value: boolean): void;
  103004. /**
  103005. * Gets the current depth function
  103006. * @returns a number defining the depth function
  103007. */
  103008. getDepthFunction(): Nullable<number>;
  103009. /**
  103010. * Sets the current depth function
  103011. * @param depthFunc defines the function to use
  103012. */
  103013. setDepthFunction(depthFunc: number): void;
  103014. /**
  103015. * Sets the current depth function to GREATER
  103016. */
  103017. setDepthFunctionToGreater(): void;
  103018. /**
  103019. * Sets the current depth function to GEQUAL
  103020. */
  103021. setDepthFunctionToGreaterOrEqual(): void;
  103022. /**
  103023. * Sets the current depth function to LESS
  103024. */
  103025. setDepthFunctionToLess(): void;
  103026. /**
  103027. * Sets the current depth function to LEQUAL
  103028. */
  103029. setDepthFunctionToLessOrEqual(): void;
  103030. private _cachedStencilBuffer;
  103031. private _cachedStencilFunction;
  103032. private _cachedStencilMask;
  103033. private _cachedStencilOperationPass;
  103034. private _cachedStencilOperationFail;
  103035. private _cachedStencilOperationDepthFail;
  103036. private _cachedStencilReference;
  103037. /**
  103038. * Caches the the state of the stencil buffer
  103039. */
  103040. cacheStencilState(): void;
  103041. /**
  103042. * Restores the state of the stencil buffer
  103043. */
  103044. restoreStencilState(): void;
  103045. /**
  103046. * Directly set the WebGL Viewport
  103047. * @param x defines the x coordinate of the viewport (in screen space)
  103048. * @param y defines the y coordinate of the viewport (in screen space)
  103049. * @param width defines the width of the viewport (in screen space)
  103050. * @param height defines the height of the viewport (in screen space)
  103051. * @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
  103052. */
  103053. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  103054. /**
  103055. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  103056. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103057. * @param y defines the y-coordinate of the corner of the clear rectangle
  103058. * @param width defines the width of the clear rectangle
  103059. * @param height defines the height of the clear rectangle
  103060. * @param clearColor defines the clear color
  103061. */
  103062. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  103063. /**
  103064. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  103065. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103066. * @param y defines the y-coordinate of the corner of the clear rectangle
  103067. * @param width defines the width of the clear rectangle
  103068. * @param height defines the height of the clear rectangle
  103069. */
  103070. enableScissor(x: number, y: number, width: number, height: number): void;
  103071. /**
  103072. * Disable previously set scissor test rectangle
  103073. */
  103074. disableScissor(): void;
  103075. protected _reportDrawCall(): void;
  103076. /**
  103077. * Initializes a webVR display and starts listening to display change events
  103078. * The onVRDisplayChangedObservable will be notified upon these changes
  103079. * @returns The onVRDisplayChangedObservable
  103080. */
  103081. initWebVR(): Observable<IDisplayChangedEventArgs>;
  103082. /** @hidden */
  103083. _prepareVRComponent(): void;
  103084. /** @hidden */
  103085. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  103086. /** @hidden */
  103087. _submitVRFrame(): void;
  103088. /**
  103089. * Call this function to leave webVR mode
  103090. * Will do nothing if webVR is not supported or if there is no webVR device
  103091. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103092. */
  103093. disableVR(): void;
  103094. /**
  103095. * Gets a boolean indicating that the system is in VR mode and is presenting
  103096. * @returns true if VR mode is engaged
  103097. */
  103098. isVRPresenting(): boolean;
  103099. /** @hidden */
  103100. _requestVRFrame(): void;
  103101. /** @hidden */
  103102. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103103. /**
  103104. * Gets the source code of the vertex shader associated with a specific webGL program
  103105. * @param program defines the program to use
  103106. * @returns a string containing the source code of the vertex shader associated with the program
  103107. */
  103108. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  103109. /**
  103110. * Gets the source code of the fragment shader associated with a specific webGL program
  103111. * @param program defines the program to use
  103112. * @returns a string containing the source code of the fragment shader associated with the program
  103113. */
  103114. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  103115. /**
  103116. * Sets a depth stencil texture from a render target to the according uniform.
  103117. * @param channel The texture channel
  103118. * @param uniform The uniform to set
  103119. * @param texture The render target texture containing the depth stencil texture to apply
  103120. */
  103121. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  103122. /**
  103123. * Sets a texture to the webGL context from a postprocess
  103124. * @param channel defines the channel to use
  103125. * @param postProcess defines the source postprocess
  103126. */
  103127. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  103128. /**
  103129. * Binds the output of the passed in post process to the texture channel specified
  103130. * @param channel The channel the texture should be bound to
  103131. * @param postProcess The post process which's output should be bound
  103132. */
  103133. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  103134. /** @hidden */
  103135. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  103136. protected _rebuildBuffers(): void;
  103137. /** @hidden */
  103138. _renderFrame(): void;
  103139. _renderLoop(): void;
  103140. /** @hidden */
  103141. _renderViews(): boolean;
  103142. /**
  103143. * Toggle full screen mode
  103144. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103145. */
  103146. switchFullscreen(requestPointerLock: boolean): void;
  103147. /**
  103148. * Enters full screen mode
  103149. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103150. */
  103151. enterFullscreen(requestPointerLock: boolean): void;
  103152. /**
  103153. * Exits full screen mode
  103154. */
  103155. exitFullscreen(): void;
  103156. /**
  103157. * Enters Pointerlock mode
  103158. */
  103159. enterPointerlock(): void;
  103160. /**
  103161. * Exits Pointerlock mode
  103162. */
  103163. exitPointerlock(): void;
  103164. /**
  103165. * Begin a new frame
  103166. */
  103167. beginFrame(): void;
  103168. /**
  103169. * Enf the current frame
  103170. */
  103171. endFrame(): void;
  103172. resize(): void;
  103173. /**
  103174. * Set the compressed texture format to use, based on the formats you have, and the formats
  103175. * supported by the hardware / browser.
  103176. *
  103177. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  103178. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  103179. * to API arguments needed to compressed textures. This puts the burden on the container
  103180. * generator to house the arcane code for determining these for current & future formats.
  103181. *
  103182. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103183. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103184. *
  103185. * Note: The result of this call is not taken into account when a texture is base64.
  103186. *
  103187. * @param formatsAvailable defines the list of those format families you have created
  103188. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  103189. *
  103190. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  103191. * @returns The extension selected.
  103192. */
  103193. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  103194. /**
  103195. * Set the compressed texture extensions or file names to skip.
  103196. *
  103197. * @param skippedFiles defines the list of those texture files you want to skip
  103198. * Example: [".dds", ".env", "myfile.png"]
  103199. */
  103200. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  103201. /**
  103202. * Force a specific size of the canvas
  103203. * @param width defines the new canvas' width
  103204. * @param height defines the new canvas' height
  103205. */
  103206. setSize(width: number, height: number): void;
  103207. /**
  103208. * Updates a dynamic vertex buffer.
  103209. * @param vertexBuffer the vertex buffer to update
  103210. * @param data the data used to update the vertex buffer
  103211. * @param byteOffset the byte offset of the data
  103212. * @param byteLength the byte length of the data
  103213. */
  103214. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  103215. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  103216. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103217. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103218. _releaseTexture(texture: InternalTexture): void;
  103219. /**
  103220. * @hidden
  103221. * Rescales a texture
  103222. * @param source input texutre
  103223. * @param destination destination texture
  103224. * @param scene scene to use to render the resize
  103225. * @param internalFormat format to use when resizing
  103226. * @param onComplete callback to be called when resize has completed
  103227. */
  103228. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  103229. /**
  103230. * Gets the current framerate
  103231. * @returns a number representing the framerate
  103232. */
  103233. getFps(): number;
  103234. /**
  103235. * Gets the time spent between current and previous frame
  103236. * @returns a number representing the delta time in ms
  103237. */
  103238. getDeltaTime(): number;
  103239. private _measureFps;
  103240. /** @hidden */
  103241. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  103242. /**
  103243. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  103244. * @param renderTarget The render target to set the frame buffer for
  103245. */
  103246. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  103247. /**
  103248. * Update a dynamic index buffer
  103249. * @param indexBuffer defines the target index buffer
  103250. * @param indices defines the data to update
  103251. * @param offset defines the offset in the target index buffer where update should start
  103252. */
  103253. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  103254. /**
  103255. * Updates the sample count of a render target texture
  103256. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103257. * @param texture defines the texture to update
  103258. * @param samples defines the sample count to set
  103259. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103260. */
  103261. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  103262. /**
  103263. * Updates a depth texture Comparison Mode and Function.
  103264. * If the comparison Function is equal to 0, the mode will be set to none.
  103265. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  103266. * @param texture The texture to set the comparison function for
  103267. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  103268. */
  103269. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  103270. /**
  103271. * Creates a webGL buffer to use with instanciation
  103272. * @param capacity defines the size of the buffer
  103273. * @returns the webGL buffer
  103274. */
  103275. createInstancesBuffer(capacity: number): DataBuffer;
  103276. /**
  103277. * Delete a webGL buffer used with instanciation
  103278. * @param buffer defines the webGL buffer to delete
  103279. */
  103280. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  103281. /** @hidden */
  103282. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  103283. dispose(): void;
  103284. private _disableTouchAction;
  103285. /**
  103286. * Display the loading screen
  103287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103288. */
  103289. displayLoadingUI(): void;
  103290. /**
  103291. * Hide the loading screen
  103292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103293. */
  103294. hideLoadingUI(): void;
  103295. /**
  103296. * Gets the current loading screen object
  103297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103298. */
  103299. /**
  103300. * Sets the current loading screen object
  103301. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103302. */
  103303. loadingScreen: ILoadingScreen;
  103304. /**
  103305. * Sets the current loading screen text
  103306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103307. */
  103308. loadingUIText: string;
  103309. /**
  103310. * Sets the current loading screen background color
  103311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103312. */
  103313. loadingUIBackgroundColor: string;
  103314. /** Pointerlock and fullscreen */
  103315. /**
  103316. * Ask the browser to promote the current element to pointerlock mode
  103317. * @param element defines the DOM element to promote
  103318. */
  103319. static _RequestPointerlock(element: HTMLElement): void;
  103320. /**
  103321. * Asks the browser to exit pointerlock mode
  103322. */
  103323. static _ExitPointerlock(): void;
  103324. /**
  103325. * Ask the browser to promote the current element to fullscreen rendering mode
  103326. * @param element defines the DOM element to promote
  103327. */
  103328. static _RequestFullscreen(element: HTMLElement): void;
  103329. /**
  103330. * Asks the browser to exit fullscreen mode
  103331. */
  103332. static _ExitFullscreen(): void;
  103333. }
  103334. }
  103335. declare module BABYLON {
  103336. /**
  103337. * The engine store class is responsible to hold all the instances of Engine and Scene created
  103338. * during the life time of the application.
  103339. */
  103340. export class EngineStore {
  103341. /** Gets the list of created engines */
  103342. static Instances: Engine[];
  103343. /** @hidden */
  103344. static _LastCreatedScene: Nullable<Scene>;
  103345. /**
  103346. * Gets the latest created engine
  103347. */
  103348. static readonly LastCreatedEngine: Nullable<Engine>;
  103349. /**
  103350. * Gets the latest created scene
  103351. */
  103352. static readonly LastCreatedScene: Nullable<Scene>;
  103353. /**
  103354. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  103355. * @ignorenaming
  103356. */
  103357. static UseFallbackTexture: boolean;
  103358. /**
  103359. * Texture content used if a texture cannot loaded
  103360. * @ignorenaming
  103361. */
  103362. static FallbackTexture: string;
  103363. }
  103364. }
  103365. declare module BABYLON {
  103366. /**
  103367. * Helper class that provides a small promise polyfill
  103368. */
  103369. export class PromisePolyfill {
  103370. /**
  103371. * Static function used to check if the polyfill is required
  103372. * If this is the case then the function will inject the polyfill to window.Promise
  103373. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  103374. */
  103375. static Apply(force?: boolean): void;
  103376. }
  103377. }
  103378. declare module BABYLON {
  103379. /**
  103380. * Interface for screenshot methods with describe argument called `size` as object with options
  103381. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  103382. */
  103383. export interface IScreenshotSize {
  103384. /**
  103385. * number in pixels for canvas height
  103386. */
  103387. height?: number;
  103388. /**
  103389. * multiplier allowing render at a higher or lower resolution
  103390. * If value is defined then height and width will be ignored and taken from camera
  103391. */
  103392. precision?: number;
  103393. /**
  103394. * number in pixels for canvas width
  103395. */
  103396. width?: number;
  103397. }
  103398. }
  103399. declare module BABYLON {
  103400. interface IColor4Like {
  103401. r: float;
  103402. g: float;
  103403. b: float;
  103404. a: float;
  103405. }
  103406. /**
  103407. * Class containing a set of static utilities functions
  103408. */
  103409. export class Tools {
  103410. /**
  103411. * Gets or sets the base URL to use to load assets
  103412. */
  103413. static BaseUrl: string;
  103414. /**
  103415. * Enable/Disable Custom HTTP Request Headers globally.
  103416. * default = false
  103417. * @see CustomRequestHeaders
  103418. */
  103419. static UseCustomRequestHeaders: boolean;
  103420. /**
  103421. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  103422. * i.e. when loading files, where the server/service expects an Authorization header
  103423. */
  103424. static CustomRequestHeaders: {
  103425. [key: string]: string;
  103426. };
  103427. /**
  103428. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  103429. */
  103430. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  103431. /**
  103432. * Default behaviour for cors in the application.
  103433. * It can be a string if the expected behavior is identical in the entire app.
  103434. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  103435. */
  103436. static CorsBehavior: string | ((url: string | string[]) => string);
  103437. /**
  103438. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  103439. * @ignorenaming
  103440. */
  103441. static UseFallbackTexture: boolean;
  103442. /**
  103443. * Use this object to register external classes like custom textures or material
  103444. * to allow the laoders to instantiate them
  103445. */
  103446. static RegisteredExternalClasses: {
  103447. [key: string]: Object;
  103448. };
  103449. /**
  103450. * Texture content used if a texture cannot loaded
  103451. * @ignorenaming
  103452. */
  103453. static fallbackTexture: string;
  103454. /**
  103455. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  103456. * @param u defines the coordinate on X axis
  103457. * @param v defines the coordinate on Y axis
  103458. * @param width defines the width of the source data
  103459. * @param height defines the height of the source data
  103460. * @param pixels defines the source byte array
  103461. * @param color defines the output color
  103462. */
  103463. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  103464. /**
  103465. * Interpolates between a and b via alpha
  103466. * @param a The lower value (returned when alpha = 0)
  103467. * @param b The upper value (returned when alpha = 1)
  103468. * @param alpha The interpolation-factor
  103469. * @return The mixed value
  103470. */
  103471. static Mix(a: number, b: number, alpha: number): number;
  103472. /**
  103473. * Tries to instantiate a new object from a given class name
  103474. * @param className defines the class name to instantiate
  103475. * @returns the new object or null if the system was not able to do the instantiation
  103476. */
  103477. static Instantiate(className: string): any;
  103478. /**
  103479. * Provides a slice function that will work even on IE
  103480. * @param data defines the array to slice
  103481. * @param start defines the start of the data (optional)
  103482. * @param end defines the end of the data (optional)
  103483. * @returns the new sliced array
  103484. */
  103485. static Slice<T>(data: T, start?: number, end?: number): T;
  103486. /**
  103487. * Polyfill for setImmediate
  103488. * @param action defines the action to execute after the current execution block
  103489. */
  103490. static SetImmediate(action: () => void): void;
  103491. /**
  103492. * Function indicating if a number is an exponent of 2
  103493. * @param value defines the value to test
  103494. * @returns true if the value is an exponent of 2
  103495. */
  103496. static IsExponentOfTwo(value: number): boolean;
  103497. private static _tmpFloatArray;
  103498. /**
  103499. * Returns the nearest 32-bit single precision float representation of a Number
  103500. * @param value A Number. If the parameter is of a different type, it will get converted
  103501. * to a number or to NaN if it cannot be converted
  103502. * @returns number
  103503. */
  103504. static FloatRound(value: number): number;
  103505. /**
  103506. * Extracts the filename from a path
  103507. * @param path defines the path to use
  103508. * @returns the filename
  103509. */
  103510. static GetFilename(path: string): string;
  103511. /**
  103512. * Extracts the "folder" part of a path (everything before the filename).
  103513. * @param uri The URI to extract the info from
  103514. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  103515. * @returns The "folder" part of the path
  103516. */
  103517. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  103518. /**
  103519. * Extracts text content from a DOM element hierarchy
  103520. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  103521. */
  103522. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  103523. /**
  103524. * Convert an angle in radians to degrees
  103525. * @param angle defines the angle to convert
  103526. * @returns the angle in degrees
  103527. */
  103528. static ToDegrees(angle: number): number;
  103529. /**
  103530. * Convert an angle in degrees to radians
  103531. * @param angle defines the angle to convert
  103532. * @returns the angle in radians
  103533. */
  103534. static ToRadians(angle: number): number;
  103535. /**
  103536. * Returns an array if obj is not an array
  103537. * @param obj defines the object to evaluate as an array
  103538. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  103539. * @returns either obj directly if obj is an array or a new array containing obj
  103540. */
  103541. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  103542. /**
  103543. * Gets the pointer prefix to use
  103544. * @returns "pointer" if touch is enabled. Else returns "mouse"
  103545. */
  103546. static GetPointerPrefix(): string;
  103547. /**
  103548. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  103549. * @param url define the url we are trying
  103550. * @param element define the dom element where to configure the cors policy
  103551. */
  103552. static SetCorsBehavior(url: string | string[], element: {
  103553. crossOrigin: string | null;
  103554. }): void;
  103555. /**
  103556. * Removes unwanted characters from an url
  103557. * @param url defines the url to clean
  103558. * @returns the cleaned url
  103559. */
  103560. static CleanUrl(url: string): string;
  103561. /**
  103562. * Gets or sets a function used to pre-process url before using them to load assets
  103563. */
  103564. static PreprocessUrl: (url: string) => string;
  103565. /**
  103566. * Loads an image as an HTMLImageElement.
  103567. * @param input url string, ArrayBuffer, or Blob to load
  103568. * @param onLoad callback called when the image successfully loads
  103569. * @param onError callback called when the image fails to load
  103570. * @param offlineProvider offline provider for caching
  103571. * @param mimeType optional mime type
  103572. * @returns the HTMLImageElement of the loaded image
  103573. */
  103574. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  103575. /**
  103576. * Loads a file from a url
  103577. * @param url url string, ArrayBuffer, or Blob to load
  103578. * @param onSuccess callback called when the file successfully loads
  103579. * @param onProgress callback called while file is loading (if the server supports this mode)
  103580. * @param offlineProvider defines the offline provider for caching
  103581. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103582. * @param onError callback called when the file fails to load
  103583. * @returns a file request object
  103584. */
  103585. 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;
  103586. /**
  103587. * Loads a file from a url
  103588. * @param url the file url to load
  103589. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  103590. */
  103591. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  103592. /**
  103593. * Load a script (identified by an url). When the url returns, the
  103594. * content of this file is added into a new script element, attached to the DOM (body element)
  103595. * @param scriptUrl defines the url of the script to laod
  103596. * @param onSuccess defines the callback called when the script is loaded
  103597. * @param onError defines the callback to call if an error occurs
  103598. * @param scriptId defines the id of the script element
  103599. */
  103600. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  103601. /**
  103602. * Load an asynchronous script (identified by an url). When the url returns, the
  103603. * content of this file is added into a new script element, attached to the DOM (body element)
  103604. * @param scriptUrl defines the url of the script to laod
  103605. * @param scriptId defines the id of the script element
  103606. * @returns a promise request object
  103607. */
  103608. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  103609. /**
  103610. * Loads a file from a blob
  103611. * @param fileToLoad defines the blob to use
  103612. * @param callback defines the callback to call when data is loaded
  103613. * @param progressCallback defines the callback to call during loading process
  103614. * @returns a file request object
  103615. */
  103616. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  103617. /**
  103618. * Reads a file from a File object
  103619. * @param file defines the file to load
  103620. * @param onSuccess defines the callback to call when data is loaded
  103621. * @param onProgress defines the callback to call during loading process
  103622. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103623. * @param onError defines the callback to call when an error occurs
  103624. * @returns a file request object
  103625. */
  103626. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103627. /**
  103628. * Creates a data url from a given string content
  103629. * @param content defines the content to convert
  103630. * @returns the new data url link
  103631. */
  103632. static FileAsURL(content: string): string;
  103633. /**
  103634. * Format the given number to a specific decimal format
  103635. * @param value defines the number to format
  103636. * @param decimals defines the number of decimals to use
  103637. * @returns the formatted string
  103638. */
  103639. static Format(value: number, decimals?: number): string;
  103640. /**
  103641. * Tries to copy an object by duplicating every property
  103642. * @param source defines the source object
  103643. * @param destination defines the target object
  103644. * @param doNotCopyList defines a list of properties to avoid
  103645. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103646. */
  103647. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  103648. /**
  103649. * Gets a boolean indicating if the given object has no own property
  103650. * @param obj defines the object to test
  103651. * @returns true if object has no own property
  103652. */
  103653. static IsEmpty(obj: any): boolean;
  103654. /**
  103655. * Function used to register events at window level
  103656. * @param windowElement defines the Window object to use
  103657. * @param events defines the events to register
  103658. */
  103659. static RegisterTopRootEvents(windowElement: Window, events: {
  103660. name: string;
  103661. handler: Nullable<(e: FocusEvent) => any>;
  103662. }[]): void;
  103663. /**
  103664. * Function used to unregister events from window level
  103665. * @param windowElement defines the Window object to use
  103666. * @param events defines the events to unregister
  103667. */
  103668. static UnregisterTopRootEvents(windowElement: Window, events: {
  103669. name: string;
  103670. handler: Nullable<(e: FocusEvent) => any>;
  103671. }[]): void;
  103672. /**
  103673. * @ignore
  103674. */
  103675. static _ScreenshotCanvas: HTMLCanvasElement;
  103676. /**
  103677. * Dumps the current bound framebuffer
  103678. * @param width defines the rendering width
  103679. * @param height defines the rendering height
  103680. * @param engine defines the hosting engine
  103681. * @param successCallback defines the callback triggered once the data are available
  103682. * @param mimeType defines the mime type of the result
  103683. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  103684. */
  103685. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103686. /**
  103687. * Converts the canvas data to blob.
  103688. * This acts as a polyfill for browsers not supporting the to blob function.
  103689. * @param canvas Defines the canvas to extract the data from
  103690. * @param successCallback Defines the callback triggered once the data are available
  103691. * @param mimeType Defines the mime type of the result
  103692. */
  103693. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  103694. /**
  103695. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  103696. * @param successCallback defines the callback triggered once the data are available
  103697. * @param mimeType defines the mime type of the result
  103698. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  103699. */
  103700. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103701. /**
  103702. * Downloads a blob in the browser
  103703. * @param blob defines the blob to download
  103704. * @param fileName defines the name of the downloaded file
  103705. */
  103706. static Download(blob: Blob, fileName: string): void;
  103707. /**
  103708. * Captures a screenshot of the current rendering
  103709. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103710. * @param engine defines the rendering engine
  103711. * @param camera defines the source camera
  103712. * @param size This parameter can be set to a single number or to an object with the
  103713. * following (optional) properties: precision, width, height. If a single number is passed,
  103714. * it will be used for both width and height. If an object is passed, the screenshot size
  103715. * will be derived from the parameters. The precision property is a multiplier allowing
  103716. * rendering at a higher or lower resolution
  103717. * @param successCallback defines the callback receives a single parameter which contains the
  103718. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103719. * src parameter of an <img> to display it
  103720. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103721. * Check your browser for supported MIME types
  103722. */
  103723. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  103724. /**
  103725. * Captures a screenshot of the current rendering
  103726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103727. * @param engine defines the rendering engine
  103728. * @param camera defines the source camera
  103729. * @param size This parameter can be set to a single number or to an object with the
  103730. * following (optional) properties: precision, width, height. If a single number is passed,
  103731. * it will be used for both width and height. If an object is passed, the screenshot size
  103732. * will be derived from the parameters. The precision property is a multiplier allowing
  103733. * rendering at a higher or lower resolution
  103734. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103735. * Check your browser for supported MIME types
  103736. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103737. * to the src parameter of an <img> to display it
  103738. */
  103739. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  103740. /**
  103741. * Generates an image screenshot from the specified camera.
  103742. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103743. * @param engine The engine to use for rendering
  103744. * @param camera The camera to use for rendering
  103745. * @param size This parameter can be set to a single number or to an object with the
  103746. * following (optional) properties: precision, width, height. If a single number is passed,
  103747. * it will be used for both width and height. If an object is passed, the screenshot size
  103748. * will be derived from the parameters. The precision property is a multiplier allowing
  103749. * rendering at a higher or lower resolution
  103750. * @param successCallback The callback receives a single parameter which contains the
  103751. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103752. * src parameter of an <img> to display it
  103753. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103754. * Check your browser for supported MIME types
  103755. * @param samples Texture samples (default: 1)
  103756. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103757. * @param fileName A name for for the downloaded file.
  103758. */
  103759. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  103760. /**
  103761. * Generates an image screenshot from the specified camera.
  103762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103763. * @param engine The engine to use for rendering
  103764. * @param camera The camera to use for rendering
  103765. * @param size This parameter can be set to a single number or to an object with the
  103766. * following (optional) properties: precision, width, height. If a single number is passed,
  103767. * it will be used for both width and height. If an object is passed, the screenshot size
  103768. * will be derived from the parameters. The precision property is a multiplier allowing
  103769. * rendering at a higher or lower resolution
  103770. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103771. * Check your browser for supported MIME types
  103772. * @param samples Texture samples (default: 1)
  103773. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103774. * @param fileName A name for for the downloaded file.
  103775. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103776. * to the src parameter of an <img> to display it
  103777. */
  103778. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  103779. /**
  103780. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103781. * Be aware Math.random() could cause collisions, but:
  103782. * "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"
  103783. * @returns a pseudo random id
  103784. */
  103785. static RandomId(): string;
  103786. /**
  103787. * Test if the given uri is a base64 string
  103788. * @param uri The uri to test
  103789. * @return True if the uri is a base64 string or false otherwise
  103790. */
  103791. static IsBase64(uri: string): boolean;
  103792. /**
  103793. * Decode the given base64 uri.
  103794. * @param uri The uri to decode
  103795. * @return The decoded base64 data.
  103796. */
  103797. static DecodeBase64(uri: string): ArrayBuffer;
  103798. /**
  103799. * Gets the absolute url.
  103800. * @param url the input url
  103801. * @return the absolute url
  103802. */
  103803. static GetAbsoluteUrl(url: string): string;
  103804. /**
  103805. * No log
  103806. */
  103807. static readonly NoneLogLevel: number;
  103808. /**
  103809. * Only message logs
  103810. */
  103811. static readonly MessageLogLevel: number;
  103812. /**
  103813. * Only warning logs
  103814. */
  103815. static readonly WarningLogLevel: number;
  103816. /**
  103817. * Only error logs
  103818. */
  103819. static readonly ErrorLogLevel: number;
  103820. /**
  103821. * All logs
  103822. */
  103823. static readonly AllLogLevel: number;
  103824. /**
  103825. * Gets a value indicating the number of loading errors
  103826. * @ignorenaming
  103827. */
  103828. static readonly errorsCount: number;
  103829. /**
  103830. * Callback called when a new log is added
  103831. */
  103832. static OnNewCacheEntry: (entry: string) => void;
  103833. /**
  103834. * Log a message to the console
  103835. * @param message defines the message to log
  103836. */
  103837. static Log(message: string): void;
  103838. /**
  103839. * Write a warning message to the console
  103840. * @param message defines the message to log
  103841. */
  103842. static Warn(message: string): void;
  103843. /**
  103844. * Write an error message to the console
  103845. * @param message defines the message to log
  103846. */
  103847. static Error(message: string): void;
  103848. /**
  103849. * Gets current log cache (list of logs)
  103850. */
  103851. static readonly LogCache: string;
  103852. /**
  103853. * Clears the log cache
  103854. */
  103855. static ClearLogCache(): void;
  103856. /**
  103857. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103858. */
  103859. static LogLevels: number;
  103860. /**
  103861. * Checks if the window object exists
  103862. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  103863. */
  103864. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  103865. /**
  103866. * No performance log
  103867. */
  103868. static readonly PerformanceNoneLogLevel: number;
  103869. /**
  103870. * Use user marks to log performance
  103871. */
  103872. static readonly PerformanceUserMarkLogLevel: number;
  103873. /**
  103874. * Log performance to the console
  103875. */
  103876. static readonly PerformanceConsoleLogLevel: number;
  103877. private static _performance;
  103878. /**
  103879. * Sets the current performance log level
  103880. */
  103881. static PerformanceLogLevel: number;
  103882. private static _StartPerformanceCounterDisabled;
  103883. private static _EndPerformanceCounterDisabled;
  103884. private static _StartUserMark;
  103885. private static _EndUserMark;
  103886. private static _StartPerformanceConsole;
  103887. private static _EndPerformanceConsole;
  103888. /**
  103889. * Starts a performance counter
  103890. */
  103891. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103892. /**
  103893. * Ends a specific performance coutner
  103894. */
  103895. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103896. /**
  103897. * Gets either window.performance.now() if supported or Date.now() else
  103898. */
  103899. static readonly Now: number;
  103900. /**
  103901. * This method will return the name of the class used to create the instance of the given object.
  103902. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  103903. * @param object the object to get the class name from
  103904. * @param isType defines if the object is actually a type
  103905. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  103906. */
  103907. static GetClassName(object: any, isType?: boolean): string;
  103908. /**
  103909. * Gets the first element of an array satisfying a given predicate
  103910. * @param array defines the array to browse
  103911. * @param predicate defines the predicate to use
  103912. * @returns null if not found or the element
  103913. */
  103914. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  103915. /**
  103916. * This method will return the name of the full name of the class, including its owning module (if any).
  103917. * 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).
  103918. * @param object the object to get the class name from
  103919. * @param isType defines if the object is actually a type
  103920. * @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.
  103921. * @ignorenaming
  103922. */
  103923. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  103924. /**
  103925. * Returns a promise that resolves after the given amount of time.
  103926. * @param delay Number of milliseconds to delay
  103927. * @returns Promise that resolves after the given amount of time
  103928. */
  103929. static DelayAsync(delay: number): Promise<void>;
  103930. }
  103931. /**
  103932. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103933. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103934. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103935. * @param name The name of the class, case should be preserved
  103936. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103937. */
  103938. export function className(name: string, module?: string): (target: Object) => void;
  103939. /**
  103940. * An implementation of a loop for asynchronous functions.
  103941. */
  103942. export class AsyncLoop {
  103943. /**
  103944. * Defines the number of iterations for the loop
  103945. */
  103946. iterations: number;
  103947. /**
  103948. * Defines the current index of the loop.
  103949. */
  103950. index: number;
  103951. private _done;
  103952. private _fn;
  103953. private _successCallback;
  103954. /**
  103955. * Constructor.
  103956. * @param iterations the number of iterations.
  103957. * @param func the function to run each iteration
  103958. * @param successCallback the callback that will be called upon succesful execution
  103959. * @param offset starting offset.
  103960. */
  103961. constructor(
  103962. /**
  103963. * Defines the number of iterations for the loop
  103964. */
  103965. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  103966. /**
  103967. * Execute the next iteration. Must be called after the last iteration was finished.
  103968. */
  103969. executeNext(): void;
  103970. /**
  103971. * Break the loop and run the success callback.
  103972. */
  103973. breakLoop(): void;
  103974. /**
  103975. * Create and run an async loop.
  103976. * @param iterations the number of iterations.
  103977. * @param fn the function to run each iteration
  103978. * @param successCallback the callback that will be called upon succesful execution
  103979. * @param offset starting offset.
  103980. * @returns the created async loop object
  103981. */
  103982. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  103983. /**
  103984. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103985. * @param iterations total number of iterations
  103986. * @param syncedIterations number of synchronous iterations in each async iteration.
  103987. * @param fn the function to call each iteration.
  103988. * @param callback a success call back that will be called when iterating stops.
  103989. * @param breakFunction a break condition (optional)
  103990. * @param timeout timeout settings for the setTimeout function. default - 0.
  103991. * @returns the created async loop object
  103992. */
  103993. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  103994. }
  103995. }
  103996. declare module BABYLON {
  103997. /**
  103998. * This class implement a typical dictionary using a string as key and the generic type T as value.
  103999. * The underlying implementation relies on an associative array to ensure the best performances.
  104000. * The value can be anything including 'null' but except 'undefined'
  104001. */
  104002. export class StringDictionary<T> {
  104003. /**
  104004. * This will clear this dictionary and copy the content from the 'source' one.
  104005. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104006. * @param source the dictionary to take the content from and copy to this dictionary
  104007. */
  104008. copyFrom(source: StringDictionary<T>): void;
  104009. /**
  104010. * Get a value based from its key
  104011. * @param key the given key to get the matching value from
  104012. * @return the value if found, otherwise undefined is returned
  104013. */
  104014. get(key: string): T | undefined;
  104015. /**
  104016. * Get a value from its key or add it if it doesn't exist.
  104017. * This method will ensure you that a given key/data will be present in the dictionary.
  104018. * @param key the given key to get the matching value from
  104019. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104020. * The factory will only be invoked if there's no data for the given key.
  104021. * @return the value corresponding to the key.
  104022. */
  104023. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104024. /**
  104025. * Get a value from its key if present in the dictionary otherwise add it
  104026. * @param key the key to get the value from
  104027. * @param val if there's no such key/value pair in the dictionary add it with this value
  104028. * @return the value corresponding to the key
  104029. */
  104030. getOrAdd(key: string, val: T): T;
  104031. /**
  104032. * Check if there's a given key in the dictionary
  104033. * @param key the key to check for
  104034. * @return true if the key is present, false otherwise
  104035. */
  104036. contains(key: string): boolean;
  104037. /**
  104038. * Add a new key and its corresponding value
  104039. * @param key the key to add
  104040. * @param value the value corresponding to the key
  104041. * @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
  104042. */
  104043. add(key: string, value: T): boolean;
  104044. /**
  104045. * Update a specific value associated to a key
  104046. * @param key defines the key to use
  104047. * @param value defines the value to store
  104048. * @returns true if the value was updated (or false if the key was not found)
  104049. */
  104050. set(key: string, value: T): boolean;
  104051. /**
  104052. * Get the element of the given key and remove it from the dictionary
  104053. * @param key defines the key to search
  104054. * @returns the value associated with the key or null if not found
  104055. */
  104056. getAndRemove(key: string): Nullable<T>;
  104057. /**
  104058. * Remove a key/value from the dictionary.
  104059. * @param key the key to remove
  104060. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104061. */
  104062. remove(key: string): boolean;
  104063. /**
  104064. * Clear the whole content of the dictionary
  104065. */
  104066. clear(): void;
  104067. /**
  104068. * Gets the current count
  104069. */
  104070. readonly count: number;
  104071. /**
  104072. * Execute a callback on each key/val of the dictionary.
  104073. * Note that you can remove any element in this dictionary in the callback implementation
  104074. * @param callback the callback to execute on a given key/value pair
  104075. */
  104076. forEach(callback: (key: string, val: T) => void): void;
  104077. /**
  104078. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104079. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104080. * Note that you can remove any element in this dictionary in the callback implementation
  104081. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104082. * @returns the first item
  104083. */
  104084. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  104085. private _count;
  104086. private _data;
  104087. }
  104088. }
  104089. declare module BABYLON {
  104090. /** @hidden */
  104091. export interface ICollisionCoordinator {
  104092. createCollider(): Collider;
  104093. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104094. init(scene: Scene): void;
  104095. }
  104096. /** @hidden */
  104097. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  104098. private _scene;
  104099. private _scaledPosition;
  104100. private _scaledVelocity;
  104101. private _finalPosition;
  104102. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104103. createCollider(): Collider;
  104104. init(scene: Scene): void;
  104105. private _collideWithWorld;
  104106. }
  104107. }
  104108. declare module BABYLON {
  104109. /**
  104110. * Class used to manage all inputs for the scene.
  104111. */
  104112. export class InputManager {
  104113. /** The distance in pixel that you have to move to prevent some events */
  104114. static DragMovementThreshold: number;
  104115. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  104116. static LongPressDelay: number;
  104117. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  104118. static DoubleClickDelay: number;
  104119. /** If you need to check double click without raising a single click at first click, enable this flag */
  104120. static ExclusiveDoubleClickMode: boolean;
  104121. private _wheelEventName;
  104122. private _onPointerMove;
  104123. private _onPointerDown;
  104124. private _onPointerUp;
  104125. private _initClickEvent;
  104126. private _initActionManager;
  104127. private _delayedSimpleClick;
  104128. private _delayedSimpleClickTimeout;
  104129. private _previousDelayedSimpleClickTimeout;
  104130. private _meshPickProceed;
  104131. private _previousButtonPressed;
  104132. private _currentPickResult;
  104133. private _previousPickResult;
  104134. private _totalPointersPressed;
  104135. private _doubleClickOccured;
  104136. private _pointerOverMesh;
  104137. private _pickedDownMesh;
  104138. private _pickedUpMesh;
  104139. private _pointerX;
  104140. private _pointerY;
  104141. private _unTranslatedPointerX;
  104142. private _unTranslatedPointerY;
  104143. private _startingPointerPosition;
  104144. private _previousStartingPointerPosition;
  104145. private _startingPointerTime;
  104146. private _previousStartingPointerTime;
  104147. private _pointerCaptures;
  104148. private _onKeyDown;
  104149. private _onKeyUp;
  104150. private _onCanvasFocusObserver;
  104151. private _onCanvasBlurObserver;
  104152. private _scene;
  104153. /**
  104154. * Creates a new InputManager
  104155. * @param scene defines the hosting scene
  104156. */
  104157. constructor(scene: Scene);
  104158. /**
  104159. * Gets the mesh that is currently under the pointer
  104160. */
  104161. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104162. /**
  104163. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  104164. */
  104165. readonly unTranslatedPointer: Vector2;
  104166. /**
  104167. * Gets or sets the current on-screen X position of the pointer
  104168. */
  104169. pointerX: number;
  104170. /**
  104171. * Gets or sets the current on-screen Y position of the pointer
  104172. */
  104173. pointerY: number;
  104174. private _updatePointerPosition;
  104175. private _processPointerMove;
  104176. private _setRayOnPointerInfo;
  104177. private _checkPrePointerObservable;
  104178. /**
  104179. * Use this method to simulate a pointer move on a mesh
  104180. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104181. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104182. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104183. */
  104184. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  104185. /**
  104186. * Use this method to simulate a pointer down on a mesh
  104187. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104188. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104189. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104190. */
  104191. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  104192. private _processPointerDown;
  104193. /** @hidden */
  104194. _isPointerSwiping(): boolean;
  104195. /**
  104196. * Use this method to simulate a pointer up on a mesh
  104197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104200. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104201. */
  104202. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  104203. private _processPointerUp;
  104204. /**
  104205. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104206. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104207. * @returns true if the pointer was captured
  104208. */
  104209. isPointerCaptured(pointerId?: number): boolean;
  104210. /**
  104211. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104212. * @param attachUp defines if you want to attach events to pointerup
  104213. * @param attachDown defines if you want to attach events to pointerdown
  104214. * @param attachMove defines if you want to attach events to pointermove
  104215. */
  104216. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104217. /**
  104218. * Detaches all event handlers
  104219. */
  104220. detachControl(): void;
  104221. /**
  104222. * Force the value of meshUnderPointer
  104223. * @param mesh defines the mesh to use
  104224. */
  104225. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  104226. /**
  104227. * Gets the mesh under the pointer
  104228. * @returns a Mesh or null if no mesh is under the pointer
  104229. */
  104230. getPointerOverMesh(): Nullable<AbstractMesh>;
  104231. }
  104232. }
  104233. declare module BABYLON {
  104234. /**
  104235. * Helper class used to generate session unique ID
  104236. */
  104237. export class UniqueIdGenerator {
  104238. private static _UniqueIdCounter;
  104239. /**
  104240. * Gets an unique (relatively to the current scene) Id
  104241. */
  104242. static readonly UniqueId: number;
  104243. }
  104244. }
  104245. declare module BABYLON {
  104246. /**
  104247. * This class defines the direct association between an animation and a target
  104248. */
  104249. export class TargetedAnimation {
  104250. /**
  104251. * Animation to perform
  104252. */
  104253. animation: Animation;
  104254. /**
  104255. * Target to animate
  104256. */
  104257. target: any;
  104258. /**
  104259. * Serialize the object
  104260. * @returns the JSON object representing the current entity
  104261. */
  104262. serialize(): any;
  104263. }
  104264. /**
  104265. * Use this class to create coordinated animations on multiple targets
  104266. */
  104267. export class AnimationGroup implements IDisposable {
  104268. /** The name of the animation group */
  104269. name: string;
  104270. private _scene;
  104271. private _targetedAnimations;
  104272. private _animatables;
  104273. private _from;
  104274. private _to;
  104275. private _isStarted;
  104276. private _isPaused;
  104277. private _speedRatio;
  104278. private _loopAnimation;
  104279. /**
  104280. * Gets or sets the unique id of the node
  104281. */
  104282. uniqueId: number;
  104283. /**
  104284. * This observable will notify when one animation have ended
  104285. */
  104286. onAnimationEndObservable: Observable<TargetedAnimation>;
  104287. /**
  104288. * Observer raised when one animation loops
  104289. */
  104290. onAnimationLoopObservable: Observable<TargetedAnimation>;
  104291. /**
  104292. * Observer raised when all animations have looped
  104293. */
  104294. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  104295. /**
  104296. * This observable will notify when all animations have ended.
  104297. */
  104298. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  104299. /**
  104300. * This observable will notify when all animations have paused.
  104301. */
  104302. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  104303. /**
  104304. * This observable will notify when all animations are playing.
  104305. */
  104306. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  104307. /**
  104308. * Gets the first frame
  104309. */
  104310. readonly from: number;
  104311. /**
  104312. * Gets the last frame
  104313. */
  104314. readonly to: number;
  104315. /**
  104316. * Define if the animations are started
  104317. */
  104318. readonly isStarted: boolean;
  104319. /**
  104320. * Gets a value indicating that the current group is playing
  104321. */
  104322. readonly isPlaying: boolean;
  104323. /**
  104324. * Gets or sets the speed ratio to use for all animations
  104325. */
  104326. /**
  104327. * Gets or sets the speed ratio to use for all animations
  104328. */
  104329. speedRatio: number;
  104330. /**
  104331. * Gets or sets if all animations should loop or not
  104332. */
  104333. loopAnimation: boolean;
  104334. /**
  104335. * Gets the targeted animations for this animation group
  104336. */
  104337. readonly targetedAnimations: Array<TargetedAnimation>;
  104338. /**
  104339. * returning the list of animatables controlled by this animation group.
  104340. */
  104341. readonly animatables: Array<Animatable>;
  104342. /**
  104343. * Instantiates a new Animation Group.
  104344. * This helps managing several animations at once.
  104345. * @see http://doc.babylonjs.com/how_to/group
  104346. * @param name Defines the name of the group
  104347. * @param scene Defines the scene the group belongs to
  104348. */
  104349. constructor(
  104350. /** The name of the animation group */
  104351. name: string, scene?: Nullable<Scene>);
  104352. /**
  104353. * Add an animation (with its target) in the group
  104354. * @param animation defines the animation we want to add
  104355. * @param target defines the target of the animation
  104356. * @returns the TargetedAnimation object
  104357. */
  104358. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  104359. /**
  104360. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  104361. * It can add constant keys at begin or end
  104362. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  104363. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  104364. * @returns the animation group
  104365. */
  104366. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  104367. private _animationLoopCount;
  104368. private _animationLoopFlags;
  104369. private _processLoop;
  104370. /**
  104371. * Start all animations on given targets
  104372. * @param loop defines if animations must loop
  104373. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  104374. * @param from defines the from key (optional)
  104375. * @param to defines the to key (optional)
  104376. * @returns the current animation group
  104377. */
  104378. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  104379. /**
  104380. * Pause all animations
  104381. * @returns the animation group
  104382. */
  104383. pause(): AnimationGroup;
  104384. /**
  104385. * Play all animations to initial state
  104386. * This function will start() the animations if they were not started or will restart() them if they were paused
  104387. * @param loop defines if animations must loop
  104388. * @returns the animation group
  104389. */
  104390. play(loop?: boolean): AnimationGroup;
  104391. /**
  104392. * Reset all animations to initial state
  104393. * @returns the animation group
  104394. */
  104395. reset(): AnimationGroup;
  104396. /**
  104397. * Restart animations from key 0
  104398. * @returns the animation group
  104399. */
  104400. restart(): AnimationGroup;
  104401. /**
  104402. * Stop all animations
  104403. * @returns the animation group
  104404. */
  104405. stop(): AnimationGroup;
  104406. /**
  104407. * Set animation weight for all animatables
  104408. * @param weight defines the weight to use
  104409. * @return the animationGroup
  104410. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  104411. */
  104412. setWeightForAllAnimatables(weight: number): AnimationGroup;
  104413. /**
  104414. * Synchronize and normalize all animatables with a source animatable
  104415. * @param root defines the root animatable to synchronize with
  104416. * @return the animationGroup
  104417. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  104418. */
  104419. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  104420. /**
  104421. * Goes to a specific frame in this animation group
  104422. * @param frame the frame number to go to
  104423. * @return the animationGroup
  104424. */
  104425. goToFrame(frame: number): AnimationGroup;
  104426. /**
  104427. * Dispose all associated resources
  104428. */
  104429. dispose(): void;
  104430. private _checkAnimationGroupEnded;
  104431. /**
  104432. * Clone the current animation group and returns a copy
  104433. * @param newName defines the name of the new group
  104434. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  104435. * @returns the new aniamtion group
  104436. */
  104437. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  104438. /**
  104439. * Serializes the animationGroup to an object
  104440. * @returns Serialized object
  104441. */
  104442. serialize(): any;
  104443. /**
  104444. * Returns a new AnimationGroup object parsed from the source provided.
  104445. * @param parsedAnimationGroup defines the source
  104446. * @param scene defines the scene that will receive the animationGroup
  104447. * @returns a new AnimationGroup
  104448. */
  104449. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  104450. /**
  104451. * Returns the string "AnimationGroup"
  104452. * @returns "AnimationGroup"
  104453. */
  104454. getClassName(): string;
  104455. /**
  104456. * Creates a detailled string about the object
  104457. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  104458. * @returns a string representing the object
  104459. */
  104460. toString(fullDetails?: boolean): string;
  104461. }
  104462. }
  104463. declare module BABYLON {
  104464. /**
  104465. * Define an interface for all classes that will hold resources
  104466. */
  104467. export interface IDisposable {
  104468. /**
  104469. * Releases all held resources
  104470. */
  104471. dispose(): void;
  104472. }
  104473. /** Interface defining initialization parameters for Scene class */
  104474. export interface SceneOptions {
  104475. /**
  104476. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  104477. * It will improve performance when the number of geometries becomes important.
  104478. */
  104479. useGeometryUniqueIdsMap?: boolean;
  104480. /**
  104481. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  104482. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  104483. */
  104484. useMaterialMeshMap?: boolean;
  104485. /**
  104486. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  104487. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  104488. */
  104489. useClonedMeshhMap?: boolean;
  104490. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  104491. virtual?: boolean;
  104492. }
  104493. /**
  104494. * Represents a scene to be rendered by the engine.
  104495. * @see http://doc.babylonjs.com/features/scene
  104496. */
  104497. export class Scene extends AbstractScene implements IAnimatable {
  104498. /** The fog is deactivated */
  104499. static readonly FOGMODE_NONE: number;
  104500. /** The fog density is following an exponential function */
  104501. static readonly FOGMODE_EXP: number;
  104502. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  104503. static readonly FOGMODE_EXP2: number;
  104504. /** The fog density is following a linear function. */
  104505. static readonly FOGMODE_LINEAR: number;
  104506. /**
  104507. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  104508. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104509. */
  104510. static MinDeltaTime: number;
  104511. /**
  104512. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  104513. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104514. */
  104515. static MaxDeltaTime: number;
  104516. /**
  104517. * Factory used to create the default material.
  104518. * @param name The name of the material to create
  104519. * @param scene The scene to create the material for
  104520. * @returns The default material
  104521. */
  104522. static DefaultMaterialFactory(scene: Scene): Material;
  104523. /**
  104524. * Factory used to create the a collision coordinator.
  104525. * @returns The collision coordinator
  104526. */
  104527. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  104528. /** @hidden */
  104529. _inputManager: InputManager;
  104530. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  104531. cameraToUseForPointers: Nullable<Camera>;
  104532. /** @hidden */
  104533. readonly _isScene: boolean;
  104534. /**
  104535. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  104536. */
  104537. autoClear: boolean;
  104538. /**
  104539. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  104540. */
  104541. autoClearDepthAndStencil: boolean;
  104542. /**
  104543. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  104544. */
  104545. clearColor: Color4;
  104546. /**
  104547. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  104548. */
  104549. ambientColor: Color3;
  104550. /**
  104551. * This is use to store the default BRDF lookup for PBR materials in your scene.
  104552. * It should only be one of the following (if not the default embedded one):
  104553. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104554. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  104555. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104556. * The material properties need to be setup according to the type of texture in use.
  104557. */
  104558. environmentBRDFTexture: BaseTexture;
  104559. /** @hidden */
  104560. protected _environmentTexture: Nullable<BaseTexture>;
  104561. /**
  104562. * Texture used in all pbr material as the reflection texture.
  104563. * As in the majority of the scene they are the same (exception for multi room and so on),
  104564. * this is easier to reference from here than from all the materials.
  104565. */
  104566. /**
  104567. * Texture used in all pbr material as the reflection texture.
  104568. * As in the majority of the scene they are the same (exception for multi room and so on),
  104569. * this is easier to set here than in all the materials.
  104570. */
  104571. environmentTexture: Nullable<BaseTexture>;
  104572. /** @hidden */
  104573. protected _environmentIntensity: number;
  104574. /**
  104575. * Intensity of the environment in all pbr material.
  104576. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  104577. * As in the majority of the scene they are the same (exception for multi room and so on),
  104578. * this is easier to reference from here than from all the materials.
  104579. */
  104580. /**
  104581. * Intensity of the environment in all pbr material.
  104582. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  104583. * As in the majority of the scene they are the same (exception for multi room and so on),
  104584. * this is easier to set here than in all the materials.
  104585. */
  104586. environmentIntensity: number;
  104587. /** @hidden */
  104588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104589. /**
  104590. * Default image processing configuration used either in the rendering
  104591. * Forward main pass or through the imageProcessingPostProcess if present.
  104592. * As in the majority of the scene they are the same (exception for multi camera),
  104593. * this is easier to reference from here than from all the materials and post process.
  104594. *
  104595. * No setter as we it is a shared configuration, you can set the values instead.
  104596. */
  104597. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  104598. private _forceWireframe;
  104599. /**
  104600. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  104601. */
  104602. forceWireframe: boolean;
  104603. private _forcePointsCloud;
  104604. /**
  104605. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  104606. */
  104607. forcePointsCloud: boolean;
  104608. /**
  104609. * Gets or sets the active clipplane 1
  104610. */
  104611. clipPlane: Nullable<Plane>;
  104612. /**
  104613. * Gets or sets the active clipplane 2
  104614. */
  104615. clipPlane2: Nullable<Plane>;
  104616. /**
  104617. * Gets or sets the active clipplane 3
  104618. */
  104619. clipPlane3: Nullable<Plane>;
  104620. /**
  104621. * Gets or sets the active clipplane 4
  104622. */
  104623. clipPlane4: Nullable<Plane>;
  104624. /**
  104625. * Gets or sets a boolean indicating if animations are enabled
  104626. */
  104627. animationsEnabled: boolean;
  104628. private _animationPropertiesOverride;
  104629. /**
  104630. * Gets or sets the animation properties override
  104631. */
  104632. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  104633. /**
  104634. * Gets or sets a boolean indicating if a constant deltatime has to be used
  104635. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  104636. */
  104637. useConstantAnimationDeltaTime: boolean;
  104638. /**
  104639. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  104640. * Please note that it requires to run a ray cast through the scene on every frame
  104641. */
  104642. constantlyUpdateMeshUnderPointer: boolean;
  104643. /**
  104644. * Defines the HTML cursor to use when hovering over interactive elements
  104645. */
  104646. hoverCursor: string;
  104647. /**
  104648. * Defines the HTML default cursor to use (empty by default)
  104649. */
  104650. defaultCursor: string;
  104651. /**
  104652. * Defines wether cursors are handled by the scene.
  104653. */
  104654. doNotHandleCursors: boolean;
  104655. /**
  104656. * This is used to call preventDefault() on pointer down
  104657. * in order to block unwanted artifacts like system double clicks
  104658. */
  104659. preventDefaultOnPointerDown: boolean;
  104660. /**
  104661. * This is used to call preventDefault() on pointer up
  104662. * in order to block unwanted artifacts like system double clicks
  104663. */
  104664. preventDefaultOnPointerUp: boolean;
  104665. /**
  104666. * Gets or sets user defined metadata
  104667. */
  104668. metadata: any;
  104669. /**
  104670. * For internal use only. Please do not use.
  104671. */
  104672. reservedDataStore: any;
  104673. /**
  104674. * Gets the name of the plugin used to load this scene (null by default)
  104675. */
  104676. loadingPluginName: string;
  104677. /**
  104678. * Use this array to add regular expressions used to disable offline support for specific urls
  104679. */
  104680. disableOfflineSupportExceptionRules: RegExp[];
  104681. /**
  104682. * An event triggered when the scene is disposed.
  104683. */
  104684. onDisposeObservable: Observable<Scene>;
  104685. private _onDisposeObserver;
  104686. /** Sets a function to be executed when this scene is disposed. */
  104687. onDispose: () => void;
  104688. /**
  104689. * An event triggered before rendering the scene (right after animations and physics)
  104690. */
  104691. onBeforeRenderObservable: Observable<Scene>;
  104692. private _onBeforeRenderObserver;
  104693. /** Sets a function to be executed before rendering this scene */
  104694. beforeRender: Nullable<() => void>;
  104695. /**
  104696. * An event triggered after rendering the scene
  104697. */
  104698. onAfterRenderObservable: Observable<Scene>;
  104699. /**
  104700. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  104701. */
  104702. onAfterRenderCameraObservable: Observable<Camera>;
  104703. private _onAfterRenderObserver;
  104704. /** Sets a function to be executed after rendering this scene */
  104705. afterRender: Nullable<() => void>;
  104706. /**
  104707. * An event triggered before animating the scene
  104708. */
  104709. onBeforeAnimationsObservable: Observable<Scene>;
  104710. /**
  104711. * An event triggered after animations processing
  104712. */
  104713. onAfterAnimationsObservable: Observable<Scene>;
  104714. /**
  104715. * An event triggered before draw calls are ready to be sent
  104716. */
  104717. onBeforeDrawPhaseObservable: Observable<Scene>;
  104718. /**
  104719. * An event triggered after draw calls have been sent
  104720. */
  104721. onAfterDrawPhaseObservable: Observable<Scene>;
  104722. /**
  104723. * An event triggered when the scene is ready
  104724. */
  104725. onReadyObservable: Observable<Scene>;
  104726. /**
  104727. * An event triggered before rendering a camera
  104728. */
  104729. onBeforeCameraRenderObservable: Observable<Camera>;
  104730. private _onBeforeCameraRenderObserver;
  104731. /** Sets a function to be executed before rendering a camera*/
  104732. beforeCameraRender: () => void;
  104733. /**
  104734. * An event triggered after rendering a camera
  104735. */
  104736. onAfterCameraRenderObservable: Observable<Camera>;
  104737. private _onAfterCameraRenderObserver;
  104738. /** Sets a function to be executed after rendering a camera*/
  104739. afterCameraRender: () => void;
  104740. /**
  104741. * An event triggered when active meshes evaluation is about to start
  104742. */
  104743. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  104744. /**
  104745. * An event triggered when active meshes evaluation is done
  104746. */
  104747. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  104748. /**
  104749. * An event triggered when particles rendering is about to start
  104750. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104751. */
  104752. onBeforeParticlesRenderingObservable: Observable<Scene>;
  104753. /**
  104754. * An event triggered when particles rendering is done
  104755. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104756. */
  104757. onAfterParticlesRenderingObservable: Observable<Scene>;
  104758. /**
  104759. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  104760. */
  104761. onDataLoadedObservable: Observable<Scene>;
  104762. /**
  104763. * An event triggered when a camera is created
  104764. */
  104765. onNewCameraAddedObservable: Observable<Camera>;
  104766. /**
  104767. * An event triggered when a camera is removed
  104768. */
  104769. onCameraRemovedObservable: Observable<Camera>;
  104770. /**
  104771. * An event triggered when a light is created
  104772. */
  104773. onNewLightAddedObservable: Observable<Light>;
  104774. /**
  104775. * An event triggered when a light is removed
  104776. */
  104777. onLightRemovedObservable: Observable<Light>;
  104778. /**
  104779. * An event triggered when a geometry is created
  104780. */
  104781. onNewGeometryAddedObservable: Observable<Geometry>;
  104782. /**
  104783. * An event triggered when a geometry is removed
  104784. */
  104785. onGeometryRemovedObservable: Observable<Geometry>;
  104786. /**
  104787. * An event triggered when a transform node is created
  104788. */
  104789. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  104790. /**
  104791. * An event triggered when a transform node is removed
  104792. */
  104793. onTransformNodeRemovedObservable: Observable<TransformNode>;
  104794. /**
  104795. * An event triggered when a mesh is created
  104796. */
  104797. onNewMeshAddedObservable: Observable<AbstractMesh>;
  104798. /**
  104799. * An event triggered when a mesh is removed
  104800. */
  104801. onMeshRemovedObservable: Observable<AbstractMesh>;
  104802. /**
  104803. * An event triggered when a skeleton is created
  104804. */
  104805. onNewSkeletonAddedObservable: Observable<Skeleton>;
  104806. /**
  104807. * An event triggered when a skeleton is removed
  104808. */
  104809. onSkeletonRemovedObservable: Observable<Skeleton>;
  104810. /**
  104811. * An event triggered when a material is created
  104812. */
  104813. onNewMaterialAddedObservable: Observable<Material>;
  104814. /**
  104815. * An event triggered when a material is removed
  104816. */
  104817. onMaterialRemovedObservable: Observable<Material>;
  104818. /**
  104819. * An event triggered when a texture is created
  104820. */
  104821. onNewTextureAddedObservable: Observable<BaseTexture>;
  104822. /**
  104823. * An event triggered when a texture is removed
  104824. */
  104825. onTextureRemovedObservable: Observable<BaseTexture>;
  104826. /**
  104827. * An event triggered when render targets are about to be rendered
  104828. * Can happen multiple times per frame.
  104829. */
  104830. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  104831. /**
  104832. * An event triggered when render targets were rendered.
  104833. * Can happen multiple times per frame.
  104834. */
  104835. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  104836. /**
  104837. * An event triggered before calculating deterministic simulation step
  104838. */
  104839. onBeforeStepObservable: Observable<Scene>;
  104840. /**
  104841. * An event triggered after calculating deterministic simulation step
  104842. */
  104843. onAfterStepObservable: Observable<Scene>;
  104844. /**
  104845. * An event triggered when the activeCamera property is updated
  104846. */
  104847. onActiveCameraChanged: Observable<Scene>;
  104848. /**
  104849. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  104850. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104851. * 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)
  104852. */
  104853. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104854. /**
  104855. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  104856. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104857. * 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)
  104858. */
  104859. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104860. /**
  104861. * This Observable will when a mesh has been imported into the scene.
  104862. */
  104863. onMeshImportedObservable: Observable<AbstractMesh>;
  104864. /**
  104865. * This Observable will when an animation file has been imported into the scene.
  104866. */
  104867. onAnimationFileImportedObservable: Observable<Scene>;
  104868. /**
  104869. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  104870. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  104871. */
  104872. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  104873. /** @hidden */
  104874. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  104875. /**
  104876. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  104877. */
  104878. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  104879. /**
  104880. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  104881. */
  104882. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  104883. /**
  104884. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  104885. */
  104886. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  104887. /** Callback called when a pointer move is detected */
  104888. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104889. /** Callback called when a pointer down is detected */
  104890. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104891. /** Callback called when a pointer up is detected */
  104892. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  104893. /** Callback called when a pointer pick is detected */
  104894. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  104895. /**
  104896. * 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).
  104897. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  104898. */
  104899. onPrePointerObservable: Observable<PointerInfoPre>;
  104900. /**
  104901. * Observable event triggered each time an input event is received from the rendering canvas
  104902. */
  104903. onPointerObservable: Observable<PointerInfo>;
  104904. /**
  104905. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  104906. */
  104907. readonly unTranslatedPointer: Vector2;
  104908. /**
  104909. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  104910. */
  104911. static DragMovementThreshold: number;
  104912. /**
  104913. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  104914. */
  104915. static LongPressDelay: number;
  104916. /**
  104917. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  104918. */
  104919. static DoubleClickDelay: number;
  104920. /** If you need to check double click without raising a single click at first click, enable this flag */
  104921. static ExclusiveDoubleClickMode: boolean;
  104922. /** @hidden */
  104923. _mirroredCameraPosition: Nullable<Vector3>;
  104924. /**
  104925. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  104926. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  104927. */
  104928. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  104929. /**
  104930. * Observable event triggered each time an keyboard event is received from the hosting window
  104931. */
  104932. onKeyboardObservable: Observable<KeyboardInfo>;
  104933. private _useRightHandedSystem;
  104934. /**
  104935. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  104936. */
  104937. useRightHandedSystem: boolean;
  104938. private _timeAccumulator;
  104939. private _currentStepId;
  104940. private _currentInternalStep;
  104941. /**
  104942. * Sets the step Id used by deterministic lock step
  104943. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104944. * @param newStepId defines the step Id
  104945. */
  104946. setStepId(newStepId: number): void;
  104947. /**
  104948. * Gets the step Id used by deterministic lock step
  104949. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104950. * @returns the step Id
  104951. */
  104952. getStepId(): number;
  104953. /**
  104954. * Gets the internal step used by deterministic lock step
  104955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104956. * @returns the internal step
  104957. */
  104958. getInternalStep(): number;
  104959. private _fogEnabled;
  104960. /**
  104961. * Gets or sets a boolean indicating if fog is enabled on this scene
  104962. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104963. * (Default is true)
  104964. */
  104965. fogEnabled: boolean;
  104966. private _fogMode;
  104967. /**
  104968. * Gets or sets the fog mode to use
  104969. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104970. * | mode | value |
  104971. * | --- | --- |
  104972. * | FOGMODE_NONE | 0 |
  104973. * | FOGMODE_EXP | 1 |
  104974. * | FOGMODE_EXP2 | 2 |
  104975. * | FOGMODE_LINEAR | 3 |
  104976. */
  104977. fogMode: number;
  104978. /**
  104979. * Gets or sets the fog color to use
  104980. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104981. * (Default is Color3(0.2, 0.2, 0.3))
  104982. */
  104983. fogColor: Color3;
  104984. /**
  104985. * Gets or sets the fog density to use
  104986. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104987. * (Default is 0.1)
  104988. */
  104989. fogDensity: number;
  104990. /**
  104991. * Gets or sets the fog start distance to use
  104992. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104993. * (Default is 0)
  104994. */
  104995. fogStart: number;
  104996. /**
  104997. * Gets or sets the fog end distance to use
  104998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104999. * (Default is 1000)
  105000. */
  105001. fogEnd: number;
  105002. private _shadowsEnabled;
  105003. /**
  105004. * Gets or sets a boolean indicating if shadows are enabled on this scene
  105005. */
  105006. shadowsEnabled: boolean;
  105007. private _lightsEnabled;
  105008. /**
  105009. * Gets or sets a boolean indicating if lights are enabled on this scene
  105010. */
  105011. lightsEnabled: boolean;
  105012. /** All of the active cameras added to this scene. */
  105013. activeCameras: Camera[];
  105014. /** @hidden */
  105015. _activeCamera: Nullable<Camera>;
  105016. /** Gets or sets the current active camera */
  105017. activeCamera: Nullable<Camera>;
  105018. private _defaultMaterial;
  105019. /** The default material used on meshes when no material is affected */
  105020. /** The default material used on meshes when no material is affected */
  105021. defaultMaterial: Material;
  105022. private _texturesEnabled;
  105023. /**
  105024. * Gets or sets a boolean indicating if textures are enabled on this scene
  105025. */
  105026. texturesEnabled: boolean;
  105027. /**
  105028. * Gets or sets a boolean indicating if particles are enabled on this scene
  105029. */
  105030. particlesEnabled: boolean;
  105031. /**
  105032. * Gets or sets a boolean indicating if sprites are enabled on this scene
  105033. */
  105034. spritesEnabled: boolean;
  105035. private _skeletonsEnabled;
  105036. /**
  105037. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  105038. */
  105039. skeletonsEnabled: boolean;
  105040. /**
  105041. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  105042. */
  105043. lensFlaresEnabled: boolean;
  105044. /**
  105045. * Gets or sets a boolean indicating if collisions are enabled on this scene
  105046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105047. */
  105048. collisionsEnabled: boolean;
  105049. private _collisionCoordinator;
  105050. /** @hidden */
  105051. readonly collisionCoordinator: ICollisionCoordinator;
  105052. /**
  105053. * Defines the gravity applied to this scene (used only for collisions)
  105054. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105055. */
  105056. gravity: Vector3;
  105057. /**
  105058. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  105059. */
  105060. postProcessesEnabled: boolean;
  105061. /**
  105062. * The list of postprocesses added to the scene
  105063. */
  105064. postProcesses: PostProcess[];
  105065. /**
  105066. * Gets the current postprocess manager
  105067. */
  105068. postProcessManager: PostProcessManager;
  105069. /**
  105070. * Gets or sets a boolean indicating if render targets are enabled on this scene
  105071. */
  105072. renderTargetsEnabled: boolean;
  105073. /**
  105074. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  105075. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  105076. */
  105077. dumpNextRenderTargets: boolean;
  105078. /**
  105079. * The list of user defined render targets added to the scene
  105080. */
  105081. customRenderTargets: RenderTargetTexture[];
  105082. /**
  105083. * Defines if texture loading must be delayed
  105084. * If true, textures will only be loaded when they need to be rendered
  105085. */
  105086. useDelayedTextureLoading: boolean;
  105087. /**
  105088. * Gets the list of meshes imported to the scene through SceneLoader
  105089. */
  105090. importedMeshesFiles: String[];
  105091. /**
  105092. * Gets or sets a boolean indicating if probes are enabled on this scene
  105093. */
  105094. probesEnabled: boolean;
  105095. /**
  105096. * Gets or sets the current offline provider to use to store scene data
  105097. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105098. */
  105099. offlineProvider: IOfflineProvider;
  105100. /**
  105101. * Gets or sets the action manager associated with the scene
  105102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105103. */
  105104. actionManager: AbstractActionManager;
  105105. private _meshesForIntersections;
  105106. /**
  105107. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  105108. */
  105109. proceduralTexturesEnabled: boolean;
  105110. private _engine;
  105111. private _totalVertices;
  105112. /** @hidden */
  105113. _activeIndices: PerfCounter;
  105114. /** @hidden */
  105115. _activeParticles: PerfCounter;
  105116. /** @hidden */
  105117. _activeBones: PerfCounter;
  105118. private _animationRatio;
  105119. /** @hidden */
  105120. _animationTimeLast: number;
  105121. /** @hidden */
  105122. _animationTime: number;
  105123. /**
  105124. * Gets or sets a general scale for animation speed
  105125. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  105126. */
  105127. animationTimeScale: number;
  105128. /** @hidden */
  105129. _cachedMaterial: Nullable<Material>;
  105130. /** @hidden */
  105131. _cachedEffect: Nullable<Effect>;
  105132. /** @hidden */
  105133. _cachedVisibility: Nullable<number>;
  105134. private _renderId;
  105135. private _frameId;
  105136. private _executeWhenReadyTimeoutId;
  105137. private _intermediateRendering;
  105138. private _viewUpdateFlag;
  105139. private _projectionUpdateFlag;
  105140. /** @hidden */
  105141. _toBeDisposed: Nullable<IDisposable>[];
  105142. private _activeRequests;
  105143. /** @hidden */
  105144. _pendingData: any[];
  105145. private _isDisposed;
  105146. /**
  105147. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  105148. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  105149. */
  105150. dispatchAllSubMeshesOfActiveMeshes: boolean;
  105151. private _activeMeshes;
  105152. private _processedMaterials;
  105153. private _renderTargets;
  105154. /** @hidden */
  105155. _activeParticleSystems: SmartArray<IParticleSystem>;
  105156. private _activeSkeletons;
  105157. private _softwareSkinnedMeshes;
  105158. private _renderingManager;
  105159. /** @hidden */
  105160. _activeAnimatables: Animatable[];
  105161. private _transformMatrix;
  105162. private _sceneUbo;
  105163. /** @hidden */
  105164. _viewMatrix: Matrix;
  105165. private _projectionMatrix;
  105166. /** @hidden */
  105167. _forcedViewPosition: Nullable<Vector3>;
  105168. /** @hidden */
  105169. _frustumPlanes: Plane[];
  105170. /**
  105171. * Gets the list of frustum planes (built from the active camera)
  105172. */
  105173. readonly frustumPlanes: Plane[];
  105174. /**
  105175. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  105176. * This is useful if there are more lights that the maximum simulteanous authorized
  105177. */
  105178. requireLightSorting: boolean;
  105179. /** @hidden */
  105180. readonly useMaterialMeshMap: boolean;
  105181. /** @hidden */
  105182. readonly useClonedMeshhMap: boolean;
  105183. private _externalData;
  105184. private _uid;
  105185. /**
  105186. * @hidden
  105187. * Backing store of defined scene components.
  105188. */
  105189. _components: ISceneComponent[];
  105190. /**
  105191. * @hidden
  105192. * Backing store of defined scene components.
  105193. */
  105194. _serializableComponents: ISceneSerializableComponent[];
  105195. /**
  105196. * List of components to register on the next registration step.
  105197. */
  105198. private _transientComponents;
  105199. /**
  105200. * Registers the transient components if needed.
  105201. */
  105202. private _registerTransientComponents;
  105203. /**
  105204. * @hidden
  105205. * Add a component to the scene.
  105206. * Note that the ccomponent could be registered on th next frame if this is called after
  105207. * the register component stage.
  105208. * @param component Defines the component to add to the scene
  105209. */
  105210. _addComponent(component: ISceneComponent): void;
  105211. /**
  105212. * @hidden
  105213. * Gets a component from the scene.
  105214. * @param name defines the name of the component to retrieve
  105215. * @returns the component or null if not present
  105216. */
  105217. _getComponent(name: string): Nullable<ISceneComponent>;
  105218. /**
  105219. * @hidden
  105220. * Defines the actions happening before camera updates.
  105221. */
  105222. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  105223. /**
  105224. * @hidden
  105225. * Defines the actions happening before clear the canvas.
  105226. */
  105227. _beforeClearStage: Stage<SimpleStageAction>;
  105228. /**
  105229. * @hidden
  105230. * Defines the actions when collecting render targets for the frame.
  105231. */
  105232. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  105233. /**
  105234. * @hidden
  105235. * Defines the actions happening for one camera in the frame.
  105236. */
  105237. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  105238. /**
  105239. * @hidden
  105240. * Defines the actions happening during the per mesh ready checks.
  105241. */
  105242. _isReadyForMeshStage: Stage<MeshStageAction>;
  105243. /**
  105244. * @hidden
  105245. * Defines the actions happening before evaluate active mesh checks.
  105246. */
  105247. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  105248. /**
  105249. * @hidden
  105250. * Defines the actions happening during the evaluate sub mesh checks.
  105251. */
  105252. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  105253. /**
  105254. * @hidden
  105255. * Defines the actions happening during the active mesh stage.
  105256. */
  105257. _activeMeshStage: Stage<ActiveMeshStageAction>;
  105258. /**
  105259. * @hidden
  105260. * Defines the actions happening during the per camera render target step.
  105261. */
  105262. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  105263. /**
  105264. * @hidden
  105265. * Defines the actions happening just before the active camera is drawing.
  105266. */
  105267. _beforeCameraDrawStage: Stage<CameraStageAction>;
  105268. /**
  105269. * @hidden
  105270. * Defines the actions happening just before a render target is drawing.
  105271. */
  105272. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  105273. /**
  105274. * @hidden
  105275. * Defines the actions happening just before a rendering group is drawing.
  105276. */
  105277. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  105278. /**
  105279. * @hidden
  105280. * Defines the actions happening just before a mesh is drawing.
  105281. */
  105282. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  105283. /**
  105284. * @hidden
  105285. * Defines the actions happening just after a mesh has been drawn.
  105286. */
  105287. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  105288. /**
  105289. * @hidden
  105290. * Defines the actions happening just after a rendering group has been drawn.
  105291. */
  105292. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  105293. /**
  105294. * @hidden
  105295. * Defines the actions happening just after the active camera has been drawn.
  105296. */
  105297. _afterCameraDrawStage: Stage<CameraStageAction>;
  105298. /**
  105299. * @hidden
  105300. * Defines the actions happening just after a render target has been drawn.
  105301. */
  105302. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  105303. /**
  105304. * @hidden
  105305. * Defines the actions happening just after rendering all cameras and computing intersections.
  105306. */
  105307. _afterRenderStage: Stage<SimpleStageAction>;
  105308. /**
  105309. * @hidden
  105310. * Defines the actions happening when a pointer move event happens.
  105311. */
  105312. _pointerMoveStage: Stage<PointerMoveStageAction>;
  105313. /**
  105314. * @hidden
  105315. * Defines the actions happening when a pointer down event happens.
  105316. */
  105317. _pointerDownStage: Stage<PointerUpDownStageAction>;
  105318. /**
  105319. * @hidden
  105320. * Defines the actions happening when a pointer up event happens.
  105321. */
  105322. _pointerUpStage: Stage<PointerUpDownStageAction>;
  105323. /**
  105324. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  105325. */
  105326. private geometriesByUniqueId;
  105327. /**
  105328. * Creates a new Scene
  105329. * @param engine defines the engine to use to render this scene
  105330. * @param options defines the scene options
  105331. */
  105332. constructor(engine: Engine, options?: SceneOptions);
  105333. /**
  105334. * Gets a string idenfifying the name of the class
  105335. * @returns "Scene" string
  105336. */
  105337. getClassName(): string;
  105338. private _defaultMeshCandidates;
  105339. /**
  105340. * @hidden
  105341. */
  105342. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105343. private _defaultSubMeshCandidates;
  105344. /**
  105345. * @hidden
  105346. */
  105347. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105348. /**
  105349. * Sets the default candidate providers for the scene.
  105350. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  105351. * and getCollidingSubMeshCandidates to their default function
  105352. */
  105353. setDefaultCandidateProviders(): void;
  105354. /**
  105355. * Gets the mesh that is currently under the pointer
  105356. */
  105357. readonly meshUnderPointer: Nullable<AbstractMesh>;
  105358. /**
  105359. * Gets or sets the current on-screen X position of the pointer
  105360. */
  105361. pointerX: number;
  105362. /**
  105363. * Gets or sets the current on-screen Y position of the pointer
  105364. */
  105365. pointerY: number;
  105366. /**
  105367. * Gets the cached material (ie. the latest rendered one)
  105368. * @returns the cached material
  105369. */
  105370. getCachedMaterial(): Nullable<Material>;
  105371. /**
  105372. * Gets the cached effect (ie. the latest rendered one)
  105373. * @returns the cached effect
  105374. */
  105375. getCachedEffect(): Nullable<Effect>;
  105376. /**
  105377. * Gets the cached visibility state (ie. the latest rendered one)
  105378. * @returns the cached visibility state
  105379. */
  105380. getCachedVisibility(): Nullable<number>;
  105381. /**
  105382. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  105383. * @param material defines the current material
  105384. * @param effect defines the current effect
  105385. * @param visibility defines the current visibility state
  105386. * @returns true if one parameter is not cached
  105387. */
  105388. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  105389. /**
  105390. * Gets the engine associated with the scene
  105391. * @returns an Engine
  105392. */
  105393. getEngine(): Engine;
  105394. /**
  105395. * Gets the total number of vertices rendered per frame
  105396. * @returns the total number of vertices rendered per frame
  105397. */
  105398. getTotalVertices(): number;
  105399. /**
  105400. * Gets the performance counter for total vertices
  105401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  105402. */
  105403. readonly totalVerticesPerfCounter: PerfCounter;
  105404. /**
  105405. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  105406. * @returns the total number of active indices rendered per frame
  105407. */
  105408. getActiveIndices(): number;
  105409. /**
  105410. * Gets the performance counter for active indices
  105411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  105412. */
  105413. readonly totalActiveIndicesPerfCounter: PerfCounter;
  105414. /**
  105415. * Gets the total number of active particles rendered per frame
  105416. * @returns the total number of active particles rendered per frame
  105417. */
  105418. getActiveParticles(): number;
  105419. /**
  105420. * Gets the performance counter for active particles
  105421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  105422. */
  105423. readonly activeParticlesPerfCounter: PerfCounter;
  105424. /**
  105425. * Gets the total number of active bones rendered per frame
  105426. * @returns the total number of active bones rendered per frame
  105427. */
  105428. getActiveBones(): number;
  105429. /**
  105430. * Gets the performance counter for active bones
  105431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  105432. */
  105433. readonly activeBonesPerfCounter: PerfCounter;
  105434. /**
  105435. * Gets the array of active meshes
  105436. * @returns an array of AbstractMesh
  105437. */
  105438. getActiveMeshes(): SmartArray<AbstractMesh>;
  105439. /**
  105440. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  105441. * @returns a number
  105442. */
  105443. getAnimationRatio(): number;
  105444. /**
  105445. * Gets an unique Id for the current render phase
  105446. * @returns a number
  105447. */
  105448. getRenderId(): number;
  105449. /**
  105450. * Gets an unique Id for the current frame
  105451. * @returns a number
  105452. */
  105453. getFrameId(): number;
  105454. /** Call this function if you want to manually increment the render Id*/
  105455. incrementRenderId(): void;
  105456. private _createUbo;
  105457. /**
  105458. * Use this method to simulate a pointer move on a mesh
  105459. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105460. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105461. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105462. * @returns the current scene
  105463. */
  105464. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  105465. /**
  105466. * Use this method to simulate a pointer down on a mesh
  105467. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105468. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105469. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105470. * @returns the current scene
  105471. */
  105472. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  105473. /**
  105474. * Use this method to simulate a pointer up on a mesh
  105475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105478. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105479. * @returns the current scene
  105480. */
  105481. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  105482. /**
  105483. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105484. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105485. * @returns true if the pointer was captured
  105486. */
  105487. isPointerCaptured(pointerId?: number): boolean;
  105488. /**
  105489. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105490. * @param attachUp defines if you want to attach events to pointerup
  105491. * @param attachDown defines if you want to attach events to pointerdown
  105492. * @param attachMove defines if you want to attach events to pointermove
  105493. */
  105494. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105495. /** Detaches all event handlers*/
  105496. detachControl(): void;
  105497. /**
  105498. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  105499. * Delay loaded resources are not taking in account
  105500. * @return true if all required resources are ready
  105501. */
  105502. isReady(): boolean;
  105503. /** Resets all cached information relative to material (including effect and visibility) */
  105504. resetCachedMaterial(): void;
  105505. /**
  105506. * Registers a function to be called before every frame render
  105507. * @param func defines the function to register
  105508. */
  105509. registerBeforeRender(func: () => void): void;
  105510. /**
  105511. * Unregisters a function called before every frame render
  105512. * @param func defines the function to unregister
  105513. */
  105514. unregisterBeforeRender(func: () => void): void;
  105515. /**
  105516. * Registers a function to be called after every frame render
  105517. * @param func defines the function to register
  105518. */
  105519. registerAfterRender(func: () => void): void;
  105520. /**
  105521. * Unregisters a function called after every frame render
  105522. * @param func defines the function to unregister
  105523. */
  105524. unregisterAfterRender(func: () => void): void;
  105525. private _executeOnceBeforeRender;
  105526. /**
  105527. * The provided function will run before render once and will be disposed afterwards.
  105528. * A timeout delay can be provided so that the function will be executed in N ms.
  105529. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  105530. * @param func The function to be executed.
  105531. * @param timeout optional delay in ms
  105532. */
  105533. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  105534. /** @hidden */
  105535. _addPendingData(data: any): void;
  105536. /** @hidden */
  105537. _removePendingData(data: any): void;
  105538. /**
  105539. * Returns the number of items waiting to be loaded
  105540. * @returns the number of items waiting to be loaded
  105541. */
  105542. getWaitingItemsCount(): number;
  105543. /**
  105544. * Returns a boolean indicating if the scene is still loading data
  105545. */
  105546. readonly isLoading: boolean;
  105547. /**
  105548. * Registers a function to be executed when the scene is ready
  105549. * @param {Function} func - the function to be executed
  105550. */
  105551. executeWhenReady(func: () => void): void;
  105552. /**
  105553. * Returns a promise that resolves when the scene is ready
  105554. * @returns A promise that resolves when the scene is ready
  105555. */
  105556. whenReadyAsync(): Promise<void>;
  105557. /** @hidden */
  105558. _checkIsReady(): void;
  105559. /**
  105560. * Gets all animatable attached to the scene
  105561. */
  105562. readonly animatables: Animatable[];
  105563. /**
  105564. * Resets the last animation time frame.
  105565. * Useful to override when animations start running when loading a scene for the first time.
  105566. */
  105567. resetLastAnimationTimeFrame(): void;
  105568. /**
  105569. * Gets the current view matrix
  105570. * @returns a Matrix
  105571. */
  105572. getViewMatrix(): Matrix;
  105573. /**
  105574. * Gets the current projection matrix
  105575. * @returns a Matrix
  105576. */
  105577. getProjectionMatrix(): Matrix;
  105578. /**
  105579. * Gets the current transform matrix
  105580. * @returns a Matrix made of View * Projection
  105581. */
  105582. getTransformMatrix(): Matrix;
  105583. /**
  105584. * Sets the current transform matrix
  105585. * @param viewL defines the View matrix to use
  105586. * @param projectionL defines the Projection matrix to use
  105587. * @param viewR defines the right View matrix to use (if provided)
  105588. * @param projectionR defines the right Projection matrix to use (if provided)
  105589. */
  105590. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  105591. /**
  105592. * Gets the uniform buffer used to store scene data
  105593. * @returns a UniformBuffer
  105594. */
  105595. getSceneUniformBuffer(): UniformBuffer;
  105596. /**
  105597. * Gets an unique (relatively to the current scene) Id
  105598. * @returns an unique number for the scene
  105599. */
  105600. getUniqueId(): number;
  105601. /**
  105602. * Add a mesh to the list of scene's meshes
  105603. * @param newMesh defines the mesh to add
  105604. * @param recursive if all child meshes should also be added to the scene
  105605. */
  105606. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  105607. /**
  105608. * Remove a mesh for the list of scene's meshes
  105609. * @param toRemove defines the mesh to remove
  105610. * @param recursive if all child meshes should also be removed from the scene
  105611. * @returns the index where the mesh was in the mesh list
  105612. */
  105613. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  105614. /**
  105615. * Add a transform node to the list of scene's transform nodes
  105616. * @param newTransformNode defines the transform node to add
  105617. */
  105618. addTransformNode(newTransformNode: TransformNode): void;
  105619. /**
  105620. * Remove a transform node for the list of scene's transform nodes
  105621. * @param toRemove defines the transform node to remove
  105622. * @returns the index where the transform node was in the transform node list
  105623. */
  105624. removeTransformNode(toRemove: TransformNode): number;
  105625. /**
  105626. * Remove a skeleton for the list of scene's skeletons
  105627. * @param toRemove defines the skeleton to remove
  105628. * @returns the index where the skeleton was in the skeleton list
  105629. */
  105630. removeSkeleton(toRemove: Skeleton): number;
  105631. /**
  105632. * Remove a morph target for the list of scene's morph targets
  105633. * @param toRemove defines the morph target to remove
  105634. * @returns the index where the morph target was in the morph target list
  105635. */
  105636. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  105637. /**
  105638. * Remove a light for the list of scene's lights
  105639. * @param toRemove defines the light to remove
  105640. * @returns the index where the light was in the light list
  105641. */
  105642. removeLight(toRemove: Light): number;
  105643. /**
  105644. * Remove a camera for the list of scene's cameras
  105645. * @param toRemove defines the camera to remove
  105646. * @returns the index where the camera was in the camera list
  105647. */
  105648. removeCamera(toRemove: Camera): number;
  105649. /**
  105650. * Remove a particle system for the list of scene's particle systems
  105651. * @param toRemove defines the particle system to remove
  105652. * @returns the index where the particle system was in the particle system list
  105653. */
  105654. removeParticleSystem(toRemove: IParticleSystem): number;
  105655. /**
  105656. * Remove a animation for the list of scene's animations
  105657. * @param toRemove defines the animation to remove
  105658. * @returns the index where the animation was in the animation list
  105659. */
  105660. removeAnimation(toRemove: Animation): number;
  105661. /**
  105662. * Will stop the animation of the given target
  105663. * @param target - the target
  105664. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  105665. * @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)
  105666. */
  105667. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  105668. /**
  105669. * Removes the given animation group from this scene.
  105670. * @param toRemove The animation group to remove
  105671. * @returns The index of the removed animation group
  105672. */
  105673. removeAnimationGroup(toRemove: AnimationGroup): number;
  105674. /**
  105675. * Removes the given multi-material from this scene.
  105676. * @param toRemove The multi-material to remove
  105677. * @returns The index of the removed multi-material
  105678. */
  105679. removeMultiMaterial(toRemove: MultiMaterial): number;
  105680. /**
  105681. * Removes the given material from this scene.
  105682. * @param toRemove The material to remove
  105683. * @returns The index of the removed material
  105684. */
  105685. removeMaterial(toRemove: Material): number;
  105686. /**
  105687. * Removes the given action manager from this scene.
  105688. * @param toRemove The action manager to remove
  105689. * @returns The index of the removed action manager
  105690. */
  105691. removeActionManager(toRemove: AbstractActionManager): number;
  105692. /**
  105693. * Removes the given texture from this scene.
  105694. * @param toRemove The texture to remove
  105695. * @returns The index of the removed texture
  105696. */
  105697. removeTexture(toRemove: BaseTexture): number;
  105698. /**
  105699. * Adds the given light to this scene
  105700. * @param newLight The light to add
  105701. */
  105702. addLight(newLight: Light): void;
  105703. /**
  105704. * Sorts the list list based on light priorities
  105705. */
  105706. sortLightsByPriority(): void;
  105707. /**
  105708. * Adds the given camera to this scene
  105709. * @param newCamera The camera to add
  105710. */
  105711. addCamera(newCamera: Camera): void;
  105712. /**
  105713. * Adds the given skeleton to this scene
  105714. * @param newSkeleton The skeleton to add
  105715. */
  105716. addSkeleton(newSkeleton: Skeleton): void;
  105717. /**
  105718. * Adds the given particle system to this scene
  105719. * @param newParticleSystem The particle system to add
  105720. */
  105721. addParticleSystem(newParticleSystem: IParticleSystem): void;
  105722. /**
  105723. * Adds the given animation to this scene
  105724. * @param newAnimation The animation to add
  105725. */
  105726. addAnimation(newAnimation: Animation): void;
  105727. /**
  105728. * Adds the given animation group to this scene.
  105729. * @param newAnimationGroup The animation group to add
  105730. */
  105731. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  105732. /**
  105733. * Adds the given multi-material to this scene
  105734. * @param newMultiMaterial The multi-material to add
  105735. */
  105736. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  105737. /**
  105738. * Adds the given material to this scene
  105739. * @param newMaterial The material to add
  105740. */
  105741. addMaterial(newMaterial: Material): void;
  105742. /**
  105743. * Adds the given morph target to this scene
  105744. * @param newMorphTargetManager The morph target to add
  105745. */
  105746. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  105747. /**
  105748. * Adds the given geometry to this scene
  105749. * @param newGeometry The geometry to add
  105750. */
  105751. addGeometry(newGeometry: Geometry): void;
  105752. /**
  105753. * Adds the given action manager to this scene
  105754. * @param newActionManager The action manager to add
  105755. */
  105756. addActionManager(newActionManager: AbstractActionManager): void;
  105757. /**
  105758. * Adds the given texture to this scene.
  105759. * @param newTexture The texture to add
  105760. */
  105761. addTexture(newTexture: BaseTexture): void;
  105762. /**
  105763. * Switch active camera
  105764. * @param newCamera defines the new active camera
  105765. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  105766. */
  105767. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  105768. /**
  105769. * sets the active camera of the scene using its ID
  105770. * @param id defines the camera's ID
  105771. * @return the new active camera or null if none found.
  105772. */
  105773. setActiveCameraByID(id: string): Nullable<Camera>;
  105774. /**
  105775. * sets the active camera of the scene using its name
  105776. * @param name defines the camera's name
  105777. * @returns the new active camera or null if none found.
  105778. */
  105779. setActiveCameraByName(name: string): Nullable<Camera>;
  105780. /**
  105781. * get an animation group using its name
  105782. * @param name defines the material's name
  105783. * @return the animation group or null if none found.
  105784. */
  105785. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  105786. /**
  105787. * Get a material using its unique id
  105788. * @param uniqueId defines the material's unique id
  105789. * @return the material or null if none found.
  105790. */
  105791. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  105792. /**
  105793. * get a material using its id
  105794. * @param id defines the material's ID
  105795. * @return the material or null if none found.
  105796. */
  105797. getMaterialByID(id: string): Nullable<Material>;
  105798. /**
  105799. * Gets a the last added material using a given id
  105800. * @param id defines the material's ID
  105801. * @return the last material with the given id or null if none found.
  105802. */
  105803. getLastMaterialByID(id: string): Nullable<Material>;
  105804. /**
  105805. * Gets a material using its name
  105806. * @param name defines the material's name
  105807. * @return the material or null if none found.
  105808. */
  105809. getMaterialByName(name: string): Nullable<Material>;
  105810. /**
  105811. * Get a texture using its unique id
  105812. * @param uniqueId defines the texture's unique id
  105813. * @return the texture or null if none found.
  105814. */
  105815. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  105816. /**
  105817. * Gets a camera using its id
  105818. * @param id defines the id to look for
  105819. * @returns the camera or null if not found
  105820. */
  105821. getCameraByID(id: string): Nullable<Camera>;
  105822. /**
  105823. * Gets a camera using its unique id
  105824. * @param uniqueId defines the unique id to look for
  105825. * @returns the camera or null if not found
  105826. */
  105827. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  105828. /**
  105829. * Gets a camera using its name
  105830. * @param name defines the camera's name
  105831. * @return the camera or null if none found.
  105832. */
  105833. getCameraByName(name: string): Nullable<Camera>;
  105834. /**
  105835. * Gets a bone using its id
  105836. * @param id defines the bone's id
  105837. * @return the bone or null if not found
  105838. */
  105839. getBoneByID(id: string): Nullable<Bone>;
  105840. /**
  105841. * Gets a bone using its id
  105842. * @param name defines the bone's name
  105843. * @return the bone or null if not found
  105844. */
  105845. getBoneByName(name: string): Nullable<Bone>;
  105846. /**
  105847. * Gets a light node using its name
  105848. * @param name defines the the light's name
  105849. * @return the light or null if none found.
  105850. */
  105851. getLightByName(name: string): Nullable<Light>;
  105852. /**
  105853. * Gets a light node using its id
  105854. * @param id defines the light's id
  105855. * @return the light or null if none found.
  105856. */
  105857. getLightByID(id: string): Nullable<Light>;
  105858. /**
  105859. * Gets a light node using its scene-generated unique ID
  105860. * @param uniqueId defines the light's unique id
  105861. * @return the light or null if none found.
  105862. */
  105863. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  105864. /**
  105865. * Gets a particle system by id
  105866. * @param id defines the particle system id
  105867. * @return the corresponding system or null if none found
  105868. */
  105869. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  105870. /**
  105871. * Gets a geometry using its ID
  105872. * @param id defines the geometry's id
  105873. * @return the geometry or null if none found.
  105874. */
  105875. getGeometryByID(id: string): Nullable<Geometry>;
  105876. private _getGeometryByUniqueID;
  105877. /**
  105878. * Add a new geometry to this scene
  105879. * @param geometry defines the geometry to be added to the scene.
  105880. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  105881. * @return a boolean defining if the geometry was added or not
  105882. */
  105883. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  105884. /**
  105885. * Removes an existing geometry
  105886. * @param geometry defines the geometry to be removed from the scene
  105887. * @return a boolean defining if the geometry was removed or not
  105888. */
  105889. removeGeometry(geometry: Geometry): boolean;
  105890. /**
  105891. * Gets the list of geometries attached to the scene
  105892. * @returns an array of Geometry
  105893. */
  105894. getGeometries(): Geometry[];
  105895. /**
  105896. * Gets the first added mesh found of a given ID
  105897. * @param id defines the id to search for
  105898. * @return the mesh found or null if not found at all
  105899. */
  105900. getMeshByID(id: string): Nullable<AbstractMesh>;
  105901. /**
  105902. * Gets a list of meshes using their id
  105903. * @param id defines the id to search for
  105904. * @returns a list of meshes
  105905. */
  105906. getMeshesByID(id: string): Array<AbstractMesh>;
  105907. /**
  105908. * Gets the first added transform node found of a given ID
  105909. * @param id defines the id to search for
  105910. * @return the found transform node or null if not found at all.
  105911. */
  105912. getTransformNodeByID(id: string): Nullable<TransformNode>;
  105913. /**
  105914. * Gets a transform node with its auto-generated unique id
  105915. * @param uniqueId efines the unique id to search for
  105916. * @return the found transform node or null if not found at all.
  105917. */
  105918. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  105919. /**
  105920. * Gets a list of transform nodes using their id
  105921. * @param id defines the id to search for
  105922. * @returns a list of transform nodes
  105923. */
  105924. getTransformNodesByID(id: string): Array<TransformNode>;
  105925. /**
  105926. * Gets a mesh with its auto-generated unique id
  105927. * @param uniqueId defines the unique id to search for
  105928. * @return the found mesh or null if not found at all.
  105929. */
  105930. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  105931. /**
  105932. * Gets a the last added mesh using a given id
  105933. * @param id defines the id to search for
  105934. * @return the found mesh or null if not found at all.
  105935. */
  105936. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  105937. /**
  105938. * Gets a the last added node (Mesh, Camera, Light) using a given id
  105939. * @param id defines the id to search for
  105940. * @return the found node or null if not found at all
  105941. */
  105942. getLastEntryByID(id: string): Nullable<Node>;
  105943. /**
  105944. * Gets a node (Mesh, Camera, Light) using a given id
  105945. * @param id defines the id to search for
  105946. * @return the found node or null if not found at all
  105947. */
  105948. getNodeByID(id: string): Nullable<Node>;
  105949. /**
  105950. * Gets a node (Mesh, Camera, Light) using a given name
  105951. * @param name defines the name to search for
  105952. * @return the found node or null if not found at all.
  105953. */
  105954. getNodeByName(name: string): Nullable<Node>;
  105955. /**
  105956. * Gets a mesh using a given name
  105957. * @param name defines the name to search for
  105958. * @return the found mesh or null if not found at all.
  105959. */
  105960. getMeshByName(name: string): Nullable<AbstractMesh>;
  105961. /**
  105962. * Gets a transform node using a given name
  105963. * @param name defines the name to search for
  105964. * @return the found transform node or null if not found at all.
  105965. */
  105966. getTransformNodeByName(name: string): Nullable<TransformNode>;
  105967. /**
  105968. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  105969. * @param id defines the id to search for
  105970. * @return the found skeleton or null if not found at all.
  105971. */
  105972. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  105973. /**
  105974. * Gets a skeleton using a given auto generated unique id
  105975. * @param uniqueId defines the unique id to search for
  105976. * @return the found skeleton or null if not found at all.
  105977. */
  105978. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  105979. /**
  105980. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  105981. * @param id defines the id to search for
  105982. * @return the found skeleton or null if not found at all.
  105983. */
  105984. getSkeletonById(id: string): Nullable<Skeleton>;
  105985. /**
  105986. * Gets a skeleton using a given name
  105987. * @param name defines the name to search for
  105988. * @return the found skeleton or null if not found at all.
  105989. */
  105990. getSkeletonByName(name: string): Nullable<Skeleton>;
  105991. /**
  105992. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  105993. * @param id defines the id to search for
  105994. * @return the found morph target manager or null if not found at all.
  105995. */
  105996. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  105997. /**
  105998. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  105999. * @param id defines the id to search for
  106000. * @return the found morph target or null if not found at all.
  106001. */
  106002. getMorphTargetById(id: string): Nullable<MorphTarget>;
  106003. /**
  106004. * Gets a boolean indicating if the given mesh is active
  106005. * @param mesh defines the mesh to look for
  106006. * @returns true if the mesh is in the active list
  106007. */
  106008. isActiveMesh(mesh: AbstractMesh): boolean;
  106009. /**
  106010. * Return a unique id as a string which can serve as an identifier for the scene
  106011. */
  106012. readonly uid: string;
  106013. /**
  106014. * Add an externaly attached data from its key.
  106015. * This method call will fail and return false, if such key already exists.
  106016. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  106017. * @param key the unique key that identifies the data
  106018. * @param data the data object to associate to the key for this Engine instance
  106019. * @return true if no such key were already present and the data was added successfully, false otherwise
  106020. */
  106021. addExternalData<T>(key: string, data: T): boolean;
  106022. /**
  106023. * Get an externaly attached data from its key
  106024. * @param key the unique key that identifies the data
  106025. * @return the associated data, if present (can be null), or undefined if not present
  106026. */
  106027. getExternalData<T>(key: string): Nullable<T>;
  106028. /**
  106029. * Get an externaly attached data from its key, create it using a factory if it's not already present
  106030. * @param key the unique key that identifies the data
  106031. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  106032. * @return the associated data, can be null if the factory returned null.
  106033. */
  106034. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  106035. /**
  106036. * Remove an externaly attached data from the Engine instance
  106037. * @param key the unique key that identifies the data
  106038. * @return true if the data was successfully removed, false if it doesn't exist
  106039. */
  106040. removeExternalData(key: string): boolean;
  106041. private _evaluateSubMesh;
  106042. /**
  106043. * Clear the processed materials smart array preventing retention point in material dispose.
  106044. */
  106045. freeProcessedMaterials(): void;
  106046. private _preventFreeActiveMeshesAndRenderingGroups;
  106047. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  106048. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  106049. * when disposing several meshes in a row or a hierarchy of meshes.
  106050. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  106051. */
  106052. blockfreeActiveMeshesAndRenderingGroups: boolean;
  106053. /**
  106054. * Clear the active meshes smart array preventing retention point in mesh dispose.
  106055. */
  106056. freeActiveMeshes(): void;
  106057. /**
  106058. * Clear the info related to rendering groups preventing retention points during dispose.
  106059. */
  106060. freeRenderingGroups(): void;
  106061. /** @hidden */
  106062. _isInIntermediateRendering(): boolean;
  106063. /**
  106064. * Lambda returning the list of potentially active meshes.
  106065. */
  106066. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  106067. /**
  106068. * Lambda returning the list of potentially active sub meshes.
  106069. */
  106070. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  106071. /**
  106072. * Lambda returning the list of potentially intersecting sub meshes.
  106073. */
  106074. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  106075. /**
  106076. * Lambda returning the list of potentially colliding sub meshes.
  106077. */
  106078. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  106079. private _activeMeshesFrozen;
  106080. private _skipEvaluateActiveMeshesCompletely;
  106081. /**
  106082. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  106083. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  106084. * @returns the current scene
  106085. */
  106086. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  106087. /**
  106088. * Use this function to restart evaluating active meshes on every frame
  106089. * @returns the current scene
  106090. */
  106091. unfreezeActiveMeshes(): Scene;
  106092. private _evaluateActiveMeshes;
  106093. private _activeMesh;
  106094. /**
  106095. * Update the transform matrix to update from the current active camera
  106096. * @param force defines a boolean used to force the update even if cache is up to date
  106097. */
  106098. updateTransformMatrix(force?: boolean): void;
  106099. private _bindFrameBuffer;
  106100. /** @hidden */
  106101. _allowPostProcessClearColor: boolean;
  106102. /** @hidden */
  106103. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  106104. private _processSubCameras;
  106105. private _checkIntersections;
  106106. /** @hidden */
  106107. _advancePhysicsEngineStep(step: number): void;
  106108. /**
  106109. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  106110. */
  106111. getDeterministicFrameTime: () => number;
  106112. /** @hidden */
  106113. _animate(): void;
  106114. /** Execute all animations (for a frame) */
  106115. animate(): void;
  106116. /**
  106117. * Render the scene
  106118. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  106119. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  106120. */
  106121. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  106122. /**
  106123. * Freeze all materials
  106124. * A frozen material will not be updatable but should be faster to render
  106125. */
  106126. freezeMaterials(): void;
  106127. /**
  106128. * Unfreeze all materials
  106129. * A frozen material will not be updatable but should be faster to render
  106130. */
  106131. unfreezeMaterials(): void;
  106132. /**
  106133. * Releases all held ressources
  106134. */
  106135. dispose(): void;
  106136. /**
  106137. * Gets if the scene is already disposed
  106138. */
  106139. readonly isDisposed: boolean;
  106140. /**
  106141. * Call this function to reduce memory footprint of the scene.
  106142. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  106143. */
  106144. clearCachedVertexData(): void;
  106145. /**
  106146. * This function will remove the local cached buffer data from texture.
  106147. * It will save memory but will prevent the texture from being rebuilt
  106148. */
  106149. cleanCachedTextureBuffer(): void;
  106150. /**
  106151. * Get the world extend vectors with an optional filter
  106152. *
  106153. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  106154. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  106155. */
  106156. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  106157. min: Vector3;
  106158. max: Vector3;
  106159. };
  106160. /**
  106161. * Creates a ray that can be used to pick in the scene
  106162. * @param x defines the x coordinate of the origin (on-screen)
  106163. * @param y defines the y coordinate of the origin (on-screen)
  106164. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  106165. * @param camera defines the camera to use for the picking
  106166. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  106167. * @returns a Ray
  106168. */
  106169. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  106170. /**
  106171. * Creates a ray that can be used to pick in the scene
  106172. * @param x defines the x coordinate of the origin (on-screen)
  106173. * @param y defines the y coordinate of the origin (on-screen)
  106174. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  106175. * @param result defines the ray where to store the picking ray
  106176. * @param camera defines the camera to use for the picking
  106177. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  106178. * @returns the current scene
  106179. */
  106180. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  106181. /**
  106182. * Creates a ray that can be used to pick in the scene
  106183. * @param x defines the x coordinate of the origin (on-screen)
  106184. * @param y defines the y coordinate of the origin (on-screen)
  106185. * @param camera defines the camera to use for the picking
  106186. * @returns a Ray
  106187. */
  106188. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  106189. /**
  106190. * Creates a ray that can be used to pick in the scene
  106191. * @param x defines the x coordinate of the origin (on-screen)
  106192. * @param y defines the y coordinate of the origin (on-screen)
  106193. * @param result defines the ray where to store the picking ray
  106194. * @param camera defines the camera to use for the picking
  106195. * @returns the current scene
  106196. */
  106197. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  106198. /** Launch a ray to try to pick a mesh in the scene
  106199. * @param x position on screen
  106200. * @param y position on screen
  106201. * @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
  106202. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  106203. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  106204. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106205. * @returns a PickingInfo
  106206. */
  106207. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  106208. /** Use the given ray to pick a mesh in the scene
  106209. * @param ray The ray to use to pick meshes
  106210. * @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
  106211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  106212. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106213. * @returns a PickingInfo
  106214. */
  106215. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  106216. /**
  106217. * Launch a ray to try to pick a mesh in the scene
  106218. * @param x X position on screen
  106219. * @param y Y position on screen
  106220. * @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
  106221. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  106222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106223. * @returns an array of PickingInfo
  106224. */
  106225. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  106226. /**
  106227. * Launch a ray to try to pick a mesh in the scene
  106228. * @param ray Ray to use
  106229. * @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
  106230. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106231. * @returns an array of PickingInfo
  106232. */
  106233. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  106234. /**
  106235. * Force the value of meshUnderPointer
  106236. * @param mesh defines the mesh to use
  106237. */
  106238. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  106239. /**
  106240. * Gets the mesh under the pointer
  106241. * @returns a Mesh or null if no mesh is under the pointer
  106242. */
  106243. getPointerOverMesh(): Nullable<AbstractMesh>;
  106244. /** @hidden */
  106245. _rebuildGeometries(): void;
  106246. /** @hidden */
  106247. _rebuildTextures(): void;
  106248. private _getByTags;
  106249. /**
  106250. * Get a list of meshes by tags
  106251. * @param tagsQuery defines the tags query to use
  106252. * @param forEach defines a predicate used to filter results
  106253. * @returns an array of Mesh
  106254. */
  106255. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  106256. /**
  106257. * Get a list of cameras by tags
  106258. * @param tagsQuery defines the tags query to use
  106259. * @param forEach defines a predicate used to filter results
  106260. * @returns an array of Camera
  106261. */
  106262. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  106263. /**
  106264. * Get a list of lights by tags
  106265. * @param tagsQuery defines the tags query to use
  106266. * @param forEach defines a predicate used to filter results
  106267. * @returns an array of Light
  106268. */
  106269. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  106270. /**
  106271. * Get a list of materials by tags
  106272. * @param tagsQuery defines the tags query to use
  106273. * @param forEach defines a predicate used to filter results
  106274. * @returns an array of Material
  106275. */
  106276. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  106277. /**
  106278. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  106279. * This allowed control for front to back rendering or reversly depending of the special needs.
  106280. *
  106281. * @param renderingGroupId The rendering group id corresponding to its index
  106282. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  106283. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  106284. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  106285. */
  106286. 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;
  106287. /**
  106288. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  106289. *
  106290. * @param renderingGroupId The rendering group id corresponding to its index
  106291. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  106292. * @param depth Automatically clears depth between groups if true and autoClear is true.
  106293. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  106294. */
  106295. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  106296. /**
  106297. * Gets the current auto clear configuration for one rendering group of the rendering
  106298. * manager.
  106299. * @param index the rendering group index to get the information for
  106300. * @returns The auto clear setup for the requested rendering group
  106301. */
  106302. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  106303. private _blockMaterialDirtyMechanism;
  106304. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  106305. blockMaterialDirtyMechanism: boolean;
  106306. /**
  106307. * Will flag all materials as dirty to trigger new shader compilation
  106308. * @param flag defines the flag used to specify which material part must be marked as dirty
  106309. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  106310. */
  106311. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106312. /** @hidden */
  106313. _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;
  106314. /** @hidden */
  106315. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106316. /** @hidden */
  106317. _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;
  106318. /** @hidden */
  106319. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  106320. /** @hidden */
  106321. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106322. /** @hidden */
  106323. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106324. }
  106325. }
  106326. declare module BABYLON {
  106327. /**
  106328. * Set of assets to keep when moving a scene into an asset container.
  106329. */
  106330. export class KeepAssets extends AbstractScene {
  106331. }
  106332. /**
  106333. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  106334. */
  106335. export class InstantiatedEntries {
  106336. /**
  106337. * List of new root nodes (eg. nodes with no parent)
  106338. */
  106339. rootNodes: TransformNode[];
  106340. /**
  106341. * List of new skeletons
  106342. */
  106343. skeletons: Skeleton[];
  106344. /**
  106345. * List of new animation groups
  106346. */
  106347. animationGroups: AnimationGroup[];
  106348. }
  106349. /**
  106350. * Container with a set of assets that can be added or removed from a scene.
  106351. */
  106352. export class AssetContainer extends AbstractScene {
  106353. /**
  106354. * The scene the AssetContainer belongs to.
  106355. */
  106356. scene: Scene;
  106357. /**
  106358. * Instantiates an AssetContainer.
  106359. * @param scene The scene the AssetContainer belongs to.
  106360. */
  106361. constructor(scene: Scene);
  106362. /**
  106363. * Instantiate or clone all meshes and add the new ones to the scene.
  106364. * Skeletons and animation groups will all be cloned
  106365. * @param nameFunction defines an optional function used to get new names for clones
  106366. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  106367. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  106368. */
  106369. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  106370. /**
  106371. * Adds all the assets from the container to the scene.
  106372. */
  106373. addAllToScene(): void;
  106374. /**
  106375. * Removes all the assets in the container from the scene
  106376. */
  106377. removeAllFromScene(): void;
  106378. /**
  106379. * Disposes all the assets in the container
  106380. */
  106381. dispose(): void;
  106382. private _moveAssets;
  106383. /**
  106384. * Removes all the assets contained in the scene and adds them to the container.
  106385. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  106386. */
  106387. moveAllFromScene(keepAssets?: KeepAssets): void;
  106388. /**
  106389. * 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.
  106390. * @returns the root mesh
  106391. */
  106392. createRootMesh(): Mesh;
  106393. /**
  106394. * Merge animations from this asset container into a scene
  106395. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106396. * @param animatables set of animatables to retarget to a node from the scene
  106397. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  106398. */
  106399. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  106400. }
  106401. }
  106402. declare module BABYLON {
  106403. /**
  106404. * Defines how the parser contract is defined.
  106405. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  106406. */
  106407. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  106408. /**
  106409. * Defines how the individual parser contract is defined.
  106410. * These parser can parse an individual asset
  106411. */
  106412. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  106413. /**
  106414. * Base class of the scene acting as a container for the different elements composing a scene.
  106415. * This class is dynamically extended by the different components of the scene increasing
  106416. * flexibility and reducing coupling
  106417. */
  106418. export abstract class AbstractScene {
  106419. /**
  106420. * Stores the list of available parsers in the application.
  106421. */
  106422. private static _BabylonFileParsers;
  106423. /**
  106424. * Stores the list of available individual parsers in the application.
  106425. */
  106426. private static _IndividualBabylonFileParsers;
  106427. /**
  106428. * Adds a parser in the list of available ones
  106429. * @param name Defines the name of the parser
  106430. * @param parser Defines the parser to add
  106431. */
  106432. static AddParser(name: string, parser: BabylonFileParser): void;
  106433. /**
  106434. * Gets a general parser from the list of avaialble ones
  106435. * @param name Defines the name of the parser
  106436. * @returns the requested parser or null
  106437. */
  106438. static GetParser(name: string): Nullable<BabylonFileParser>;
  106439. /**
  106440. * Adds n individual parser in the list of available ones
  106441. * @param name Defines the name of the parser
  106442. * @param parser Defines the parser to add
  106443. */
  106444. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  106445. /**
  106446. * Gets an individual parser from the list of avaialble ones
  106447. * @param name Defines the name of the parser
  106448. * @returns the requested parser or null
  106449. */
  106450. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  106451. /**
  106452. * Parser json data and populate both a scene and its associated container object
  106453. * @param jsonData Defines the data to parse
  106454. * @param scene Defines the scene to parse the data for
  106455. * @param container Defines the container attached to the parsing sequence
  106456. * @param rootUrl Defines the root url of the data
  106457. */
  106458. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  106459. /**
  106460. * Gets the list of root nodes (ie. nodes with no parent)
  106461. */
  106462. rootNodes: Node[];
  106463. /** All of the cameras added to this scene
  106464. * @see http://doc.babylonjs.com/babylon101/cameras
  106465. */
  106466. cameras: Camera[];
  106467. /**
  106468. * All of the lights added to this scene
  106469. * @see http://doc.babylonjs.com/babylon101/lights
  106470. */
  106471. lights: Light[];
  106472. /**
  106473. * All of the (abstract) meshes added to this scene
  106474. */
  106475. meshes: AbstractMesh[];
  106476. /**
  106477. * The list of skeletons added to the scene
  106478. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106479. */
  106480. skeletons: Skeleton[];
  106481. /**
  106482. * All of the particle systems added to this scene
  106483. * @see http://doc.babylonjs.com/babylon101/particles
  106484. */
  106485. particleSystems: IParticleSystem[];
  106486. /**
  106487. * Gets a list of Animations associated with the scene
  106488. */
  106489. animations: Animation[];
  106490. /**
  106491. * All of the animation groups added to this scene
  106492. * @see http://doc.babylonjs.com/how_to/group
  106493. */
  106494. animationGroups: AnimationGroup[];
  106495. /**
  106496. * All of the multi-materials added to this scene
  106497. * @see http://doc.babylonjs.com/how_to/multi_materials
  106498. */
  106499. multiMaterials: MultiMaterial[];
  106500. /**
  106501. * All of the materials added to this scene
  106502. * In the context of a Scene, it is not supposed to be modified manually.
  106503. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  106504. * Note also that the order of the Material within the array is not significant and might change.
  106505. * @see http://doc.babylonjs.com/babylon101/materials
  106506. */
  106507. materials: Material[];
  106508. /**
  106509. * The list of morph target managers added to the scene
  106510. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106511. */
  106512. morphTargetManagers: MorphTargetManager[];
  106513. /**
  106514. * The list of geometries used in the scene.
  106515. */
  106516. geometries: Geometry[];
  106517. /**
  106518. * All of the tranform nodes added to this scene
  106519. * In the context of a Scene, it is not supposed to be modified manually.
  106520. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  106521. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  106522. * @see http://doc.babylonjs.com/how_to/transformnode
  106523. */
  106524. transformNodes: TransformNode[];
  106525. /**
  106526. * ActionManagers available on the scene.
  106527. */
  106528. actionManagers: AbstractActionManager[];
  106529. /**
  106530. * Textures to keep.
  106531. */
  106532. textures: BaseTexture[];
  106533. /**
  106534. * Environment texture for the scene
  106535. */
  106536. environmentTexture: Nullable<BaseTexture>;
  106537. /**
  106538. * @returns all meshes, lights, cameras, transformNodes and bones
  106539. */
  106540. getNodes(): Array<Node>;
  106541. }
  106542. }
  106543. declare module BABYLON {
  106544. /**
  106545. * Interface used to define options for Sound class
  106546. */
  106547. export interface ISoundOptions {
  106548. /**
  106549. * Does the sound autoplay once loaded.
  106550. */
  106551. autoplay?: boolean;
  106552. /**
  106553. * Does the sound loop after it finishes playing once.
  106554. */
  106555. loop?: boolean;
  106556. /**
  106557. * Sound's volume
  106558. */
  106559. volume?: number;
  106560. /**
  106561. * Is it a spatial sound?
  106562. */
  106563. spatialSound?: boolean;
  106564. /**
  106565. * Maximum distance to hear that sound
  106566. */
  106567. maxDistance?: number;
  106568. /**
  106569. * Uses user defined attenuation function
  106570. */
  106571. useCustomAttenuation?: boolean;
  106572. /**
  106573. * Define the roll off factor of spatial sounds.
  106574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106575. */
  106576. rolloffFactor?: number;
  106577. /**
  106578. * Define the reference distance the sound should be heard perfectly.
  106579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106580. */
  106581. refDistance?: number;
  106582. /**
  106583. * Define the distance attenuation model the sound will follow.
  106584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106585. */
  106586. distanceModel?: string;
  106587. /**
  106588. * Defines the playback speed (1 by default)
  106589. */
  106590. playbackRate?: number;
  106591. /**
  106592. * Defines if the sound is from a streaming source
  106593. */
  106594. streaming?: boolean;
  106595. /**
  106596. * Defines an optional length (in seconds) inside the sound file
  106597. */
  106598. length?: number;
  106599. /**
  106600. * Defines an optional offset (in seconds) inside the sound file
  106601. */
  106602. offset?: number;
  106603. /**
  106604. * If true, URLs will not be required to state the audio file codec to use.
  106605. */
  106606. skipCodecCheck?: boolean;
  106607. }
  106608. /**
  106609. * Defines a sound that can be played in the application.
  106610. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  106611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106612. */
  106613. export class Sound {
  106614. /**
  106615. * The name of the sound in the scene.
  106616. */
  106617. name: string;
  106618. /**
  106619. * Does the sound autoplay once loaded.
  106620. */
  106621. autoplay: boolean;
  106622. /**
  106623. * Does the sound loop after it finishes playing once.
  106624. */
  106625. loop: boolean;
  106626. /**
  106627. * Does the sound use a custom attenuation curve to simulate the falloff
  106628. * happening when the source gets further away from the camera.
  106629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106630. */
  106631. useCustomAttenuation: boolean;
  106632. /**
  106633. * The sound track id this sound belongs to.
  106634. */
  106635. soundTrackId: number;
  106636. /**
  106637. * Is this sound currently played.
  106638. */
  106639. isPlaying: boolean;
  106640. /**
  106641. * Is this sound currently paused.
  106642. */
  106643. isPaused: boolean;
  106644. /**
  106645. * Does this sound enables spatial sound.
  106646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106647. */
  106648. spatialSound: boolean;
  106649. /**
  106650. * Define the reference distance the sound should be heard perfectly.
  106651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106652. */
  106653. refDistance: number;
  106654. /**
  106655. * Define the roll off factor of spatial sounds.
  106656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106657. */
  106658. rolloffFactor: number;
  106659. /**
  106660. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  106661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106662. */
  106663. maxDistance: number;
  106664. /**
  106665. * Define the distance attenuation model the sound will follow.
  106666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106667. */
  106668. distanceModel: string;
  106669. /**
  106670. * @hidden
  106671. * Back Compat
  106672. **/
  106673. onended: () => any;
  106674. /**
  106675. * Observable event when the current playing sound finishes.
  106676. */
  106677. onEndedObservable: Observable<Sound>;
  106678. private _panningModel;
  106679. private _playbackRate;
  106680. private _streaming;
  106681. private _startTime;
  106682. private _startOffset;
  106683. private _position;
  106684. /** @hidden */
  106685. _positionInEmitterSpace: boolean;
  106686. private _localDirection;
  106687. private _volume;
  106688. private _isReadyToPlay;
  106689. private _isDirectional;
  106690. private _readyToPlayCallback;
  106691. private _audioBuffer;
  106692. private _soundSource;
  106693. private _streamingSource;
  106694. private _soundPanner;
  106695. private _soundGain;
  106696. private _inputAudioNode;
  106697. private _outputAudioNode;
  106698. private _coneInnerAngle;
  106699. private _coneOuterAngle;
  106700. private _coneOuterGain;
  106701. private _scene;
  106702. private _connectedTransformNode;
  106703. private _customAttenuationFunction;
  106704. private _registerFunc;
  106705. private _isOutputConnected;
  106706. private _htmlAudioElement;
  106707. private _urlType;
  106708. private _length?;
  106709. private _offset?;
  106710. /** @hidden */
  106711. static _SceneComponentInitialization: (scene: Scene) => void;
  106712. /**
  106713. * Create a sound and attach it to a scene
  106714. * @param name Name of your sound
  106715. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  106716. * @param scene defines the scene the sound belongs to
  106717. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  106718. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  106719. */
  106720. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  106721. /**
  106722. * Release the sound and its associated resources
  106723. */
  106724. dispose(): void;
  106725. /**
  106726. * Gets if the sounds is ready to be played or not.
  106727. * @returns true if ready, otherwise false
  106728. */
  106729. isReady(): boolean;
  106730. private _soundLoaded;
  106731. /**
  106732. * Sets the data of the sound from an audiobuffer
  106733. * @param audioBuffer The audioBuffer containing the data
  106734. */
  106735. setAudioBuffer(audioBuffer: AudioBuffer): void;
  106736. /**
  106737. * Updates the current sounds options such as maxdistance, loop...
  106738. * @param options A JSON object containing values named as the object properties
  106739. */
  106740. updateOptions(options: ISoundOptions): void;
  106741. private _createSpatialParameters;
  106742. private _updateSpatialParameters;
  106743. /**
  106744. * Switch the panning model to HRTF:
  106745. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106747. */
  106748. switchPanningModelToHRTF(): void;
  106749. /**
  106750. * Switch the panning model to Equal Power:
  106751. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106753. */
  106754. switchPanningModelToEqualPower(): void;
  106755. private _switchPanningModel;
  106756. /**
  106757. * Connect this sound to a sound track audio node like gain...
  106758. * @param soundTrackAudioNode the sound track audio node to connect to
  106759. */
  106760. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  106761. /**
  106762. * Transform this sound into a directional source
  106763. * @param coneInnerAngle Size of the inner cone in degree
  106764. * @param coneOuterAngle Size of the outer cone in degree
  106765. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  106766. */
  106767. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  106768. /**
  106769. * Gets or sets the inner angle for the directional cone.
  106770. */
  106771. /**
  106772. * Gets or sets the inner angle for the directional cone.
  106773. */
  106774. directionalConeInnerAngle: number;
  106775. /**
  106776. * Gets or sets the outer angle for the directional cone.
  106777. */
  106778. /**
  106779. * Gets or sets the outer angle for the directional cone.
  106780. */
  106781. directionalConeOuterAngle: number;
  106782. /**
  106783. * Sets the position of the emitter if spatial sound is enabled
  106784. * @param newPosition Defines the new posisiton
  106785. */
  106786. setPosition(newPosition: Vector3): void;
  106787. /**
  106788. * Sets the local direction of the emitter if spatial sound is enabled
  106789. * @param newLocalDirection Defines the new local direction
  106790. */
  106791. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  106792. private _updateDirection;
  106793. /** @hidden */
  106794. updateDistanceFromListener(): void;
  106795. /**
  106796. * Sets a new custom attenuation function for the sound.
  106797. * @param callback Defines the function used for the attenuation
  106798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106799. */
  106800. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  106801. /**
  106802. * Play the sound
  106803. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  106804. * @param offset (optional) Start the sound at a specific time in seconds
  106805. * @param length (optional) Sound duration (in seconds)
  106806. */
  106807. play(time?: number, offset?: number, length?: number): void;
  106808. private _onended;
  106809. /**
  106810. * Stop the sound
  106811. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  106812. */
  106813. stop(time?: number): void;
  106814. /**
  106815. * Put the sound in pause
  106816. */
  106817. pause(): void;
  106818. /**
  106819. * Sets a dedicated volume for this sounds
  106820. * @param newVolume Define the new volume of the sound
  106821. * @param time Define time for gradual change to new volume
  106822. */
  106823. setVolume(newVolume: number, time?: number): void;
  106824. /**
  106825. * Set the sound play back rate
  106826. * @param newPlaybackRate Define the playback rate the sound should be played at
  106827. */
  106828. setPlaybackRate(newPlaybackRate: number): void;
  106829. /**
  106830. * Gets the volume of the sound.
  106831. * @returns the volume of the sound
  106832. */
  106833. getVolume(): number;
  106834. /**
  106835. * Attach the sound to a dedicated mesh
  106836. * @param transformNode The transform node to connect the sound with
  106837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106838. */
  106839. attachToMesh(transformNode: TransformNode): void;
  106840. /**
  106841. * Detach the sound from the previously attached mesh
  106842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106843. */
  106844. detachFromMesh(): void;
  106845. private _onRegisterAfterWorldMatrixUpdate;
  106846. /**
  106847. * Clone the current sound in the scene.
  106848. * @returns the new sound clone
  106849. */
  106850. clone(): Nullable<Sound>;
  106851. /**
  106852. * Gets the current underlying audio buffer containing the data
  106853. * @returns the audio buffer
  106854. */
  106855. getAudioBuffer(): Nullable<AudioBuffer>;
  106856. /**
  106857. * Serializes the Sound in a JSON representation
  106858. * @returns the JSON representation of the sound
  106859. */
  106860. serialize(): any;
  106861. /**
  106862. * Parse a JSON representation of a sound to innstantiate in a given scene
  106863. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  106864. * @param scene Define the scene the new parsed sound should be created in
  106865. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  106866. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  106867. * @returns the newly parsed sound
  106868. */
  106869. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  106870. }
  106871. }
  106872. declare module BABYLON {
  106873. /**
  106874. * This defines an action helpful to play a defined sound on a triggered action.
  106875. */
  106876. export class PlaySoundAction extends Action {
  106877. private _sound;
  106878. /**
  106879. * Instantiate the action
  106880. * @param triggerOptions defines the trigger options
  106881. * @param sound defines the sound to play
  106882. * @param condition defines the trigger related conditions
  106883. */
  106884. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106885. /** @hidden */
  106886. _prepare(): void;
  106887. /**
  106888. * Execute the action and play the sound.
  106889. */
  106890. execute(): void;
  106891. /**
  106892. * Serializes the actions and its related information.
  106893. * @param parent defines the object to serialize in
  106894. * @returns the serialized object
  106895. */
  106896. serialize(parent: any): any;
  106897. }
  106898. /**
  106899. * This defines an action helpful to stop a defined sound on a triggered action.
  106900. */
  106901. export class StopSoundAction extends Action {
  106902. private _sound;
  106903. /**
  106904. * Instantiate the action
  106905. * @param triggerOptions defines the trigger options
  106906. * @param sound defines the sound to stop
  106907. * @param condition defines the trigger related conditions
  106908. */
  106909. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106910. /** @hidden */
  106911. _prepare(): void;
  106912. /**
  106913. * Execute the action and stop the sound.
  106914. */
  106915. execute(): void;
  106916. /**
  106917. * Serializes the actions and its related information.
  106918. * @param parent defines the object to serialize in
  106919. * @returns the serialized object
  106920. */
  106921. serialize(parent: any): any;
  106922. }
  106923. }
  106924. declare module BABYLON {
  106925. /**
  106926. * This defines an action responsible to change the value of a property
  106927. * by interpolating between its current value and the newly set one once triggered.
  106928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106929. */
  106930. export class InterpolateValueAction extends Action {
  106931. /**
  106932. * Defines the path of the property where the value should be interpolated
  106933. */
  106934. propertyPath: string;
  106935. /**
  106936. * Defines the target value at the end of the interpolation.
  106937. */
  106938. value: any;
  106939. /**
  106940. * Defines the time it will take for the property to interpolate to the value.
  106941. */
  106942. duration: number;
  106943. /**
  106944. * Defines if the other scene animations should be stopped when the action has been triggered
  106945. */
  106946. stopOtherAnimations?: boolean;
  106947. /**
  106948. * Defines a callback raised once the interpolation animation has been done.
  106949. */
  106950. onInterpolationDone?: () => void;
  106951. /**
  106952. * Observable triggered once the interpolation animation has been done.
  106953. */
  106954. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  106955. private _target;
  106956. private _effectiveTarget;
  106957. private _property;
  106958. /**
  106959. * Instantiate the action
  106960. * @param triggerOptions defines the trigger options
  106961. * @param target defines the object containing the value to interpolate
  106962. * @param propertyPath defines the path to the property in the target object
  106963. * @param value defines the target value at the end of the interpolation
  106964. * @param duration deines the time it will take for the property to interpolate to the value.
  106965. * @param condition defines the trigger related conditions
  106966. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  106967. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  106968. */
  106969. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  106970. /** @hidden */
  106971. _prepare(): void;
  106972. /**
  106973. * Execute the action starts the value interpolation.
  106974. */
  106975. execute(): void;
  106976. /**
  106977. * Serializes the actions and its related information.
  106978. * @param parent defines the object to serialize in
  106979. * @returns the serialized object
  106980. */
  106981. serialize(parent: any): any;
  106982. }
  106983. }
  106984. declare module BABYLON {
  106985. /**
  106986. * Options allowed during the creation of a sound track.
  106987. */
  106988. export interface ISoundTrackOptions {
  106989. /**
  106990. * The volume the sound track should take during creation
  106991. */
  106992. volume?: number;
  106993. /**
  106994. * Define if the sound track is the main sound track of the scene
  106995. */
  106996. mainTrack?: boolean;
  106997. }
  106998. /**
  106999. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  107000. * It will be also used in a future release to apply effects on a specific track.
  107001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107002. */
  107003. export class SoundTrack {
  107004. /**
  107005. * The unique identifier of the sound track in the scene.
  107006. */
  107007. id: number;
  107008. /**
  107009. * The list of sounds included in the sound track.
  107010. */
  107011. soundCollection: Array<Sound>;
  107012. private _outputAudioNode;
  107013. private _scene;
  107014. private _connectedAnalyser;
  107015. private _options;
  107016. private _isInitialized;
  107017. /**
  107018. * Creates a new sound track.
  107019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107020. * @param scene Define the scene the sound track belongs to
  107021. * @param options
  107022. */
  107023. constructor(scene: Scene, options?: ISoundTrackOptions);
  107024. private _initializeSoundTrackAudioGraph;
  107025. /**
  107026. * Release the sound track and its associated resources
  107027. */
  107028. dispose(): void;
  107029. /**
  107030. * Adds a sound to this sound track
  107031. * @param sound define the cound to add
  107032. * @ignoreNaming
  107033. */
  107034. AddSound(sound: Sound): void;
  107035. /**
  107036. * Removes a sound to this sound track
  107037. * @param sound define the cound to remove
  107038. * @ignoreNaming
  107039. */
  107040. RemoveSound(sound: Sound): void;
  107041. /**
  107042. * Set a global volume for the full sound track.
  107043. * @param newVolume Define the new volume of the sound track
  107044. */
  107045. setVolume(newVolume: number): void;
  107046. /**
  107047. * Switch the panning model to HRTF:
  107048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107050. */
  107051. switchPanningModelToHRTF(): void;
  107052. /**
  107053. * Switch the panning model to Equal Power:
  107054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107056. */
  107057. switchPanningModelToEqualPower(): void;
  107058. /**
  107059. * Connect the sound track to an audio analyser allowing some amazing
  107060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107062. * @param analyser The analyser to connect to the engine
  107063. */
  107064. connectToAnalyser(analyser: Analyser): void;
  107065. }
  107066. }
  107067. declare module BABYLON {
  107068. interface AbstractScene {
  107069. /**
  107070. * The list of sounds used in the scene.
  107071. */
  107072. sounds: Nullable<Array<Sound>>;
  107073. }
  107074. interface Scene {
  107075. /**
  107076. * @hidden
  107077. * Backing field
  107078. */
  107079. _mainSoundTrack: SoundTrack;
  107080. /**
  107081. * The main sound track played by the scene.
  107082. * It cotains your primary collection of sounds.
  107083. */
  107084. mainSoundTrack: SoundTrack;
  107085. /**
  107086. * The list of sound tracks added to the scene
  107087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107088. */
  107089. soundTracks: Nullable<Array<SoundTrack>>;
  107090. /**
  107091. * Gets a sound using a given name
  107092. * @param name defines the name to search for
  107093. * @return the found sound or null if not found at all.
  107094. */
  107095. getSoundByName(name: string): Nullable<Sound>;
  107096. /**
  107097. * Gets or sets if audio support is enabled
  107098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107099. */
  107100. audioEnabled: boolean;
  107101. /**
  107102. * Gets or sets if audio will be output to headphones
  107103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107104. */
  107105. headphone: boolean;
  107106. /**
  107107. * Gets or sets custom audio listener position provider
  107108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107109. */
  107110. audioListenerPositionProvider: Nullable<() => Vector3>;
  107111. /**
  107112. * Gets or sets a refresh rate when using 3D audio positioning
  107113. */
  107114. audioPositioningRefreshRate: number;
  107115. }
  107116. /**
  107117. * Defines the sound scene component responsible to manage any sounds
  107118. * in a given scene.
  107119. */
  107120. export class AudioSceneComponent implements ISceneSerializableComponent {
  107121. /**
  107122. * The component name helpfull to identify the component in the list of scene components.
  107123. */
  107124. readonly name: string;
  107125. /**
  107126. * The scene the component belongs to.
  107127. */
  107128. scene: Scene;
  107129. private _audioEnabled;
  107130. /**
  107131. * Gets whether audio is enabled or not.
  107132. * Please use related enable/disable method to switch state.
  107133. */
  107134. readonly audioEnabled: boolean;
  107135. private _headphone;
  107136. /**
  107137. * Gets whether audio is outputing to headphone or not.
  107138. * Please use the according Switch methods to change output.
  107139. */
  107140. readonly headphone: boolean;
  107141. /**
  107142. * Gets or sets a refresh rate when using 3D audio positioning
  107143. */
  107144. audioPositioningRefreshRate: number;
  107145. private _audioListenerPositionProvider;
  107146. /**
  107147. * Gets the current audio listener position provider
  107148. */
  107149. /**
  107150. * Sets a custom listener position for all sounds in the scene
  107151. * By default, this is the position of the first active camera
  107152. */
  107153. audioListenerPositionProvider: Nullable<() => Vector3>;
  107154. /**
  107155. * Creates a new instance of the component for the given scene
  107156. * @param scene Defines the scene to register the component in
  107157. */
  107158. constructor(scene: Scene);
  107159. /**
  107160. * Registers the component in a given scene
  107161. */
  107162. register(): void;
  107163. /**
  107164. * Rebuilds the elements related to this component in case of
  107165. * context lost for instance.
  107166. */
  107167. rebuild(): void;
  107168. /**
  107169. * Serializes the component data to the specified json object
  107170. * @param serializationObject The object to serialize to
  107171. */
  107172. serialize(serializationObject: any): void;
  107173. /**
  107174. * Adds all the elements from the container to the scene
  107175. * @param container the container holding the elements
  107176. */
  107177. addFromContainer(container: AbstractScene): void;
  107178. /**
  107179. * Removes all the elements in the container from the scene
  107180. * @param container contains the elements to remove
  107181. * @param dispose if the removed element should be disposed (default: false)
  107182. */
  107183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107184. /**
  107185. * Disposes the component and the associated ressources.
  107186. */
  107187. dispose(): void;
  107188. /**
  107189. * Disables audio in the associated scene.
  107190. */
  107191. disableAudio(): void;
  107192. /**
  107193. * Enables audio in the associated scene.
  107194. */
  107195. enableAudio(): void;
  107196. /**
  107197. * Switch audio to headphone output.
  107198. */
  107199. switchAudioModeForHeadphones(): void;
  107200. /**
  107201. * Switch audio to normal speakers.
  107202. */
  107203. switchAudioModeForNormalSpeakers(): void;
  107204. private _cachedCameraDirection;
  107205. private _cachedCameraPosition;
  107206. private _lastCheck;
  107207. private _afterRender;
  107208. }
  107209. }
  107210. declare module BABYLON {
  107211. /**
  107212. * Wraps one or more Sound objects and selects one with random weight for playback.
  107213. */
  107214. export class WeightedSound {
  107215. /** When true a Sound will be selected and played when the current playing Sound completes. */
  107216. loop: boolean;
  107217. private _coneInnerAngle;
  107218. private _coneOuterAngle;
  107219. private _volume;
  107220. /** A Sound is currently playing. */
  107221. isPlaying: boolean;
  107222. /** A Sound is currently paused. */
  107223. isPaused: boolean;
  107224. private _sounds;
  107225. private _weights;
  107226. private _currentIndex?;
  107227. /**
  107228. * Creates a new WeightedSound from the list of sounds given.
  107229. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  107230. * @param sounds Array of Sounds that will be selected from.
  107231. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  107232. */
  107233. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  107234. /**
  107235. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  107236. */
  107237. /**
  107238. * The size of cone in degress for a directional sound in which there will be no attenuation.
  107239. */
  107240. directionalConeInnerAngle: number;
  107241. /**
  107242. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  107243. * Listener angles between innerAngle and outerAngle will falloff linearly.
  107244. */
  107245. /**
  107246. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  107247. * Listener angles between innerAngle and outerAngle will falloff linearly.
  107248. */
  107249. directionalConeOuterAngle: number;
  107250. /**
  107251. * Playback volume.
  107252. */
  107253. /**
  107254. * Playback volume.
  107255. */
  107256. volume: number;
  107257. private _onended;
  107258. /**
  107259. * Suspend playback
  107260. */
  107261. pause(): void;
  107262. /**
  107263. * Stop playback
  107264. */
  107265. stop(): void;
  107266. /**
  107267. * Start playback.
  107268. * @param startOffset Position the clip head at a specific time in seconds.
  107269. */
  107270. play(startOffset?: number): void;
  107271. }
  107272. }
  107273. declare module BABYLON {
  107274. /**
  107275. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  107276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107277. */
  107278. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  107279. /**
  107280. * Gets the name of the behavior.
  107281. */
  107282. readonly name: string;
  107283. /**
  107284. * The easing function used by animations
  107285. */
  107286. static EasingFunction: BackEase;
  107287. /**
  107288. * The easing mode used by animations
  107289. */
  107290. static EasingMode: number;
  107291. /**
  107292. * The duration of the animation, in milliseconds
  107293. */
  107294. transitionDuration: number;
  107295. /**
  107296. * Length of the distance animated by the transition when lower radius is reached
  107297. */
  107298. lowerRadiusTransitionRange: number;
  107299. /**
  107300. * Length of the distance animated by the transition when upper radius is reached
  107301. */
  107302. upperRadiusTransitionRange: number;
  107303. private _autoTransitionRange;
  107304. /**
  107305. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  107306. */
  107307. /**
  107308. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  107309. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  107310. */
  107311. autoTransitionRange: boolean;
  107312. private _attachedCamera;
  107313. private _onAfterCheckInputsObserver;
  107314. private _onMeshTargetChangedObserver;
  107315. /**
  107316. * Initializes the behavior.
  107317. */
  107318. init(): void;
  107319. /**
  107320. * Attaches the behavior to its arc rotate camera.
  107321. * @param camera Defines the camera to attach the behavior to
  107322. */
  107323. attach(camera: ArcRotateCamera): void;
  107324. /**
  107325. * Detaches the behavior from its current arc rotate camera.
  107326. */
  107327. detach(): void;
  107328. private _radiusIsAnimating;
  107329. private _radiusBounceTransition;
  107330. private _animatables;
  107331. private _cachedWheelPrecision;
  107332. /**
  107333. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  107334. * @param radiusLimit The limit to check against.
  107335. * @return Bool to indicate if at limit.
  107336. */
  107337. private _isRadiusAtLimit;
  107338. /**
  107339. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  107340. * @param radiusDelta The delta by which to animate to. Can be negative.
  107341. */
  107342. private _applyBoundRadiusAnimation;
  107343. /**
  107344. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  107345. */
  107346. protected _clearAnimationLocks(): void;
  107347. /**
  107348. * Stops and removes all animations that have been applied to the camera
  107349. */
  107350. stopAllAnimations(): void;
  107351. }
  107352. }
  107353. declare module BABYLON {
  107354. /**
  107355. * 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.
  107356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107357. */
  107358. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  107359. /**
  107360. * Gets the name of the behavior.
  107361. */
  107362. readonly name: string;
  107363. private _mode;
  107364. private _radiusScale;
  107365. private _positionScale;
  107366. private _defaultElevation;
  107367. private _elevationReturnTime;
  107368. private _elevationReturnWaitTime;
  107369. private _zoomStopsAnimation;
  107370. private _framingTime;
  107371. /**
  107372. * The easing function used by animations
  107373. */
  107374. static EasingFunction: ExponentialEase;
  107375. /**
  107376. * The easing mode used by animations
  107377. */
  107378. static EasingMode: number;
  107379. /**
  107380. * Sets the current mode used by the behavior
  107381. */
  107382. /**
  107383. * Gets current mode used by the behavior.
  107384. */
  107385. mode: number;
  107386. /**
  107387. * Sets the scale applied to the radius (1 by default)
  107388. */
  107389. /**
  107390. * Gets the scale applied to the radius
  107391. */
  107392. radiusScale: number;
  107393. /**
  107394. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  107395. */
  107396. /**
  107397. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  107398. */
  107399. positionScale: number;
  107400. /**
  107401. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  107402. * behaviour is triggered, in radians.
  107403. */
  107404. /**
  107405. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  107406. * behaviour is triggered, in radians.
  107407. */
  107408. defaultElevation: number;
  107409. /**
  107410. * Sets the time (in milliseconds) taken to return to the default beta position.
  107411. * Negative value indicates camera should not return to default.
  107412. */
  107413. /**
  107414. * Gets the time (in milliseconds) taken to return to the default beta position.
  107415. * Negative value indicates camera should not return to default.
  107416. */
  107417. elevationReturnTime: number;
  107418. /**
  107419. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  107420. */
  107421. /**
  107422. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  107423. */
  107424. elevationReturnWaitTime: number;
  107425. /**
  107426. * Sets the flag that indicates if user zooming should stop animation.
  107427. */
  107428. /**
  107429. * Gets the flag that indicates if user zooming should stop animation.
  107430. */
  107431. zoomStopsAnimation: boolean;
  107432. /**
  107433. * Sets the transition time when framing the mesh, in milliseconds
  107434. */
  107435. /**
  107436. * Gets the transition time when framing the mesh, in milliseconds
  107437. */
  107438. framingTime: number;
  107439. /**
  107440. * Define if the behavior should automatically change the configured
  107441. * camera limits and sensibilities.
  107442. */
  107443. autoCorrectCameraLimitsAndSensibility: boolean;
  107444. private _onPrePointerObservableObserver;
  107445. private _onAfterCheckInputsObserver;
  107446. private _onMeshTargetChangedObserver;
  107447. private _attachedCamera;
  107448. private _isPointerDown;
  107449. private _lastInteractionTime;
  107450. /**
  107451. * Initializes the behavior.
  107452. */
  107453. init(): void;
  107454. /**
  107455. * Attaches the behavior to its arc rotate camera.
  107456. * @param camera Defines the camera to attach the behavior to
  107457. */
  107458. attach(camera: ArcRotateCamera): void;
  107459. /**
  107460. * Detaches the behavior from its current arc rotate camera.
  107461. */
  107462. detach(): void;
  107463. private _animatables;
  107464. private _betaIsAnimating;
  107465. private _betaTransition;
  107466. private _radiusTransition;
  107467. private _vectorTransition;
  107468. /**
  107469. * Targets the given mesh and updates zoom level accordingly.
  107470. * @param mesh The mesh to target.
  107471. * @param radius Optional. If a cached radius position already exists, overrides default.
  107472. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  107473. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  107474. * @param onAnimationEnd Callback triggered at the end of the framing animation
  107475. */
  107476. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  107477. /**
  107478. * Targets the given mesh with its children and updates zoom level accordingly.
  107479. * @param mesh The mesh to target.
  107480. * @param radius Optional. If a cached radius position already exists, overrides default.
  107481. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  107482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  107483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  107484. */
  107485. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  107486. /**
  107487. * Targets the given meshes with their children and updates zoom level accordingly.
  107488. * @param meshes The mesh to target.
  107489. * @param radius Optional. If a cached radius position already exists, overrides default.
  107490. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  107491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  107492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  107493. */
  107494. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  107495. /**
  107496. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  107497. * @param minimumWorld Determines the smaller position of the bounding box extend
  107498. * @param maximumWorld Determines the bigger position of the bounding box extend
  107499. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  107500. * @param onAnimationEnd Callback triggered at the end of the framing animation
  107501. */
  107502. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  107503. /**
  107504. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  107505. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  107506. * frustum width.
  107507. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  107508. * to fully enclose the mesh in the viewing frustum.
  107509. */
  107510. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  107511. /**
  107512. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  107513. * is automatically returned to its default position (expected to be above ground plane).
  107514. */
  107515. private _maintainCameraAboveGround;
  107516. /**
  107517. * Returns the frustum slope based on the canvas ratio and camera FOV
  107518. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  107519. */
  107520. private _getFrustumSlope;
  107521. /**
  107522. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  107523. */
  107524. private _clearAnimationLocks;
  107525. /**
  107526. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107527. */
  107528. private _applyUserInteraction;
  107529. /**
  107530. * Stops and removes all animations that have been applied to the camera
  107531. */
  107532. stopAllAnimations(): void;
  107533. /**
  107534. * Gets a value indicating if the user is moving the camera
  107535. */
  107536. readonly isUserIsMoving: boolean;
  107537. /**
  107538. * The camera can move all the way towards the mesh.
  107539. */
  107540. static IgnoreBoundsSizeMode: number;
  107541. /**
  107542. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  107543. */
  107544. static FitFrustumSidesMode: number;
  107545. }
  107546. }
  107547. declare module BABYLON {
  107548. /**
  107549. * Base class for Camera Pointer Inputs.
  107550. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  107551. * for example usage.
  107552. */
  107553. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  107554. /**
  107555. * Defines the camera the input is attached to.
  107556. */
  107557. abstract camera: Camera;
  107558. /**
  107559. * Whether keyboard modifier keys are pressed at time of last mouse event.
  107560. */
  107561. protected _altKey: boolean;
  107562. protected _ctrlKey: boolean;
  107563. protected _metaKey: boolean;
  107564. protected _shiftKey: boolean;
  107565. /**
  107566. * Which mouse buttons were pressed at time of last mouse event.
  107567. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  107568. */
  107569. protected _buttonsPressed: number;
  107570. /**
  107571. * Defines the buttons associated with the input to handle camera move.
  107572. */
  107573. buttons: number[];
  107574. /**
  107575. * Attach the input controls to a specific dom element to get the input from.
  107576. * @param element Defines the element the controls should be listened from
  107577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107578. */
  107579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107580. /**
  107581. * Detach the current controls from the specified dom element.
  107582. * @param element Defines the element to stop listening the inputs from
  107583. */
  107584. detachControl(element: Nullable<HTMLElement>): void;
  107585. /**
  107586. * Gets the class name of the current input.
  107587. * @returns the class name
  107588. */
  107589. getClassName(): string;
  107590. /**
  107591. * Get the friendly name associated with the input class.
  107592. * @returns the input friendly name
  107593. */
  107594. getSimpleName(): string;
  107595. /**
  107596. * Called on pointer POINTERDOUBLETAP event.
  107597. * Override this method to provide functionality on POINTERDOUBLETAP event.
  107598. */
  107599. protected onDoubleTap(type: string): void;
  107600. /**
  107601. * Called on pointer POINTERMOVE event if only a single touch is active.
  107602. * Override this method to provide functionality.
  107603. */
  107604. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107605. /**
  107606. * Called on pointer POINTERMOVE event if multiple touches are active.
  107607. * Override this method to provide functionality.
  107608. */
  107609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107610. /**
  107611. * Called on JS contextmenu event.
  107612. * Override this method to provide functionality.
  107613. */
  107614. protected onContextMenu(evt: PointerEvent): void;
  107615. /**
  107616. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  107617. * press.
  107618. * Override this method to provide functionality.
  107619. */
  107620. protected onButtonDown(evt: PointerEvent): void;
  107621. /**
  107622. * Called each time a new POINTERUP event occurs. Ie, for each button
  107623. * release.
  107624. * Override this method to provide functionality.
  107625. */
  107626. protected onButtonUp(evt: PointerEvent): void;
  107627. /**
  107628. * Called when window becomes inactive.
  107629. * Override this method to provide functionality.
  107630. */
  107631. protected onLostFocus(): void;
  107632. private _pointerInput;
  107633. private _observer;
  107634. private _onLostFocus;
  107635. private pointA;
  107636. private pointB;
  107637. }
  107638. }
  107639. declare module BABYLON {
  107640. /**
  107641. * Manage the pointers inputs to control an arc rotate camera.
  107642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107643. */
  107644. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  107645. /**
  107646. * Defines the camera the input is attached to.
  107647. */
  107648. camera: ArcRotateCamera;
  107649. /**
  107650. * Gets the class name of the current input.
  107651. * @returns the class name
  107652. */
  107653. getClassName(): string;
  107654. /**
  107655. * Defines the buttons associated with the input to handle camera move.
  107656. */
  107657. buttons: number[];
  107658. /**
  107659. * Defines the pointer angular sensibility along the X axis or how fast is
  107660. * the camera rotating.
  107661. */
  107662. angularSensibilityX: number;
  107663. /**
  107664. * Defines the pointer angular sensibility along the Y axis or how fast is
  107665. * the camera rotating.
  107666. */
  107667. angularSensibilityY: number;
  107668. /**
  107669. * Defines the pointer pinch precision or how fast is the camera zooming.
  107670. */
  107671. pinchPrecision: number;
  107672. /**
  107673. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  107674. * from 0.
  107675. * It defines the percentage of current camera.radius to use as delta when
  107676. * pinch zoom is used.
  107677. */
  107678. pinchDeltaPercentage: number;
  107679. /**
  107680. * Defines the pointer panning sensibility or how fast is the camera moving.
  107681. */
  107682. panningSensibility: number;
  107683. /**
  107684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  107685. */
  107686. multiTouchPanning: boolean;
  107687. /**
  107688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  107689. * zoom (pinch) through multitouch.
  107690. */
  107691. multiTouchPanAndZoom: boolean;
  107692. /**
  107693. * Revers pinch action direction.
  107694. */
  107695. pinchInwards: boolean;
  107696. private _isPanClick;
  107697. private _twoFingerActivityCount;
  107698. private _isPinching;
  107699. /**
  107700. * Called on pointer POINTERMOVE event if only a single touch is active.
  107701. */
  107702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107703. /**
  107704. * Called on pointer POINTERDOUBLETAP event.
  107705. */
  107706. protected onDoubleTap(type: string): void;
  107707. /**
  107708. * Called on pointer POINTERMOVE event if multiple touches are active.
  107709. */
  107710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107711. /**
  107712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  107713. * press.
  107714. */
  107715. protected onButtonDown(evt: PointerEvent): void;
  107716. /**
  107717. * Called each time a new POINTERUP event occurs. Ie, for each button
  107718. * release.
  107719. */
  107720. protected onButtonUp(evt: PointerEvent): void;
  107721. /**
  107722. * Called when window becomes inactive.
  107723. */
  107724. protected onLostFocus(): void;
  107725. }
  107726. }
  107727. declare module BABYLON {
  107728. /**
  107729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  107730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107731. */
  107732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  107733. /**
  107734. * Defines the camera the input is attached to.
  107735. */
  107736. camera: ArcRotateCamera;
  107737. /**
  107738. * Defines the list of key codes associated with the up action (increase alpha)
  107739. */
  107740. keysUp: number[];
  107741. /**
  107742. * Defines the list of key codes associated with the down action (decrease alpha)
  107743. */
  107744. keysDown: number[];
  107745. /**
  107746. * Defines the list of key codes associated with the left action (increase beta)
  107747. */
  107748. keysLeft: number[];
  107749. /**
  107750. * Defines the list of key codes associated with the right action (decrease beta)
  107751. */
  107752. keysRight: number[];
  107753. /**
  107754. * Defines the list of key codes associated with the reset action.
  107755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  107756. */
  107757. keysReset: number[];
  107758. /**
  107759. * Defines the panning sensibility of the inputs.
  107760. * (How fast is the camera paning)
  107761. */
  107762. panningSensibility: number;
  107763. /**
  107764. * Defines the zooming sensibility of the inputs.
  107765. * (How fast is the camera zooming)
  107766. */
  107767. zoomingSensibility: number;
  107768. /**
  107769. * Defines wether maintaining the alt key down switch the movement mode from
  107770. * orientation to zoom.
  107771. */
  107772. useAltToZoom: boolean;
  107773. /**
  107774. * Rotation speed of the camera
  107775. */
  107776. angularSpeed: number;
  107777. private _keys;
  107778. private _ctrlPressed;
  107779. private _altPressed;
  107780. private _onCanvasBlurObserver;
  107781. private _onKeyboardObserver;
  107782. private _engine;
  107783. private _scene;
  107784. /**
  107785. * Attach the input controls to a specific dom element to get the input from.
  107786. * @param element Defines the element the controls should be listened from
  107787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107788. */
  107789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107790. /**
  107791. * Detach the current controls from the specified dom element.
  107792. * @param element Defines the element to stop listening the inputs from
  107793. */
  107794. detachControl(element: Nullable<HTMLElement>): void;
  107795. /**
  107796. * Update the current camera state depending on the inputs that have been used this frame.
  107797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107798. */
  107799. checkInputs(): void;
  107800. /**
  107801. * Gets the class name of the current intput.
  107802. * @returns the class name
  107803. */
  107804. getClassName(): string;
  107805. /**
  107806. * Get the friendly name associated with the input class.
  107807. * @returns the input friendly name
  107808. */
  107809. getSimpleName(): string;
  107810. }
  107811. }
  107812. declare module BABYLON {
  107813. /**
  107814. * Manage the mouse wheel inputs to control an arc rotate camera.
  107815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107816. */
  107817. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  107818. /**
  107819. * Defines the camera the input is attached to.
  107820. */
  107821. camera: ArcRotateCamera;
  107822. /**
  107823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107824. */
  107825. wheelPrecision: number;
  107826. /**
  107827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  107828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  107829. */
  107830. wheelDeltaPercentage: number;
  107831. private _wheel;
  107832. private _observer;
  107833. private computeDeltaFromMouseWheelLegacyEvent;
  107834. /**
  107835. * Attach the input controls to a specific dom element to get the input from.
  107836. * @param element Defines the element the controls should be listened from
  107837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107838. */
  107839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107840. /**
  107841. * Detach the current controls from the specified dom element.
  107842. * @param element Defines the element to stop listening the inputs from
  107843. */
  107844. detachControl(element: Nullable<HTMLElement>): void;
  107845. /**
  107846. * Gets the class name of the current intput.
  107847. * @returns the class name
  107848. */
  107849. getClassName(): string;
  107850. /**
  107851. * Get the friendly name associated with the input class.
  107852. * @returns the input friendly name
  107853. */
  107854. getSimpleName(): string;
  107855. }
  107856. }
  107857. declare module BABYLON {
  107858. /**
  107859. * Default Inputs manager for the ArcRotateCamera.
  107860. * It groups all the default supported inputs for ease of use.
  107861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107862. */
  107863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  107864. /**
  107865. * Instantiates a new ArcRotateCameraInputsManager.
  107866. * @param camera Defines the camera the inputs belong to
  107867. */
  107868. constructor(camera: ArcRotateCamera);
  107869. /**
  107870. * Add mouse wheel input support to the input manager.
  107871. * @returns the current input manager
  107872. */
  107873. addMouseWheel(): ArcRotateCameraInputsManager;
  107874. /**
  107875. * Add pointers input support to the input manager.
  107876. * @returns the current input manager
  107877. */
  107878. addPointers(): ArcRotateCameraInputsManager;
  107879. /**
  107880. * Add keyboard input support to the input manager.
  107881. * @returns the current input manager
  107882. */
  107883. addKeyboard(): ArcRotateCameraInputsManager;
  107884. }
  107885. }
  107886. declare module BABYLON {
  107887. /**
  107888. * This represents an orbital type of camera.
  107889. *
  107890. * 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.
  107891. * 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.
  107892. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  107893. */
  107894. export class ArcRotateCamera extends TargetCamera {
  107895. /**
  107896. * Defines the rotation angle of the camera along the longitudinal axis.
  107897. */
  107898. alpha: number;
  107899. /**
  107900. * Defines the rotation angle of the camera along the latitudinal axis.
  107901. */
  107902. beta: number;
  107903. /**
  107904. * Defines the radius of the camera from it s target point.
  107905. */
  107906. radius: number;
  107907. protected _target: Vector3;
  107908. protected _targetHost: Nullable<AbstractMesh>;
  107909. /**
  107910. * Defines the target point of the camera.
  107911. * The camera looks towards it form the radius distance.
  107912. */
  107913. target: Vector3;
  107914. /**
  107915. * Define the current local position of the camera in the scene
  107916. */
  107917. position: Vector3;
  107918. protected _upVector: Vector3;
  107919. protected _upToYMatrix: Matrix;
  107920. protected _YToUpMatrix: Matrix;
  107921. /**
  107922. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  107923. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  107924. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  107925. */
  107926. upVector: Vector3;
  107927. /**
  107928. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  107929. */
  107930. setMatUp(): void;
  107931. /**
  107932. * Current inertia value on the longitudinal axis.
  107933. * The bigger this number the longer it will take for the camera to stop.
  107934. */
  107935. inertialAlphaOffset: number;
  107936. /**
  107937. * Current inertia value on the latitudinal axis.
  107938. * The bigger this number the longer it will take for the camera to stop.
  107939. */
  107940. inertialBetaOffset: number;
  107941. /**
  107942. * Current inertia value on the radius axis.
  107943. * The bigger this number the longer it will take for the camera to stop.
  107944. */
  107945. inertialRadiusOffset: number;
  107946. /**
  107947. * Minimum allowed angle on the longitudinal axis.
  107948. * This can help limiting how the Camera is able to move in the scene.
  107949. */
  107950. lowerAlphaLimit: Nullable<number>;
  107951. /**
  107952. * Maximum allowed angle on the longitudinal axis.
  107953. * This can help limiting how the Camera is able to move in the scene.
  107954. */
  107955. upperAlphaLimit: Nullable<number>;
  107956. /**
  107957. * Minimum allowed angle on the latitudinal axis.
  107958. * This can help limiting how the Camera is able to move in the scene.
  107959. */
  107960. lowerBetaLimit: number;
  107961. /**
  107962. * Maximum allowed angle on the latitudinal axis.
  107963. * This can help limiting how the Camera is able to move in the scene.
  107964. */
  107965. upperBetaLimit: number;
  107966. /**
  107967. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  107968. * This can help limiting how the Camera is able to move in the scene.
  107969. */
  107970. lowerRadiusLimit: Nullable<number>;
  107971. /**
  107972. * Maximum allowed distance of the camera to the target (The camera can not get further).
  107973. * This can help limiting how the Camera is able to move in the scene.
  107974. */
  107975. upperRadiusLimit: Nullable<number>;
  107976. /**
  107977. * Defines the current inertia value used during panning of the camera along the X axis.
  107978. */
  107979. inertialPanningX: number;
  107980. /**
  107981. * Defines the current inertia value used during panning of the camera along the Y axis.
  107982. */
  107983. inertialPanningY: number;
  107984. /**
  107985. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  107986. * Basically if your fingers moves away from more than this distance you will be considered
  107987. * in pinch mode.
  107988. */
  107989. pinchToPanMaxDistance: number;
  107990. /**
  107991. * Defines the maximum distance the camera can pan.
  107992. * This could help keeping the cammera always in your scene.
  107993. */
  107994. panningDistanceLimit: Nullable<number>;
  107995. /**
  107996. * Defines the target of the camera before paning.
  107997. */
  107998. panningOriginTarget: Vector3;
  107999. /**
  108000. * Defines the value of the inertia used during panning.
  108001. * 0 would mean stop inertia and one would mean no decelleration at all.
  108002. */
  108003. panningInertia: number;
  108004. /**
  108005. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  108006. */
  108007. angularSensibilityX: number;
  108008. /**
  108009. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  108010. */
  108011. angularSensibilityY: number;
  108012. /**
  108013. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  108014. */
  108015. pinchPrecision: number;
  108016. /**
  108017. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  108018. * It will be used instead of pinchDeltaPrecision if different from 0.
  108019. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108020. */
  108021. pinchDeltaPercentage: number;
  108022. /**
  108023. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  108024. */
  108025. panningSensibility: number;
  108026. /**
  108027. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  108028. */
  108029. keysUp: number[];
  108030. /**
  108031. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  108032. */
  108033. keysDown: number[];
  108034. /**
  108035. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  108036. */
  108037. keysLeft: number[];
  108038. /**
  108039. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  108040. */
  108041. keysRight: number[];
  108042. /**
  108043. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108044. */
  108045. wheelPrecision: number;
  108046. /**
  108047. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  108048. * It will be used instead of pinchDeltaPrecision if different from 0.
  108049. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108050. */
  108051. wheelDeltaPercentage: number;
  108052. /**
  108053. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  108054. */
  108055. zoomOnFactor: number;
  108056. /**
  108057. * Defines a screen offset for the camera position.
  108058. */
  108059. targetScreenOffset: Vector2;
  108060. /**
  108061. * Allows the camera to be completely reversed.
  108062. * If false the camera can not arrive upside down.
  108063. */
  108064. allowUpsideDown: boolean;
  108065. /**
  108066. * Define if double tap/click is used to restore the previously saved state of the camera.
  108067. */
  108068. useInputToRestoreState: boolean;
  108069. /** @hidden */
  108070. _viewMatrix: Matrix;
  108071. /** @hidden */
  108072. _useCtrlForPanning: boolean;
  108073. /** @hidden */
  108074. _panningMouseButton: number;
  108075. /**
  108076. * Defines the input associated to the camera.
  108077. */
  108078. inputs: ArcRotateCameraInputsManager;
  108079. /** @hidden */
  108080. _reset: () => void;
  108081. /**
  108082. * Defines the allowed panning axis.
  108083. */
  108084. panningAxis: Vector3;
  108085. protected _localDirection: Vector3;
  108086. protected _transformedDirection: Vector3;
  108087. private _bouncingBehavior;
  108088. /**
  108089. * Gets the bouncing behavior of the camera if it has been enabled.
  108090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108091. */
  108092. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  108093. /**
  108094. * Defines if the bouncing behavior of the camera is enabled on the camera.
  108095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108096. */
  108097. useBouncingBehavior: boolean;
  108098. private _framingBehavior;
  108099. /**
  108100. * Gets the framing behavior of the camera if it has been enabled.
  108101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108102. */
  108103. readonly framingBehavior: Nullable<FramingBehavior>;
  108104. /**
  108105. * Defines if the framing behavior of the camera is enabled on the camera.
  108106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108107. */
  108108. useFramingBehavior: boolean;
  108109. private _autoRotationBehavior;
  108110. /**
  108111. * Gets the auto rotation behavior of the camera if it has been enabled.
  108112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  108113. */
  108114. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  108115. /**
  108116. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  108117. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  108118. */
  108119. useAutoRotationBehavior: boolean;
  108120. /**
  108121. * Observable triggered when the mesh target has been changed on the camera.
  108122. */
  108123. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  108124. /**
  108125. * Event raised when the camera is colliding with a mesh.
  108126. */
  108127. onCollide: (collidedMesh: AbstractMesh) => void;
  108128. /**
  108129. * Defines whether the camera should check collision with the objects oh the scene.
  108130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  108131. */
  108132. checkCollisions: boolean;
  108133. /**
  108134. * Defines the collision radius of the camera.
  108135. * This simulates a sphere around the camera.
  108136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108137. */
  108138. collisionRadius: Vector3;
  108139. protected _collider: Collider;
  108140. protected _previousPosition: Vector3;
  108141. protected _collisionVelocity: Vector3;
  108142. protected _newPosition: Vector3;
  108143. protected _previousAlpha: number;
  108144. protected _previousBeta: number;
  108145. protected _previousRadius: number;
  108146. protected _collisionTriggered: boolean;
  108147. protected _targetBoundingCenter: Nullable<Vector3>;
  108148. private _computationVector;
  108149. /**
  108150. * Instantiates a new ArcRotateCamera in a given scene
  108151. * @param name Defines the name of the camera
  108152. * @param alpha Defines the camera rotation along the logitudinal axis
  108153. * @param beta Defines the camera rotation along the latitudinal axis
  108154. * @param radius Defines the camera distance from its target
  108155. * @param target Defines the camera target
  108156. * @param scene Defines the scene the camera belongs to
  108157. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  108158. */
  108159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108160. /** @hidden */
  108161. _initCache(): void;
  108162. /** @hidden */
  108163. _updateCache(ignoreParentClass?: boolean): void;
  108164. protected _getTargetPosition(): Vector3;
  108165. private _storedAlpha;
  108166. private _storedBeta;
  108167. private _storedRadius;
  108168. private _storedTarget;
  108169. private _storedTargetScreenOffset;
  108170. /**
  108171. * Stores the current state of the camera (alpha, beta, radius and target)
  108172. * @returns the camera itself
  108173. */
  108174. storeState(): Camera;
  108175. /**
  108176. * @hidden
  108177. * Restored camera state. You must call storeState() first
  108178. */
  108179. _restoreStateValues(): boolean;
  108180. /** @hidden */
  108181. _isSynchronizedViewMatrix(): boolean;
  108182. /**
  108183. * Attached controls to the current camera.
  108184. * @param element Defines the element the controls should be listened from
  108185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108186. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  108187. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  108188. */
  108189. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  108190. /**
  108191. * Detach the current controls from the camera.
  108192. * The camera will stop reacting to inputs.
  108193. * @param element Defines the element to stop listening the inputs from
  108194. */
  108195. detachControl(element: HTMLElement): void;
  108196. /** @hidden */
  108197. _checkInputs(): void;
  108198. protected _checkLimits(): void;
  108199. /**
  108200. * Rebuilds angles (alpha, beta) and radius from the give position and target
  108201. */
  108202. rebuildAnglesAndRadius(): void;
  108203. /**
  108204. * Use a position to define the current camera related information like alpha, beta and radius
  108205. * @param position Defines the position to set the camera at
  108206. */
  108207. setPosition(position: Vector3): void;
  108208. /**
  108209. * Defines the target the camera should look at.
  108210. * This will automatically adapt alpha beta and radius to fit within the new target.
  108211. * @param target Defines the new target as a Vector or a mesh
  108212. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  108213. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  108214. */
  108215. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  108216. /** @hidden */
  108217. _getViewMatrix(): Matrix;
  108218. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  108219. /**
  108220. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  108221. * @param meshes Defines the mesh to zoom on
  108222. * @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)
  108223. */
  108224. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  108225. /**
  108226. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  108227. * The target will be changed but the radius
  108228. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  108229. * @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)
  108230. */
  108231. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  108232. min: Vector3;
  108233. max: Vector3;
  108234. distance: number;
  108235. }, doNotUpdateMaxZ?: boolean): void;
  108236. /**
  108237. * @override
  108238. * Override Camera.createRigCamera
  108239. */
  108240. createRigCamera(name: string, cameraIndex: number): Camera;
  108241. /**
  108242. * @hidden
  108243. * @override
  108244. * Override Camera._updateRigCameras
  108245. */
  108246. _updateRigCameras(): void;
  108247. /**
  108248. * Destroy the camera and release the current resources hold by it.
  108249. */
  108250. dispose(): void;
  108251. /**
  108252. * Gets the current object class name.
  108253. * @return the class name
  108254. */
  108255. getClassName(): string;
  108256. }
  108257. }
  108258. declare module BABYLON {
  108259. /**
  108260. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  108261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  108262. */
  108263. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  108264. /**
  108265. * Gets the name of the behavior.
  108266. */
  108267. readonly name: string;
  108268. private _zoomStopsAnimation;
  108269. private _idleRotationSpeed;
  108270. private _idleRotationWaitTime;
  108271. private _idleRotationSpinupTime;
  108272. /**
  108273. * Sets the flag that indicates if user zooming should stop animation.
  108274. */
  108275. /**
  108276. * Gets the flag that indicates if user zooming should stop animation.
  108277. */
  108278. zoomStopsAnimation: boolean;
  108279. /**
  108280. * Sets the default speed at which the camera rotates around the model.
  108281. */
  108282. /**
  108283. * Gets the default speed at which the camera rotates around the model.
  108284. */
  108285. idleRotationSpeed: number;
  108286. /**
  108287. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  108288. */
  108289. /**
  108290. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  108291. */
  108292. idleRotationWaitTime: number;
  108293. /**
  108294. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  108295. */
  108296. /**
  108297. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  108298. */
  108299. idleRotationSpinupTime: number;
  108300. /**
  108301. * Gets a value indicating if the camera is currently rotating because of this behavior
  108302. */
  108303. readonly rotationInProgress: boolean;
  108304. private _onPrePointerObservableObserver;
  108305. private _onAfterCheckInputsObserver;
  108306. private _attachedCamera;
  108307. private _isPointerDown;
  108308. private _lastFrameTime;
  108309. private _lastInteractionTime;
  108310. private _cameraRotationSpeed;
  108311. /**
  108312. * Initializes the behavior.
  108313. */
  108314. init(): void;
  108315. /**
  108316. * Attaches the behavior to its arc rotate camera.
  108317. * @param camera Defines the camera to attach the behavior to
  108318. */
  108319. attach(camera: ArcRotateCamera): void;
  108320. /**
  108321. * Detaches the behavior from its current arc rotate camera.
  108322. */
  108323. detach(): void;
  108324. /**
  108325. * Returns true if user is scrolling.
  108326. * @return true if user is scrolling.
  108327. */
  108328. private _userIsZooming;
  108329. private _lastFrameRadius;
  108330. private _shouldAnimationStopForInteraction;
  108331. /**
  108332. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108333. */
  108334. private _applyUserInteraction;
  108335. private _userIsMoving;
  108336. }
  108337. }
  108338. declare module BABYLON {
  108339. /**
  108340. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  108341. */
  108342. export class AttachToBoxBehavior implements Behavior<Mesh> {
  108343. private ui;
  108344. /**
  108345. * The name of the behavior
  108346. */
  108347. name: string;
  108348. /**
  108349. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  108350. */
  108351. distanceAwayFromFace: number;
  108352. /**
  108353. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  108354. */
  108355. distanceAwayFromBottomOfFace: number;
  108356. private _faceVectors;
  108357. private _target;
  108358. private _scene;
  108359. private _onRenderObserver;
  108360. private _tmpMatrix;
  108361. private _tmpVector;
  108362. /**
  108363. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  108364. * @param ui The transform node that should be attched to the mesh
  108365. */
  108366. constructor(ui: TransformNode);
  108367. /**
  108368. * Initializes the behavior
  108369. */
  108370. init(): void;
  108371. private _closestFace;
  108372. private _zeroVector;
  108373. private _lookAtTmpMatrix;
  108374. private _lookAtToRef;
  108375. /**
  108376. * Attaches the AttachToBoxBehavior to the passed in mesh
  108377. * @param target The mesh that the specified node will be attached to
  108378. */
  108379. attach(target: Mesh): void;
  108380. /**
  108381. * Detaches the behavior from the mesh
  108382. */
  108383. detach(): void;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  108389. */
  108390. export class FadeInOutBehavior implements Behavior<Mesh> {
  108391. /**
  108392. * Time in milliseconds to delay before fading in (Default: 0)
  108393. */
  108394. delay: number;
  108395. /**
  108396. * Time in milliseconds for the mesh to fade in (Default: 300)
  108397. */
  108398. fadeInTime: number;
  108399. private _millisecondsPerFrame;
  108400. private _hovered;
  108401. private _hoverValue;
  108402. private _ownerNode;
  108403. /**
  108404. * Instatiates the FadeInOutBehavior
  108405. */
  108406. constructor();
  108407. /**
  108408. * The name of the behavior
  108409. */
  108410. readonly name: string;
  108411. /**
  108412. * Initializes the behavior
  108413. */
  108414. init(): void;
  108415. /**
  108416. * Attaches the fade behavior on the passed in mesh
  108417. * @param ownerNode The mesh that will be faded in/out once attached
  108418. */
  108419. attach(ownerNode: Mesh): void;
  108420. /**
  108421. * Detaches the behavior from the mesh
  108422. */
  108423. detach(): void;
  108424. /**
  108425. * Triggers the mesh to begin fading in or out
  108426. * @param value if the object should fade in or out (true to fade in)
  108427. */
  108428. fadeIn(value: boolean): void;
  108429. private _update;
  108430. private _setAllVisibility;
  108431. }
  108432. }
  108433. declare module BABYLON {
  108434. /**
  108435. * Class containing a set of static utilities functions for managing Pivots
  108436. * @hidden
  108437. */
  108438. export class PivotTools {
  108439. private static _PivotCached;
  108440. private static _OldPivotPoint;
  108441. private static _PivotTranslation;
  108442. private static _PivotTmpVector;
  108443. /** @hidden */
  108444. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  108445. /** @hidden */
  108446. static _RestorePivotPoint(mesh: AbstractMesh): void;
  108447. }
  108448. }
  108449. declare module BABYLON {
  108450. /**
  108451. * Class containing static functions to help procedurally build meshes
  108452. */
  108453. export class PlaneBuilder {
  108454. /**
  108455. * Creates a plane mesh
  108456. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  108457. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  108458. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  108459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108462. * @param name defines the name of the mesh
  108463. * @param options defines the options used to create the mesh
  108464. * @param scene defines the hosting scene
  108465. * @returns the plane mesh
  108466. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  108467. */
  108468. static CreatePlane(name: string, options: {
  108469. size?: number;
  108470. width?: number;
  108471. height?: number;
  108472. sideOrientation?: number;
  108473. frontUVs?: Vector4;
  108474. backUVs?: Vector4;
  108475. updatable?: boolean;
  108476. sourcePlane?: Plane;
  108477. }, scene?: Nullable<Scene>): Mesh;
  108478. }
  108479. }
  108480. declare module BABYLON {
  108481. /**
  108482. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  108483. */
  108484. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  108485. private static _AnyMouseID;
  108486. /**
  108487. * Abstract mesh the behavior is set on
  108488. */
  108489. attachedNode: AbstractMesh;
  108490. private _dragPlane;
  108491. private _scene;
  108492. private _pointerObserver;
  108493. private _beforeRenderObserver;
  108494. private static _planeScene;
  108495. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  108496. /**
  108497. * 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)
  108498. */
  108499. maxDragAngle: number;
  108500. /**
  108501. * @hidden
  108502. */
  108503. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  108504. /**
  108505. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  108506. */
  108507. currentDraggingPointerID: number;
  108508. /**
  108509. * The last position where the pointer hit the drag plane in world space
  108510. */
  108511. lastDragPosition: Vector3;
  108512. /**
  108513. * If the behavior is currently in a dragging state
  108514. */
  108515. dragging: boolean;
  108516. /**
  108517. * 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)
  108518. */
  108519. dragDeltaRatio: number;
  108520. /**
  108521. * If the drag plane orientation should be updated during the dragging (Default: true)
  108522. */
  108523. updateDragPlane: boolean;
  108524. private _debugMode;
  108525. private _moving;
  108526. /**
  108527. * Fires each time the attached mesh is dragged with the pointer
  108528. * * delta between last drag position and current drag position in world space
  108529. * * dragDistance along the drag axis
  108530. * * dragPlaneNormal normal of the current drag plane used during the drag
  108531. * * dragPlanePoint in world space where the drag intersects the drag plane
  108532. */
  108533. onDragObservable: Observable<{
  108534. delta: Vector3;
  108535. dragPlanePoint: Vector3;
  108536. dragPlaneNormal: Vector3;
  108537. dragDistance: number;
  108538. pointerId: number;
  108539. }>;
  108540. /**
  108541. * Fires each time a drag begins (eg. mouse down on mesh)
  108542. */
  108543. onDragStartObservable: Observable<{
  108544. dragPlanePoint: Vector3;
  108545. pointerId: number;
  108546. }>;
  108547. /**
  108548. * Fires each time a drag ends (eg. mouse release after drag)
  108549. */
  108550. onDragEndObservable: Observable<{
  108551. dragPlanePoint: Vector3;
  108552. pointerId: number;
  108553. }>;
  108554. /**
  108555. * If the attached mesh should be moved when dragged
  108556. */
  108557. moveAttached: boolean;
  108558. /**
  108559. * If the drag behavior will react to drag events (Default: true)
  108560. */
  108561. enabled: boolean;
  108562. /**
  108563. * If pointer events should start and release the drag (Default: true)
  108564. */
  108565. startAndReleaseDragOnPointerEvents: boolean;
  108566. /**
  108567. * If camera controls should be detached during the drag
  108568. */
  108569. detachCameraControls: boolean;
  108570. /**
  108571. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  108572. */
  108573. useObjectOrienationForDragging: boolean;
  108574. private _options;
  108575. /**
  108576. * Gets the options used by the behavior
  108577. */
  108578. /**
  108579. * Sets the options used by the behavior
  108580. */
  108581. options: {
  108582. dragAxis?: Vector3;
  108583. dragPlaneNormal?: Vector3;
  108584. };
  108585. /**
  108586. * Creates a pointer drag behavior that can be attached to a mesh
  108587. * @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)
  108588. */
  108589. constructor(options?: {
  108590. dragAxis?: Vector3;
  108591. dragPlaneNormal?: Vector3;
  108592. });
  108593. /**
  108594. * Predicate to determine if it is valid to move the object to a new position when it is moved
  108595. */
  108596. validateDrag: (targetPosition: Vector3) => boolean;
  108597. /**
  108598. * The name of the behavior
  108599. */
  108600. readonly name: string;
  108601. /**
  108602. * Initializes the behavior
  108603. */
  108604. init(): void;
  108605. private _tmpVector;
  108606. private _alternatePickedPoint;
  108607. private _worldDragAxis;
  108608. private _targetPosition;
  108609. private _attachedElement;
  108610. /**
  108611. * Attaches the drag behavior the passed in mesh
  108612. * @param ownerNode The mesh that will be dragged around once attached
  108613. * @param predicate Predicate to use for pick filtering
  108614. */
  108615. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  108616. /**
  108617. * Force relase the drag action by code.
  108618. */
  108619. releaseDrag(): void;
  108620. private _startDragRay;
  108621. private _lastPointerRay;
  108622. /**
  108623. * Simulates the start of a pointer drag event on the behavior
  108624. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  108625. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  108626. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  108627. */
  108628. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  108629. private _startDrag;
  108630. private _dragDelta;
  108631. private _moveDrag;
  108632. private _pickWithRayOnDragPlane;
  108633. private _pointA;
  108634. private _pointB;
  108635. private _pointC;
  108636. private _lineA;
  108637. private _lineB;
  108638. private _localAxis;
  108639. private _lookAt;
  108640. private _updateDragPlanePosition;
  108641. /**
  108642. * Detaches the behavior from the mesh
  108643. */
  108644. detach(): void;
  108645. }
  108646. }
  108647. declare module BABYLON {
  108648. /**
  108649. * A behavior that when attached to a mesh will allow the mesh to be scaled
  108650. */
  108651. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  108652. private _dragBehaviorA;
  108653. private _dragBehaviorB;
  108654. private _startDistance;
  108655. private _initialScale;
  108656. private _targetScale;
  108657. private _ownerNode;
  108658. private _sceneRenderObserver;
  108659. /**
  108660. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  108661. */
  108662. constructor();
  108663. /**
  108664. * The name of the behavior
  108665. */
  108666. readonly name: string;
  108667. /**
  108668. * Initializes the behavior
  108669. */
  108670. init(): void;
  108671. private _getCurrentDistance;
  108672. /**
  108673. * Attaches the scale behavior the passed in mesh
  108674. * @param ownerNode The mesh that will be scaled around once attached
  108675. */
  108676. attach(ownerNode: Mesh): void;
  108677. /**
  108678. * Detaches the behavior from the mesh
  108679. */
  108680. detach(): void;
  108681. }
  108682. }
  108683. declare module BABYLON {
  108684. /**
  108685. * 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
  108686. */
  108687. export class SixDofDragBehavior implements Behavior<Mesh> {
  108688. private static _virtualScene;
  108689. private _ownerNode;
  108690. private _sceneRenderObserver;
  108691. private _scene;
  108692. private _targetPosition;
  108693. private _virtualOriginMesh;
  108694. private _virtualDragMesh;
  108695. private _pointerObserver;
  108696. private _moving;
  108697. private _startingOrientation;
  108698. /**
  108699. * 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)
  108700. */
  108701. private zDragFactor;
  108702. /**
  108703. * If the object should rotate to face the drag origin
  108704. */
  108705. rotateDraggedObject: boolean;
  108706. /**
  108707. * If the behavior is currently in a dragging state
  108708. */
  108709. dragging: boolean;
  108710. /**
  108711. * 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)
  108712. */
  108713. dragDeltaRatio: number;
  108714. /**
  108715. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  108716. */
  108717. currentDraggingPointerID: number;
  108718. /**
  108719. * If camera controls should be detached during the drag
  108720. */
  108721. detachCameraControls: boolean;
  108722. /**
  108723. * Fires each time a drag starts
  108724. */
  108725. onDragStartObservable: Observable<{}>;
  108726. /**
  108727. * Fires each time a drag ends (eg. mouse release after drag)
  108728. */
  108729. onDragEndObservable: Observable<{}>;
  108730. /**
  108731. * 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
  108732. */
  108733. constructor();
  108734. /**
  108735. * The name of the behavior
  108736. */
  108737. readonly name: string;
  108738. /**
  108739. * Initializes the behavior
  108740. */
  108741. init(): void;
  108742. /**
  108743. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  108744. */
  108745. private readonly _pointerCamera;
  108746. /**
  108747. * Attaches the scale behavior the passed in mesh
  108748. * @param ownerNode The mesh that will be scaled around once attached
  108749. */
  108750. attach(ownerNode: Mesh): void;
  108751. /**
  108752. * Detaches the behavior from the mesh
  108753. */
  108754. detach(): void;
  108755. }
  108756. }
  108757. declare module BABYLON {
  108758. /**
  108759. * Class used to apply inverse kinematics to bones
  108760. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  108761. */
  108762. export class BoneIKController {
  108763. private static _tmpVecs;
  108764. private static _tmpQuat;
  108765. private static _tmpMats;
  108766. /**
  108767. * Gets or sets the target mesh
  108768. */
  108769. targetMesh: AbstractMesh;
  108770. /** Gets or sets the mesh used as pole */
  108771. poleTargetMesh: AbstractMesh;
  108772. /**
  108773. * Gets or sets the bone used as pole
  108774. */
  108775. poleTargetBone: Nullable<Bone>;
  108776. /**
  108777. * Gets or sets the target position
  108778. */
  108779. targetPosition: Vector3;
  108780. /**
  108781. * Gets or sets the pole target position
  108782. */
  108783. poleTargetPosition: Vector3;
  108784. /**
  108785. * Gets or sets the pole target local offset
  108786. */
  108787. poleTargetLocalOffset: Vector3;
  108788. /**
  108789. * Gets or sets the pole angle
  108790. */
  108791. poleAngle: number;
  108792. /**
  108793. * Gets or sets the mesh associated with the controller
  108794. */
  108795. mesh: AbstractMesh;
  108796. /**
  108797. * 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)
  108798. */
  108799. slerpAmount: number;
  108800. private _bone1Quat;
  108801. private _bone1Mat;
  108802. private _bone2Ang;
  108803. private _bone1;
  108804. private _bone2;
  108805. private _bone1Length;
  108806. private _bone2Length;
  108807. private _maxAngle;
  108808. private _maxReach;
  108809. private _rightHandedSystem;
  108810. private _bendAxis;
  108811. private _slerping;
  108812. private _adjustRoll;
  108813. /**
  108814. * Gets or sets maximum allowed angle
  108815. */
  108816. maxAngle: number;
  108817. /**
  108818. * Creates a new BoneIKController
  108819. * @param mesh defines the mesh to control
  108820. * @param bone defines the bone to control
  108821. * @param options defines options to set up the controller
  108822. */
  108823. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  108824. targetMesh?: AbstractMesh;
  108825. poleTargetMesh?: AbstractMesh;
  108826. poleTargetBone?: Bone;
  108827. poleTargetLocalOffset?: Vector3;
  108828. poleAngle?: number;
  108829. bendAxis?: Vector3;
  108830. maxAngle?: number;
  108831. slerpAmount?: number;
  108832. });
  108833. private _setMaxAngle;
  108834. /**
  108835. * Force the controller to update the bones
  108836. */
  108837. update(): void;
  108838. }
  108839. }
  108840. declare module BABYLON {
  108841. /**
  108842. * Class used to make a bone look toward a point in space
  108843. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  108844. */
  108845. export class BoneLookController {
  108846. private static _tmpVecs;
  108847. private static _tmpQuat;
  108848. private static _tmpMats;
  108849. /**
  108850. * The target Vector3 that the bone will look at
  108851. */
  108852. target: Vector3;
  108853. /**
  108854. * The mesh that the bone is attached to
  108855. */
  108856. mesh: AbstractMesh;
  108857. /**
  108858. * The bone that will be looking to the target
  108859. */
  108860. bone: Bone;
  108861. /**
  108862. * The up axis of the coordinate system that is used when the bone is rotated
  108863. */
  108864. upAxis: Vector3;
  108865. /**
  108866. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  108867. */
  108868. upAxisSpace: Space;
  108869. /**
  108870. * Used to make an adjustment to the yaw of the bone
  108871. */
  108872. adjustYaw: number;
  108873. /**
  108874. * Used to make an adjustment to the pitch of the bone
  108875. */
  108876. adjustPitch: number;
  108877. /**
  108878. * Used to make an adjustment to the roll of the bone
  108879. */
  108880. adjustRoll: number;
  108881. /**
  108882. * 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)
  108883. */
  108884. slerpAmount: number;
  108885. private _minYaw;
  108886. private _maxYaw;
  108887. private _minPitch;
  108888. private _maxPitch;
  108889. private _minYawSin;
  108890. private _minYawCos;
  108891. private _maxYawSin;
  108892. private _maxYawCos;
  108893. private _midYawConstraint;
  108894. private _minPitchTan;
  108895. private _maxPitchTan;
  108896. private _boneQuat;
  108897. private _slerping;
  108898. private _transformYawPitch;
  108899. private _transformYawPitchInv;
  108900. private _firstFrameSkipped;
  108901. private _yawRange;
  108902. private _fowardAxis;
  108903. /**
  108904. * Gets or sets the minimum yaw angle that the bone can look to
  108905. */
  108906. minYaw: number;
  108907. /**
  108908. * Gets or sets the maximum yaw angle that the bone can look to
  108909. */
  108910. maxYaw: number;
  108911. /**
  108912. * Gets or sets the minimum pitch angle that the bone can look to
  108913. */
  108914. minPitch: number;
  108915. /**
  108916. * Gets or sets the maximum pitch angle that the bone can look to
  108917. */
  108918. maxPitch: number;
  108919. /**
  108920. * Create a BoneLookController
  108921. * @param mesh the mesh that the bone belongs to
  108922. * @param bone the bone that will be looking to the target
  108923. * @param target the target Vector3 to look at
  108924. * @param options optional settings:
  108925. * * maxYaw: the maximum angle the bone will yaw to
  108926. * * minYaw: the minimum angle the bone will yaw to
  108927. * * maxPitch: the maximum angle the bone will pitch to
  108928. * * minPitch: the minimum angle the bone will yaw to
  108929. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  108930. * * upAxis: the up axis of the coordinate system
  108931. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  108932. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  108933. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  108934. * * adjustYaw: used to make an adjustment to the yaw of the bone
  108935. * * adjustPitch: used to make an adjustment to the pitch of the bone
  108936. * * adjustRoll: used to make an adjustment to the roll of the bone
  108937. **/
  108938. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  108939. maxYaw?: number;
  108940. minYaw?: number;
  108941. maxPitch?: number;
  108942. minPitch?: number;
  108943. slerpAmount?: number;
  108944. upAxis?: Vector3;
  108945. upAxisSpace?: Space;
  108946. yawAxis?: Vector3;
  108947. pitchAxis?: Vector3;
  108948. adjustYaw?: number;
  108949. adjustPitch?: number;
  108950. adjustRoll?: number;
  108951. });
  108952. /**
  108953. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  108954. */
  108955. update(): void;
  108956. private _getAngleDiff;
  108957. private _getAngleBetween;
  108958. private _isAngleBetween;
  108959. }
  108960. }
  108961. declare module BABYLON {
  108962. /**
  108963. * Manage the gamepad inputs to control an arc rotate camera.
  108964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108965. */
  108966. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  108967. /**
  108968. * Defines the camera the input is attached to.
  108969. */
  108970. camera: ArcRotateCamera;
  108971. /**
  108972. * Defines the gamepad the input is gathering event from.
  108973. */
  108974. gamepad: Nullable<Gamepad>;
  108975. /**
  108976. * Defines the gamepad rotation sensiblity.
  108977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108978. */
  108979. gamepadRotationSensibility: number;
  108980. /**
  108981. * Defines the gamepad move sensiblity.
  108982. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108983. */
  108984. gamepadMoveSensibility: number;
  108985. private _yAxisScale;
  108986. /**
  108987. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108988. */
  108989. invertYAxis: boolean;
  108990. private _onGamepadConnectedObserver;
  108991. private _onGamepadDisconnectedObserver;
  108992. /**
  108993. * Attach the input controls to a specific dom element to get the input from.
  108994. * @param element Defines the element the controls should be listened from
  108995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108996. */
  108997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108998. /**
  108999. * Detach the current controls from the specified dom element.
  109000. * @param element Defines the element to stop listening the inputs from
  109001. */
  109002. detachControl(element: Nullable<HTMLElement>): void;
  109003. /**
  109004. * Update the current camera state depending on the inputs that have been used this frame.
  109005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109006. */
  109007. checkInputs(): void;
  109008. /**
  109009. * Gets the class name of the current intput.
  109010. * @returns the class name
  109011. */
  109012. getClassName(): string;
  109013. /**
  109014. * Get the friendly name associated with the input class.
  109015. * @returns the input friendly name
  109016. */
  109017. getSimpleName(): string;
  109018. }
  109019. }
  109020. declare module BABYLON {
  109021. interface ArcRotateCameraInputsManager {
  109022. /**
  109023. * Add orientation input support to the input manager.
  109024. * @returns the current input manager
  109025. */
  109026. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  109027. }
  109028. /**
  109029. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  109030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109031. */
  109032. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  109033. /**
  109034. * Defines the camera the input is attached to.
  109035. */
  109036. camera: ArcRotateCamera;
  109037. /**
  109038. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  109039. */
  109040. alphaCorrection: number;
  109041. /**
  109042. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  109043. */
  109044. gammaCorrection: number;
  109045. private _alpha;
  109046. private _gamma;
  109047. private _dirty;
  109048. private _deviceOrientationHandler;
  109049. /**
  109050. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  109051. */
  109052. constructor();
  109053. /**
  109054. * Attach the input controls to a specific dom element to get the input from.
  109055. * @param element Defines the element the controls should be listened from
  109056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109057. */
  109058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109059. /** @hidden */
  109060. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  109061. /**
  109062. * Update the current camera state depending on the inputs that have been used this frame.
  109063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109064. */
  109065. checkInputs(): void;
  109066. /**
  109067. * Detach the current controls from the specified dom element.
  109068. * @param element Defines the element to stop listening the inputs from
  109069. */
  109070. detachControl(element: Nullable<HTMLElement>): void;
  109071. /**
  109072. * Gets the class name of the current intput.
  109073. * @returns the class name
  109074. */
  109075. getClassName(): string;
  109076. /**
  109077. * Get the friendly name associated with the input class.
  109078. * @returns the input friendly name
  109079. */
  109080. getSimpleName(): string;
  109081. }
  109082. }
  109083. declare module BABYLON {
  109084. /**
  109085. * Listen to mouse events to control the camera.
  109086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109087. */
  109088. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  109089. /**
  109090. * Defines the camera the input is attached to.
  109091. */
  109092. camera: FlyCamera;
  109093. /**
  109094. * Defines if touch is enabled. (Default is true.)
  109095. */
  109096. touchEnabled: boolean;
  109097. /**
  109098. * Defines the buttons associated with the input to handle camera rotation.
  109099. */
  109100. buttons: number[];
  109101. /**
  109102. * Assign buttons for Yaw control.
  109103. */
  109104. buttonsYaw: number[];
  109105. /**
  109106. * Assign buttons for Pitch control.
  109107. */
  109108. buttonsPitch: number[];
  109109. /**
  109110. * Assign buttons for Roll control.
  109111. */
  109112. buttonsRoll: number[];
  109113. /**
  109114. * Detect if any button is being pressed while mouse is moved.
  109115. * -1 = Mouse locked.
  109116. * 0 = Left button.
  109117. * 1 = Middle Button.
  109118. * 2 = Right Button.
  109119. */
  109120. activeButton: number;
  109121. /**
  109122. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  109123. * Higher values reduce its sensitivity.
  109124. */
  109125. angularSensibility: number;
  109126. private _mousemoveCallback;
  109127. private _observer;
  109128. private _rollObserver;
  109129. private previousPosition;
  109130. private noPreventDefault;
  109131. private element;
  109132. /**
  109133. * Listen to mouse events to control the camera.
  109134. * @param touchEnabled Define if touch is enabled. (Default is true.)
  109135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109136. */
  109137. constructor(touchEnabled?: boolean);
  109138. /**
  109139. * Attach the mouse control to the HTML DOM element.
  109140. * @param element Defines the element that listens to the input events.
  109141. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  109142. */
  109143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109144. /**
  109145. * Detach the current controls from the specified dom element.
  109146. * @param element Defines the element to stop listening the inputs from
  109147. */
  109148. detachControl(element: Nullable<HTMLElement>): void;
  109149. /**
  109150. * Gets the class name of the current input.
  109151. * @returns the class name.
  109152. */
  109153. getClassName(): string;
  109154. /**
  109155. * Get the friendly name associated with the input class.
  109156. * @returns the input's friendly name.
  109157. */
  109158. getSimpleName(): string;
  109159. private _pointerInput;
  109160. private _onMouseMove;
  109161. /**
  109162. * Rotate camera by mouse offset.
  109163. */
  109164. private rotateCamera;
  109165. }
  109166. }
  109167. declare module BABYLON {
  109168. /**
  109169. * Default Inputs manager for the FlyCamera.
  109170. * It groups all the default supported inputs for ease of use.
  109171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109172. */
  109173. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  109174. /**
  109175. * Instantiates a new FlyCameraInputsManager.
  109176. * @param camera Defines the camera the inputs belong to.
  109177. */
  109178. constructor(camera: FlyCamera);
  109179. /**
  109180. * Add keyboard input support to the input manager.
  109181. * @returns the new FlyCameraKeyboardMoveInput().
  109182. */
  109183. addKeyboard(): FlyCameraInputsManager;
  109184. /**
  109185. * Add mouse input support to the input manager.
  109186. * @param touchEnabled Enable touch screen support.
  109187. * @returns the new FlyCameraMouseInput().
  109188. */
  109189. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  109190. }
  109191. }
  109192. declare module BABYLON {
  109193. /**
  109194. * This is a flying camera, designed for 3D movement and rotation in all directions,
  109195. * such as in a 3D Space Shooter or a Flight Simulator.
  109196. */
  109197. export class FlyCamera extends TargetCamera {
  109198. /**
  109199. * Define the collision ellipsoid of the camera.
  109200. * This is helpful for simulating a camera body, like a player's body.
  109201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109202. */
  109203. ellipsoid: Vector3;
  109204. /**
  109205. * Define an offset for the position of the ellipsoid around the camera.
  109206. * This can be helpful if the camera is attached away from the player's body center,
  109207. * such as at its head.
  109208. */
  109209. ellipsoidOffset: Vector3;
  109210. /**
  109211. * Enable or disable collisions of the camera with the rest of the scene objects.
  109212. */
  109213. checkCollisions: boolean;
  109214. /**
  109215. * Enable or disable gravity on the camera.
  109216. */
  109217. applyGravity: boolean;
  109218. /**
  109219. * Define the current direction the camera is moving to.
  109220. */
  109221. cameraDirection: Vector3;
  109222. /**
  109223. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  109224. * This overrides and empties cameraRotation.
  109225. */
  109226. rotationQuaternion: Quaternion;
  109227. /**
  109228. * Track Roll to maintain the wanted Rolling when looking around.
  109229. */
  109230. _trackRoll: number;
  109231. /**
  109232. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  109233. */
  109234. rollCorrect: number;
  109235. /**
  109236. * Mimic a banked turn, Rolling the camera when Yawing.
  109237. * It's recommended to use rollCorrect = 10 for faster banking correction.
  109238. */
  109239. bankedTurn: boolean;
  109240. /**
  109241. * Limit in radians for how much Roll banking will add. (Default: 90°)
  109242. */
  109243. bankedTurnLimit: number;
  109244. /**
  109245. * Value of 0 disables the banked Roll.
  109246. * Value of 1 is equal to the Yaw angle in radians.
  109247. */
  109248. bankedTurnMultiplier: number;
  109249. /**
  109250. * The inputs manager loads all the input sources, such as keyboard and mouse.
  109251. */
  109252. inputs: FlyCameraInputsManager;
  109253. /**
  109254. * Gets the input sensibility for mouse input.
  109255. * Higher values reduce sensitivity.
  109256. */
  109257. /**
  109258. * Sets the input sensibility for a mouse input.
  109259. * Higher values reduce sensitivity.
  109260. */
  109261. angularSensibility: number;
  109262. /**
  109263. * Get the keys for camera movement forward.
  109264. */
  109265. /**
  109266. * Set the keys for camera movement forward.
  109267. */
  109268. keysForward: number[];
  109269. /**
  109270. * Get the keys for camera movement backward.
  109271. */
  109272. keysBackward: number[];
  109273. /**
  109274. * Get the keys for camera movement up.
  109275. */
  109276. /**
  109277. * Set the keys for camera movement up.
  109278. */
  109279. keysUp: number[];
  109280. /**
  109281. * Get the keys for camera movement down.
  109282. */
  109283. /**
  109284. * Set the keys for camera movement down.
  109285. */
  109286. keysDown: number[];
  109287. /**
  109288. * Get the keys for camera movement left.
  109289. */
  109290. /**
  109291. * Set the keys for camera movement left.
  109292. */
  109293. keysLeft: number[];
  109294. /**
  109295. * Set the keys for camera movement right.
  109296. */
  109297. /**
  109298. * Set the keys for camera movement right.
  109299. */
  109300. keysRight: number[];
  109301. /**
  109302. * Event raised when the camera collides with a mesh in the scene.
  109303. */
  109304. onCollide: (collidedMesh: AbstractMesh) => void;
  109305. private _collider;
  109306. private _needMoveForGravity;
  109307. private _oldPosition;
  109308. private _diffPosition;
  109309. private _newPosition;
  109310. /** @hidden */
  109311. _localDirection: Vector3;
  109312. /** @hidden */
  109313. _transformedDirection: Vector3;
  109314. /**
  109315. * Instantiates a FlyCamera.
  109316. * This is a flying camera, designed for 3D movement and rotation in all directions,
  109317. * such as in a 3D Space Shooter or a Flight Simulator.
  109318. * @param name Define the name of the camera in the scene.
  109319. * @param position Define the starting position of the camera in the scene.
  109320. * @param scene Define the scene the camera belongs to.
  109321. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  109322. */
  109323. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109324. /**
  109325. * Attach a control to the HTML DOM element.
  109326. * @param element Defines the element that listens to the input events.
  109327. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  109328. */
  109329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109330. /**
  109331. * Detach a control from the HTML DOM element.
  109332. * The camera will stop reacting to that input.
  109333. * @param element Defines the element that listens to the input events.
  109334. */
  109335. detachControl(element: HTMLElement): void;
  109336. private _collisionMask;
  109337. /**
  109338. * Get the mask that the camera ignores in collision events.
  109339. */
  109340. /**
  109341. * Set the mask that the camera ignores in collision events.
  109342. */
  109343. collisionMask: number;
  109344. /** @hidden */
  109345. _collideWithWorld(displacement: Vector3): void;
  109346. /** @hidden */
  109347. private _onCollisionPositionChange;
  109348. /** @hidden */
  109349. _checkInputs(): void;
  109350. /** @hidden */
  109351. _decideIfNeedsToMove(): boolean;
  109352. /** @hidden */
  109353. _updatePosition(): void;
  109354. /**
  109355. * Restore the Roll to its target value at the rate specified.
  109356. * @param rate - Higher means slower restoring.
  109357. * @hidden
  109358. */
  109359. restoreRoll(rate: number): void;
  109360. /**
  109361. * Destroy the camera and release the current resources held by it.
  109362. */
  109363. dispose(): void;
  109364. /**
  109365. * Get the current object class name.
  109366. * @returns the class name.
  109367. */
  109368. getClassName(): string;
  109369. }
  109370. }
  109371. declare module BABYLON {
  109372. /**
  109373. * Listen to keyboard events to control the camera.
  109374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109375. */
  109376. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  109377. /**
  109378. * Defines the camera the input is attached to.
  109379. */
  109380. camera: FlyCamera;
  109381. /**
  109382. * The list of keyboard keys used to control the forward move of the camera.
  109383. */
  109384. keysForward: number[];
  109385. /**
  109386. * The list of keyboard keys used to control the backward move of the camera.
  109387. */
  109388. keysBackward: number[];
  109389. /**
  109390. * The list of keyboard keys used to control the forward move of the camera.
  109391. */
  109392. keysUp: number[];
  109393. /**
  109394. * The list of keyboard keys used to control the backward move of the camera.
  109395. */
  109396. keysDown: number[];
  109397. /**
  109398. * The list of keyboard keys used to control the right strafe move of the camera.
  109399. */
  109400. keysRight: number[];
  109401. /**
  109402. * The list of keyboard keys used to control the left strafe move of the camera.
  109403. */
  109404. keysLeft: number[];
  109405. private _keys;
  109406. private _onCanvasBlurObserver;
  109407. private _onKeyboardObserver;
  109408. private _engine;
  109409. private _scene;
  109410. /**
  109411. * Attach the input controls to a specific dom element to get the input from.
  109412. * @param element Defines the element the controls should be listened from
  109413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109414. */
  109415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109416. /**
  109417. * Detach the current controls from the specified dom element.
  109418. * @param element Defines the element to stop listening the inputs from
  109419. */
  109420. detachControl(element: Nullable<HTMLElement>): void;
  109421. /**
  109422. * Gets the class name of the current intput.
  109423. * @returns the class name
  109424. */
  109425. getClassName(): string;
  109426. /** @hidden */
  109427. _onLostFocus(e: FocusEvent): void;
  109428. /**
  109429. * Get the friendly name associated with the input class.
  109430. * @returns the input friendly name
  109431. */
  109432. getSimpleName(): string;
  109433. /**
  109434. * Update the current camera state depending on the inputs that have been used this frame.
  109435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109436. */
  109437. checkInputs(): void;
  109438. }
  109439. }
  109440. declare module BABYLON {
  109441. /**
  109442. * Manage the mouse wheel inputs to control a follow camera.
  109443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109444. */
  109445. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  109446. /**
  109447. * Defines the camera the input is attached to.
  109448. */
  109449. camera: FollowCamera;
  109450. /**
  109451. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  109452. */
  109453. axisControlRadius: boolean;
  109454. /**
  109455. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  109456. */
  109457. axisControlHeight: boolean;
  109458. /**
  109459. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  109460. */
  109461. axisControlRotation: boolean;
  109462. /**
  109463. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  109464. * relation to mouseWheel events.
  109465. */
  109466. wheelPrecision: number;
  109467. /**
  109468. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  109469. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  109470. */
  109471. wheelDeltaPercentage: number;
  109472. private _wheel;
  109473. private _observer;
  109474. /**
  109475. * Attach the input controls to a specific dom element to get the input from.
  109476. * @param element Defines the element the controls should be listened from
  109477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109478. */
  109479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109480. /**
  109481. * Detach the current controls from the specified dom element.
  109482. * @param element Defines the element to stop listening the inputs from
  109483. */
  109484. detachControl(element: Nullable<HTMLElement>): void;
  109485. /**
  109486. * Gets the class name of the current intput.
  109487. * @returns the class name
  109488. */
  109489. getClassName(): string;
  109490. /**
  109491. * Get the friendly name associated with the input class.
  109492. * @returns the input friendly name
  109493. */
  109494. getSimpleName(): string;
  109495. }
  109496. }
  109497. declare module BABYLON {
  109498. /**
  109499. * Manage the pointers inputs to control an follow camera.
  109500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109501. */
  109502. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  109503. /**
  109504. * Defines the camera the input is attached to.
  109505. */
  109506. camera: FollowCamera;
  109507. /**
  109508. * Gets the class name of the current input.
  109509. * @returns the class name
  109510. */
  109511. getClassName(): string;
  109512. /**
  109513. * Defines the pointer angular sensibility along the X axis or how fast is
  109514. * the camera rotating.
  109515. * A negative number will reverse the axis direction.
  109516. */
  109517. angularSensibilityX: number;
  109518. /**
  109519. * Defines the pointer angular sensibility along the Y axis or how fast is
  109520. * the camera rotating.
  109521. * A negative number will reverse the axis direction.
  109522. */
  109523. angularSensibilityY: number;
  109524. /**
  109525. * Defines the pointer pinch precision or how fast is the camera zooming.
  109526. * A negative number will reverse the axis direction.
  109527. */
  109528. pinchPrecision: number;
  109529. /**
  109530. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  109531. * from 0.
  109532. * It defines the percentage of current camera.radius to use as delta when
  109533. * pinch zoom is used.
  109534. */
  109535. pinchDeltaPercentage: number;
  109536. /**
  109537. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  109538. */
  109539. axisXControlRadius: boolean;
  109540. /**
  109541. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  109542. */
  109543. axisXControlHeight: boolean;
  109544. /**
  109545. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  109546. */
  109547. axisXControlRotation: boolean;
  109548. /**
  109549. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  109550. */
  109551. axisYControlRadius: boolean;
  109552. /**
  109553. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  109554. */
  109555. axisYControlHeight: boolean;
  109556. /**
  109557. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  109558. */
  109559. axisYControlRotation: boolean;
  109560. /**
  109561. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  109562. */
  109563. axisPinchControlRadius: boolean;
  109564. /**
  109565. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  109566. */
  109567. axisPinchControlHeight: boolean;
  109568. /**
  109569. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  109570. */
  109571. axisPinchControlRotation: boolean;
  109572. /**
  109573. * Log error messages if basic misconfiguration has occurred.
  109574. */
  109575. warningEnable: boolean;
  109576. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109577. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109578. private _warningCounter;
  109579. private _warning;
  109580. }
  109581. }
  109582. declare module BABYLON {
  109583. /**
  109584. * Default Inputs manager for the FollowCamera.
  109585. * It groups all the default supported inputs for ease of use.
  109586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109587. */
  109588. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  109589. /**
  109590. * Instantiates a new FollowCameraInputsManager.
  109591. * @param camera Defines the camera the inputs belong to
  109592. */
  109593. constructor(camera: FollowCamera);
  109594. /**
  109595. * Add keyboard input support to the input manager.
  109596. * @returns the current input manager
  109597. */
  109598. addKeyboard(): FollowCameraInputsManager;
  109599. /**
  109600. * Add mouse wheel input support to the input manager.
  109601. * @returns the current input manager
  109602. */
  109603. addMouseWheel(): FollowCameraInputsManager;
  109604. /**
  109605. * Add pointers input support to the input manager.
  109606. * @returns the current input manager
  109607. */
  109608. addPointers(): FollowCameraInputsManager;
  109609. /**
  109610. * Add orientation input support to the input manager.
  109611. * @returns the current input manager
  109612. */
  109613. addVRDeviceOrientation(): FollowCameraInputsManager;
  109614. }
  109615. }
  109616. declare module BABYLON {
  109617. /**
  109618. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  109619. * an arc rotate version arcFollowCamera are available.
  109620. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109621. */
  109622. export class FollowCamera extends TargetCamera {
  109623. /**
  109624. * Distance the follow camera should follow an object at
  109625. */
  109626. radius: number;
  109627. /**
  109628. * Minimum allowed distance of the camera to the axis of rotation
  109629. * (The camera can not get closer).
  109630. * This can help limiting how the Camera is able to move in the scene.
  109631. */
  109632. lowerRadiusLimit: Nullable<number>;
  109633. /**
  109634. * Maximum allowed distance of the camera to the axis of rotation
  109635. * (The camera can not get further).
  109636. * This can help limiting how the Camera is able to move in the scene.
  109637. */
  109638. upperRadiusLimit: Nullable<number>;
  109639. /**
  109640. * Define a rotation offset between the camera and the object it follows
  109641. */
  109642. rotationOffset: number;
  109643. /**
  109644. * Minimum allowed angle to camera position relative to target object.
  109645. * This can help limiting how the Camera is able to move in the scene.
  109646. */
  109647. lowerRotationOffsetLimit: Nullable<number>;
  109648. /**
  109649. * Maximum allowed angle to camera position relative to target object.
  109650. * This can help limiting how the Camera is able to move in the scene.
  109651. */
  109652. upperRotationOffsetLimit: Nullable<number>;
  109653. /**
  109654. * Define a height offset between the camera and the object it follows.
  109655. * It can help following an object from the top (like a car chaing a plane)
  109656. */
  109657. heightOffset: number;
  109658. /**
  109659. * Minimum allowed height of camera position relative to target object.
  109660. * This can help limiting how the Camera is able to move in the scene.
  109661. */
  109662. lowerHeightOffsetLimit: Nullable<number>;
  109663. /**
  109664. * Maximum allowed height of camera position relative to target object.
  109665. * This can help limiting how the Camera is able to move in the scene.
  109666. */
  109667. upperHeightOffsetLimit: Nullable<number>;
  109668. /**
  109669. * Define how fast the camera can accelerate to follow it s target.
  109670. */
  109671. cameraAcceleration: number;
  109672. /**
  109673. * Define the speed limit of the camera following an object.
  109674. */
  109675. maxCameraSpeed: number;
  109676. /**
  109677. * Define the target of the camera.
  109678. */
  109679. lockedTarget: Nullable<AbstractMesh>;
  109680. /**
  109681. * Defines the input associated with the camera.
  109682. */
  109683. inputs: FollowCameraInputsManager;
  109684. /**
  109685. * Instantiates the follow camera.
  109686. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109687. * @param name Define the name of the camera in the scene
  109688. * @param position Define the position of the camera
  109689. * @param scene Define the scene the camera belong to
  109690. * @param lockedTarget Define the target of the camera
  109691. */
  109692. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  109693. private _follow;
  109694. /**
  109695. * Attached controls to the current camera.
  109696. * @param element Defines the element the controls should be listened from
  109697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109698. */
  109699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109700. /**
  109701. * Detach the current controls from the camera.
  109702. * The camera will stop reacting to inputs.
  109703. * @param element Defines the element to stop listening the inputs from
  109704. */
  109705. detachControl(element: HTMLElement): void;
  109706. /** @hidden */
  109707. _checkInputs(): void;
  109708. private _checkLimits;
  109709. /**
  109710. * Gets the camera class name.
  109711. * @returns the class name
  109712. */
  109713. getClassName(): string;
  109714. }
  109715. /**
  109716. * Arc Rotate version of the follow camera.
  109717. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  109718. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109719. */
  109720. export class ArcFollowCamera extends TargetCamera {
  109721. /** The longitudinal angle of the camera */
  109722. alpha: number;
  109723. /** The latitudinal angle of the camera */
  109724. beta: number;
  109725. /** The radius of the camera from its target */
  109726. radius: number;
  109727. /** Define the camera target (the messh it should follow) */
  109728. target: Nullable<AbstractMesh>;
  109729. private _cartesianCoordinates;
  109730. /**
  109731. * Instantiates a new ArcFollowCamera
  109732. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109733. * @param name Define the name of the camera
  109734. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  109735. * @param beta Define the rotation angle of the camera around the elevation axis
  109736. * @param radius Define the radius of the camera from its target point
  109737. * @param target Define the target of the camera
  109738. * @param scene Define the scene the camera belongs to
  109739. */
  109740. constructor(name: string,
  109741. /** The longitudinal angle of the camera */
  109742. alpha: number,
  109743. /** The latitudinal angle of the camera */
  109744. beta: number,
  109745. /** The radius of the camera from its target */
  109746. radius: number,
  109747. /** Define the camera target (the messh it should follow) */
  109748. target: Nullable<AbstractMesh>, scene: Scene);
  109749. private _follow;
  109750. /** @hidden */
  109751. _checkInputs(): void;
  109752. /**
  109753. * Returns the class name of the object.
  109754. * It is mostly used internally for serialization purposes.
  109755. */
  109756. getClassName(): string;
  109757. }
  109758. }
  109759. declare module BABYLON {
  109760. /**
  109761. * Manage the keyboard inputs to control the movement of a follow camera.
  109762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109763. */
  109764. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  109765. /**
  109766. * Defines the camera the input is attached to.
  109767. */
  109768. camera: FollowCamera;
  109769. /**
  109770. * Defines the list of key codes associated with the up action (increase heightOffset)
  109771. */
  109772. keysHeightOffsetIncr: number[];
  109773. /**
  109774. * Defines the list of key codes associated with the down action (decrease heightOffset)
  109775. */
  109776. keysHeightOffsetDecr: number[];
  109777. /**
  109778. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  109779. */
  109780. keysHeightOffsetModifierAlt: boolean;
  109781. /**
  109782. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  109783. */
  109784. keysHeightOffsetModifierCtrl: boolean;
  109785. /**
  109786. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  109787. */
  109788. keysHeightOffsetModifierShift: boolean;
  109789. /**
  109790. * Defines the list of key codes associated with the left action (increase rotationOffset)
  109791. */
  109792. keysRotationOffsetIncr: number[];
  109793. /**
  109794. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  109795. */
  109796. keysRotationOffsetDecr: number[];
  109797. /**
  109798. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  109799. */
  109800. keysRotationOffsetModifierAlt: boolean;
  109801. /**
  109802. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  109803. */
  109804. keysRotationOffsetModifierCtrl: boolean;
  109805. /**
  109806. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  109807. */
  109808. keysRotationOffsetModifierShift: boolean;
  109809. /**
  109810. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  109811. */
  109812. keysRadiusIncr: number[];
  109813. /**
  109814. * Defines the list of key codes associated with the zoom-out action (increase radius)
  109815. */
  109816. keysRadiusDecr: number[];
  109817. /**
  109818. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  109819. */
  109820. keysRadiusModifierAlt: boolean;
  109821. /**
  109822. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  109823. */
  109824. keysRadiusModifierCtrl: boolean;
  109825. /**
  109826. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  109827. */
  109828. keysRadiusModifierShift: boolean;
  109829. /**
  109830. * Defines the rate of change of heightOffset.
  109831. */
  109832. heightSensibility: number;
  109833. /**
  109834. * Defines the rate of change of rotationOffset.
  109835. */
  109836. rotationSensibility: number;
  109837. /**
  109838. * Defines the rate of change of radius.
  109839. */
  109840. radiusSensibility: number;
  109841. private _keys;
  109842. private _ctrlPressed;
  109843. private _altPressed;
  109844. private _shiftPressed;
  109845. private _onCanvasBlurObserver;
  109846. private _onKeyboardObserver;
  109847. private _engine;
  109848. private _scene;
  109849. /**
  109850. * Attach the input controls to a specific dom element to get the input from.
  109851. * @param element Defines the element the controls should be listened from
  109852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109853. */
  109854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109855. /**
  109856. * Detach the current controls from the specified dom element.
  109857. * @param element Defines the element to stop listening the inputs from
  109858. */
  109859. detachControl(element: Nullable<HTMLElement>): void;
  109860. /**
  109861. * Update the current camera state depending on the inputs that have been used this frame.
  109862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109863. */
  109864. checkInputs(): void;
  109865. /**
  109866. * Gets the class name of the current input.
  109867. * @returns the class name
  109868. */
  109869. getClassName(): string;
  109870. /**
  109871. * Get the friendly name associated with the input class.
  109872. * @returns the input friendly name
  109873. */
  109874. getSimpleName(): string;
  109875. /**
  109876. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109877. * allow modification of the heightOffset value.
  109878. */
  109879. private _modifierHeightOffset;
  109880. /**
  109881. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109882. * allow modification of the rotationOffset value.
  109883. */
  109884. private _modifierRotationOffset;
  109885. /**
  109886. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109887. * allow modification of the radius value.
  109888. */
  109889. private _modifierRadius;
  109890. }
  109891. }
  109892. declare module BABYLON {
  109893. interface FreeCameraInputsManager {
  109894. /**
  109895. * @hidden
  109896. */
  109897. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  109898. /**
  109899. * Add orientation input support to the input manager.
  109900. * @returns the current input manager
  109901. */
  109902. addDeviceOrientation(): FreeCameraInputsManager;
  109903. }
  109904. /**
  109905. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  109906. * Screen rotation is taken into account.
  109907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109908. */
  109909. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  109910. private _camera;
  109911. private _screenOrientationAngle;
  109912. private _constantTranform;
  109913. private _screenQuaternion;
  109914. private _alpha;
  109915. private _beta;
  109916. private _gamma;
  109917. /**
  109918. * Can be used to detect if a device orientation sensor is available on a device
  109919. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  109920. * @returns a promise that will resolve on orientation change
  109921. */
  109922. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  109923. /**
  109924. * @hidden
  109925. */
  109926. _onDeviceOrientationChangedObservable: Observable<void>;
  109927. /**
  109928. * Instantiates a new input
  109929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109930. */
  109931. constructor();
  109932. /**
  109933. * Define the camera controlled by the input.
  109934. */
  109935. camera: FreeCamera;
  109936. /**
  109937. * Attach the input controls to a specific dom element to get the input from.
  109938. * @param element Defines the element the controls should be listened from
  109939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109940. */
  109941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109942. private _orientationChanged;
  109943. private _deviceOrientation;
  109944. /**
  109945. * Detach the current controls from the specified dom element.
  109946. * @param element Defines the element to stop listening the inputs from
  109947. */
  109948. detachControl(element: Nullable<HTMLElement>): void;
  109949. /**
  109950. * Update the current camera state depending on the inputs that have been used this frame.
  109951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109952. */
  109953. checkInputs(): void;
  109954. /**
  109955. * Gets the class name of the current intput.
  109956. * @returns the class name
  109957. */
  109958. getClassName(): string;
  109959. /**
  109960. * Get the friendly name associated with the input class.
  109961. * @returns the input friendly name
  109962. */
  109963. getSimpleName(): string;
  109964. }
  109965. }
  109966. declare module BABYLON {
  109967. /**
  109968. * Manage the gamepad inputs to control a free camera.
  109969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109970. */
  109971. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  109972. /**
  109973. * Define the camera the input is attached to.
  109974. */
  109975. camera: FreeCamera;
  109976. /**
  109977. * Define the Gamepad controlling the input
  109978. */
  109979. gamepad: Nullable<Gamepad>;
  109980. /**
  109981. * Defines the gamepad rotation sensiblity.
  109982. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109983. */
  109984. gamepadAngularSensibility: number;
  109985. /**
  109986. * Defines the gamepad move sensiblity.
  109987. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109988. */
  109989. gamepadMoveSensibility: number;
  109990. private _yAxisScale;
  109991. /**
  109992. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109993. */
  109994. invertYAxis: boolean;
  109995. private _onGamepadConnectedObserver;
  109996. private _onGamepadDisconnectedObserver;
  109997. private _cameraTransform;
  109998. private _deltaTransform;
  109999. private _vector3;
  110000. private _vector2;
  110001. /**
  110002. * Attach the input controls to a specific dom element to get the input from.
  110003. * @param element Defines the element the controls should be listened from
  110004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110005. */
  110006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110007. /**
  110008. * Detach the current controls from the specified dom element.
  110009. * @param element Defines the element to stop listening the inputs from
  110010. */
  110011. detachControl(element: Nullable<HTMLElement>): void;
  110012. /**
  110013. * Update the current camera state depending on the inputs that have been used this frame.
  110014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110015. */
  110016. checkInputs(): void;
  110017. /**
  110018. * Gets the class name of the current intput.
  110019. * @returns the class name
  110020. */
  110021. getClassName(): string;
  110022. /**
  110023. * Get the friendly name associated with the input class.
  110024. * @returns the input friendly name
  110025. */
  110026. getSimpleName(): string;
  110027. }
  110028. }
  110029. declare module BABYLON {
  110030. /**
  110031. * Defines the potential axis of a Joystick
  110032. */
  110033. export enum JoystickAxis {
  110034. /** X axis */
  110035. X = 0,
  110036. /** Y axis */
  110037. Y = 1,
  110038. /** Z axis */
  110039. Z = 2
  110040. }
  110041. /**
  110042. * Class used to define virtual joystick (used in touch mode)
  110043. */
  110044. export class VirtualJoystick {
  110045. /**
  110046. * Gets or sets a boolean indicating that left and right values must be inverted
  110047. */
  110048. reverseLeftRight: boolean;
  110049. /**
  110050. * Gets or sets a boolean indicating that up and down values must be inverted
  110051. */
  110052. reverseUpDown: boolean;
  110053. /**
  110054. * Gets the offset value for the position (ie. the change of the position value)
  110055. */
  110056. deltaPosition: Vector3;
  110057. /**
  110058. * Gets a boolean indicating if the virtual joystick was pressed
  110059. */
  110060. pressed: boolean;
  110061. /**
  110062. * Canvas the virtual joystick will render onto, default z-index of this is 5
  110063. */
  110064. static Canvas: Nullable<HTMLCanvasElement>;
  110065. private static _globalJoystickIndex;
  110066. private static vjCanvasContext;
  110067. private static vjCanvasWidth;
  110068. private static vjCanvasHeight;
  110069. private static halfWidth;
  110070. private _action;
  110071. private _axisTargetedByLeftAndRight;
  110072. private _axisTargetedByUpAndDown;
  110073. private _joystickSensibility;
  110074. private _inversedSensibility;
  110075. private _joystickPointerID;
  110076. private _joystickColor;
  110077. private _joystickPointerPos;
  110078. private _joystickPreviousPointerPos;
  110079. private _joystickPointerStartPos;
  110080. private _deltaJoystickVector;
  110081. private _leftJoystick;
  110082. private _touches;
  110083. private _onPointerDownHandlerRef;
  110084. private _onPointerMoveHandlerRef;
  110085. private _onPointerUpHandlerRef;
  110086. private _onResize;
  110087. /**
  110088. * Creates a new virtual joystick
  110089. * @param leftJoystick defines that the joystick is for left hand (false by default)
  110090. */
  110091. constructor(leftJoystick?: boolean);
  110092. /**
  110093. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  110094. * @param newJoystickSensibility defines the new sensibility
  110095. */
  110096. setJoystickSensibility(newJoystickSensibility: number): void;
  110097. private _onPointerDown;
  110098. private _onPointerMove;
  110099. private _onPointerUp;
  110100. /**
  110101. * Change the color of the virtual joystick
  110102. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  110103. */
  110104. setJoystickColor(newColor: string): void;
  110105. /**
  110106. * Defines a callback to call when the joystick is touched
  110107. * @param action defines the callback
  110108. */
  110109. setActionOnTouch(action: () => any): void;
  110110. /**
  110111. * Defines which axis you'd like to control for left & right
  110112. * @param axis defines the axis to use
  110113. */
  110114. setAxisForLeftRight(axis: JoystickAxis): void;
  110115. /**
  110116. * Defines which axis you'd like to control for up & down
  110117. * @param axis defines the axis to use
  110118. */
  110119. setAxisForUpDown(axis: JoystickAxis): void;
  110120. private _drawVirtualJoystick;
  110121. /**
  110122. * Release internal HTML canvas
  110123. */
  110124. releaseCanvas(): void;
  110125. }
  110126. }
  110127. declare module BABYLON {
  110128. interface FreeCameraInputsManager {
  110129. /**
  110130. * Add virtual joystick input support to the input manager.
  110131. * @returns the current input manager
  110132. */
  110133. addVirtualJoystick(): FreeCameraInputsManager;
  110134. }
  110135. /**
  110136. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  110137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110138. */
  110139. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  110140. /**
  110141. * Defines the camera the input is attached to.
  110142. */
  110143. camera: FreeCamera;
  110144. private _leftjoystick;
  110145. private _rightjoystick;
  110146. /**
  110147. * Gets the left stick of the virtual joystick.
  110148. * @returns The virtual Joystick
  110149. */
  110150. getLeftJoystick(): VirtualJoystick;
  110151. /**
  110152. * Gets the right stick of the virtual joystick.
  110153. * @returns The virtual Joystick
  110154. */
  110155. getRightJoystick(): VirtualJoystick;
  110156. /**
  110157. * Update the current camera state depending on the inputs that have been used this frame.
  110158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110159. */
  110160. checkInputs(): void;
  110161. /**
  110162. * Attach the input controls to a specific dom element to get the input from.
  110163. * @param element Defines the element the controls should be listened from
  110164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110165. */
  110166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110167. /**
  110168. * Detach the current controls from the specified dom element.
  110169. * @param element Defines the element to stop listening the inputs from
  110170. */
  110171. detachControl(element: Nullable<HTMLElement>): void;
  110172. /**
  110173. * Gets the class name of the current intput.
  110174. * @returns the class name
  110175. */
  110176. getClassName(): string;
  110177. /**
  110178. * Get the friendly name associated with the input class.
  110179. * @returns the input friendly name
  110180. */
  110181. getSimpleName(): string;
  110182. }
  110183. }
  110184. declare module BABYLON {
  110185. /**
  110186. * This represents a FPS type of camera controlled by touch.
  110187. * This is like a universal camera minus the Gamepad controls.
  110188. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110189. */
  110190. export class TouchCamera extends FreeCamera {
  110191. /**
  110192. * Defines the touch sensibility for rotation.
  110193. * The higher the faster.
  110194. */
  110195. touchAngularSensibility: number;
  110196. /**
  110197. * Defines the touch sensibility for move.
  110198. * The higher the faster.
  110199. */
  110200. touchMoveSensibility: number;
  110201. /**
  110202. * Instantiates a new touch camera.
  110203. * This represents a FPS type of camera controlled by touch.
  110204. * This is like a universal camera minus the Gamepad controls.
  110205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110206. * @param name Define the name of the camera in the scene
  110207. * @param position Define the start position of the camera in the scene
  110208. * @param scene Define the scene the camera belongs to
  110209. */
  110210. constructor(name: string, position: Vector3, scene: Scene);
  110211. /**
  110212. * Gets the current object class name.
  110213. * @return the class name
  110214. */
  110215. getClassName(): string;
  110216. /** @hidden */
  110217. _setupInputs(): void;
  110218. }
  110219. }
  110220. declare module BABYLON {
  110221. /**
  110222. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  110223. * being tilted forward or back and left or right.
  110224. */
  110225. export class DeviceOrientationCamera extends FreeCamera {
  110226. private _initialQuaternion;
  110227. private _quaternionCache;
  110228. private _tmpDragQuaternion;
  110229. private _disablePointerInputWhenUsingDeviceOrientation;
  110230. /**
  110231. * Creates a new device orientation camera
  110232. * @param name The name of the camera
  110233. * @param position The start position camera
  110234. * @param scene The scene the camera belongs to
  110235. */
  110236. constructor(name: string, position: Vector3, scene: Scene);
  110237. /**
  110238. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  110239. */
  110240. disablePointerInputWhenUsingDeviceOrientation: boolean;
  110241. private _dragFactor;
  110242. /**
  110243. * Enabled turning on the y axis when the orientation sensor is active
  110244. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  110245. */
  110246. enableHorizontalDragging(dragFactor?: number): void;
  110247. /**
  110248. * Gets the current instance class name ("DeviceOrientationCamera").
  110249. * This helps avoiding instanceof at run time.
  110250. * @returns the class name
  110251. */
  110252. getClassName(): string;
  110253. /**
  110254. * @hidden
  110255. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  110256. */
  110257. _checkInputs(): void;
  110258. /**
  110259. * Reset the camera to its default orientation on the specified axis only.
  110260. * @param axis The axis to reset
  110261. */
  110262. resetToCurrentRotation(axis?: Axis): void;
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /**
  110267. * Defines supported buttons for XBox360 compatible gamepads
  110268. */
  110269. export enum Xbox360Button {
  110270. /** A */
  110271. A = 0,
  110272. /** B */
  110273. B = 1,
  110274. /** X */
  110275. X = 2,
  110276. /** Y */
  110277. Y = 3,
  110278. /** Start */
  110279. Start = 4,
  110280. /** Back */
  110281. Back = 5,
  110282. /** Left button */
  110283. LB = 6,
  110284. /** Right button */
  110285. RB = 7,
  110286. /** Left stick */
  110287. LeftStick = 8,
  110288. /** Right stick */
  110289. RightStick = 9
  110290. }
  110291. /** Defines values for XBox360 DPad */
  110292. export enum Xbox360Dpad {
  110293. /** Up */
  110294. Up = 0,
  110295. /** Down */
  110296. Down = 1,
  110297. /** Left */
  110298. Left = 2,
  110299. /** Right */
  110300. Right = 3
  110301. }
  110302. /**
  110303. * Defines a XBox360 gamepad
  110304. */
  110305. export class Xbox360Pad extends Gamepad {
  110306. private _leftTrigger;
  110307. private _rightTrigger;
  110308. private _onlefttriggerchanged;
  110309. private _onrighttriggerchanged;
  110310. private _onbuttondown;
  110311. private _onbuttonup;
  110312. private _ondpaddown;
  110313. private _ondpadup;
  110314. /** Observable raised when a button is pressed */
  110315. onButtonDownObservable: Observable<Xbox360Button>;
  110316. /** Observable raised when a button is released */
  110317. onButtonUpObservable: Observable<Xbox360Button>;
  110318. /** Observable raised when a pad is pressed */
  110319. onPadDownObservable: Observable<Xbox360Dpad>;
  110320. /** Observable raised when a pad is released */
  110321. onPadUpObservable: Observable<Xbox360Dpad>;
  110322. private _buttonA;
  110323. private _buttonB;
  110324. private _buttonX;
  110325. private _buttonY;
  110326. private _buttonBack;
  110327. private _buttonStart;
  110328. private _buttonLB;
  110329. private _buttonRB;
  110330. private _buttonLeftStick;
  110331. private _buttonRightStick;
  110332. private _dPadUp;
  110333. private _dPadDown;
  110334. private _dPadLeft;
  110335. private _dPadRight;
  110336. private _isXboxOnePad;
  110337. /**
  110338. * Creates a new XBox360 gamepad object
  110339. * @param id defines the id of this gamepad
  110340. * @param index defines its index
  110341. * @param gamepad defines the internal HTML gamepad object
  110342. * @param xboxOne defines if it is a XBox One gamepad
  110343. */
  110344. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  110345. /**
  110346. * Defines the callback to call when left trigger is pressed
  110347. * @param callback defines the callback to use
  110348. */
  110349. onlefttriggerchanged(callback: (value: number) => void): void;
  110350. /**
  110351. * Defines the callback to call when right trigger is pressed
  110352. * @param callback defines the callback to use
  110353. */
  110354. onrighttriggerchanged(callback: (value: number) => void): void;
  110355. /**
  110356. * Gets the left trigger value
  110357. */
  110358. /**
  110359. * Sets the left trigger value
  110360. */
  110361. leftTrigger: number;
  110362. /**
  110363. * Gets the right trigger value
  110364. */
  110365. /**
  110366. * Sets the right trigger value
  110367. */
  110368. rightTrigger: number;
  110369. /**
  110370. * Defines the callback to call when a button is pressed
  110371. * @param callback defines the callback to use
  110372. */
  110373. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  110374. /**
  110375. * Defines the callback to call when a button is released
  110376. * @param callback defines the callback to use
  110377. */
  110378. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  110379. /**
  110380. * Defines the callback to call when a pad is pressed
  110381. * @param callback defines the callback to use
  110382. */
  110383. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  110384. /**
  110385. * Defines the callback to call when a pad is released
  110386. * @param callback defines the callback to use
  110387. */
  110388. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  110389. private _setButtonValue;
  110390. private _setDPadValue;
  110391. /**
  110392. * Gets the value of the `A` button
  110393. */
  110394. /**
  110395. * Sets the value of the `A` button
  110396. */
  110397. buttonA: number;
  110398. /**
  110399. * Gets the value of the `B` button
  110400. */
  110401. /**
  110402. * Sets the value of the `B` button
  110403. */
  110404. buttonB: number;
  110405. /**
  110406. * Gets the value of the `X` button
  110407. */
  110408. /**
  110409. * Sets the value of the `X` button
  110410. */
  110411. buttonX: number;
  110412. /**
  110413. * Gets the value of the `Y` button
  110414. */
  110415. /**
  110416. * Sets the value of the `Y` button
  110417. */
  110418. buttonY: number;
  110419. /**
  110420. * Gets the value of the `Start` button
  110421. */
  110422. /**
  110423. * Sets the value of the `Start` button
  110424. */
  110425. buttonStart: number;
  110426. /**
  110427. * Gets the value of the `Back` button
  110428. */
  110429. /**
  110430. * Sets the value of the `Back` button
  110431. */
  110432. buttonBack: number;
  110433. /**
  110434. * Gets the value of the `Left` button
  110435. */
  110436. /**
  110437. * Sets the value of the `Left` button
  110438. */
  110439. buttonLB: number;
  110440. /**
  110441. * Gets the value of the `Right` button
  110442. */
  110443. /**
  110444. * Sets the value of the `Right` button
  110445. */
  110446. buttonRB: number;
  110447. /**
  110448. * Gets the value of the Left joystick
  110449. */
  110450. /**
  110451. * Sets the value of the Left joystick
  110452. */
  110453. buttonLeftStick: number;
  110454. /**
  110455. * Gets the value of the Right joystick
  110456. */
  110457. /**
  110458. * Sets the value of the Right joystick
  110459. */
  110460. buttonRightStick: number;
  110461. /**
  110462. * Gets the value of D-pad up
  110463. */
  110464. /**
  110465. * Sets the value of D-pad up
  110466. */
  110467. dPadUp: number;
  110468. /**
  110469. * Gets the value of D-pad down
  110470. */
  110471. /**
  110472. * Sets the value of D-pad down
  110473. */
  110474. dPadDown: number;
  110475. /**
  110476. * Gets the value of D-pad left
  110477. */
  110478. /**
  110479. * Sets the value of D-pad left
  110480. */
  110481. dPadLeft: number;
  110482. /**
  110483. * Gets the value of D-pad right
  110484. */
  110485. /**
  110486. * Sets the value of D-pad right
  110487. */
  110488. dPadRight: number;
  110489. /**
  110490. * Force the gamepad to synchronize with device values
  110491. */
  110492. update(): void;
  110493. /**
  110494. * Disposes the gamepad
  110495. */
  110496. dispose(): void;
  110497. }
  110498. }
  110499. declare module BABYLON {
  110500. /**
  110501. * Defines supported buttons for DualShock compatible gamepads
  110502. */
  110503. export enum DualShockButton {
  110504. /** Cross */
  110505. Cross = 0,
  110506. /** Circle */
  110507. Circle = 1,
  110508. /** Square */
  110509. Square = 2,
  110510. /** Triangle */
  110511. Triangle = 3,
  110512. /** Options */
  110513. Options = 4,
  110514. /** Share */
  110515. Share = 5,
  110516. /** L1 */
  110517. L1 = 6,
  110518. /** R1 */
  110519. R1 = 7,
  110520. /** Left stick */
  110521. LeftStick = 8,
  110522. /** Right stick */
  110523. RightStick = 9
  110524. }
  110525. /** Defines values for DualShock DPad */
  110526. export enum DualShockDpad {
  110527. /** Up */
  110528. Up = 0,
  110529. /** Down */
  110530. Down = 1,
  110531. /** Left */
  110532. Left = 2,
  110533. /** Right */
  110534. Right = 3
  110535. }
  110536. /**
  110537. * Defines a DualShock gamepad
  110538. */
  110539. export class DualShockPad extends Gamepad {
  110540. private _leftTrigger;
  110541. private _rightTrigger;
  110542. private _onlefttriggerchanged;
  110543. private _onrighttriggerchanged;
  110544. private _onbuttondown;
  110545. private _onbuttonup;
  110546. private _ondpaddown;
  110547. private _ondpadup;
  110548. /** Observable raised when a button is pressed */
  110549. onButtonDownObservable: Observable<DualShockButton>;
  110550. /** Observable raised when a button is released */
  110551. onButtonUpObservable: Observable<DualShockButton>;
  110552. /** Observable raised when a pad is pressed */
  110553. onPadDownObservable: Observable<DualShockDpad>;
  110554. /** Observable raised when a pad is released */
  110555. onPadUpObservable: Observable<DualShockDpad>;
  110556. private _buttonCross;
  110557. private _buttonCircle;
  110558. private _buttonSquare;
  110559. private _buttonTriangle;
  110560. private _buttonShare;
  110561. private _buttonOptions;
  110562. private _buttonL1;
  110563. private _buttonR1;
  110564. private _buttonLeftStick;
  110565. private _buttonRightStick;
  110566. private _dPadUp;
  110567. private _dPadDown;
  110568. private _dPadLeft;
  110569. private _dPadRight;
  110570. /**
  110571. * Creates a new DualShock gamepad object
  110572. * @param id defines the id of this gamepad
  110573. * @param index defines its index
  110574. * @param gamepad defines the internal HTML gamepad object
  110575. */
  110576. constructor(id: string, index: number, gamepad: any);
  110577. /**
  110578. * Defines the callback to call when left trigger is pressed
  110579. * @param callback defines the callback to use
  110580. */
  110581. onlefttriggerchanged(callback: (value: number) => void): void;
  110582. /**
  110583. * Defines the callback to call when right trigger is pressed
  110584. * @param callback defines the callback to use
  110585. */
  110586. onrighttriggerchanged(callback: (value: number) => void): void;
  110587. /**
  110588. * Gets the left trigger value
  110589. */
  110590. /**
  110591. * Sets the left trigger value
  110592. */
  110593. leftTrigger: number;
  110594. /**
  110595. * Gets the right trigger value
  110596. */
  110597. /**
  110598. * Sets the right trigger value
  110599. */
  110600. rightTrigger: number;
  110601. /**
  110602. * Defines the callback to call when a button is pressed
  110603. * @param callback defines the callback to use
  110604. */
  110605. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  110606. /**
  110607. * Defines the callback to call when a button is released
  110608. * @param callback defines the callback to use
  110609. */
  110610. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  110611. /**
  110612. * Defines the callback to call when a pad is pressed
  110613. * @param callback defines the callback to use
  110614. */
  110615. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  110616. /**
  110617. * Defines the callback to call when a pad is released
  110618. * @param callback defines the callback to use
  110619. */
  110620. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  110621. private _setButtonValue;
  110622. private _setDPadValue;
  110623. /**
  110624. * Gets the value of the `Cross` button
  110625. */
  110626. /**
  110627. * Sets the value of the `Cross` button
  110628. */
  110629. buttonCross: number;
  110630. /**
  110631. * Gets the value of the `Circle` button
  110632. */
  110633. /**
  110634. * Sets the value of the `Circle` button
  110635. */
  110636. buttonCircle: number;
  110637. /**
  110638. * Gets the value of the `Square` button
  110639. */
  110640. /**
  110641. * Sets the value of the `Square` button
  110642. */
  110643. buttonSquare: number;
  110644. /**
  110645. * Gets the value of the `Triangle` button
  110646. */
  110647. /**
  110648. * Sets the value of the `Triangle` button
  110649. */
  110650. buttonTriangle: number;
  110651. /**
  110652. * Gets the value of the `Options` button
  110653. */
  110654. /**
  110655. * Sets the value of the `Options` button
  110656. */
  110657. buttonOptions: number;
  110658. /**
  110659. * Gets the value of the `Share` button
  110660. */
  110661. /**
  110662. * Sets the value of the `Share` button
  110663. */
  110664. buttonShare: number;
  110665. /**
  110666. * Gets the value of the `L1` button
  110667. */
  110668. /**
  110669. * Sets the value of the `L1` button
  110670. */
  110671. buttonL1: number;
  110672. /**
  110673. * Gets the value of the `R1` button
  110674. */
  110675. /**
  110676. * Sets the value of the `R1` button
  110677. */
  110678. buttonR1: number;
  110679. /**
  110680. * Gets the value of the Left joystick
  110681. */
  110682. /**
  110683. * Sets the value of the Left joystick
  110684. */
  110685. buttonLeftStick: number;
  110686. /**
  110687. * Gets the value of the Right joystick
  110688. */
  110689. /**
  110690. * Sets the value of the Right joystick
  110691. */
  110692. buttonRightStick: number;
  110693. /**
  110694. * Gets the value of D-pad up
  110695. */
  110696. /**
  110697. * Sets the value of D-pad up
  110698. */
  110699. dPadUp: number;
  110700. /**
  110701. * Gets the value of D-pad down
  110702. */
  110703. /**
  110704. * Sets the value of D-pad down
  110705. */
  110706. dPadDown: number;
  110707. /**
  110708. * Gets the value of D-pad left
  110709. */
  110710. /**
  110711. * Sets the value of D-pad left
  110712. */
  110713. dPadLeft: number;
  110714. /**
  110715. * Gets the value of D-pad right
  110716. */
  110717. /**
  110718. * Sets the value of D-pad right
  110719. */
  110720. dPadRight: number;
  110721. /**
  110722. * Force the gamepad to synchronize with device values
  110723. */
  110724. update(): void;
  110725. /**
  110726. * Disposes the gamepad
  110727. */
  110728. dispose(): void;
  110729. }
  110730. }
  110731. declare module BABYLON {
  110732. /**
  110733. * Manager for handling gamepads
  110734. */
  110735. export class GamepadManager {
  110736. private _scene?;
  110737. private _babylonGamepads;
  110738. private _oneGamepadConnected;
  110739. /** @hidden */
  110740. _isMonitoring: boolean;
  110741. private _gamepadEventSupported;
  110742. private _gamepadSupport;
  110743. /**
  110744. * observable to be triggered when the gamepad controller has been connected
  110745. */
  110746. onGamepadConnectedObservable: Observable<Gamepad>;
  110747. /**
  110748. * observable to be triggered when the gamepad controller has been disconnected
  110749. */
  110750. onGamepadDisconnectedObservable: Observable<Gamepad>;
  110751. private _onGamepadConnectedEvent;
  110752. private _onGamepadDisconnectedEvent;
  110753. /**
  110754. * Initializes the gamepad manager
  110755. * @param _scene BabylonJS scene
  110756. */
  110757. constructor(_scene?: Scene | undefined);
  110758. /**
  110759. * The gamepads in the game pad manager
  110760. */
  110761. readonly gamepads: Gamepad[];
  110762. /**
  110763. * Get the gamepad controllers based on type
  110764. * @param type The type of gamepad controller
  110765. * @returns Nullable gamepad
  110766. */
  110767. getGamepadByType(type?: number): Nullable<Gamepad>;
  110768. /**
  110769. * Disposes the gamepad manager
  110770. */
  110771. dispose(): void;
  110772. private _addNewGamepad;
  110773. private _startMonitoringGamepads;
  110774. private _stopMonitoringGamepads;
  110775. /** @hidden */
  110776. _checkGamepadsStatus(): void;
  110777. private _updateGamepadObjects;
  110778. }
  110779. }
  110780. declare module BABYLON {
  110781. interface Scene {
  110782. /** @hidden */
  110783. _gamepadManager: Nullable<GamepadManager>;
  110784. /**
  110785. * Gets the gamepad manager associated with the scene
  110786. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  110787. */
  110788. gamepadManager: GamepadManager;
  110789. }
  110790. /**
  110791. * Interface representing a free camera inputs manager
  110792. */
  110793. interface FreeCameraInputsManager {
  110794. /**
  110795. * Adds gamepad input support to the FreeCameraInputsManager.
  110796. * @returns the FreeCameraInputsManager
  110797. */
  110798. addGamepad(): FreeCameraInputsManager;
  110799. }
  110800. /**
  110801. * Interface representing an arc rotate camera inputs manager
  110802. */
  110803. interface ArcRotateCameraInputsManager {
  110804. /**
  110805. * Adds gamepad input support to the ArcRotateCamera InputManager.
  110806. * @returns the camera inputs manager
  110807. */
  110808. addGamepad(): ArcRotateCameraInputsManager;
  110809. }
  110810. /**
  110811. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  110812. */
  110813. export class GamepadSystemSceneComponent implements ISceneComponent {
  110814. /**
  110815. * The component name helpfull to identify the component in the list of scene components.
  110816. */
  110817. readonly name: string;
  110818. /**
  110819. * The scene the component belongs to.
  110820. */
  110821. scene: Scene;
  110822. /**
  110823. * Creates a new instance of the component for the given scene
  110824. * @param scene Defines the scene to register the component in
  110825. */
  110826. constructor(scene: Scene);
  110827. /**
  110828. * Registers the component in a given scene
  110829. */
  110830. register(): void;
  110831. /**
  110832. * Rebuilds the elements related to this component in case of
  110833. * context lost for instance.
  110834. */
  110835. rebuild(): void;
  110836. /**
  110837. * Disposes the component and the associated ressources
  110838. */
  110839. dispose(): void;
  110840. private _beforeCameraUpdate;
  110841. }
  110842. }
  110843. declare module BABYLON {
  110844. /**
  110845. * 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,
  110846. * which still works and will still be found in many Playgrounds.
  110847. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110848. */
  110849. export class UniversalCamera extends TouchCamera {
  110850. /**
  110851. * Defines the gamepad rotation sensiblity.
  110852. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110853. */
  110854. gamepadAngularSensibility: number;
  110855. /**
  110856. * Defines the gamepad move sensiblity.
  110857. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110858. */
  110859. gamepadMoveSensibility: number;
  110860. /**
  110861. * 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,
  110862. * which still works and will still be found in many Playgrounds.
  110863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110864. * @param name Define the name of the camera in the scene
  110865. * @param position Define the start position of the camera in the scene
  110866. * @param scene Define the scene the camera belongs to
  110867. */
  110868. constructor(name: string, position: Vector3, scene: Scene);
  110869. /**
  110870. * Gets the current object class name.
  110871. * @return the class name
  110872. */
  110873. getClassName(): string;
  110874. }
  110875. }
  110876. declare module BABYLON {
  110877. /**
  110878. * This represents a FPS type of camera. This is only here for back compat purpose.
  110879. * Please use the UniversalCamera instead as both are identical.
  110880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110881. */
  110882. export class GamepadCamera extends UniversalCamera {
  110883. /**
  110884. * Instantiates a new Gamepad Camera
  110885. * This represents a FPS type of camera. This is only here for back compat purpose.
  110886. * Please use the UniversalCamera instead as both are identical.
  110887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110888. * @param name Define the name of the camera in the scene
  110889. * @param position Define the start position of the camera in the scene
  110890. * @param scene Define the scene the camera belongs to
  110891. */
  110892. constructor(name: string, position: Vector3, scene: Scene);
  110893. /**
  110894. * Gets the current object class name.
  110895. * @return the class name
  110896. */
  110897. getClassName(): string;
  110898. }
  110899. }
  110900. declare module BABYLON {
  110901. /** @hidden */
  110902. export var passPixelShader: {
  110903. name: string;
  110904. shader: string;
  110905. };
  110906. }
  110907. declare module BABYLON {
  110908. /** @hidden */
  110909. export var passCubePixelShader: {
  110910. name: string;
  110911. shader: string;
  110912. };
  110913. }
  110914. declare module BABYLON {
  110915. /**
  110916. * PassPostProcess which produces an output the same as it's input
  110917. */
  110918. export class PassPostProcess extends PostProcess {
  110919. /**
  110920. * Creates the PassPostProcess
  110921. * @param name The name of the effect.
  110922. * @param options The required width/height ratio to downsize to before computing the render pass.
  110923. * @param camera The camera to apply the render pass to.
  110924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110925. * @param engine The engine which the post process will be applied. (default: current engine)
  110926. * @param reusable If the post process can be reused on the same frame. (default: false)
  110927. * @param textureType The type of texture to be used when performing the post processing.
  110928. * @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)
  110929. */
  110930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110931. }
  110932. /**
  110933. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  110934. */
  110935. export class PassCubePostProcess extends PostProcess {
  110936. private _face;
  110937. /**
  110938. * Gets or sets the cube face to display.
  110939. * * 0 is +X
  110940. * * 1 is -X
  110941. * * 2 is +Y
  110942. * * 3 is -Y
  110943. * * 4 is +Z
  110944. * * 5 is -Z
  110945. */
  110946. face: number;
  110947. /**
  110948. * Creates the PassCubePostProcess
  110949. * @param name The name of the effect.
  110950. * @param options The required width/height ratio to downsize to before computing the render pass.
  110951. * @param camera The camera to apply the render pass to.
  110952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110953. * @param engine The engine which the post process will be applied. (default: current engine)
  110954. * @param reusable If the post process can be reused on the same frame. (default: false)
  110955. * @param textureType The type of texture to be used when performing the post processing.
  110956. * @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)
  110957. */
  110958. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110959. }
  110960. }
  110961. declare module BABYLON {
  110962. /** @hidden */
  110963. export var anaglyphPixelShader: {
  110964. name: string;
  110965. shader: string;
  110966. };
  110967. }
  110968. declare module BABYLON {
  110969. /**
  110970. * Postprocess used to generate anaglyphic rendering
  110971. */
  110972. export class AnaglyphPostProcess extends PostProcess {
  110973. private _passedProcess;
  110974. /**
  110975. * Creates a new AnaglyphPostProcess
  110976. * @param name defines postprocess name
  110977. * @param options defines creation options or target ratio scale
  110978. * @param rigCameras defines cameras using this postprocess
  110979. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  110980. * @param engine defines hosting engine
  110981. * @param reusable defines if the postprocess will be reused multiple times per frame
  110982. */
  110983. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  110984. }
  110985. }
  110986. declare module BABYLON {
  110987. /**
  110988. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  110989. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110990. */
  110991. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  110992. /**
  110993. * Creates a new AnaglyphArcRotateCamera
  110994. * @param name defines camera name
  110995. * @param alpha defines alpha angle (in radians)
  110996. * @param beta defines beta angle (in radians)
  110997. * @param radius defines radius
  110998. * @param target defines camera target
  110999. * @param interaxialDistance defines distance between each color axis
  111000. * @param scene defines the hosting scene
  111001. */
  111002. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  111003. /**
  111004. * Gets camera class name
  111005. * @returns AnaglyphArcRotateCamera
  111006. */
  111007. getClassName(): string;
  111008. }
  111009. }
  111010. declare module BABYLON {
  111011. /**
  111012. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  111013. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111014. */
  111015. export class AnaglyphFreeCamera extends FreeCamera {
  111016. /**
  111017. * Creates a new AnaglyphFreeCamera
  111018. * @param name defines camera name
  111019. * @param position defines initial position
  111020. * @param interaxialDistance defines distance between each color axis
  111021. * @param scene defines the hosting scene
  111022. */
  111023. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  111024. /**
  111025. * Gets camera class name
  111026. * @returns AnaglyphFreeCamera
  111027. */
  111028. getClassName(): string;
  111029. }
  111030. }
  111031. declare module BABYLON {
  111032. /**
  111033. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  111034. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111035. */
  111036. export class AnaglyphGamepadCamera extends GamepadCamera {
  111037. /**
  111038. * Creates a new AnaglyphGamepadCamera
  111039. * @param name defines camera name
  111040. * @param position defines initial position
  111041. * @param interaxialDistance defines distance between each color axis
  111042. * @param scene defines the hosting scene
  111043. */
  111044. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  111045. /**
  111046. * Gets camera class name
  111047. * @returns AnaglyphGamepadCamera
  111048. */
  111049. getClassName(): string;
  111050. }
  111051. }
  111052. declare module BABYLON {
  111053. /**
  111054. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  111055. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111056. */
  111057. export class AnaglyphUniversalCamera extends UniversalCamera {
  111058. /**
  111059. * Creates a new AnaglyphUniversalCamera
  111060. * @param name defines camera name
  111061. * @param position defines initial position
  111062. * @param interaxialDistance defines distance between each color axis
  111063. * @param scene defines the hosting scene
  111064. */
  111065. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  111066. /**
  111067. * Gets camera class name
  111068. * @returns AnaglyphUniversalCamera
  111069. */
  111070. getClassName(): string;
  111071. }
  111072. }
  111073. declare module BABYLON {
  111074. /** @hidden */
  111075. export var stereoscopicInterlacePixelShader: {
  111076. name: string;
  111077. shader: string;
  111078. };
  111079. }
  111080. declare module BABYLON {
  111081. /**
  111082. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  111083. */
  111084. export class StereoscopicInterlacePostProcess extends PostProcess {
  111085. private _stepSize;
  111086. private _passedProcess;
  111087. /**
  111088. * Initializes a StereoscopicInterlacePostProcess
  111089. * @param name The name of the effect.
  111090. * @param rigCameras The rig cameras to be appled to the post process
  111091. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  111092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111093. * @param engine The engine which the post process will be applied. (default: current engine)
  111094. * @param reusable If the post process can be reused on the same frame. (default: false)
  111095. */
  111096. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  111102. * @see http://doc.babylonjs.com/features/cameras
  111103. */
  111104. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  111105. /**
  111106. * Creates a new StereoscopicArcRotateCamera
  111107. * @param name defines camera name
  111108. * @param alpha defines alpha angle (in radians)
  111109. * @param beta defines beta angle (in radians)
  111110. * @param radius defines radius
  111111. * @param target defines camera target
  111112. * @param interaxialDistance defines distance between each color axis
  111113. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  111114. * @param scene defines the hosting scene
  111115. */
  111116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  111117. /**
  111118. * Gets camera class name
  111119. * @returns StereoscopicArcRotateCamera
  111120. */
  111121. getClassName(): string;
  111122. }
  111123. }
  111124. declare module BABYLON {
  111125. /**
  111126. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  111127. * @see http://doc.babylonjs.com/features/cameras
  111128. */
  111129. export class StereoscopicFreeCamera extends FreeCamera {
  111130. /**
  111131. * Creates a new StereoscopicFreeCamera
  111132. * @param name defines camera name
  111133. * @param position defines initial position
  111134. * @param interaxialDistance defines distance between each color axis
  111135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  111136. * @param scene defines the hosting scene
  111137. */
  111138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  111139. /**
  111140. * Gets camera class name
  111141. * @returns StereoscopicFreeCamera
  111142. */
  111143. getClassName(): string;
  111144. }
  111145. }
  111146. declare module BABYLON {
  111147. /**
  111148. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  111149. * @see http://doc.babylonjs.com/features/cameras
  111150. */
  111151. export class StereoscopicGamepadCamera extends GamepadCamera {
  111152. /**
  111153. * Creates a new StereoscopicGamepadCamera
  111154. * @param name defines camera name
  111155. * @param position defines initial position
  111156. * @param interaxialDistance defines distance between each color axis
  111157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  111158. * @param scene defines the hosting scene
  111159. */
  111160. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  111161. /**
  111162. * Gets camera class name
  111163. * @returns StereoscopicGamepadCamera
  111164. */
  111165. getClassName(): string;
  111166. }
  111167. }
  111168. declare module BABYLON {
  111169. /**
  111170. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  111171. * @see http://doc.babylonjs.com/features/cameras
  111172. */
  111173. export class StereoscopicUniversalCamera extends UniversalCamera {
  111174. /**
  111175. * Creates a new StereoscopicUniversalCamera
  111176. * @param name defines camera name
  111177. * @param position defines initial position
  111178. * @param interaxialDistance defines distance between each color axis
  111179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  111180. * @param scene defines the hosting scene
  111181. */
  111182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  111183. /**
  111184. * Gets camera class name
  111185. * @returns StereoscopicUniversalCamera
  111186. */
  111187. getClassName(): string;
  111188. }
  111189. }
  111190. declare module BABYLON {
  111191. /**
  111192. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  111193. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  111194. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  111195. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  111196. */
  111197. export class VirtualJoysticksCamera extends FreeCamera {
  111198. /**
  111199. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  111200. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  111201. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  111202. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  111203. * @param name Define the name of the camera in the scene
  111204. * @param position Define the start position of the camera in the scene
  111205. * @param scene Define the scene the camera belongs to
  111206. */
  111207. constructor(name: string, position: Vector3, scene: Scene);
  111208. /**
  111209. * Gets the current object class name.
  111210. * @return the class name
  111211. */
  111212. getClassName(): string;
  111213. }
  111214. }
  111215. declare module BABYLON {
  111216. /**
  111217. * This represents all the required metrics to create a VR camera.
  111218. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  111219. */
  111220. export class VRCameraMetrics {
  111221. /**
  111222. * Define the horizontal resolution off the screen.
  111223. */
  111224. hResolution: number;
  111225. /**
  111226. * Define the vertical resolution off the screen.
  111227. */
  111228. vResolution: number;
  111229. /**
  111230. * Define the horizontal screen size.
  111231. */
  111232. hScreenSize: number;
  111233. /**
  111234. * Define the vertical screen size.
  111235. */
  111236. vScreenSize: number;
  111237. /**
  111238. * Define the vertical screen center position.
  111239. */
  111240. vScreenCenter: number;
  111241. /**
  111242. * Define the distance of the eyes to the screen.
  111243. */
  111244. eyeToScreenDistance: number;
  111245. /**
  111246. * Define the distance between both lenses
  111247. */
  111248. lensSeparationDistance: number;
  111249. /**
  111250. * Define the distance between both viewer's eyes.
  111251. */
  111252. interpupillaryDistance: number;
  111253. /**
  111254. * Define the distortion factor of the VR postprocess.
  111255. * Please, touch with care.
  111256. */
  111257. distortionK: number[];
  111258. /**
  111259. * Define the chromatic aberration correction factors for the VR post process.
  111260. */
  111261. chromaAbCorrection: number[];
  111262. /**
  111263. * Define the scale factor of the post process.
  111264. * The smaller the better but the slower.
  111265. */
  111266. postProcessScaleFactor: number;
  111267. /**
  111268. * Define an offset for the lens center.
  111269. */
  111270. lensCenterOffset: number;
  111271. /**
  111272. * Define if the current vr camera should compensate the distortion of the lense or not.
  111273. */
  111274. compensateDistortion: boolean;
  111275. /**
  111276. * Defines if multiview should be enabled when rendering (Default: false)
  111277. */
  111278. multiviewEnabled: boolean;
  111279. /**
  111280. * Gets the rendering aspect ratio based on the provided resolutions.
  111281. */
  111282. readonly aspectRatio: number;
  111283. /**
  111284. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  111285. */
  111286. readonly aspectRatioFov: number;
  111287. /**
  111288. * @hidden
  111289. */
  111290. readonly leftHMatrix: Matrix;
  111291. /**
  111292. * @hidden
  111293. */
  111294. readonly rightHMatrix: Matrix;
  111295. /**
  111296. * @hidden
  111297. */
  111298. readonly leftPreViewMatrix: Matrix;
  111299. /**
  111300. * @hidden
  111301. */
  111302. readonly rightPreViewMatrix: Matrix;
  111303. /**
  111304. * Get the default VRMetrics based on the most generic setup.
  111305. * @returns the default vr metrics
  111306. */
  111307. static GetDefault(): VRCameraMetrics;
  111308. }
  111309. }
  111310. declare module BABYLON {
  111311. /** @hidden */
  111312. export var vrDistortionCorrectionPixelShader: {
  111313. name: string;
  111314. shader: string;
  111315. };
  111316. }
  111317. declare module BABYLON {
  111318. /**
  111319. * VRDistortionCorrectionPostProcess used for mobile VR
  111320. */
  111321. export class VRDistortionCorrectionPostProcess extends PostProcess {
  111322. private _isRightEye;
  111323. private _distortionFactors;
  111324. private _postProcessScaleFactor;
  111325. private _lensCenterOffset;
  111326. private _scaleIn;
  111327. private _scaleFactor;
  111328. private _lensCenter;
  111329. /**
  111330. * Initializes the VRDistortionCorrectionPostProcess
  111331. * @param name The name of the effect.
  111332. * @param camera The camera to apply the render pass to.
  111333. * @param isRightEye If this is for the right eye distortion
  111334. * @param vrMetrics All the required metrics for the VR camera
  111335. */
  111336. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  111337. }
  111338. }
  111339. declare module BABYLON {
  111340. /**
  111341. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  111342. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  111343. */
  111344. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  111345. /**
  111346. * Creates a new VRDeviceOrientationArcRotateCamera
  111347. * @param name defines camera name
  111348. * @param alpha defines the camera rotation along the logitudinal axis
  111349. * @param beta defines the camera rotation along the latitudinal axis
  111350. * @param radius defines the camera distance from its target
  111351. * @param target defines the camera target
  111352. * @param scene defines the scene the camera belongs to
  111353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  111354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  111355. */
  111356. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  111357. /**
  111358. * Gets camera class name
  111359. * @returns VRDeviceOrientationArcRotateCamera
  111360. */
  111361. getClassName(): string;
  111362. }
  111363. }
  111364. declare module BABYLON {
  111365. /**
  111366. * Camera used to simulate VR rendering (based on FreeCamera)
  111367. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  111368. */
  111369. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  111370. /**
  111371. * Creates a new VRDeviceOrientationFreeCamera
  111372. * @param name defines camera name
  111373. * @param position defines the start position of the camera
  111374. * @param scene defines the scene the camera belongs to
  111375. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  111376. * @param vrCameraMetrics defines the vr metrics associated to the camera
  111377. */
  111378. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  111379. /**
  111380. * Gets camera class name
  111381. * @returns VRDeviceOrientationFreeCamera
  111382. */
  111383. getClassName(): string;
  111384. }
  111385. }
  111386. declare module BABYLON {
  111387. /**
  111388. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  111389. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  111390. */
  111391. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  111392. /**
  111393. * Creates a new VRDeviceOrientationGamepadCamera
  111394. * @param name defines camera name
  111395. * @param position defines the start position of the camera
  111396. * @param scene defines the scene the camera belongs to
  111397. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  111398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  111399. */
  111400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  111401. /**
  111402. * Gets camera class name
  111403. * @returns VRDeviceOrientationGamepadCamera
  111404. */
  111405. getClassName(): string;
  111406. }
  111407. }
  111408. declare module BABYLON {
  111409. /** @hidden */
  111410. export var imageProcessingPixelShader: {
  111411. name: string;
  111412. shader: string;
  111413. };
  111414. }
  111415. declare module BABYLON {
  111416. /**
  111417. * ImageProcessingPostProcess
  111418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  111419. */
  111420. export class ImageProcessingPostProcess extends PostProcess {
  111421. /**
  111422. * Default configuration related to image processing available in the PBR Material.
  111423. */
  111424. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111425. /**
  111426. * Gets the image processing configuration used either in this material.
  111427. */
  111428. /**
  111429. * Sets the Default image processing configuration used either in the this material.
  111430. *
  111431. * If sets to null, the scene one is in use.
  111432. */
  111433. imageProcessingConfiguration: ImageProcessingConfiguration;
  111434. /**
  111435. * Keep track of the image processing observer to allow dispose and replace.
  111436. */
  111437. private _imageProcessingObserver;
  111438. /**
  111439. * Attaches a new image processing configuration to the PBR Material.
  111440. * @param configuration
  111441. */
  111442. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  111443. /**
  111444. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  111445. */
  111446. /**
  111447. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  111448. */
  111449. colorCurves: Nullable<ColorCurves>;
  111450. /**
  111451. * Gets wether the color curves effect is enabled.
  111452. */
  111453. /**
  111454. * Sets wether the color curves effect is enabled.
  111455. */
  111456. colorCurvesEnabled: boolean;
  111457. /**
  111458. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  111459. */
  111460. /**
  111461. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  111462. */
  111463. colorGradingTexture: Nullable<BaseTexture>;
  111464. /**
  111465. * Gets wether the color grading effect is enabled.
  111466. */
  111467. /**
  111468. * Gets wether the color grading effect is enabled.
  111469. */
  111470. colorGradingEnabled: boolean;
  111471. /**
  111472. * Gets exposure used in the effect.
  111473. */
  111474. /**
  111475. * Sets exposure used in the effect.
  111476. */
  111477. exposure: number;
  111478. /**
  111479. * Gets wether tonemapping is enabled or not.
  111480. */
  111481. /**
  111482. * Sets wether tonemapping is enabled or not
  111483. */
  111484. toneMappingEnabled: boolean;
  111485. /**
  111486. * Gets the type of tone mapping effect.
  111487. */
  111488. /**
  111489. * Sets the type of tone mapping effect.
  111490. */
  111491. toneMappingType: number;
  111492. /**
  111493. * Gets contrast used in the effect.
  111494. */
  111495. /**
  111496. * Sets contrast used in the effect.
  111497. */
  111498. contrast: number;
  111499. /**
  111500. * Gets Vignette stretch size.
  111501. */
  111502. /**
  111503. * Sets Vignette stretch size.
  111504. */
  111505. vignetteStretch: number;
  111506. /**
  111507. * Gets Vignette centre X Offset.
  111508. */
  111509. /**
  111510. * Sets Vignette centre X Offset.
  111511. */
  111512. vignetteCentreX: number;
  111513. /**
  111514. * Gets Vignette centre Y Offset.
  111515. */
  111516. /**
  111517. * Sets Vignette centre Y Offset.
  111518. */
  111519. vignetteCentreY: number;
  111520. /**
  111521. * Gets Vignette weight or intensity of the vignette effect.
  111522. */
  111523. /**
  111524. * Sets Vignette weight or intensity of the vignette effect.
  111525. */
  111526. vignetteWeight: number;
  111527. /**
  111528. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  111529. * if vignetteEnabled is set to true.
  111530. */
  111531. /**
  111532. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  111533. * if vignetteEnabled is set to true.
  111534. */
  111535. vignetteColor: Color4;
  111536. /**
  111537. * Gets Camera field of view used by the Vignette effect.
  111538. */
  111539. /**
  111540. * Sets Camera field of view used by the Vignette effect.
  111541. */
  111542. vignetteCameraFov: number;
  111543. /**
  111544. * Gets the vignette blend mode allowing different kind of effect.
  111545. */
  111546. /**
  111547. * Sets the vignette blend mode allowing different kind of effect.
  111548. */
  111549. vignetteBlendMode: number;
  111550. /**
  111551. * Gets wether the vignette effect is enabled.
  111552. */
  111553. /**
  111554. * Sets wether the vignette effect is enabled.
  111555. */
  111556. vignetteEnabled: boolean;
  111557. private _fromLinearSpace;
  111558. /**
  111559. * Gets wether the input of the processing is in Gamma or Linear Space.
  111560. */
  111561. /**
  111562. * Sets wether the input of the processing is in Gamma or Linear Space.
  111563. */
  111564. fromLinearSpace: boolean;
  111565. /**
  111566. * Defines cache preventing GC.
  111567. */
  111568. private _defines;
  111569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  111570. /**
  111571. * "ImageProcessingPostProcess"
  111572. * @returns "ImageProcessingPostProcess"
  111573. */
  111574. getClassName(): string;
  111575. protected _updateParameters(): void;
  111576. dispose(camera?: Camera): void;
  111577. }
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. * Class containing static functions to help procedurally build meshes
  111582. */
  111583. export class GroundBuilder {
  111584. /**
  111585. * Creates a ground mesh
  111586. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  111587. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  111588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111589. * @param name defines the name of the mesh
  111590. * @param options defines the options used to create the mesh
  111591. * @param scene defines the hosting scene
  111592. * @returns the ground mesh
  111593. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  111594. */
  111595. static CreateGround(name: string, options: {
  111596. width?: number;
  111597. height?: number;
  111598. subdivisions?: number;
  111599. subdivisionsX?: number;
  111600. subdivisionsY?: number;
  111601. updatable?: boolean;
  111602. }, scene: any): Mesh;
  111603. /**
  111604. * Creates a tiled ground mesh
  111605. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  111606. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  111607. * * 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
  111608. * * 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
  111609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111610. * @param name defines the name of the mesh
  111611. * @param options defines the options used to create the mesh
  111612. * @param scene defines the hosting scene
  111613. * @returns the tiled ground mesh
  111614. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  111615. */
  111616. static CreateTiledGround(name: string, options: {
  111617. xmin: number;
  111618. zmin: number;
  111619. xmax: number;
  111620. zmax: number;
  111621. subdivisions?: {
  111622. w: number;
  111623. h: number;
  111624. };
  111625. precision?: {
  111626. w: number;
  111627. h: number;
  111628. };
  111629. updatable?: boolean;
  111630. }, scene?: Nullable<Scene>): Mesh;
  111631. /**
  111632. * Creates a ground mesh from a height map
  111633. * * The parameter `url` sets the URL of the height map image resource.
  111634. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  111635. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  111636. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  111637. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  111638. * * 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.
  111639. * * 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).
  111640. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  111641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111642. * @param name defines the name of the mesh
  111643. * @param url defines the url to the height map
  111644. * @param options defines the options used to create the mesh
  111645. * @param scene defines the hosting scene
  111646. * @returns the ground mesh
  111647. * @see https://doc.babylonjs.com/babylon101/height_map
  111648. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  111649. */
  111650. static CreateGroundFromHeightMap(name: string, url: string, options: {
  111651. width?: number;
  111652. height?: number;
  111653. subdivisions?: number;
  111654. minHeight?: number;
  111655. maxHeight?: number;
  111656. colorFilter?: Color3;
  111657. alphaFilter?: number;
  111658. updatable?: boolean;
  111659. onReady?: (mesh: GroundMesh) => void;
  111660. }, scene?: Nullable<Scene>): GroundMesh;
  111661. }
  111662. }
  111663. declare module BABYLON {
  111664. /**
  111665. * Class containing static functions to help procedurally build meshes
  111666. */
  111667. export class TorusBuilder {
  111668. /**
  111669. * Creates a torus mesh
  111670. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  111671. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  111672. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  111673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111676. * @param name defines the name of the mesh
  111677. * @param options defines the options used to create the mesh
  111678. * @param scene defines the hosting scene
  111679. * @returns the torus mesh
  111680. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  111681. */
  111682. static CreateTorus(name: string, options: {
  111683. diameter?: number;
  111684. thickness?: number;
  111685. tessellation?: number;
  111686. updatable?: boolean;
  111687. sideOrientation?: number;
  111688. frontUVs?: Vector4;
  111689. backUVs?: Vector4;
  111690. }, scene: any): Mesh;
  111691. }
  111692. }
  111693. declare module BABYLON {
  111694. /**
  111695. * Class containing static functions to help procedurally build meshes
  111696. */
  111697. export class CylinderBuilder {
  111698. /**
  111699. * Creates a cylinder or a cone mesh
  111700. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  111701. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  111702. * * 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.
  111703. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  111704. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  111705. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  111706. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  111707. * * 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).
  111708. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  111709. * * 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).
  111710. * * 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
  111711. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  111712. * * 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
  111713. * * 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.
  111714. * * If `enclose` is false, a ring surface is one element.
  111715. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  111716. * * 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
  111717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111720. * @param name defines the name of the mesh
  111721. * @param options defines the options used to create the mesh
  111722. * @param scene defines the hosting scene
  111723. * @returns the cylinder mesh
  111724. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  111725. */
  111726. static CreateCylinder(name: string, options: {
  111727. height?: number;
  111728. diameterTop?: number;
  111729. diameterBottom?: number;
  111730. diameter?: number;
  111731. tessellation?: number;
  111732. subdivisions?: number;
  111733. arc?: number;
  111734. faceColors?: Color4[];
  111735. faceUV?: Vector4[];
  111736. updatable?: boolean;
  111737. hasRings?: boolean;
  111738. enclose?: boolean;
  111739. cap?: number;
  111740. sideOrientation?: number;
  111741. frontUVs?: Vector4;
  111742. backUVs?: Vector4;
  111743. }, scene: any): Mesh;
  111744. }
  111745. }
  111746. declare module BABYLON {
  111747. /**
  111748. * States of the webXR experience
  111749. */
  111750. export enum WebXRState {
  111751. /**
  111752. * Transitioning to being in XR mode
  111753. */
  111754. ENTERING_XR = 0,
  111755. /**
  111756. * Transitioning to non XR mode
  111757. */
  111758. EXITING_XR = 1,
  111759. /**
  111760. * In XR mode and presenting
  111761. */
  111762. IN_XR = 2,
  111763. /**
  111764. * Not entered XR mode
  111765. */
  111766. NOT_IN_XR = 3
  111767. }
  111768. /**
  111769. * Abstraction of the XR render target
  111770. */
  111771. export interface WebXRRenderTarget extends IDisposable {
  111772. /**
  111773. * xrpresent context of the canvas which can be used to display/mirror xr content
  111774. */
  111775. canvasContext: WebGLRenderingContext;
  111776. /**
  111777. * xr layer for the canvas
  111778. */
  111779. xrLayer: Nullable<XRWebGLLayer>;
  111780. /**
  111781. * Initializes the xr layer for the session
  111782. * @param xrSession xr session
  111783. * @returns a promise that will resolve once the XR Layer has been created
  111784. */
  111785. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  111786. }
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * COnfiguration object for WebXR output canvas
  111791. */
  111792. export class WebXRManagedOutputCanvasOptions {
  111793. /**
  111794. * Options for this XR Layer output
  111795. */
  111796. canvasOptions: XRWebGLLayerOptions;
  111797. /**
  111798. * CSS styling for a newly created canvas (if not provided)
  111799. */
  111800. newCanvasCssStyle?: string;
  111801. /**
  111802. * Get the default values of the configuration object
  111803. * @returns default values of this configuration object
  111804. */
  111805. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  111806. }
  111807. /**
  111808. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  111809. */
  111810. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  111811. private configuration;
  111812. private _engine;
  111813. private _canvas;
  111814. /**
  111815. * xrpresent context of the canvas which can be used to display/mirror xr content
  111816. */
  111817. canvasContext: WebGLRenderingContext;
  111818. /**
  111819. * xr layer for the canvas
  111820. */
  111821. xrLayer: Nullable<XRWebGLLayer>;
  111822. /**
  111823. * Initializes the xr layer for the session
  111824. * @param xrSession xr session
  111825. * @returns a promise that will resolve once the XR Layer has been created
  111826. */
  111827. initializeXRLayerAsync(xrSession: any): any;
  111828. /**
  111829. * Initializes the canvas to be added/removed upon entering/exiting xr
  111830. * @param engine the Babylon engine
  111831. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  111832. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  111833. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  111834. */
  111835. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  111836. /**
  111837. * Disposes of the object
  111838. */
  111839. dispose(): void;
  111840. private _setManagedOutputCanvas;
  111841. private _addCanvas;
  111842. private _removeCanvas;
  111843. }
  111844. }
  111845. declare module BABYLON {
  111846. /**
  111847. * Manages an XRSession to work with Babylon's engine
  111848. * @see https://doc.babylonjs.com/how_to/webxr
  111849. */
  111850. export class WebXRSessionManager implements IDisposable {
  111851. /** The scene which the session should be created for */
  111852. scene: Scene;
  111853. /**
  111854. * Fires every time a new xrFrame arrives which can be used to update the camera
  111855. */
  111856. onXRFrameObservable: Observable<XRFrame>;
  111857. /**
  111858. * Fires when the xr session is ended either by the device or manually done
  111859. */
  111860. onXRSessionEnded: Observable<any>;
  111861. /**
  111862. * Fires when the xr session is ended either by the device or manually done
  111863. */
  111864. onXRSessionInit: Observable<XRSession>;
  111865. /**
  111866. * Underlying xr session
  111867. */
  111868. session: XRSession;
  111869. /**
  111870. * Type of reference space used when creating the session
  111871. */
  111872. referenceSpace: XRReferenceSpace;
  111873. /**
  111874. * Current XR frame
  111875. */
  111876. currentFrame: Nullable<XRFrame>;
  111877. /** WebXR timestamp updated every frame */
  111878. currentTimestamp: number;
  111879. private _xrNavigator;
  111880. private baseLayer;
  111881. private _rttProvider;
  111882. private _sessionEnded;
  111883. /**
  111884. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  111885. * @param scene The scene which the session should be created for
  111886. */
  111887. constructor(
  111888. /** The scene which the session should be created for */
  111889. scene: Scene);
  111890. /**
  111891. * Initializes the manager
  111892. * After initialization enterXR can be called to start an XR session
  111893. * @returns Promise which resolves after it is initialized
  111894. */
  111895. initializeAsync(): Promise<void>;
  111896. /**
  111897. * Initializes an xr session
  111898. * @param xrSessionMode mode to initialize
  111899. * @param optionalFeatures defines optional values to pass to the session builder
  111900. * @returns a promise which will resolve once the session has been initialized
  111901. */
  111902. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  111903. /**
  111904. * Sets the reference space on the xr session
  111905. * @param referenceSpace space to set
  111906. * @returns a promise that will resolve once the reference space has been set
  111907. */
  111908. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  111909. /**
  111910. * Updates the render state of the session
  111911. * @param state state to set
  111912. * @returns a promise that resolves once the render state has been updated
  111913. */
  111914. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  111915. /**
  111916. * Starts rendering to the xr layer
  111917. * @returns a promise that will resolve once rendering has started
  111918. */
  111919. startRenderingToXRAsync(): Promise<void>;
  111920. /**
  111921. * Gets the correct render target texture to be rendered this frame for this eye
  111922. * @param eye the eye for which to get the render target
  111923. * @returns the render target for the specified eye
  111924. */
  111925. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  111926. /**
  111927. * Stops the xrSession and restores the renderloop
  111928. * @returns Promise which resolves after it exits XR
  111929. */
  111930. exitXRAsync(): Promise<void>;
  111931. /**
  111932. * Checks if a session would be supported for the creation options specified
  111933. * @param sessionMode session mode to check if supported eg. immersive-vr
  111934. * @returns true if supported
  111935. */
  111936. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111937. /**
  111938. * Creates a WebXRRenderTarget object for the XR session
  111939. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  111940. * @param options optional options to provide when creating a new render target
  111941. * @returns a WebXR render target to which the session can render
  111942. */
  111943. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  111944. /**
  111945. * @hidden
  111946. * Converts the render layer of xrSession to a render target
  111947. * @param session session to create render target for
  111948. * @param scene scene the new render target should be created for
  111949. * @param baseLayer the webgl layer to create the render target for
  111950. */
  111951. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  111952. /**
  111953. * Disposes of the session manager
  111954. */
  111955. dispose(): void;
  111956. /**
  111957. * Gets a promise returning true when fullfiled if the given session mode is supported
  111958. * @param sessionMode defines the session to test
  111959. * @returns a promise
  111960. */
  111961. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111962. }
  111963. }
  111964. declare module BABYLON {
  111965. /**
  111966. * WebXR Camera which holds the views for the xrSession
  111967. * @see https://doc.babylonjs.com/how_to/webxr
  111968. */
  111969. export class WebXRCamera extends FreeCamera {
  111970. /**
  111971. * Is the camera in debug mode. Used when using an emulator
  111972. */
  111973. debugMode: boolean;
  111974. /**
  111975. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  111976. * @param name the name of the camera
  111977. * @param scene the scene to add the camera to
  111978. */
  111979. constructor(name: string, scene: Scene);
  111980. private _updateNumberOfRigCameras;
  111981. /** @hidden */
  111982. _updateForDualEyeDebugging(): void;
  111983. /**
  111984. * Updates the cameras position from the current pose information of the XR session
  111985. * @param xrSessionManager the session containing pose information
  111986. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  111987. */
  111988. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  111989. }
  111990. }
  111991. declare module BABYLON {
  111992. /**
  111993. * Defining the interface required for a (webxr) feature
  111994. */
  111995. export interface IWebXRFeature extends IDisposable {
  111996. /**
  111997. * Attach the feature to the session
  111998. * Will usually be called by the features manager
  111999. *
  112000. * @returns true if successful.
  112001. */
  112002. attach(): boolean;
  112003. /**
  112004. * Detach the feature from the session
  112005. * Will usually be called by the features manager
  112006. *
  112007. * @returns true if successful.
  112008. */
  112009. detach(): boolean;
  112010. }
  112011. /**
  112012. * Defining the constructor of a feature. Used to register the modules.
  112013. */
  112014. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  112015. /**
  112016. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  112017. * It is mainly used in AR sessions.
  112018. *
  112019. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  112020. */
  112021. export class WebXRFeaturesManager implements IDisposable {
  112022. private _xrSessionManager;
  112023. private static readonly _AvailableFeatures;
  112024. /**
  112025. * Used to register a module. After calling this function a developer can use this feature in the scene.
  112026. * Mainly used internally.
  112027. *
  112028. * @param featureName the name of the feature to register
  112029. * @param constructorFunction the function used to construct the module
  112030. * @param version the (babylon) version of the module
  112031. * @param stable is that a stable version of this module
  112032. */
  112033. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  112034. /**
  112035. * Returns a constructor of a specific feature.
  112036. *
  112037. * @param featureName the name of the feature to construct
  112038. * @param version the version of the feature to load
  112039. * @param xrSessionManager the xrSessionManager. Used to construct the module
  112040. * @param options optional options provided to the module.
  112041. * @returns a function that, when called, will return a new instance of this feature
  112042. */
  112043. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  112044. /**
  112045. * Return the latest unstable version of this feature
  112046. * @param featureName the name of the feature to search
  112047. * @returns the version number. if not found will return -1
  112048. */
  112049. static GetLatestVersionOfFeature(featureName: string): number;
  112050. /**
  112051. * Return the latest stable version of this feature
  112052. * @param featureName the name of the feature to search
  112053. * @returns the version number. if not found will return -1
  112054. */
  112055. static GetStableVersionOfFeature(featureName: string): number;
  112056. /**
  112057. * Can be used to return the list of features currently registered
  112058. *
  112059. * @returns an Array of available features
  112060. */
  112061. static GetAvailableFeatures(): string[];
  112062. /**
  112063. * Gets the versions available for a specific feature
  112064. * @param featureName the name of the feature
  112065. * @returns an array with the available versions
  112066. */
  112067. static GetAvailableVersions(featureName: string): string[];
  112068. private _features;
  112069. /**
  112070. * constructs a new features manages.
  112071. *
  112072. * @param _xrSessionManager an instance of WebXRSessionManager
  112073. */
  112074. constructor(_xrSessionManager: WebXRSessionManager);
  112075. /**
  112076. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  112077. *
  112078. * @param featureName the name of the feature to load or the class of the feature
  112079. * @param version optional version to load. if not provided the latest version will be enabled
  112080. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  112081. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  112082. * @returns a new constructed feature or throws an error if feature not found.
  112083. */
  112084. enableFeature(featureName: string | {
  112085. Name: string;
  112086. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  112087. /**
  112088. * Used to disable an already-enabled feature
  112089. * @param featureName the feature to disable
  112090. * @returns true if disable was successful
  112091. */
  112092. disableFeature(featureName: string | {
  112093. Name: string;
  112094. }): boolean;
  112095. /**
  112096. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  112097. * Can be used during a session to start a feature
  112098. * @param featureName the name of feature to attach
  112099. */
  112100. attachFeature(featureName: string): void;
  112101. /**
  112102. * Can be used inside a session or when the session ends to detach a specific feature
  112103. * @param featureName the name of the feature to detach
  112104. */
  112105. detachFeature(featureName: string): void;
  112106. /**
  112107. * Get the list of enabled features
  112108. * @returns an array of enabled features
  112109. */
  112110. getEnabledFeatures(): string[];
  112111. /**
  112112. * get the implementation of an enabled feature.
  112113. * @param featureName the name of the feature to load
  112114. * @returns the feature class, if found
  112115. */
  112116. getEnabledFeature(featureName: string): IWebXRFeature;
  112117. /**
  112118. * dispose this features manager
  112119. */
  112120. dispose(): void;
  112121. }
  112122. }
  112123. declare module BABYLON {
  112124. /**
  112125. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  112126. * @see https://doc.babylonjs.com/how_to/webxr
  112127. */
  112128. export class WebXRExperienceHelper implements IDisposable {
  112129. private scene;
  112130. /**
  112131. * 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
  112132. */
  112133. container: AbstractMesh;
  112134. /**
  112135. * Camera used to render xr content
  112136. */
  112137. camera: WebXRCamera;
  112138. /**
  112139. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  112140. */
  112141. state: WebXRState;
  112142. private _setState;
  112143. private static _TmpVector;
  112144. /**
  112145. * Fires when the state of the experience helper has changed
  112146. */
  112147. onStateChangedObservable: Observable<WebXRState>;
  112148. /** Session manager used to keep track of xr session */
  112149. sessionManager: WebXRSessionManager;
  112150. /** A features manager for this xr session */
  112151. featuresManager: WebXRFeaturesManager;
  112152. private _nonVRCamera;
  112153. private _originalSceneAutoClear;
  112154. private _supported;
  112155. /**
  112156. * Creates the experience helper
  112157. * @param scene the scene to attach the experience helper to
  112158. * @returns a promise for the experience helper
  112159. */
  112160. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  112161. /**
  112162. * Creates a WebXRExperienceHelper
  112163. * @param scene The scene the helper should be created in
  112164. */
  112165. private constructor();
  112166. /**
  112167. * Exits XR mode and returns the scene to its original state
  112168. * @returns promise that resolves after xr mode has exited
  112169. */
  112170. exitXRAsync(): Promise<void>;
  112171. /**
  112172. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  112173. * @param sessionMode options for the XR session
  112174. * @param referenceSpaceType frame of reference of the XR session
  112175. * @param renderTarget the output canvas that will be used to enter XR mode
  112176. * @returns promise that resolves after xr mode has entered
  112177. */
  112178. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  112179. /**
  112180. * Updates the global position of the camera by moving the camera's container
  112181. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  112182. * @param position The desired global position of the camera
  112183. */
  112184. setPositionOfCameraUsingContainer(position: Vector3): void;
  112185. /**
  112186. * Rotates the xr camera by rotating the camera's container around the camera's position
  112187. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  112188. * @param rotation the desired quaternion rotation to apply to the camera
  112189. */
  112190. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  112191. /**
  112192. * Disposes of the experience helper
  112193. */
  112194. dispose(): void;
  112195. }
  112196. }
  112197. declare module BABYLON {
  112198. /**
  112199. * Represents an XR input
  112200. */
  112201. export class WebXRController {
  112202. private scene;
  112203. /** The underlying input source for the controller */
  112204. inputSource: XRInputSource;
  112205. private parentContainer;
  112206. /**
  112207. * 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
  112208. */
  112209. grip?: AbstractMesh;
  112210. /**
  112211. * Pointer which can be used to select objects or attach a visible laser to
  112212. */
  112213. pointer: AbstractMesh;
  112214. private _gamepadMode;
  112215. /**
  112216. * If available, this is the gamepad object related to this controller.
  112217. * Using this object it is possible to get click events and trackpad changes of the
  112218. * webxr controller that is currently being used.
  112219. */
  112220. gamepadController?: WebVRController;
  112221. /**
  112222. * Event that fires when the controller is removed/disposed
  112223. */
  112224. onDisposeObservable: Observable<{}>;
  112225. private _tmpQuaternion;
  112226. private _tmpVector;
  112227. /**
  112228. * Creates the controller
  112229. * @see https://doc.babylonjs.com/how_to/webxr
  112230. * @param scene the scene which the controller should be associated to
  112231. * @param inputSource the underlying input source for the controller
  112232. * @param parentContainer parent that the controller meshes should be children of
  112233. */
  112234. constructor(scene: Scene,
  112235. /** The underlying input source for the controller */
  112236. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  112237. /**
  112238. * Updates the controller pose based on the given XRFrame
  112239. * @param xrFrame xr frame to update the pose with
  112240. * @param referenceSpace reference space to use
  112241. */
  112242. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  112243. /**
  112244. * Gets a world space ray coming from the controller
  112245. * @param result the resulting ray
  112246. */
  112247. getWorldPointerRayToRef(result: Ray): void;
  112248. /**
  112249. * Get the scene associated with this controller
  112250. * @returns the scene object
  112251. */
  112252. getScene(): Scene;
  112253. /**
  112254. * Disposes of the object
  112255. */
  112256. dispose(): void;
  112257. }
  112258. }
  112259. declare module BABYLON {
  112260. /**
  112261. * XR input used to track XR inputs such as controllers/rays
  112262. */
  112263. export class WebXRInput implements IDisposable {
  112264. /**
  112265. * Base experience the input listens to
  112266. */
  112267. baseExperience: WebXRExperienceHelper;
  112268. /**
  112269. * XR controllers being tracked
  112270. */
  112271. controllers: Array<WebXRController>;
  112272. private _frameObserver;
  112273. private _stateObserver;
  112274. /**
  112275. * Event when a controller has been connected/added
  112276. */
  112277. onControllerAddedObservable: Observable<WebXRController>;
  112278. /**
  112279. * Event when a controller has been removed/disconnected
  112280. */
  112281. onControllerRemovedObservable: Observable<WebXRController>;
  112282. /**
  112283. * Initializes the WebXRInput
  112284. * @param baseExperience experience helper which the input should be created for
  112285. */
  112286. constructor(
  112287. /**
  112288. * Base experience the input listens to
  112289. */
  112290. baseExperience: WebXRExperienceHelper);
  112291. private _onInputSourcesChange;
  112292. private _addAndRemoveControllers;
  112293. /**
  112294. * Disposes of the object
  112295. */
  112296. dispose(): void;
  112297. }
  112298. }
  112299. declare module BABYLON {
  112300. /**
  112301. * Class used to represent data loading progression
  112302. */
  112303. export class SceneLoaderProgressEvent {
  112304. /** defines if data length to load can be evaluated */
  112305. readonly lengthComputable: boolean;
  112306. /** defines the loaded data length */
  112307. readonly loaded: number;
  112308. /** defines the data length to load */
  112309. readonly total: number;
  112310. /**
  112311. * Create a new progress event
  112312. * @param lengthComputable defines if data length to load can be evaluated
  112313. * @param loaded defines the loaded data length
  112314. * @param total defines the data length to load
  112315. */
  112316. constructor(
  112317. /** defines if data length to load can be evaluated */
  112318. lengthComputable: boolean,
  112319. /** defines the loaded data length */
  112320. loaded: number,
  112321. /** defines the data length to load */
  112322. total: number);
  112323. /**
  112324. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  112325. * @param event defines the source event
  112326. * @returns a new SceneLoaderProgressEvent
  112327. */
  112328. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  112329. }
  112330. /**
  112331. * Interface used by SceneLoader plugins to define supported file extensions
  112332. */
  112333. export interface ISceneLoaderPluginExtensions {
  112334. /**
  112335. * Defines the list of supported extensions
  112336. */
  112337. [extension: string]: {
  112338. isBinary: boolean;
  112339. };
  112340. }
  112341. /**
  112342. * Interface used by SceneLoader plugin factory
  112343. */
  112344. export interface ISceneLoaderPluginFactory {
  112345. /**
  112346. * Defines the name of the factory
  112347. */
  112348. name: string;
  112349. /**
  112350. * Function called to create a new plugin
  112351. * @return the new plugin
  112352. */
  112353. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  112354. /**
  112355. * The callback that returns true if the data can be directly loaded.
  112356. * @param data string containing the file data
  112357. * @returns if the data can be loaded directly
  112358. */
  112359. canDirectLoad?(data: string): boolean;
  112360. }
  112361. /**
  112362. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  112363. */
  112364. export interface ISceneLoaderPluginBase {
  112365. /**
  112366. * The friendly name of this plugin.
  112367. */
  112368. name: string;
  112369. /**
  112370. * The file extensions supported by this plugin.
  112371. */
  112372. extensions: string | ISceneLoaderPluginExtensions;
  112373. /**
  112374. * The callback called when loading from a url.
  112375. * @param scene scene loading this url
  112376. * @param url url to load
  112377. * @param onSuccess callback called when the file successfully loads
  112378. * @param onProgress callback called while file is loading (if the server supports this mode)
  112379. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112380. * @param onError callback called when the file fails to load
  112381. * @returns a file request object
  112382. */
  112383. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  112384. /**
  112385. * The callback called when loading from a file object.
  112386. * @param scene scene loading this file
  112387. * @param file defines the file to load
  112388. * @param onSuccess defines the callback to call when data is loaded
  112389. * @param onProgress defines the callback to call during loading process
  112390. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  112391. * @param onError defines the callback to call when an error occurs
  112392. * @returns a file request object
  112393. */
  112394. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  112395. /**
  112396. * The callback that returns true if the data can be directly loaded.
  112397. * @param data string containing the file data
  112398. * @returns if the data can be loaded directly
  112399. */
  112400. canDirectLoad?(data: string): boolean;
  112401. /**
  112402. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  112403. * @param scene scene loading this data
  112404. * @param data string containing the data
  112405. * @returns data to pass to the plugin
  112406. */
  112407. directLoad?(scene: Scene, data: string): any;
  112408. /**
  112409. * The callback that allows custom handling of the root url based on the response url.
  112410. * @param rootUrl the original root url
  112411. * @param responseURL the response url if available
  112412. * @returns the new root url
  112413. */
  112414. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  112415. }
  112416. /**
  112417. * Interface used to define a SceneLoader plugin
  112418. */
  112419. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  112420. /**
  112421. * Import meshes into a scene.
  112422. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  112423. * @param scene The scene to import into
  112424. * @param data The data to import
  112425. * @param rootUrl The root url for scene and resources
  112426. * @param meshes The meshes array to import into
  112427. * @param particleSystems The particle systems array to import into
  112428. * @param skeletons The skeletons array to import into
  112429. * @param onError The callback when import fails
  112430. * @returns True if successful or false otherwise
  112431. */
  112432. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  112433. /**
  112434. * Load into a scene.
  112435. * @param scene The scene to load into
  112436. * @param data The data to import
  112437. * @param rootUrl The root url for scene and resources
  112438. * @param onError The callback when import fails
  112439. * @returns True if successful or false otherwise
  112440. */
  112441. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  112442. /**
  112443. * Load into an asset container.
  112444. * @param scene The scene to load into
  112445. * @param data The data to import
  112446. * @param rootUrl The root url for scene and resources
  112447. * @param onError The callback when import fails
  112448. * @returns The loaded asset container
  112449. */
  112450. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  112451. }
  112452. /**
  112453. * Interface used to define an async SceneLoader plugin
  112454. */
  112455. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  112456. /**
  112457. * Import meshes into a scene.
  112458. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  112459. * @param scene The scene to import into
  112460. * @param data The data to import
  112461. * @param rootUrl The root url for scene and resources
  112462. * @param onProgress The callback when the load progresses
  112463. * @param fileName Defines the name of the file to load
  112464. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  112465. */
  112466. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  112467. meshes: AbstractMesh[];
  112468. particleSystems: IParticleSystem[];
  112469. skeletons: Skeleton[];
  112470. animationGroups: AnimationGroup[];
  112471. }>;
  112472. /**
  112473. * Load into a scene.
  112474. * @param scene The scene to load into
  112475. * @param data The data to import
  112476. * @param rootUrl The root url for scene and resources
  112477. * @param onProgress The callback when the load progresses
  112478. * @param fileName Defines the name of the file to load
  112479. * @returns Nothing
  112480. */
  112481. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  112482. /**
  112483. * Load into an asset container.
  112484. * @param scene The scene to load into
  112485. * @param data The data to import
  112486. * @param rootUrl The root url for scene and resources
  112487. * @param onProgress The callback when the load progresses
  112488. * @param fileName Defines the name of the file to load
  112489. * @returns The loaded asset container
  112490. */
  112491. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  112492. }
  112493. /**
  112494. * Mode that determines how to handle old animation groups before loading new ones.
  112495. */
  112496. export enum SceneLoaderAnimationGroupLoadingMode {
  112497. /**
  112498. * Reset all old animations to initial state then dispose them.
  112499. */
  112500. Clean = 0,
  112501. /**
  112502. * Stop all old animations.
  112503. */
  112504. Stop = 1,
  112505. /**
  112506. * Restart old animations from first frame.
  112507. */
  112508. Sync = 2,
  112509. /**
  112510. * Old animations remains untouched.
  112511. */
  112512. NoSync = 3
  112513. }
  112514. /**
  112515. * Class used to load scene from various file formats using registered plugins
  112516. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  112517. */
  112518. export class SceneLoader {
  112519. /**
  112520. * No logging while loading
  112521. */
  112522. static readonly NO_LOGGING: number;
  112523. /**
  112524. * Minimal logging while loading
  112525. */
  112526. static readonly MINIMAL_LOGGING: number;
  112527. /**
  112528. * Summary logging while loading
  112529. */
  112530. static readonly SUMMARY_LOGGING: number;
  112531. /**
  112532. * Detailled logging while loading
  112533. */
  112534. static readonly DETAILED_LOGGING: number;
  112535. /**
  112536. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  112537. */
  112538. static ForceFullSceneLoadingForIncremental: boolean;
  112539. /**
  112540. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  112541. */
  112542. static ShowLoadingScreen: boolean;
  112543. /**
  112544. * Defines the current logging level (while loading the scene)
  112545. * @ignorenaming
  112546. */
  112547. static loggingLevel: number;
  112548. /**
  112549. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  112550. */
  112551. static CleanBoneMatrixWeights: boolean;
  112552. /**
  112553. * Event raised when a plugin is used to load a scene
  112554. */
  112555. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  112556. private static _registeredPlugins;
  112557. private static _getDefaultPlugin;
  112558. private static _getPluginForExtension;
  112559. private static _getPluginForDirectLoad;
  112560. private static _getPluginForFilename;
  112561. private static _getDirectLoad;
  112562. private static _loadData;
  112563. private static _getFileInfo;
  112564. /**
  112565. * Gets a plugin that can load the given extension
  112566. * @param extension defines the extension to load
  112567. * @returns a plugin or null if none works
  112568. */
  112569. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  112570. /**
  112571. * Gets a boolean indicating that the given extension can be loaded
  112572. * @param extension defines the extension to load
  112573. * @returns true if the extension is supported
  112574. */
  112575. static IsPluginForExtensionAvailable(extension: string): boolean;
  112576. /**
  112577. * Adds a new plugin to the list of registered plugins
  112578. * @param plugin defines the plugin to add
  112579. */
  112580. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  112581. /**
  112582. * Import meshes into a scene
  112583. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  112584. * @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)
  112585. * @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)
  112586. * @param scene the instance of BABYLON.Scene to append to
  112587. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  112588. * @param onProgress a callback with a progress event for each file being loaded
  112589. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112590. * @param pluginExtension the extension used to determine the plugin
  112591. * @returns The loaded plugin
  112592. */
  112593. 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>;
  112594. /**
  112595. * Import meshes into a scene
  112596. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  112597. * @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)
  112598. * @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)
  112599. * @param scene the instance of BABYLON.Scene to append to
  112600. * @param onProgress a callback with a progress event for each file being loaded
  112601. * @param pluginExtension the extension used to determine the plugin
  112602. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  112603. */
  112604. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  112605. meshes: AbstractMesh[];
  112606. particleSystems: IParticleSystem[];
  112607. skeletons: Skeleton[];
  112608. animationGroups: AnimationGroup[];
  112609. }>;
  112610. /**
  112611. * Load a scene
  112612. * @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)
  112613. * @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)
  112614. * @param engine is the instance of BABYLON.Engine to use to create the scene
  112615. * @param onSuccess a callback with the scene when import succeeds
  112616. * @param onProgress a callback with a progress event for each file being loaded
  112617. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112618. * @param pluginExtension the extension used to determine the plugin
  112619. * @returns The loaded plugin
  112620. */
  112621. 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>;
  112622. /**
  112623. * Load a scene
  112624. * @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)
  112625. * @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)
  112626. * @param engine is the instance of BABYLON.Engine to use to create the scene
  112627. * @param onProgress a callback with a progress event for each file being loaded
  112628. * @param pluginExtension the extension used to determine the plugin
  112629. * @returns The loaded scene
  112630. */
  112631. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  112632. /**
  112633. * Append a scene
  112634. * @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)
  112635. * @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)
  112636. * @param scene is the instance of BABYLON.Scene to append to
  112637. * @param onSuccess a callback with the scene when import succeeds
  112638. * @param onProgress a callback with a progress event for each file being loaded
  112639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112640. * @param pluginExtension the extension used to determine the plugin
  112641. * @returns The loaded plugin
  112642. */
  112643. 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>;
  112644. /**
  112645. * Append a scene
  112646. * @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)
  112647. * @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)
  112648. * @param scene is the instance of BABYLON.Scene to append to
  112649. * @param onProgress a callback with a progress event for each file being loaded
  112650. * @param pluginExtension the extension used to determine the plugin
  112651. * @returns The given scene
  112652. */
  112653. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  112654. /**
  112655. * Load a scene into an asset container
  112656. * @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)
  112657. * @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)
  112658. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  112659. * @param onSuccess a callback with the scene when import succeeds
  112660. * @param onProgress a callback with a progress event for each file being loaded
  112661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112662. * @param pluginExtension the extension used to determine the plugin
  112663. * @returns The loaded plugin
  112664. */
  112665. 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>;
  112666. /**
  112667. * Load a scene into an asset container
  112668. * @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)
  112669. * @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)
  112670. * @param scene is the instance of Scene to append to
  112671. * @param onProgress a callback with a progress event for each file being loaded
  112672. * @param pluginExtension the extension used to determine the plugin
  112673. * @returns The loaded asset container
  112674. */
  112675. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  112676. /**
  112677. * Import animations from a file into a scene
  112678. * @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)
  112679. * @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)
  112680. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  112681. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  112682. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  112683. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  112684. * @param onSuccess a callback with the scene when import succeeds
  112685. * @param onProgress a callback with a progress event for each file being loaded
  112686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112687. */
  112688. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  112689. /**
  112690. * Import animations from a file into a scene
  112691. * @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)
  112692. * @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)
  112693. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  112694. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  112695. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  112696. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  112697. * @param onSuccess a callback with the scene when import succeeds
  112698. * @param onProgress a callback with a progress event for each file being loaded
  112699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  112700. * @returns the updated scene with imported animations
  112701. */
  112702. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  112703. }
  112704. }
  112705. declare module BABYLON {
  112706. /**
  112707. * Generic Controller
  112708. */
  112709. export class GenericController extends WebVRController {
  112710. /**
  112711. * Base Url for the controller model.
  112712. */
  112713. static readonly MODEL_BASE_URL: string;
  112714. /**
  112715. * File name for the controller model.
  112716. */
  112717. static readonly MODEL_FILENAME: string;
  112718. /**
  112719. * Creates a new GenericController from a gamepad
  112720. * @param vrGamepad the gamepad that the controller should be created from
  112721. */
  112722. constructor(vrGamepad: any);
  112723. /**
  112724. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112725. * @param scene scene in which to add meshes
  112726. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112727. */
  112728. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112729. /**
  112730. * Called once for each button that changed state since the last frame
  112731. * @param buttonIdx Which button index changed
  112732. * @param state New state of the button
  112733. * @param changes Which properties on the state changed since last frame
  112734. */
  112735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112736. }
  112737. }
  112738. declare module BABYLON {
  112739. /**
  112740. * Defines the WindowsMotionController object that the state of the windows motion controller
  112741. */
  112742. export class WindowsMotionController extends WebVRController {
  112743. /**
  112744. * The base url used to load the left and right controller models
  112745. */
  112746. static MODEL_BASE_URL: string;
  112747. /**
  112748. * The name of the left controller model file
  112749. */
  112750. static MODEL_LEFT_FILENAME: string;
  112751. /**
  112752. * The name of the right controller model file
  112753. */
  112754. static MODEL_RIGHT_FILENAME: string;
  112755. /**
  112756. * The controller name prefix for this controller type
  112757. */
  112758. static readonly GAMEPAD_ID_PREFIX: string;
  112759. /**
  112760. * The controller id pattern for this controller type
  112761. */
  112762. private static readonly GAMEPAD_ID_PATTERN;
  112763. private _loadedMeshInfo;
  112764. protected readonly _mapping: {
  112765. buttons: string[];
  112766. buttonMeshNames: {
  112767. 'trigger': string;
  112768. 'menu': string;
  112769. 'grip': string;
  112770. 'thumbstick': string;
  112771. 'trackpad': string;
  112772. };
  112773. buttonObservableNames: {
  112774. 'trigger': string;
  112775. 'menu': string;
  112776. 'grip': string;
  112777. 'thumbstick': string;
  112778. 'trackpad': string;
  112779. };
  112780. axisMeshNames: string[];
  112781. pointingPoseMeshName: string;
  112782. };
  112783. /**
  112784. * Fired when the trackpad on this controller is clicked
  112785. */
  112786. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112787. /**
  112788. * Fired when the trackpad on this controller is modified
  112789. */
  112790. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112791. /**
  112792. * The current x and y values of this controller's trackpad
  112793. */
  112794. trackpad: StickValues;
  112795. /**
  112796. * Creates a new WindowsMotionController from a gamepad
  112797. * @param vrGamepad the gamepad that the controller should be created from
  112798. */
  112799. constructor(vrGamepad: any);
  112800. /**
  112801. * Fired when the trigger on this controller is modified
  112802. */
  112803. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112804. /**
  112805. * Fired when the menu button on this controller is modified
  112806. */
  112807. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112808. /**
  112809. * Fired when the grip button on this controller is modified
  112810. */
  112811. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112812. /**
  112813. * Fired when the thumbstick button on this controller is modified
  112814. */
  112815. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112816. /**
  112817. * Fired when the touchpad button on this controller is modified
  112818. */
  112819. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112820. /**
  112821. * Fired when the touchpad values on this controller are modified
  112822. */
  112823. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  112824. protected _updateTrackpad(): void;
  112825. /**
  112826. * Called once per frame by the engine.
  112827. */
  112828. update(): void;
  112829. /**
  112830. * Called once for each button that changed state since the last frame
  112831. * @param buttonIdx Which button index changed
  112832. * @param state New state of the button
  112833. * @param changes Which properties on the state changed since last frame
  112834. */
  112835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112836. /**
  112837. * Moves the buttons on the controller mesh based on their current state
  112838. * @param buttonName the name of the button to move
  112839. * @param buttonValue the value of the button which determines the buttons new position
  112840. */
  112841. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  112842. /**
  112843. * Moves the axis on the controller mesh based on its current state
  112844. * @param axis the index of the axis
  112845. * @param axisValue the value of the axis which determines the meshes new position
  112846. * @hidden
  112847. */
  112848. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  112849. /**
  112850. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112851. * @param scene scene in which to add meshes
  112852. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112853. */
  112854. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  112855. /**
  112856. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  112857. * can be transformed by button presses and axes values, based on this._mapping.
  112858. *
  112859. * @param scene scene in which the meshes exist
  112860. * @param meshes list of meshes that make up the controller model to process
  112861. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  112862. */
  112863. private processModel;
  112864. private createMeshInfo;
  112865. /**
  112866. * Gets the ray of the controller in the direction the controller is pointing
  112867. * @param length the length the resulting ray should be
  112868. * @returns a ray in the direction the controller is pointing
  112869. */
  112870. getForwardRay(length?: number): Ray;
  112871. /**
  112872. * Disposes of the controller
  112873. */
  112874. dispose(): void;
  112875. }
  112876. /**
  112877. * This class represents a new windows motion controller in XR.
  112878. */
  112879. export class XRWindowsMotionController extends WindowsMotionController {
  112880. /**
  112881. * Changing the original WIndowsMotionController mapping to fir the new mapping
  112882. */
  112883. protected readonly _mapping: {
  112884. buttons: string[];
  112885. buttonMeshNames: {
  112886. 'trigger': string;
  112887. 'menu': string;
  112888. 'grip': string;
  112889. 'thumbstick': string;
  112890. 'trackpad': string;
  112891. };
  112892. buttonObservableNames: {
  112893. 'trigger': string;
  112894. 'menu': string;
  112895. 'grip': string;
  112896. 'thumbstick': string;
  112897. 'trackpad': string;
  112898. };
  112899. axisMeshNames: string[];
  112900. pointingPoseMeshName: string;
  112901. };
  112902. /**
  112903. * Construct a new XR-Based windows motion controller
  112904. *
  112905. * @param gamepadInfo the gamepad object from the browser
  112906. */
  112907. constructor(gamepadInfo: any);
  112908. /**
  112909. * holds the thumbstick values (X,Y)
  112910. */
  112911. thumbstickValues: StickValues;
  112912. /**
  112913. * Fired when the thumbstick on this controller is clicked
  112914. */
  112915. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  112916. /**
  112917. * Fired when the thumbstick on this controller is modified
  112918. */
  112919. onThumbstickValuesChangedObservable: Observable<StickValues>;
  112920. /**
  112921. * Fired when the touchpad button on this controller is modified
  112922. */
  112923. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112924. /**
  112925. * Fired when the touchpad values on this controller are modified
  112926. */
  112927. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112928. /**
  112929. * Fired when the thumbstick button on this controller is modified
  112930. * here to prevent breaking changes
  112931. */
  112932. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112933. /**
  112934. * updating the thumbstick(!) and not the trackpad.
  112935. * This is named this way due to the difference between WebVR and XR and to avoid
  112936. * changing the parent class.
  112937. */
  112938. protected _updateTrackpad(): void;
  112939. /**
  112940. * Disposes the class with joy
  112941. */
  112942. dispose(): void;
  112943. }
  112944. }
  112945. declare module BABYLON {
  112946. /**
  112947. * Oculus Touch Controller
  112948. */
  112949. export class OculusTouchController extends WebVRController {
  112950. /**
  112951. * Base Url for the controller model.
  112952. */
  112953. static MODEL_BASE_URL: string;
  112954. /**
  112955. * File name for the left controller model.
  112956. */
  112957. static MODEL_LEFT_FILENAME: string;
  112958. /**
  112959. * File name for the right controller model.
  112960. */
  112961. static MODEL_RIGHT_FILENAME: string;
  112962. /**
  112963. * Base Url for the Quest controller model.
  112964. */
  112965. static QUEST_MODEL_BASE_URL: string;
  112966. /**
  112967. * @hidden
  112968. * If the controllers are running on a device that needs the updated Quest controller models
  112969. */
  112970. static _IsQuest: boolean;
  112971. /**
  112972. * Fired when the secondary trigger on this controller is modified
  112973. */
  112974. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112975. /**
  112976. * Fired when the thumb rest on this controller is modified
  112977. */
  112978. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  112979. /**
  112980. * Creates a new OculusTouchController from a gamepad
  112981. * @param vrGamepad the gamepad that the controller should be created from
  112982. */
  112983. constructor(vrGamepad: any);
  112984. /**
  112985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112986. * @param scene scene in which to add meshes
  112987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112988. */
  112989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112990. /**
  112991. * Fired when the A button on this controller is modified
  112992. */
  112993. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112994. /**
  112995. * Fired when the B button on this controller is modified
  112996. */
  112997. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112998. /**
  112999. * Fired when the X button on this controller is modified
  113000. */
  113001. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  113002. /**
  113003. * Fired when the Y button on this controller is modified
  113004. */
  113005. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  113006. /**
  113007. * Called once for each button that changed state since the last frame
  113008. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  113009. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  113010. * 2) secondary trigger (same)
  113011. * 3) A (right) X (left), touch, pressed = value
  113012. * 4) B / Y
  113013. * 5) thumb rest
  113014. * @param buttonIdx Which button index changed
  113015. * @param state New state of the button
  113016. * @param changes Which properties on the state changed since last frame
  113017. */
  113018. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * Vive Controller
  113024. */
  113025. export class ViveController extends WebVRController {
  113026. /**
  113027. * Base Url for the controller model.
  113028. */
  113029. static MODEL_BASE_URL: string;
  113030. /**
  113031. * File name for the controller model.
  113032. */
  113033. static MODEL_FILENAME: string;
  113034. /**
  113035. * Creates a new ViveController from a gamepad
  113036. * @param vrGamepad the gamepad that the controller should be created from
  113037. */
  113038. constructor(vrGamepad: any);
  113039. /**
  113040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113041. * @param scene scene in which to add meshes
  113042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113043. */
  113044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113045. /**
  113046. * Fired when the left button on this controller is modified
  113047. */
  113048. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  113049. /**
  113050. * Fired when the right button on this controller is modified
  113051. */
  113052. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  113053. /**
  113054. * Fired when the menu button on this controller is modified
  113055. */
  113056. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  113057. /**
  113058. * Called once for each button that changed state since the last frame
  113059. * Vive mapping:
  113060. * 0: touchpad
  113061. * 1: trigger
  113062. * 2: left AND right buttons
  113063. * 3: menu button
  113064. * @param buttonIdx Which button index changed
  113065. * @param state New state of the button
  113066. * @param changes Which properties on the state changed since last frame
  113067. */
  113068. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113069. }
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  113074. */
  113075. export class WebXRControllerModelLoader {
  113076. /**
  113077. * an observable that triggers when a new model (the mesh itself) was initialized.
  113078. * To know when the mesh was loaded use the controller's own modelLoaded() method
  113079. */
  113080. onControllerModelLoaded: Observable<WebXRController>;
  113081. /**
  113082. * Creates the WebXRControllerModelLoader
  113083. * @param input xr input that creates the controllers
  113084. */
  113085. constructor(input: WebXRInput);
  113086. }
  113087. }
  113088. declare module BABYLON {
  113089. /**
  113090. * Handles pointer input automatically for the pointer of XR controllers
  113091. */
  113092. export class WebXRControllerPointerSelection {
  113093. private static _idCounter;
  113094. private _tmpRay;
  113095. /**
  113096. * Creates a WebXRControllerPointerSelection
  113097. * @param input input manager to setup pointer selection
  113098. */
  113099. constructor(input: WebXRInput);
  113100. private _convertNormalToDirectionOfRay;
  113101. private _updatePointerDistance;
  113102. }
  113103. }
  113104. declare module BABYLON {
  113105. /**
  113106. * Enables teleportation
  113107. */
  113108. export class WebXRControllerTeleportation {
  113109. private _teleportationFillColor;
  113110. private _teleportationBorderColor;
  113111. private _tmpRay;
  113112. private _tmpVector;
  113113. /**
  113114. * when set to true (default) teleportation will wait for thumbstick changes.
  113115. * When set to false teleportation will be disabled.
  113116. *
  113117. * If set to false while teleporting results can be unexpected.
  113118. */
  113119. enabled: boolean;
  113120. /**
  113121. * Creates a WebXRControllerTeleportation
  113122. * @param input input manager to add teleportation to
  113123. * @param floorMeshes floormeshes which can be teleported to
  113124. */
  113125. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  113126. }
  113127. }
  113128. declare module BABYLON {
  113129. /**
  113130. * Button which can be used to enter a different mode of XR
  113131. */
  113132. export class WebXREnterExitUIButton {
  113133. /** button element */
  113134. element: HTMLElement;
  113135. /** XR initialization options for the button */
  113136. sessionMode: XRSessionMode;
  113137. /** Reference space type */
  113138. referenceSpaceType: XRReferenceSpaceType;
  113139. /**
  113140. * Creates a WebXREnterExitUIButton
  113141. * @param element button element
  113142. * @param sessionMode XR initialization session mode
  113143. * @param referenceSpaceType the type of reference space to be used
  113144. */
  113145. constructor(
  113146. /** button element */
  113147. element: HTMLElement,
  113148. /** XR initialization options for the button */
  113149. sessionMode: XRSessionMode,
  113150. /** Reference space type */
  113151. referenceSpaceType: XRReferenceSpaceType);
  113152. /**
  113153. * Overwritable function which can be used to update the button's visuals when the state changes
  113154. * @param activeButton the current active button in the UI
  113155. */
  113156. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  113157. }
  113158. /**
  113159. * Options to create the webXR UI
  113160. */
  113161. export class WebXREnterExitUIOptions {
  113162. /**
  113163. * Context to enter xr with
  113164. */
  113165. renderTarget?: Nullable<WebXRRenderTarget>;
  113166. /**
  113167. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  113168. */
  113169. customButtons?: Array<WebXREnterExitUIButton>;
  113170. /**
  113171. * A session mode to use when creating the default button.
  113172. * Default is immersive-vr
  113173. */
  113174. sessionMode?: XRSessionMode;
  113175. /**
  113176. * A reference space type to use when creating the default button.
  113177. * Default is local-floor
  113178. */
  113179. referenceSpaceType?: XRReferenceSpaceType;
  113180. }
  113181. /**
  113182. * UI to allow the user to enter/exit XR mode
  113183. */
  113184. export class WebXREnterExitUI implements IDisposable {
  113185. private scene;
  113186. /** version of the options passed to this UI */
  113187. options: WebXREnterExitUIOptions;
  113188. private _overlay;
  113189. private _buttons;
  113190. private _activeButton;
  113191. /**
  113192. * Fired every time the active button is changed.
  113193. *
  113194. * When xr is entered via a button that launches xr that button will be the callback parameter
  113195. *
  113196. * When exiting xr the callback parameter will be null)
  113197. */
  113198. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  113199. /**
  113200. * Creates UI to allow the user to enter/exit XR mode
  113201. * @param scene the scene to add the ui to
  113202. * @param helper the xr experience helper to enter/exit xr with
  113203. * @param options options to configure the UI
  113204. * @returns the created ui
  113205. */
  113206. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  113207. /**
  113208. *
  113209. * @param scene babylon scene object to use
  113210. * @param options (read-only) version of the options passed to this UI
  113211. */
  113212. private constructor();
  113213. private _updateButtons;
  113214. /**
  113215. * Disposes of the object
  113216. */
  113217. dispose(): void;
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /**
  113222. * Options for the default xr helper
  113223. */
  113224. export class WebXRDefaultExperienceOptions {
  113225. /**
  113226. * Floor meshes that should be used for teleporting
  113227. */
  113228. floorMeshes: Array<AbstractMesh>;
  113229. /**
  113230. * Enable or disable default UI to enter XR
  113231. */
  113232. disableDefaultUI?: boolean;
  113233. /**
  113234. * optional configuration for the output canvas
  113235. */
  113236. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  113237. /**
  113238. * optional UI options. This can be used among other to change session mode and reference space type
  113239. */
  113240. uiOptions?: WebXREnterExitUIOptions;
  113241. }
  113242. /**
  113243. * Default experience which provides a similar setup to the previous webVRExperience
  113244. */
  113245. export class WebXRDefaultExperience {
  113246. /**
  113247. * Base experience
  113248. */
  113249. baseExperience: WebXRExperienceHelper;
  113250. /**
  113251. * Input experience extension
  113252. */
  113253. input: WebXRInput;
  113254. /**
  113255. * Loads the controller models
  113256. */
  113257. controllerModelLoader: WebXRControllerModelLoader;
  113258. /**
  113259. * Enables laser pointer and selection
  113260. */
  113261. pointerSelection: WebXRControllerPointerSelection;
  113262. /**
  113263. * Enables teleportation
  113264. */
  113265. teleportation: WebXRControllerTeleportation;
  113266. /**
  113267. * Enables ui for entering/exiting xr
  113268. */
  113269. enterExitUI: WebXREnterExitUI;
  113270. /**
  113271. * Default target xr should render to
  113272. */
  113273. renderTarget: WebXRRenderTarget;
  113274. /**
  113275. * Creates the default xr experience
  113276. * @param scene scene
  113277. * @param options options for basic configuration
  113278. * @returns resulting WebXRDefaultExperience
  113279. */
  113280. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113281. private constructor();
  113282. /**
  113283. * DIsposes of the experience helper
  113284. */
  113285. dispose(): void;
  113286. }
  113287. }
  113288. declare module BABYLON {
  113289. /**
  113290. * Options to modify the vr teleportation behavior.
  113291. */
  113292. export interface VRTeleportationOptions {
  113293. /**
  113294. * The name of the mesh which should be used as the teleportation floor. (default: null)
  113295. */
  113296. floorMeshName?: string;
  113297. /**
  113298. * A list of meshes to be used as the teleportation floor. (default: empty)
  113299. */
  113300. floorMeshes?: Mesh[];
  113301. /**
  113302. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  113303. */
  113304. teleportationMode?: number;
  113305. /**
  113306. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  113307. */
  113308. teleportationTime?: number;
  113309. /**
  113310. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  113311. */
  113312. teleportationSpeed?: number;
  113313. /**
  113314. * The easing function used in the animation or null for Linear. (default CircleEase)
  113315. */
  113316. easingFunction?: EasingFunction;
  113317. }
  113318. /**
  113319. * Options to modify the vr experience helper's behavior.
  113320. */
  113321. export interface VRExperienceHelperOptions extends WebVROptions {
  113322. /**
  113323. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  113324. */
  113325. createDeviceOrientationCamera?: boolean;
  113326. /**
  113327. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  113328. */
  113329. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  113330. /**
  113331. * Uses the main button on the controller to toggle the laser casted. (default: true)
  113332. */
  113333. laserToggle?: boolean;
  113334. /**
  113335. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  113336. */
  113337. floorMeshes?: Mesh[];
  113338. /**
  113339. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  113340. */
  113341. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  113342. /**
  113343. * Defines if WebXR should be used instead of WebVR (if available)
  113344. */
  113345. useXR?: boolean;
  113346. }
  113347. /**
  113348. * Event containing information after VR has been entered
  113349. */
  113350. export class OnAfterEnteringVRObservableEvent {
  113351. /**
  113352. * If entering vr was successful
  113353. */
  113354. success: boolean;
  113355. }
  113356. /**
  113357. * Helps to quickly add VR support to an existing scene.
  113358. * See http://doc.babylonjs.com/how_to/webvr_helper
  113359. */
  113360. export class VRExperienceHelper {
  113361. /** Options to modify the vr experience helper's behavior. */
  113362. webVROptions: VRExperienceHelperOptions;
  113363. private _scene;
  113364. private _position;
  113365. private _btnVR;
  113366. private _btnVRDisplayed;
  113367. private _webVRsupported;
  113368. private _webVRready;
  113369. private _webVRrequesting;
  113370. private _webVRpresenting;
  113371. private _hasEnteredVR;
  113372. private _fullscreenVRpresenting;
  113373. private _inputElement;
  113374. private _webVRCamera;
  113375. private _vrDeviceOrientationCamera;
  113376. private _deviceOrientationCamera;
  113377. private _existingCamera;
  113378. private _onKeyDown;
  113379. private _onVrDisplayPresentChange;
  113380. private _onVRDisplayChanged;
  113381. private _onVRRequestPresentStart;
  113382. private _onVRRequestPresentComplete;
  113383. /**
  113384. * 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)
  113385. */
  113386. enableGazeEvenWhenNoPointerLock: boolean;
  113387. /**
  113388. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  113389. */
  113390. exitVROnDoubleTap: boolean;
  113391. /**
  113392. * Observable raised right before entering VR.
  113393. */
  113394. onEnteringVRObservable: Observable<VRExperienceHelper>;
  113395. /**
  113396. * Observable raised when entering VR has completed.
  113397. */
  113398. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  113399. /**
  113400. * Observable raised when exiting VR.
  113401. */
  113402. onExitingVRObservable: Observable<VRExperienceHelper>;
  113403. /**
  113404. * Observable raised when controller mesh is loaded.
  113405. */
  113406. onControllerMeshLoadedObservable: Observable<WebVRController>;
  113407. /** Return this.onEnteringVRObservable
  113408. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  113409. */
  113410. readonly onEnteringVR: Observable<VRExperienceHelper>;
  113411. /** Return this.onExitingVRObservable
  113412. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  113413. */
  113414. readonly onExitingVR: Observable<VRExperienceHelper>;
  113415. /** Return this.onControllerMeshLoadedObservable
  113416. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  113417. */
  113418. readonly onControllerMeshLoaded: Observable<WebVRController>;
  113419. private _rayLength;
  113420. private _useCustomVRButton;
  113421. private _teleportationRequested;
  113422. private _teleportActive;
  113423. private _floorMeshName;
  113424. private _floorMeshesCollection;
  113425. private _teleportationMode;
  113426. private _teleportationTime;
  113427. private _teleportationSpeed;
  113428. private _teleportationEasing;
  113429. private _rotationAllowed;
  113430. private _teleportBackwardsVector;
  113431. private _teleportationTarget;
  113432. private _isDefaultTeleportationTarget;
  113433. private _postProcessMove;
  113434. private _teleportationFillColor;
  113435. private _teleportationBorderColor;
  113436. private _rotationAngle;
  113437. private _haloCenter;
  113438. private _cameraGazer;
  113439. private _padSensibilityUp;
  113440. private _padSensibilityDown;
  113441. private _leftController;
  113442. private _rightController;
  113443. /**
  113444. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  113445. */
  113446. onNewMeshSelected: Observable<AbstractMesh>;
  113447. /**
  113448. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  113449. * This observable will provide the mesh and the controller used to select the mesh
  113450. */
  113451. onMeshSelectedWithController: Observable<{
  113452. mesh: AbstractMesh;
  113453. controller: WebVRController;
  113454. }>;
  113455. /**
  113456. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  113457. */
  113458. onNewMeshPicked: Observable<PickingInfo>;
  113459. private _circleEase;
  113460. /**
  113461. * Observable raised before camera teleportation
  113462. */
  113463. onBeforeCameraTeleport: Observable<Vector3>;
  113464. /**
  113465. * Observable raised after camera teleportation
  113466. */
  113467. onAfterCameraTeleport: Observable<Vector3>;
  113468. /**
  113469. * Observable raised when current selected mesh gets unselected
  113470. */
  113471. onSelectedMeshUnselected: Observable<AbstractMesh>;
  113472. private _raySelectionPredicate;
  113473. /**
  113474. * To be optionaly changed by user to define custom ray selection
  113475. */
  113476. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  113477. /**
  113478. * To be optionaly changed by user to define custom selection logic (after ray selection)
  113479. */
  113480. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113481. /**
  113482. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  113483. */
  113484. teleportationEnabled: boolean;
  113485. private _defaultHeight;
  113486. private _teleportationInitialized;
  113487. private _interactionsEnabled;
  113488. private _interactionsRequested;
  113489. private _displayGaze;
  113490. private _displayLaserPointer;
  113491. /**
  113492. * The mesh used to display where the user is going to teleport.
  113493. */
  113494. /**
  113495. * Sets the mesh to be used to display where the user is going to teleport.
  113496. */
  113497. teleportationTarget: Mesh;
  113498. /**
  113499. * 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
  113500. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  113501. * See http://doc.babylonjs.com/resources/baking_transformations
  113502. */
  113503. gazeTrackerMesh: Mesh;
  113504. /**
  113505. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  113506. */
  113507. updateGazeTrackerScale: boolean;
  113508. /**
  113509. * If the gaze trackers color should be updated when selecting meshes
  113510. */
  113511. updateGazeTrackerColor: boolean;
  113512. /**
  113513. * If the controller laser color should be updated when selecting meshes
  113514. */
  113515. updateControllerLaserColor: boolean;
  113516. /**
  113517. * The gaze tracking mesh corresponding to the left controller
  113518. */
  113519. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  113520. /**
  113521. * The gaze tracking mesh corresponding to the right controller
  113522. */
  113523. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  113524. /**
  113525. * If the ray of the gaze should be displayed.
  113526. */
  113527. /**
  113528. * Sets if the ray of the gaze should be displayed.
  113529. */
  113530. displayGaze: boolean;
  113531. /**
  113532. * If the ray of the LaserPointer should be displayed.
  113533. */
  113534. /**
  113535. * Sets if the ray of the LaserPointer should be displayed.
  113536. */
  113537. displayLaserPointer: boolean;
  113538. /**
  113539. * The deviceOrientationCamera used as the camera when not in VR.
  113540. */
  113541. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  113542. /**
  113543. * Based on the current WebVR support, returns the current VR camera used.
  113544. */
  113545. readonly currentVRCamera: Nullable<Camera>;
  113546. /**
  113547. * The webVRCamera which is used when in VR.
  113548. */
  113549. readonly webVRCamera: WebVRFreeCamera;
  113550. /**
  113551. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  113552. */
  113553. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  113554. /**
  113555. * The html button that is used to trigger entering into VR.
  113556. */
  113557. readonly vrButton: Nullable<HTMLButtonElement>;
  113558. private readonly _teleportationRequestInitiated;
  113559. /**
  113560. * Defines wether or not Pointer lock should be requested when switching to
  113561. * full screen.
  113562. */
  113563. requestPointerLockOnFullScreen: boolean;
  113564. /**
  113565. * If asking to force XR, this will be populated with the default xr experience
  113566. */
  113567. xr: WebXRDefaultExperience;
  113568. /**
  113569. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  113570. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  113571. */
  113572. xrTestDone: boolean;
  113573. /**
  113574. * Instantiates a VRExperienceHelper.
  113575. * Helps to quickly add VR support to an existing scene.
  113576. * @param scene The scene the VRExperienceHelper belongs to.
  113577. * @param webVROptions Options to modify the vr experience helper's behavior.
  113578. */
  113579. constructor(scene: Scene,
  113580. /** Options to modify the vr experience helper's behavior. */
  113581. webVROptions?: VRExperienceHelperOptions);
  113582. private completeVRInit;
  113583. private _onDefaultMeshLoaded;
  113584. private _onResize;
  113585. private _onFullscreenChange;
  113586. /**
  113587. * Gets a value indicating if we are currently in VR mode.
  113588. */
  113589. readonly isInVRMode: boolean;
  113590. private onVrDisplayPresentChange;
  113591. private onVRDisplayChanged;
  113592. private moveButtonToBottomRight;
  113593. private displayVRButton;
  113594. private updateButtonVisibility;
  113595. private _cachedAngularSensibility;
  113596. /**
  113597. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  113598. * Otherwise, will use the fullscreen API.
  113599. */
  113600. enterVR(): void;
  113601. /**
  113602. * Attempt to exit VR, or fullscreen.
  113603. */
  113604. exitVR(): void;
  113605. /**
  113606. * The position of the vr experience helper.
  113607. */
  113608. /**
  113609. * Sets the position of the vr experience helper.
  113610. */
  113611. position: Vector3;
  113612. /**
  113613. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  113614. */
  113615. enableInteractions(): void;
  113616. private readonly _noControllerIsActive;
  113617. private beforeRender;
  113618. private _isTeleportationFloor;
  113619. /**
  113620. * Adds a floor mesh to be used for teleportation.
  113621. * @param floorMesh the mesh to be used for teleportation.
  113622. */
  113623. addFloorMesh(floorMesh: Mesh): void;
  113624. /**
  113625. * Removes a floor mesh from being used for teleportation.
  113626. * @param floorMesh the mesh to be removed.
  113627. */
  113628. removeFloorMesh(floorMesh: Mesh): void;
  113629. /**
  113630. * Enables interactions and teleportation using the VR controllers and gaze.
  113631. * @param vrTeleportationOptions options to modify teleportation behavior.
  113632. */
  113633. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  113634. private _onNewGamepadConnected;
  113635. private _tryEnableInteractionOnController;
  113636. private _onNewGamepadDisconnected;
  113637. private _enableInteractionOnController;
  113638. private _checkTeleportWithRay;
  113639. private _checkRotate;
  113640. private _checkTeleportBackwards;
  113641. private _enableTeleportationOnController;
  113642. private _createTeleportationCircles;
  113643. private _displayTeleportationTarget;
  113644. private _hideTeleportationTarget;
  113645. private _rotateCamera;
  113646. private _moveTeleportationSelectorTo;
  113647. private _workingVector;
  113648. private _workingQuaternion;
  113649. private _workingMatrix;
  113650. /**
  113651. * Time Constant Teleportation Mode
  113652. */
  113653. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  113654. /**
  113655. * Speed Constant Teleportation Mode
  113656. */
  113657. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  113658. /**
  113659. * Teleports the users feet to the desired location
  113660. * @param location The location where the user's feet should be placed
  113661. */
  113662. teleportCamera(location: Vector3): void;
  113663. private _convertNormalToDirectionOfRay;
  113664. private _castRayAndSelectObject;
  113665. private _notifySelectedMeshUnselected;
  113666. /**
  113667. * Sets the color of the laser ray from the vr controllers.
  113668. * @param color new color for the ray.
  113669. */
  113670. changeLaserColor(color: Color3): void;
  113671. /**
  113672. * Sets the color of the ray from the vr headsets gaze.
  113673. * @param color new color for the ray.
  113674. */
  113675. changeGazeColor(color: Color3): void;
  113676. /**
  113677. * Exits VR and disposes of the vr experience helper
  113678. */
  113679. dispose(): void;
  113680. /**
  113681. * Gets the name of the VRExperienceHelper class
  113682. * @returns "VRExperienceHelper"
  113683. */
  113684. getClassName(): string;
  113685. }
  113686. }
  113687. declare module BABYLON {
  113688. /**
  113689. * Options used for hit testing
  113690. */
  113691. export interface IWebXRHitTestOptions {
  113692. /**
  113693. * Only test when user interacted with the scene. Default - hit test every frame
  113694. */
  113695. testOnPointerDownOnly?: boolean;
  113696. /**
  113697. * The node to use to transform the local results to world coordinates
  113698. */
  113699. worldParentNode?: TransformNode;
  113700. }
  113701. /**
  113702. * Interface defining the babylon result of raycasting/hit-test
  113703. */
  113704. export interface IWebXRHitResult {
  113705. /**
  113706. * The native hit test result
  113707. */
  113708. xrHitResult: XRHitResult;
  113709. /**
  113710. * Transformation matrix that can be applied to a node that will put it in the hit point location
  113711. */
  113712. transformationMatrix: Matrix;
  113713. }
  113714. /**
  113715. * The currently-working hit-test module.
  113716. * Hit test (or raycasting) is used to interact with the real world.
  113717. * For further information read here - https://github.com/immersive-web/hit-test
  113718. */
  113719. export class WebXRHitTestLegacy implements IWebXRFeature {
  113720. private _xrSessionManager;
  113721. /**
  113722. * options to use when constructing this feature
  113723. */
  113724. readonly options: IWebXRHitTestOptions;
  113725. /**
  113726. * The module's name
  113727. */
  113728. static readonly Name: string;
  113729. /**
  113730. * The (Babylon) version of this module.
  113731. * This is an integer representing the implementation version.
  113732. * This number does not correspond to the webxr specs version
  113733. */
  113734. static readonly Version: number;
  113735. /**
  113736. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  113737. * @param event the (select) event to use to select with
  113738. * @param referenceSpace the reference space to use for this hit test
  113739. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  113740. */
  113741. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  113742. /**
  113743. * execute a hit test with an XR Ray
  113744. *
  113745. * @param xrSession a native xrSession that will execute this hit test
  113746. * @param xrRay the ray (position and direction) to use for raycasting
  113747. * @param referenceSpace native XR reference space to use for the hit-test
  113748. * @param filter filter function that will filter the results
  113749. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  113750. */
  113751. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  113752. /**
  113753. * Triggered when new babylon (transformed) hit test results are available
  113754. */
  113755. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  113756. /**
  113757. * Creates a new instance of the (legacy version) hit test feature
  113758. * @param _xrSessionManager an instance of WebXRSessionManager
  113759. * @param options options to use when constructing this feature
  113760. */
  113761. constructor(_xrSessionManager: WebXRSessionManager,
  113762. /**
  113763. * options to use when constructing this feature
  113764. */
  113765. options?: IWebXRHitTestOptions);
  113766. private _onSelectEnabled;
  113767. private _xrFrameObserver;
  113768. private _attached;
  113769. /**
  113770. * Populated with the last native XR Hit Results
  113771. */
  113772. lastNativeXRHitResults: XRHitResult[];
  113773. /**
  113774. * attach this feature
  113775. * Will usually be called by the features manager
  113776. *
  113777. * @returns true if successful.
  113778. */
  113779. attach(): boolean;
  113780. /**
  113781. * detach this feature.
  113782. * Will usually be called by the features manager
  113783. *
  113784. * @returns true if successful.
  113785. */
  113786. detach(): boolean;
  113787. private _onHitTestResults;
  113788. private _onSelect;
  113789. /**
  113790. * Dispose this feature and all of the resources attached
  113791. */
  113792. dispose(): void;
  113793. }
  113794. }
  113795. declare module BABYLON {
  113796. /**
  113797. * Options used in the plane detector module
  113798. */
  113799. export interface IWebXRPlaneDetectorOptions {
  113800. /**
  113801. * The node to use to transform the local results to world coordinates
  113802. */
  113803. worldParentNode?: TransformNode;
  113804. }
  113805. /**
  113806. * A babylon interface for a webxr plane.
  113807. * A Plane is actually a polygon, built from N points in space
  113808. */
  113809. export interface IWebXRPlane {
  113810. /**
  113811. * a babylon-assigned ID for this polygon
  113812. */
  113813. id: number;
  113814. /**
  113815. * the native xr-plane object
  113816. */
  113817. xrPlane: XRPlane;
  113818. /**
  113819. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  113820. */
  113821. polygonDefinition: Array<Vector3>;
  113822. /**
  113823. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  113824. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  113825. */
  113826. transformationMatrix: Matrix;
  113827. }
  113828. /**
  113829. * The plane detector is used to detect planes in the real world when in AR
  113830. * For more information see https://github.com/immersive-web/real-world-geometry/
  113831. */
  113832. export class WebXRPlaneDetector implements IWebXRFeature {
  113833. private _xrSessionManager;
  113834. private _options;
  113835. /**
  113836. * The module's name
  113837. */
  113838. static readonly Name: string;
  113839. /**
  113840. * The (Babylon) version of this module.
  113841. * This is an integer representing the implementation version.
  113842. * This number does not correspond to the webxr specs version
  113843. */
  113844. static readonly Version: number;
  113845. /**
  113846. * Observers registered here will be executed when a new plane was added to the session
  113847. */
  113848. onPlaneAddedObservable: Observable<IWebXRPlane>;
  113849. /**
  113850. * Observers registered here will be executed when a plane is no longer detected in the session
  113851. */
  113852. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  113853. /**
  113854. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  113855. * This can execute N times every frame
  113856. */
  113857. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  113858. private _enabled;
  113859. private _attached;
  113860. private _detectedPlanes;
  113861. private _lastFrameDetected;
  113862. private _observerTracked;
  113863. /**
  113864. * construct a new Plane Detector
  113865. * @param _xrSessionManager an instance of xr Session manager
  113866. * @param _options configuration to use when constructing this feature
  113867. */
  113868. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  113869. /**
  113870. * attach this feature
  113871. * Will usually be called by the features manager
  113872. *
  113873. * @returns true if successful.
  113874. */
  113875. attach(): boolean;
  113876. /**
  113877. * detach this feature.
  113878. * Will usually be called by the features manager
  113879. *
  113880. * @returns true if successful.
  113881. */
  113882. detach(): boolean;
  113883. /**
  113884. * Dispose this feature and all of the resources attached
  113885. */
  113886. dispose(): void;
  113887. private _updatePlaneWithXRPlane;
  113888. /**
  113889. * avoiding using Array.find for global support.
  113890. * @param xrPlane the plane to find in the array
  113891. */
  113892. private findIndexInPlaneArray;
  113893. }
  113894. }
  113895. declare module BABYLON {
  113896. /**
  113897. * Configuration options of the anchor system
  113898. */
  113899. export interface IWebXRAnchorSystemOptions {
  113900. /**
  113901. * a node that will be used to convert local to world coordinates
  113902. */
  113903. worldParentNode?: TransformNode;
  113904. /**
  113905. * should the anchor system use plane detection.
  113906. * If set to true, the plane-detection feature should be set using setPlaneDetector
  113907. */
  113908. usePlaneDetection?: boolean;
  113909. /**
  113910. * Should a new anchor be added every time a select event is triggered
  113911. */
  113912. addAnchorOnSelect?: boolean;
  113913. }
  113914. /**
  113915. * A babylon container for an XR Anchor
  113916. */
  113917. export interface IWebXRAnchor {
  113918. /**
  113919. * A babylon-assigned ID for this anchor
  113920. */
  113921. id: number;
  113922. /**
  113923. * The native anchor object
  113924. */
  113925. xrAnchor: XRAnchor;
  113926. /**
  113927. * Transformation matrix to apply to an object attached to this anchor
  113928. */
  113929. transformationMatrix: Matrix;
  113930. }
  113931. /**
  113932. * An implementation of the anchor system of WebXR.
  113933. * Note that the current documented implementation is not available in any browser. Future implementations
  113934. * will use the frame to create an anchor and not the session or a detected plane
  113935. * For further information see https://github.com/immersive-web/anchors/
  113936. */
  113937. export class WebXRAnchorSystem implements IWebXRFeature {
  113938. private _xrSessionManager;
  113939. private _options;
  113940. /**
  113941. * The module's name
  113942. */
  113943. static readonly Name: string;
  113944. /**
  113945. * The (Babylon) version of this module.
  113946. * This is an integer representing the implementation version.
  113947. * This number does not correspond to the webxr specs version
  113948. */
  113949. static readonly Version: number;
  113950. /**
  113951. * Observers registered here will be executed when a new anchor was added to the session
  113952. */
  113953. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  113954. /**
  113955. * Observers registered here will be executed when an existing anchor updates
  113956. * This can execute N times every frame
  113957. */
  113958. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  113959. /**
  113960. * Observers registered here will be executed when an anchor was removed from the session
  113961. */
  113962. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  113963. private _planeDetector;
  113964. private _hitTestModule;
  113965. private _enabled;
  113966. private _attached;
  113967. private _trackedAnchors;
  113968. private _lastFrameDetected;
  113969. private _observerTracked;
  113970. /**
  113971. * constructs a new anchor system
  113972. * @param _xrSessionManager an instance of WebXRSessionManager
  113973. * @param _options configuration object for this feature
  113974. */
  113975. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  113976. /**
  113977. * set the plane detector to use in order to create anchors from frames
  113978. * @param planeDetector the plane-detector module to use
  113979. * @param enable enable plane-anchors. default is true
  113980. */
  113981. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  113982. /**
  113983. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  113984. * @param hitTestModule the hit-test module to use.
  113985. */
  113986. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  113987. /**
  113988. * attach this feature
  113989. * Will usually be called by the features manager
  113990. *
  113991. * @returns true if successful.
  113992. */
  113993. attach(): boolean;
  113994. /**
  113995. * detach this feature.
  113996. * Will usually be called by the features manager
  113997. *
  113998. * @returns true if successful.
  113999. */
  114000. detach(): boolean;
  114001. /**
  114002. * Dispose this feature and all of the resources attached
  114003. */
  114004. dispose(): void;
  114005. private _onSelect;
  114006. /**
  114007. * Add anchor at a specific XR point.
  114008. *
  114009. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  114010. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  114011. * @returns a promise the fulfills when the anchor was created
  114012. */
  114013. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  114014. private _updateAnchorWithXRFrame;
  114015. /**
  114016. * avoiding using Array.find for global support.
  114017. * @param xrAnchor the plane to find in the array
  114018. */
  114019. private _findIndexInAnchorArray;
  114020. }
  114021. }
  114022. declare module BABYLON {
  114023. /**
  114024. * Options interface for the background remover plugin
  114025. */
  114026. export interface IWebXRBackgroundRemoverOptions {
  114027. /**
  114028. * don't disable the environment helper
  114029. */
  114030. ignoreEnvironmentHelper?: boolean;
  114031. /**
  114032. * flags to configure the removal of the environment helper.
  114033. * If not set, the entire background will be removed. If set, flags should be set as well.
  114034. */
  114035. environmentHelperRemovalFlags?: {
  114036. /**
  114037. * Should the skybox be removed (default false)
  114038. */
  114039. skyBox?: boolean;
  114040. /**
  114041. * Should the ground be removed (default false)
  114042. */
  114043. ground?: boolean;
  114044. };
  114045. /**
  114046. * Further background meshes to disable when entering AR
  114047. */
  114048. backgroundMeshes?: AbstractMesh[];
  114049. }
  114050. /**
  114051. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  114052. */
  114053. export class WebXRBackgroundRemover implements IWebXRFeature {
  114054. private _xrSessionManager;
  114055. /**
  114056. * read-only options to be used in this module
  114057. */
  114058. readonly options: IWebXRBackgroundRemoverOptions;
  114059. /**
  114060. * The module's name
  114061. */
  114062. static readonly Name: string;
  114063. /**
  114064. * The (Babylon) version of this module.
  114065. * This is an integer representing the implementation version.
  114066. * This number does not correspond to the webxr specs version
  114067. */
  114068. static readonly Version: number;
  114069. /**
  114070. * registered observers will be triggered when the background state changes
  114071. */
  114072. onBackgroundStateChangedObservable: Observable<boolean>;
  114073. /**
  114074. * constructs a new background remover module
  114075. * @param _xrSessionManager the session manager for this module
  114076. * @param options read-only options to be used in this module
  114077. */
  114078. constructor(_xrSessionManager: WebXRSessionManager,
  114079. /**
  114080. * read-only options to be used in this module
  114081. */
  114082. options?: IWebXRBackgroundRemoverOptions);
  114083. /**
  114084. * attach this feature
  114085. * Will usually be called by the features manager
  114086. *
  114087. * @returns true if successful.
  114088. */
  114089. attach(): boolean;
  114090. /**
  114091. * detach this feature.
  114092. * Will usually be called by the features manager
  114093. *
  114094. * @returns true if successful.
  114095. */
  114096. detach(): boolean;
  114097. private _setBackgroundState;
  114098. /**
  114099. * Dispose this feature and all of the resources attached
  114100. */
  114101. dispose(): void;
  114102. }
  114103. }
  114104. declare module BABYLON {
  114105. /**
  114106. * Contains an array of blocks representing the octree
  114107. */
  114108. export interface IOctreeContainer<T> {
  114109. /**
  114110. * Blocks within the octree
  114111. */
  114112. blocks: Array<OctreeBlock<T>>;
  114113. }
  114114. /**
  114115. * Class used to store a cell in an octree
  114116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114117. */
  114118. export class OctreeBlock<T> {
  114119. /**
  114120. * Gets the content of the current block
  114121. */
  114122. entries: T[];
  114123. /**
  114124. * Gets the list of block children
  114125. */
  114126. blocks: Array<OctreeBlock<T>>;
  114127. private _depth;
  114128. private _maxDepth;
  114129. private _capacity;
  114130. private _minPoint;
  114131. private _maxPoint;
  114132. private _boundingVectors;
  114133. private _creationFunc;
  114134. /**
  114135. * Creates a new block
  114136. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  114137. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  114138. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  114139. * @param depth defines the current depth of this block in the octree
  114140. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  114141. * @param creationFunc defines a callback to call when an element is added to the block
  114142. */
  114143. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  114144. /**
  114145. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  114146. */
  114147. readonly capacity: number;
  114148. /**
  114149. * Gets the minimum vector (in world space) of the block's bounding box
  114150. */
  114151. readonly minPoint: Vector3;
  114152. /**
  114153. * Gets the maximum vector (in world space) of the block's bounding box
  114154. */
  114155. readonly maxPoint: Vector3;
  114156. /**
  114157. * Add a new element to this block
  114158. * @param entry defines the element to add
  114159. */
  114160. addEntry(entry: T): void;
  114161. /**
  114162. * Remove an element from this block
  114163. * @param entry defines the element to remove
  114164. */
  114165. removeEntry(entry: T): void;
  114166. /**
  114167. * Add an array of elements to this block
  114168. * @param entries defines the array of elements to add
  114169. */
  114170. addEntries(entries: T[]): void;
  114171. /**
  114172. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  114173. * @param frustumPlanes defines the frustum planes to test
  114174. * @param selection defines the array to store current content if selection is positive
  114175. * @param allowDuplicate defines if the selection array can contains duplicated entries
  114176. */
  114177. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  114178. /**
  114179. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  114180. * @param sphereCenter defines the bounding sphere center
  114181. * @param sphereRadius defines the bounding sphere radius
  114182. * @param selection defines the array to store current content if selection is positive
  114183. * @param allowDuplicate defines if the selection array can contains duplicated entries
  114184. */
  114185. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  114186. /**
  114187. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  114188. * @param ray defines the ray to test with
  114189. * @param selection defines the array to store current content if selection is positive
  114190. */
  114191. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  114192. /**
  114193. * Subdivide the content into child blocks (this block will then be empty)
  114194. */
  114195. createInnerBlocks(): void;
  114196. /**
  114197. * @hidden
  114198. */
  114199. 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;
  114200. }
  114201. }
  114202. declare module BABYLON {
  114203. /**
  114204. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  114205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114206. */
  114207. export class Octree<T> {
  114208. /** 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.) */
  114209. maxDepth: number;
  114210. /**
  114211. * Blocks within the octree containing objects
  114212. */
  114213. blocks: Array<OctreeBlock<T>>;
  114214. /**
  114215. * Content stored in the octree
  114216. */
  114217. dynamicContent: T[];
  114218. private _maxBlockCapacity;
  114219. private _selectionContent;
  114220. private _creationFunc;
  114221. /**
  114222. * Creates a octree
  114223. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114224. * @param creationFunc function to be used to instatiate the octree
  114225. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  114226. * @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.)
  114227. */
  114228. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  114229. /** 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.) */
  114230. maxDepth?: number);
  114231. /**
  114232. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  114233. * @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);
  114234. * @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);
  114235. * @param entries meshes to be added to the octree blocks
  114236. */
  114237. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  114238. /**
  114239. * Adds a mesh to the octree
  114240. * @param entry Mesh to add to the octree
  114241. */
  114242. addMesh(entry: T): void;
  114243. /**
  114244. * Remove an element from the octree
  114245. * @param entry defines the element to remove
  114246. */
  114247. removeMesh(entry: T): void;
  114248. /**
  114249. * Selects an array of meshes within the frustum
  114250. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  114251. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  114252. * @returns array of meshes within the frustum
  114253. */
  114254. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  114255. /**
  114256. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  114257. * @param sphereCenter defines the bounding sphere center
  114258. * @param sphereRadius defines the bounding sphere radius
  114259. * @param allowDuplicate defines if the selection array can contains duplicated entries
  114260. * @returns an array of objects that intersect the sphere
  114261. */
  114262. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  114263. /**
  114264. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  114265. * @param ray defines the ray to test with
  114266. * @returns array of intersected objects
  114267. */
  114268. intersectsRay(ray: Ray): SmartArray<T>;
  114269. /**
  114270. * Adds a mesh into the octree block if it intersects the block
  114271. */
  114272. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  114273. /**
  114274. * Adds a submesh into the octree block if it intersects the block
  114275. */
  114276. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  114277. }
  114278. }
  114279. declare module BABYLON {
  114280. interface Scene {
  114281. /**
  114282. * @hidden
  114283. * Backing Filed
  114284. */
  114285. _selectionOctree: Octree<AbstractMesh>;
  114286. /**
  114287. * Gets the octree used to boost mesh selection (picking)
  114288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114289. */
  114290. selectionOctree: Octree<AbstractMesh>;
  114291. /**
  114292. * Creates or updates the octree used to boost selection (picking)
  114293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114294. * @param maxCapacity defines the maximum capacity per leaf
  114295. * @param maxDepth defines the maximum depth of the octree
  114296. * @returns an octree of AbstractMesh
  114297. */
  114298. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  114299. }
  114300. interface AbstractMesh {
  114301. /**
  114302. * @hidden
  114303. * Backing Field
  114304. */
  114305. _submeshesOctree: Octree<SubMesh>;
  114306. /**
  114307. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  114308. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  114309. * @param maxCapacity defines the maximum size of each block (64 by default)
  114310. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  114311. * @returns the new octree
  114312. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  114313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  114314. */
  114315. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  114316. }
  114317. /**
  114318. * Defines the octree scene component responsible to manage any octrees
  114319. * in a given scene.
  114320. */
  114321. export class OctreeSceneComponent {
  114322. /**
  114323. * The component name help to identify the component in the list of scene components.
  114324. */
  114325. readonly name: string;
  114326. /**
  114327. * The scene the component belongs to.
  114328. */
  114329. scene: Scene;
  114330. /**
  114331. * Indicates if the meshes have been checked to make sure they are isEnabled()
  114332. */
  114333. readonly checksIsEnabled: boolean;
  114334. /**
  114335. * Creates a new instance of the component for the given scene
  114336. * @param scene Defines the scene to register the component in
  114337. */
  114338. constructor(scene: Scene);
  114339. /**
  114340. * Registers the component in a given scene
  114341. */
  114342. register(): void;
  114343. /**
  114344. * Return the list of active meshes
  114345. * @returns the list of active meshes
  114346. */
  114347. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  114348. /**
  114349. * Return the list of active sub meshes
  114350. * @param mesh The mesh to get the candidates sub meshes from
  114351. * @returns the list of active sub meshes
  114352. */
  114353. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  114354. private _tempRay;
  114355. /**
  114356. * Return the list of sub meshes intersecting with a given local ray
  114357. * @param mesh defines the mesh to find the submesh for
  114358. * @param localRay defines the ray in local space
  114359. * @returns the list of intersecting sub meshes
  114360. */
  114361. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  114362. /**
  114363. * Return the list of sub meshes colliding with a collider
  114364. * @param mesh defines the mesh to find the submesh for
  114365. * @param collider defines the collider to evaluate the collision against
  114366. * @returns the list of colliding sub meshes
  114367. */
  114368. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  114369. /**
  114370. * Rebuilds the elements related to this component in case of
  114371. * context lost for instance.
  114372. */
  114373. rebuild(): void;
  114374. /**
  114375. * Disposes the component and the associated ressources.
  114376. */
  114377. dispose(): void;
  114378. }
  114379. }
  114380. declare module BABYLON {
  114381. /**
  114382. * Renders a layer on top of an existing scene
  114383. */
  114384. export class UtilityLayerRenderer implements IDisposable {
  114385. /** the original scene that will be rendered on top of */
  114386. originalScene: Scene;
  114387. private _pointerCaptures;
  114388. private _lastPointerEvents;
  114389. private static _DefaultUtilityLayer;
  114390. private static _DefaultKeepDepthUtilityLayer;
  114391. private _sharedGizmoLight;
  114392. private _renderCamera;
  114393. /**
  114394. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  114395. * @returns the camera that is used when rendering the utility layer
  114396. */
  114397. getRenderCamera(): Nullable<Camera>;
  114398. /**
  114399. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  114400. * @param cam the camera that should be used when rendering the utility layer
  114401. */
  114402. setRenderCamera(cam: Nullable<Camera>): void;
  114403. /**
  114404. * @hidden
  114405. * Light which used by gizmos to get light shading
  114406. */
  114407. _getSharedGizmoLight(): HemisphericLight;
  114408. /**
  114409. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  114410. */
  114411. pickUtilitySceneFirst: boolean;
  114412. /**
  114413. * 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)
  114414. */
  114415. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  114416. /**
  114417. * 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)
  114418. */
  114419. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  114420. /**
  114421. * The scene that is rendered on top of the original scene
  114422. */
  114423. utilityLayerScene: Scene;
  114424. /**
  114425. * If the utility layer should automatically be rendered on top of existing scene
  114426. */
  114427. shouldRender: boolean;
  114428. /**
  114429. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  114430. */
  114431. onlyCheckPointerDownEvents: boolean;
  114432. /**
  114433. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  114434. */
  114435. processAllEvents: boolean;
  114436. /**
  114437. * Observable raised when the pointer move from the utility layer scene to the main scene
  114438. */
  114439. onPointerOutObservable: Observable<number>;
  114440. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  114441. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  114442. private _afterRenderObserver;
  114443. private _sceneDisposeObserver;
  114444. private _originalPointerObserver;
  114445. /**
  114446. * Instantiates a UtilityLayerRenderer
  114447. * @param originalScene the original scene that will be rendered on top of
  114448. * @param handleEvents boolean indicating if the utility layer should handle events
  114449. */
  114450. constructor(
  114451. /** the original scene that will be rendered on top of */
  114452. originalScene: Scene, handleEvents?: boolean);
  114453. private _notifyObservers;
  114454. /**
  114455. * Renders the utility layers scene on top of the original scene
  114456. */
  114457. render(): void;
  114458. /**
  114459. * Disposes of the renderer
  114460. */
  114461. dispose(): void;
  114462. private _updateCamera;
  114463. }
  114464. }
  114465. declare module BABYLON {
  114466. /**
  114467. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  114468. */
  114469. export class Gizmo implements IDisposable {
  114470. /** The utility layer the gizmo will be added to */
  114471. gizmoLayer: UtilityLayerRenderer;
  114472. /**
  114473. * The root mesh of the gizmo
  114474. */
  114475. _rootMesh: Mesh;
  114476. private _attachedMesh;
  114477. /**
  114478. * Ratio for the scale of the gizmo (Default: 1)
  114479. */
  114480. scaleRatio: number;
  114481. /**
  114482. * If a custom mesh has been set (Default: false)
  114483. */
  114484. protected _customMeshSet: boolean;
  114485. /**
  114486. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  114487. * * When set, interactions will be enabled
  114488. */
  114489. attachedMesh: Nullable<AbstractMesh>;
  114490. /**
  114491. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114492. * @param mesh The mesh to replace the default mesh of the gizmo
  114493. */
  114494. setCustomMesh(mesh: Mesh): void;
  114495. /**
  114496. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  114497. */
  114498. updateGizmoRotationToMatchAttachedMesh: boolean;
  114499. /**
  114500. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  114501. */
  114502. updateGizmoPositionToMatchAttachedMesh: boolean;
  114503. /**
  114504. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  114505. */
  114506. updateScale: boolean;
  114507. protected _interactionsEnabled: boolean;
  114508. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114509. private _beforeRenderObserver;
  114510. private _tempVector;
  114511. /**
  114512. * Creates a gizmo
  114513. * @param gizmoLayer The utility layer the gizmo will be added to
  114514. */
  114515. constructor(
  114516. /** The utility layer the gizmo will be added to */
  114517. gizmoLayer?: UtilityLayerRenderer);
  114518. /**
  114519. * Updates the gizmo to match the attached mesh's position/rotation
  114520. */
  114521. protected _update(): void;
  114522. /**
  114523. * Disposes of the gizmo
  114524. */
  114525. dispose(): void;
  114526. }
  114527. }
  114528. declare module BABYLON {
  114529. /**
  114530. * Single plane drag gizmo
  114531. */
  114532. export class PlaneDragGizmo extends Gizmo {
  114533. /**
  114534. * Drag behavior responsible for the gizmos dragging interactions
  114535. */
  114536. dragBehavior: PointerDragBehavior;
  114537. private _pointerObserver;
  114538. /**
  114539. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114540. */
  114541. snapDistance: number;
  114542. /**
  114543. * Event that fires each time the gizmo snaps to a new location.
  114544. * * snapDistance is the the change in distance
  114545. */
  114546. onSnapObservable: Observable<{
  114547. snapDistance: number;
  114548. }>;
  114549. private _plane;
  114550. private _coloredMaterial;
  114551. private _hoverMaterial;
  114552. private _isEnabled;
  114553. private _parent;
  114554. /** @hidden */
  114555. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  114556. /** @hidden */
  114557. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  114558. /**
  114559. * Creates a PlaneDragGizmo
  114560. * @param gizmoLayer The utility layer the gizmo will be added to
  114561. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  114562. * @param color The color of the gizmo
  114563. */
  114564. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  114565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114566. /**
  114567. * If the gizmo is enabled
  114568. */
  114569. isEnabled: boolean;
  114570. /**
  114571. * Disposes of the gizmo
  114572. */
  114573. dispose(): void;
  114574. }
  114575. }
  114576. declare module BABYLON {
  114577. /**
  114578. * Gizmo that enables dragging a mesh along 3 axis
  114579. */
  114580. export class PositionGizmo extends Gizmo {
  114581. /**
  114582. * Internal gizmo used for interactions on the x axis
  114583. */
  114584. xGizmo: AxisDragGizmo;
  114585. /**
  114586. * Internal gizmo used for interactions on the y axis
  114587. */
  114588. yGizmo: AxisDragGizmo;
  114589. /**
  114590. * Internal gizmo used for interactions on the z axis
  114591. */
  114592. zGizmo: AxisDragGizmo;
  114593. /**
  114594. * Internal gizmo used for interactions on the yz plane
  114595. */
  114596. xPlaneGizmo: PlaneDragGizmo;
  114597. /**
  114598. * Internal gizmo used for interactions on the xz plane
  114599. */
  114600. yPlaneGizmo: PlaneDragGizmo;
  114601. /**
  114602. * Internal gizmo used for interactions on the xy plane
  114603. */
  114604. zPlaneGizmo: PlaneDragGizmo;
  114605. /**
  114606. * private variables
  114607. */
  114608. private _meshAttached;
  114609. private _updateGizmoRotationToMatchAttachedMesh;
  114610. private _snapDistance;
  114611. private _scaleRatio;
  114612. /** Fires an event when any of it's sub gizmos are dragged */
  114613. onDragStartObservable: Observable<unknown>;
  114614. /** Fires an event when any of it's sub gizmos are released from dragging */
  114615. onDragEndObservable: Observable<unknown>;
  114616. /**
  114617. * If set to true, planar drag is enabled
  114618. */
  114619. private _planarGizmoEnabled;
  114620. attachedMesh: Nullable<AbstractMesh>;
  114621. /**
  114622. * Creates a PositionGizmo
  114623. * @param gizmoLayer The utility layer the gizmo will be added to
  114624. */
  114625. constructor(gizmoLayer?: UtilityLayerRenderer);
  114626. /**
  114627. * If the planar drag gizmo is enabled
  114628. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  114629. */
  114630. planarGizmoEnabled: boolean;
  114631. updateGizmoRotationToMatchAttachedMesh: boolean;
  114632. /**
  114633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114634. */
  114635. snapDistance: number;
  114636. /**
  114637. * Ratio for the scale of the gizmo (Default: 1)
  114638. */
  114639. scaleRatio: number;
  114640. /**
  114641. * Disposes of the gizmo
  114642. */
  114643. dispose(): void;
  114644. /**
  114645. * CustomMeshes are not supported by this gizmo
  114646. * @param mesh The mesh to replace the default mesh of the gizmo
  114647. */
  114648. setCustomMesh(mesh: Mesh): void;
  114649. }
  114650. }
  114651. declare module BABYLON {
  114652. /**
  114653. * Single axis drag gizmo
  114654. */
  114655. export class AxisDragGizmo extends Gizmo {
  114656. /**
  114657. * Drag behavior responsible for the gizmos dragging interactions
  114658. */
  114659. dragBehavior: PointerDragBehavior;
  114660. private _pointerObserver;
  114661. /**
  114662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114663. */
  114664. snapDistance: number;
  114665. /**
  114666. * Event that fires each time the gizmo snaps to a new location.
  114667. * * snapDistance is the the change in distance
  114668. */
  114669. onSnapObservable: Observable<{
  114670. snapDistance: number;
  114671. }>;
  114672. private _isEnabled;
  114673. private _parent;
  114674. private _arrow;
  114675. private _coloredMaterial;
  114676. private _hoverMaterial;
  114677. /** @hidden */
  114678. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  114679. /** @hidden */
  114680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  114681. /**
  114682. * Creates an AxisDragGizmo
  114683. * @param gizmoLayer The utility layer the gizmo will be added to
  114684. * @param dragAxis The axis which the gizmo will be able to drag on
  114685. * @param color The color of the gizmo
  114686. */
  114687. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  114688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114689. /**
  114690. * If the gizmo is enabled
  114691. */
  114692. isEnabled: boolean;
  114693. /**
  114694. * Disposes of the gizmo
  114695. */
  114696. dispose(): void;
  114697. }
  114698. }
  114699. declare module BABYLON.Debug {
  114700. /**
  114701. * The Axes viewer will show 3 axes in a specific point in space
  114702. */
  114703. export class AxesViewer {
  114704. private _xAxis;
  114705. private _yAxis;
  114706. private _zAxis;
  114707. private _scaleLinesFactor;
  114708. private _instanced;
  114709. /**
  114710. * Gets the hosting scene
  114711. */
  114712. scene: Scene;
  114713. /**
  114714. * Gets or sets a number used to scale line length
  114715. */
  114716. scaleLines: number;
  114717. /** Gets the node hierarchy used to render x-axis */
  114718. readonly xAxis: TransformNode;
  114719. /** Gets the node hierarchy used to render y-axis */
  114720. readonly yAxis: TransformNode;
  114721. /** Gets the node hierarchy used to render z-axis */
  114722. readonly zAxis: TransformNode;
  114723. /**
  114724. * Creates a new AxesViewer
  114725. * @param scene defines the hosting scene
  114726. * @param scaleLines defines a number used to scale line length (1 by default)
  114727. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  114728. * @param xAxis defines the node hierarchy used to render the x-axis
  114729. * @param yAxis defines the node hierarchy used to render the y-axis
  114730. * @param zAxis defines the node hierarchy used to render the z-axis
  114731. */
  114732. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  114733. /**
  114734. * Force the viewer to update
  114735. * @param position defines the position of the viewer
  114736. * @param xaxis defines the x axis of the viewer
  114737. * @param yaxis defines the y axis of the viewer
  114738. * @param zaxis defines the z axis of the viewer
  114739. */
  114740. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  114741. /**
  114742. * Creates an instance of this axes viewer.
  114743. * @returns a new axes viewer with instanced meshes
  114744. */
  114745. createInstance(): AxesViewer;
  114746. /** Releases resources */
  114747. dispose(): void;
  114748. private static _SetRenderingGroupId;
  114749. }
  114750. }
  114751. declare module BABYLON.Debug {
  114752. /**
  114753. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  114754. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  114755. */
  114756. export class BoneAxesViewer extends AxesViewer {
  114757. /**
  114758. * Gets or sets the target mesh where to display the axes viewer
  114759. */
  114760. mesh: Nullable<Mesh>;
  114761. /**
  114762. * Gets or sets the target bone where to display the axes viewer
  114763. */
  114764. bone: Nullable<Bone>;
  114765. /** Gets current position */
  114766. pos: Vector3;
  114767. /** Gets direction of X axis */
  114768. xaxis: Vector3;
  114769. /** Gets direction of Y axis */
  114770. yaxis: Vector3;
  114771. /** Gets direction of Z axis */
  114772. zaxis: Vector3;
  114773. /**
  114774. * Creates a new BoneAxesViewer
  114775. * @param scene defines the hosting scene
  114776. * @param bone defines the target bone
  114777. * @param mesh defines the target mesh
  114778. * @param scaleLines defines a scaling factor for line length (1 by default)
  114779. */
  114780. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  114781. /**
  114782. * Force the viewer to update
  114783. */
  114784. update(): void;
  114785. /** Releases resources */
  114786. dispose(): void;
  114787. }
  114788. }
  114789. declare module BABYLON {
  114790. /**
  114791. * Interface used to define scene explorer extensibility option
  114792. */
  114793. export interface IExplorerExtensibilityOption {
  114794. /**
  114795. * Define the option label
  114796. */
  114797. label: string;
  114798. /**
  114799. * Defines the action to execute on click
  114800. */
  114801. action: (entity: any) => void;
  114802. }
  114803. /**
  114804. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  114805. */
  114806. export interface IExplorerExtensibilityGroup {
  114807. /**
  114808. * Defines a predicate to test if a given type mut be extended
  114809. */
  114810. predicate: (entity: any) => boolean;
  114811. /**
  114812. * Gets the list of options added to a type
  114813. */
  114814. entries: IExplorerExtensibilityOption[];
  114815. }
  114816. /**
  114817. * Interface used to define the options to use to create the Inspector
  114818. */
  114819. export interface IInspectorOptions {
  114820. /**
  114821. * Display in overlay mode (default: false)
  114822. */
  114823. overlay?: boolean;
  114824. /**
  114825. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  114826. */
  114827. globalRoot?: HTMLElement;
  114828. /**
  114829. * Display the Scene explorer
  114830. */
  114831. showExplorer?: boolean;
  114832. /**
  114833. * Display the property inspector
  114834. */
  114835. showInspector?: boolean;
  114836. /**
  114837. * Display in embed mode (both panes on the right)
  114838. */
  114839. embedMode?: boolean;
  114840. /**
  114841. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  114842. */
  114843. handleResize?: boolean;
  114844. /**
  114845. * Allow the panes to popup (default: true)
  114846. */
  114847. enablePopup?: boolean;
  114848. /**
  114849. * Allow the panes to be closed by users (default: true)
  114850. */
  114851. enableClose?: boolean;
  114852. /**
  114853. * Optional list of extensibility entries
  114854. */
  114855. explorerExtensibility?: IExplorerExtensibilityGroup[];
  114856. /**
  114857. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  114858. */
  114859. inspectorURL?: string;
  114860. /**
  114861. * Optional initial tab (default to DebugLayerTab.Properties)
  114862. */
  114863. initialTab?: DebugLayerTab;
  114864. }
  114865. interface Scene {
  114866. /**
  114867. * @hidden
  114868. * Backing field
  114869. */
  114870. _debugLayer: DebugLayer;
  114871. /**
  114872. * Gets the debug layer (aka Inspector) associated with the scene
  114873. * @see http://doc.babylonjs.com/features/playground_debuglayer
  114874. */
  114875. debugLayer: DebugLayer;
  114876. }
  114877. /**
  114878. * Enum of inspector action tab
  114879. */
  114880. export enum DebugLayerTab {
  114881. /**
  114882. * Properties tag (default)
  114883. */
  114884. Properties = 0,
  114885. /**
  114886. * Debug tab
  114887. */
  114888. Debug = 1,
  114889. /**
  114890. * Statistics tab
  114891. */
  114892. Statistics = 2,
  114893. /**
  114894. * Tools tab
  114895. */
  114896. Tools = 3,
  114897. /**
  114898. * Settings tab
  114899. */
  114900. Settings = 4
  114901. }
  114902. /**
  114903. * The debug layer (aka Inspector) is the go to tool in order to better understand
  114904. * what is happening in your scene
  114905. * @see http://doc.babylonjs.com/features/playground_debuglayer
  114906. */
  114907. export class DebugLayer {
  114908. /**
  114909. * Define the url to get the inspector script from.
  114910. * By default it uses the babylonjs CDN.
  114911. * @ignoreNaming
  114912. */
  114913. static InspectorURL: string;
  114914. private _scene;
  114915. private BJSINSPECTOR;
  114916. private _onPropertyChangedObservable?;
  114917. /**
  114918. * Observable triggered when a property is changed through the inspector.
  114919. */
  114920. readonly onPropertyChangedObservable: any;
  114921. /**
  114922. * Instantiates a new debug layer.
  114923. * The debug layer (aka Inspector) is the go to tool in order to better understand
  114924. * what is happening in your scene
  114925. * @see http://doc.babylonjs.com/features/playground_debuglayer
  114926. * @param scene Defines the scene to inspect
  114927. */
  114928. constructor(scene: Scene);
  114929. /** Creates the inspector window. */
  114930. private _createInspector;
  114931. /**
  114932. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  114933. * @param entity defines the entity to select
  114934. * @param lineContainerTitle defines the specific block to highlight
  114935. */
  114936. select(entity: any, lineContainerTitle?: string): void;
  114937. /** Get the inspector from bundle or global */
  114938. private _getGlobalInspector;
  114939. /**
  114940. * Get if the inspector is visible or not.
  114941. * @returns true if visible otherwise, false
  114942. */
  114943. isVisible(): boolean;
  114944. /**
  114945. * Hide the inspector and close its window.
  114946. */
  114947. hide(): void;
  114948. /**
  114949. * Launch the debugLayer.
  114950. * @param config Define the configuration of the inspector
  114951. * @return a promise fulfilled when the debug layer is visible
  114952. */
  114953. show(config?: IInspectorOptions): Promise<DebugLayer>;
  114954. }
  114955. }
  114956. declare module BABYLON {
  114957. /**
  114958. * Class containing static functions to help procedurally build meshes
  114959. */
  114960. export class BoxBuilder {
  114961. /**
  114962. * Creates a box mesh
  114963. * * The parameter `size` sets the size (float) of each box side (default 1)
  114964. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114965. * * 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)
  114966. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114970. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114971. * @param name defines the name of the mesh
  114972. * @param options defines the options used to create the mesh
  114973. * @param scene defines the hosting scene
  114974. * @returns the box mesh
  114975. */
  114976. static CreateBox(name: string, options: {
  114977. size?: number;
  114978. width?: number;
  114979. height?: number;
  114980. depth?: number;
  114981. faceUV?: Vector4[];
  114982. faceColors?: Color4[];
  114983. sideOrientation?: number;
  114984. frontUVs?: Vector4;
  114985. backUVs?: Vector4;
  114986. wrap?: boolean;
  114987. topBaseAt?: number;
  114988. bottomBaseAt?: number;
  114989. updatable?: boolean;
  114990. }, scene?: Nullable<Scene>): Mesh;
  114991. }
  114992. }
  114993. declare module BABYLON {
  114994. /**
  114995. * Class containing static functions to help procedurally build meshes
  114996. */
  114997. export class SphereBuilder {
  114998. /**
  114999. * Creates a sphere mesh
  115000. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115001. * * 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`)
  115002. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115003. * * 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
  115004. * * 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)
  115005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115008. * @param name defines the name of the mesh
  115009. * @param options defines the options used to create the mesh
  115010. * @param scene defines the hosting scene
  115011. * @returns the sphere mesh
  115012. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115013. */
  115014. static CreateSphere(name: string, options: {
  115015. segments?: number;
  115016. diameter?: number;
  115017. diameterX?: number;
  115018. diameterY?: number;
  115019. diameterZ?: number;
  115020. arc?: number;
  115021. slice?: number;
  115022. sideOrientation?: number;
  115023. frontUVs?: Vector4;
  115024. backUVs?: Vector4;
  115025. updatable?: boolean;
  115026. }, scene?: Nullable<Scene>): Mesh;
  115027. }
  115028. }
  115029. declare module BABYLON.Debug {
  115030. /**
  115031. * Used to show the physics impostor around the specific mesh
  115032. */
  115033. export class PhysicsViewer {
  115034. /** @hidden */
  115035. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  115036. /** @hidden */
  115037. protected _meshes: Array<Nullable<AbstractMesh>>;
  115038. /** @hidden */
  115039. protected _scene: Nullable<Scene>;
  115040. /** @hidden */
  115041. protected _numMeshes: number;
  115042. /** @hidden */
  115043. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  115044. private _renderFunction;
  115045. private _utilityLayer;
  115046. private _debugBoxMesh;
  115047. private _debugSphereMesh;
  115048. private _debugCylinderMesh;
  115049. private _debugMaterial;
  115050. private _debugMeshMeshes;
  115051. /**
  115052. * Creates a new PhysicsViewer
  115053. * @param scene defines the hosting scene
  115054. */
  115055. constructor(scene: Scene);
  115056. /** @hidden */
  115057. protected _updateDebugMeshes(): void;
  115058. /**
  115059. * Renders a specified physic impostor
  115060. * @param impostor defines the impostor to render
  115061. * @param targetMesh defines the mesh represented by the impostor
  115062. * @returns the new debug mesh used to render the impostor
  115063. */
  115064. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  115065. /**
  115066. * Hides a specified physic impostor
  115067. * @param impostor defines the impostor to hide
  115068. */
  115069. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  115070. private _getDebugMaterial;
  115071. private _getDebugBoxMesh;
  115072. private _getDebugSphereMesh;
  115073. private _getDebugCylinderMesh;
  115074. private _getDebugMeshMesh;
  115075. private _getDebugMesh;
  115076. /** Releases all resources */
  115077. dispose(): void;
  115078. }
  115079. }
  115080. declare module BABYLON {
  115081. /**
  115082. * Class containing static functions to help procedurally build meshes
  115083. */
  115084. export class LinesBuilder {
  115085. /**
  115086. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115087. * * 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
  115088. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115089. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115090. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115091. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115092. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115093. * * 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
  115094. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115097. * @param name defines the name of the new line system
  115098. * @param options defines the options used to create the line system
  115099. * @param scene defines the hosting scene
  115100. * @returns a new line system mesh
  115101. */
  115102. static CreateLineSystem(name: string, options: {
  115103. lines: Vector3[][];
  115104. updatable?: boolean;
  115105. instance?: Nullable<LinesMesh>;
  115106. colors?: Nullable<Color4[][]>;
  115107. useVertexAlpha?: boolean;
  115108. }, scene: Nullable<Scene>): LinesMesh;
  115109. /**
  115110. * Creates a line mesh
  115111. * 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
  115112. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115113. * * The parameter `points` is an array successive Vector3
  115114. * * 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
  115115. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115117. * * When updating an instance, remember that only point positions can change, not the number of points
  115118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115120. * @param name defines the name of the new line system
  115121. * @param options defines the options used to create the line system
  115122. * @param scene defines the hosting scene
  115123. * @returns a new line mesh
  115124. */
  115125. static CreateLines(name: string, options: {
  115126. points: Vector3[];
  115127. updatable?: boolean;
  115128. instance?: Nullable<LinesMesh>;
  115129. colors?: Color4[];
  115130. useVertexAlpha?: boolean;
  115131. }, scene?: Nullable<Scene>): LinesMesh;
  115132. /**
  115133. * Creates a dashed line mesh
  115134. * * 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
  115135. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115136. * * The parameter `points` is an array successive Vector3
  115137. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115138. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115139. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115140. * * 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
  115141. * * When updating an instance, remember that only point positions can change, not the number of points
  115142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115143. * @param name defines the name of the mesh
  115144. * @param options defines the options used to create the mesh
  115145. * @param scene defines the hosting scene
  115146. * @returns the dashed line mesh
  115147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115148. */
  115149. static CreateDashedLines(name: string, options: {
  115150. points: Vector3[];
  115151. dashSize?: number;
  115152. gapSize?: number;
  115153. dashNb?: number;
  115154. updatable?: boolean;
  115155. instance?: LinesMesh;
  115156. }, scene?: Nullable<Scene>): LinesMesh;
  115157. }
  115158. }
  115159. declare module BABYLON {
  115160. /**
  115161. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  115162. * in order to better appreciate the issue one might have.
  115163. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  115164. */
  115165. export class RayHelper {
  115166. /**
  115167. * Defines the ray we are currently tryin to visualize.
  115168. */
  115169. ray: Nullable<Ray>;
  115170. private _renderPoints;
  115171. private _renderLine;
  115172. private _renderFunction;
  115173. private _scene;
  115174. private _updateToMeshFunction;
  115175. private _attachedToMesh;
  115176. private _meshSpaceDirection;
  115177. private _meshSpaceOrigin;
  115178. /**
  115179. * Helper function to create a colored helper in a scene in one line.
  115180. * @param ray Defines the ray we are currently tryin to visualize
  115181. * @param scene Defines the scene the ray is used in
  115182. * @param color Defines the color we want to see the ray in
  115183. * @returns The newly created ray helper.
  115184. */
  115185. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  115186. /**
  115187. * Instantiate a new ray helper.
  115188. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  115189. * in order to better appreciate the issue one might have.
  115190. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  115191. * @param ray Defines the ray we are currently tryin to visualize
  115192. */
  115193. constructor(ray: Ray);
  115194. /**
  115195. * Shows the ray we are willing to debug.
  115196. * @param scene Defines the scene the ray needs to be rendered in
  115197. * @param color Defines the color the ray needs to be rendered in
  115198. */
  115199. show(scene: Scene, color?: Color3): void;
  115200. /**
  115201. * Hides the ray we are debugging.
  115202. */
  115203. hide(): void;
  115204. private _render;
  115205. /**
  115206. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  115207. * @param mesh Defines the mesh we want the helper attached to
  115208. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  115209. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  115210. * @param length Defines the length of the ray
  115211. */
  115212. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  115213. /**
  115214. * Detach the ray helper from the mesh it has previously been attached to.
  115215. */
  115216. detachFromMesh(): void;
  115217. private _updateToMesh;
  115218. /**
  115219. * Dispose the helper and release its associated resources.
  115220. */
  115221. dispose(): void;
  115222. }
  115223. }
  115224. declare module BABYLON.Debug {
  115225. /**
  115226. * Class used to render a debug view of a given skeleton
  115227. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  115228. */
  115229. export class SkeletonViewer {
  115230. /** defines the skeleton to render */
  115231. skeleton: Skeleton;
  115232. /** defines the mesh attached to the skeleton */
  115233. mesh: AbstractMesh;
  115234. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  115235. autoUpdateBonesMatrices: boolean;
  115236. /** defines the rendering group id to use with the viewer */
  115237. renderingGroupId: number;
  115238. /** Gets or sets the color used to render the skeleton */
  115239. color: Color3;
  115240. private _scene;
  115241. private _debugLines;
  115242. private _debugMesh;
  115243. private _isEnabled;
  115244. private _renderFunction;
  115245. private _utilityLayer;
  115246. /**
  115247. * Returns the mesh used to render the bones
  115248. */
  115249. readonly debugMesh: Nullable<LinesMesh>;
  115250. /**
  115251. * Creates a new SkeletonViewer
  115252. * @param skeleton defines the skeleton to render
  115253. * @param mesh defines the mesh attached to the skeleton
  115254. * @param scene defines the hosting scene
  115255. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  115256. * @param renderingGroupId defines the rendering group id to use with the viewer
  115257. */
  115258. constructor(
  115259. /** defines the skeleton to render */
  115260. skeleton: Skeleton,
  115261. /** defines the mesh attached to the skeleton */
  115262. mesh: AbstractMesh, scene: Scene,
  115263. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  115264. autoUpdateBonesMatrices?: boolean,
  115265. /** defines the rendering group id to use with the viewer */
  115266. renderingGroupId?: number);
  115267. /** Gets or sets a boolean indicating if the viewer is enabled */
  115268. isEnabled: boolean;
  115269. private _getBonePosition;
  115270. private _getLinesForBonesWithLength;
  115271. private _getLinesForBonesNoLength;
  115272. /** Update the viewer to sync with current skeleton state */
  115273. update(): void;
  115274. /** Release associated resources */
  115275. dispose(): void;
  115276. }
  115277. }
  115278. declare module BABYLON {
  115279. /**
  115280. * Options to create the null engine
  115281. */
  115282. export class NullEngineOptions {
  115283. /**
  115284. * Render width (Default: 512)
  115285. */
  115286. renderWidth: number;
  115287. /**
  115288. * Render height (Default: 256)
  115289. */
  115290. renderHeight: number;
  115291. /**
  115292. * Texture size (Default: 512)
  115293. */
  115294. textureSize: number;
  115295. /**
  115296. * If delta time between frames should be constant
  115297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115298. */
  115299. deterministicLockstep: boolean;
  115300. /**
  115301. * Maximum about of steps between frames (Default: 4)
  115302. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115303. */
  115304. lockstepMaxSteps: number;
  115305. }
  115306. /**
  115307. * The null engine class provides support for headless version of babylon.js.
  115308. * This can be used in server side scenario or for testing purposes
  115309. */
  115310. export class NullEngine extends Engine {
  115311. private _options;
  115312. /**
  115313. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  115314. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115315. * @returns true if engine is in deterministic lock step mode
  115316. */
  115317. isDeterministicLockStep(): boolean;
  115318. /**
  115319. * Gets the max steps when engine is running in deterministic lock step
  115320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115321. * @returns the max steps
  115322. */
  115323. getLockstepMaxSteps(): number;
  115324. /**
  115325. * Gets the current hardware scaling level.
  115326. * By default the hardware scaling level is computed from the window device ratio.
  115327. * 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.
  115328. * @returns a number indicating the current hardware scaling level
  115329. */
  115330. getHardwareScalingLevel(): number;
  115331. constructor(options?: NullEngineOptions);
  115332. /**
  115333. * Creates a vertex buffer
  115334. * @param vertices the data for the vertex buffer
  115335. * @returns the new WebGL static buffer
  115336. */
  115337. createVertexBuffer(vertices: FloatArray): DataBuffer;
  115338. /**
  115339. * Creates a new index buffer
  115340. * @param indices defines the content of the index buffer
  115341. * @param updatable defines if the index buffer must be updatable
  115342. * @returns a new webGL buffer
  115343. */
  115344. createIndexBuffer(indices: IndicesArray): DataBuffer;
  115345. /**
  115346. * Clear the current render buffer or the current render target (if any is set up)
  115347. * @param color defines the color to use
  115348. * @param backBuffer defines if the back buffer must be cleared
  115349. * @param depth defines if the depth buffer must be cleared
  115350. * @param stencil defines if the stencil buffer must be cleared
  115351. */
  115352. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115353. /**
  115354. * Gets the current render width
  115355. * @param useScreen defines if screen size must be used (or the current render target if any)
  115356. * @returns a number defining the current render width
  115357. */
  115358. getRenderWidth(useScreen?: boolean): number;
  115359. /**
  115360. * Gets the current render height
  115361. * @param useScreen defines if screen size must be used (or the current render target if any)
  115362. * @returns a number defining the current render height
  115363. */
  115364. getRenderHeight(useScreen?: boolean): number;
  115365. /**
  115366. * Set the WebGL's viewport
  115367. * @param viewport defines the viewport element to be used
  115368. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115369. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115370. */
  115371. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115372. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  115373. /**
  115374. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115375. * @param pipelineContext defines the pipeline context to use
  115376. * @param uniformsNames defines the list of uniform names
  115377. * @returns an array of webGL uniform locations
  115378. */
  115379. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115380. /**
  115381. * Gets the lsit of active attributes for a given webGL program
  115382. * @param pipelineContext defines the pipeline context to use
  115383. * @param attributesNames defines the list of attribute names to get
  115384. * @returns an array of indices indicating the offset of each attribute
  115385. */
  115386. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115387. /**
  115388. * Binds an effect to the webGL context
  115389. * @param effect defines the effect to bind
  115390. */
  115391. bindSamplers(effect: Effect): void;
  115392. /**
  115393. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115394. * @param effect defines the effect to activate
  115395. */
  115396. enableEffect(effect: Effect): void;
  115397. /**
  115398. * Set various states to the webGL context
  115399. * @param culling defines backface culling state
  115400. * @param zOffset defines the value to apply to zOffset (0 by default)
  115401. * @param force defines if states must be applied even if cache is up to date
  115402. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  115403. */
  115404. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115405. /**
  115406. * Set the value of an uniform to an array of int32
  115407. * @param uniform defines the webGL uniform location where to store the value
  115408. * @param array defines the array of int32 to store
  115409. */
  115410. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  115411. /**
  115412. * Set the value of an uniform to an array of int32 (stored as vec2)
  115413. * @param uniform defines the webGL uniform location where to store the value
  115414. * @param array defines the array of int32 to store
  115415. */
  115416. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  115417. /**
  115418. * Set the value of an uniform to an array of int32 (stored as vec3)
  115419. * @param uniform defines the webGL uniform location where to store the value
  115420. * @param array defines the array of int32 to store
  115421. */
  115422. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  115423. /**
  115424. * Set the value of an uniform to an array of int32 (stored as vec4)
  115425. * @param uniform defines the webGL uniform location where to store the value
  115426. * @param array defines the array of int32 to store
  115427. */
  115428. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  115429. /**
  115430. * Set the value of an uniform to an array of float32
  115431. * @param uniform defines the webGL uniform location where to store the value
  115432. * @param array defines the array of float32 to store
  115433. */
  115434. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  115435. /**
  115436. * Set the value of an uniform to an array of float32 (stored as vec2)
  115437. * @param uniform defines the webGL uniform location where to store the value
  115438. * @param array defines the array of float32 to store
  115439. */
  115440. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  115441. /**
  115442. * Set the value of an uniform to an array of float32 (stored as vec3)
  115443. * @param uniform defines the webGL uniform location where to store the value
  115444. * @param array defines the array of float32 to store
  115445. */
  115446. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  115447. /**
  115448. * Set the value of an uniform to an array of float32 (stored as vec4)
  115449. * @param uniform defines the webGL uniform location where to store the value
  115450. * @param array defines the array of float32 to store
  115451. */
  115452. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  115453. /**
  115454. * Set the value of an uniform to an array of number
  115455. * @param uniform defines the webGL uniform location where to store the value
  115456. * @param array defines the array of number to store
  115457. */
  115458. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  115459. /**
  115460. * Set the value of an uniform to an array of number (stored as vec2)
  115461. * @param uniform defines the webGL uniform location where to store the value
  115462. * @param array defines the array of number to store
  115463. */
  115464. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  115465. /**
  115466. * Set the value of an uniform to an array of number (stored as vec3)
  115467. * @param uniform defines the webGL uniform location where to store the value
  115468. * @param array defines the array of number to store
  115469. */
  115470. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  115471. /**
  115472. * Set the value of an uniform to an array of number (stored as vec4)
  115473. * @param uniform defines the webGL uniform location where to store the value
  115474. * @param array defines the array of number to store
  115475. */
  115476. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  115477. /**
  115478. * Set the value of an uniform to an array of float32 (stored as matrices)
  115479. * @param uniform defines the webGL uniform location where to store the value
  115480. * @param matrices defines the array of float32 to store
  115481. */
  115482. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  115483. /**
  115484. * Set the value of an uniform to a matrix (3x3)
  115485. * @param uniform defines the webGL uniform location where to store the value
  115486. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115487. */
  115488. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115489. /**
  115490. * Set the value of an uniform to a matrix (2x2)
  115491. * @param uniform defines the webGL uniform location where to store the value
  115492. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115493. */
  115494. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115495. /**
  115496. * Set the value of an uniform to a number (float)
  115497. * @param uniform defines the webGL uniform location where to store the value
  115498. * @param value defines the float number to store
  115499. */
  115500. setFloat(uniform: WebGLUniformLocation, value: number): void;
  115501. /**
  115502. * Set the value of an uniform to a vec2
  115503. * @param uniform defines the webGL uniform location where to store the value
  115504. * @param x defines the 1st component of the value
  115505. * @param y defines the 2nd component of the value
  115506. */
  115507. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  115508. /**
  115509. * Set the value of an uniform to a vec3
  115510. * @param uniform defines the webGL uniform location where to store the value
  115511. * @param x defines the 1st component of the value
  115512. * @param y defines the 2nd component of the value
  115513. * @param z defines the 3rd component of the value
  115514. */
  115515. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  115516. /**
  115517. * Set the value of an uniform to a boolean
  115518. * @param uniform defines the webGL uniform location where to store the value
  115519. * @param bool defines the boolean to store
  115520. */
  115521. setBool(uniform: WebGLUniformLocation, bool: number): void;
  115522. /**
  115523. * Set the value of an uniform to a vec4
  115524. * @param uniform defines the webGL uniform location where to store the value
  115525. * @param x defines the 1st component of the value
  115526. * @param y defines the 2nd component of the value
  115527. * @param z defines the 3rd component of the value
  115528. * @param w defines the 4th component of the value
  115529. */
  115530. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  115531. /**
  115532. * Sets the current alpha mode
  115533. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115534. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115536. */
  115537. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115538. /**
  115539. * Bind webGl buffers directly to the webGL context
  115540. * @param vertexBuffers defines the vertex buffer to bind
  115541. * @param indexBuffer defines the index buffer to bind
  115542. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115543. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115544. * @param effect defines the effect associated with the vertex buffer
  115545. */
  115546. bindBuffers(vertexBuffers: {
  115547. [key: string]: VertexBuffer;
  115548. }, indexBuffer: DataBuffer, effect: Effect): void;
  115549. /**
  115550. * Force the entire cache to be cleared
  115551. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115552. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115553. */
  115554. wipeCaches(bruteForce?: boolean): void;
  115555. /**
  115556. * Send a draw order
  115557. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115558. * @param indexStart defines the starting index
  115559. * @param indexCount defines the number of index to draw
  115560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115561. */
  115562. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115563. /**
  115564. * Draw a list of indexed primitives
  115565. * @param fillMode defines the primitive to use
  115566. * @param indexStart defines the starting index
  115567. * @param indexCount defines the number of index to draw
  115568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115569. */
  115570. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115571. /**
  115572. * Draw a list of unindexed primitives
  115573. * @param fillMode defines the primitive to use
  115574. * @param verticesStart defines the index of first vertex to draw
  115575. * @param verticesCount defines the count of vertices to draw
  115576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115577. */
  115578. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115579. /** @hidden */
  115580. _createTexture(): WebGLTexture;
  115581. /** @hidden */
  115582. _releaseTexture(texture: InternalTexture): void;
  115583. /**
  115584. * Usually called from Texture.ts.
  115585. * Passed information to create a WebGLTexture
  115586. * @param urlArg defines a value which contains one of the following:
  115587. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115588. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115589. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115590. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115591. * @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)
  115592. * @param scene needed for loading to the correct scene
  115593. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115594. * @param onLoad optional callback to be called upon successful completion
  115595. * @param onError optional callback to be called upon failure
  115596. * @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
  115597. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115598. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115599. * @param forcedExtension defines the extension to use to pick the right loader
  115600. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  115601. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115602. */
  115603. 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;
  115604. /**
  115605. * Creates a new render target texture
  115606. * @param size defines the size of the texture
  115607. * @param options defines the options used to create the texture
  115608. * @returns a new render target texture stored in an InternalTexture
  115609. */
  115610. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  115611. /**
  115612. * Update the sampling mode of a given texture
  115613. * @param samplingMode defines the required sampling mode
  115614. * @param texture defines the texture to update
  115615. */
  115616. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  115617. /**
  115618. * Binds the frame buffer to the specified texture.
  115619. * @param texture The texture to render to or null for the default canvas
  115620. * @param faceIndex The face of the texture to render to in case of cube texture
  115621. * @param requiredWidth The width of the target to render to
  115622. * @param requiredHeight The height of the target to render to
  115623. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115624. * @param depthStencilTexture The depth stencil texture to use to render
  115625. * @param lodLevel defines le lod level to bind to the frame buffer
  115626. */
  115627. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  115628. /**
  115629. * Unbind the current render target texture from the webGL context
  115630. * @param texture defines the render target texture to unbind
  115631. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115632. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115633. */
  115634. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115635. /**
  115636. * Creates a dynamic vertex buffer
  115637. * @param vertices the data for the dynamic vertex buffer
  115638. * @returns the new WebGL dynamic buffer
  115639. */
  115640. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  115641. /**
  115642. * Update the content of a dynamic texture
  115643. * @param texture defines the texture to update
  115644. * @param canvas defines the canvas containing the source
  115645. * @param invertY defines if data must be stored with Y axis inverted
  115646. * @param premulAlpha defines if alpha is stored as premultiplied
  115647. * @param format defines the format of the data
  115648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115649. */
  115650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  115651. /**
  115652. * Gets a boolean indicating if all created effects are ready
  115653. * @returns true if all effects are ready
  115654. */
  115655. areAllEffectsReady(): boolean;
  115656. /**
  115657. * @hidden
  115658. * Get the current error code of the webGL context
  115659. * @returns the error code
  115660. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115661. */
  115662. getError(): number;
  115663. /** @hidden */
  115664. _getUnpackAlignement(): number;
  115665. /** @hidden */
  115666. _unpackFlipY(value: boolean): void;
  115667. /**
  115668. * Update a dynamic index buffer
  115669. * @param indexBuffer defines the target index buffer
  115670. * @param indices defines the data to update
  115671. * @param offset defines the offset in the target index buffer where update should start
  115672. */
  115673. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  115674. /**
  115675. * Updates a dynamic vertex buffer.
  115676. * @param vertexBuffer the vertex buffer to update
  115677. * @param vertices the data used to update the vertex buffer
  115678. * @param byteOffset the byte offset of the data (optional)
  115679. * @param byteLength the byte length of the data (optional)
  115680. */
  115681. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  115682. /** @hidden */
  115683. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  115684. /** @hidden */
  115685. _bindTexture(channel: number, texture: InternalTexture): void;
  115686. protected _deleteBuffer(buffer: WebGLBuffer): void;
  115687. /**
  115688. * 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
  115689. */
  115690. releaseEffects(): void;
  115691. displayLoadingUI(): void;
  115692. hideLoadingUI(): void;
  115693. /** @hidden */
  115694. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115695. /** @hidden */
  115696. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115697. /** @hidden */
  115698. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115699. /** @hidden */
  115700. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  115701. }
  115702. }
  115703. declare module BABYLON {
  115704. /** @hidden */
  115705. export class _OcclusionDataStorage {
  115706. /** @hidden */
  115707. occlusionInternalRetryCounter: number;
  115708. /** @hidden */
  115709. isOcclusionQueryInProgress: boolean;
  115710. /** @hidden */
  115711. isOccluded: boolean;
  115712. /** @hidden */
  115713. occlusionRetryCount: number;
  115714. /** @hidden */
  115715. occlusionType: number;
  115716. /** @hidden */
  115717. occlusionQueryAlgorithmType: number;
  115718. }
  115719. interface Engine {
  115720. /**
  115721. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  115722. * @return the new query
  115723. */
  115724. createQuery(): WebGLQuery;
  115725. /**
  115726. * Delete and release a webGL query
  115727. * @param query defines the query to delete
  115728. * @return the current engine
  115729. */
  115730. deleteQuery(query: WebGLQuery): Engine;
  115731. /**
  115732. * Check if a given query has resolved and got its value
  115733. * @param query defines the query to check
  115734. * @returns true if the query got its value
  115735. */
  115736. isQueryResultAvailable(query: WebGLQuery): boolean;
  115737. /**
  115738. * Gets the value of a given query
  115739. * @param query defines the query to check
  115740. * @returns the value of the query
  115741. */
  115742. getQueryResult(query: WebGLQuery): number;
  115743. /**
  115744. * Initiates an occlusion query
  115745. * @param algorithmType defines the algorithm to use
  115746. * @param query defines the query to use
  115747. * @returns the current engine
  115748. * @see http://doc.babylonjs.com/features/occlusionquery
  115749. */
  115750. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  115751. /**
  115752. * Ends an occlusion query
  115753. * @see http://doc.babylonjs.com/features/occlusionquery
  115754. * @param algorithmType defines the algorithm to use
  115755. * @returns the current engine
  115756. */
  115757. endOcclusionQuery(algorithmType: number): Engine;
  115758. /**
  115759. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  115760. * Please note that only one query can be issued at a time
  115761. * @returns a time token used to track the time span
  115762. */
  115763. startTimeQuery(): Nullable<_TimeToken>;
  115764. /**
  115765. * Ends a time query
  115766. * @param token defines the token used to measure the time span
  115767. * @returns the time spent (in ns)
  115768. */
  115769. endTimeQuery(token: _TimeToken): int;
  115770. /** @hidden */
  115771. _currentNonTimestampToken: Nullable<_TimeToken>;
  115772. /** @hidden */
  115773. _createTimeQuery(): WebGLQuery;
  115774. /** @hidden */
  115775. _deleteTimeQuery(query: WebGLQuery): void;
  115776. /** @hidden */
  115777. _getGlAlgorithmType(algorithmType: number): number;
  115778. /** @hidden */
  115779. _getTimeQueryResult(query: WebGLQuery): any;
  115780. /** @hidden */
  115781. _getTimeQueryAvailability(query: WebGLQuery): any;
  115782. }
  115783. interface AbstractMesh {
  115784. /**
  115785. * Backing filed
  115786. * @hidden
  115787. */
  115788. __occlusionDataStorage: _OcclusionDataStorage;
  115789. /**
  115790. * Access property
  115791. * @hidden
  115792. */
  115793. _occlusionDataStorage: _OcclusionDataStorage;
  115794. /**
  115795. * 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.
  115796. * The default value is -1 which means don't break the query and wait till the result
  115797. * @see http://doc.babylonjs.com/features/occlusionquery
  115798. */
  115799. occlusionRetryCount: number;
  115800. /**
  115801. * 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:
  115802. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  115803. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  115804. * * 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.
  115805. * @see http://doc.babylonjs.com/features/occlusionquery
  115806. */
  115807. occlusionType: number;
  115808. /**
  115809. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  115810. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  115811. * * 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.
  115812. * @see http://doc.babylonjs.com/features/occlusionquery
  115813. */
  115814. occlusionQueryAlgorithmType: number;
  115815. /**
  115816. * 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
  115817. * @see http://doc.babylonjs.com/features/occlusionquery
  115818. */
  115819. isOccluded: boolean;
  115820. /**
  115821. * Flag to check the progress status of the query
  115822. * @see http://doc.babylonjs.com/features/occlusionquery
  115823. */
  115824. isOcclusionQueryInProgress: boolean;
  115825. }
  115826. }
  115827. declare module BABYLON {
  115828. /** @hidden */
  115829. export var _forceTransformFeedbackToBundle: boolean;
  115830. interface Engine {
  115831. /**
  115832. * Creates a webGL transform feedback object
  115833. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  115834. * @returns the webGL transform feedback object
  115835. */
  115836. createTransformFeedback(): WebGLTransformFeedback;
  115837. /**
  115838. * Delete a webGL transform feedback object
  115839. * @param value defines the webGL transform feedback object to delete
  115840. */
  115841. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  115842. /**
  115843. * Bind a webGL transform feedback object to the webgl context
  115844. * @param value defines the webGL transform feedback object to bind
  115845. */
  115846. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  115847. /**
  115848. * Begins a transform feedback operation
  115849. * @param usePoints defines if points or triangles must be used
  115850. */
  115851. beginTransformFeedback(usePoints: boolean): void;
  115852. /**
  115853. * Ends a transform feedback operation
  115854. */
  115855. endTransformFeedback(): void;
  115856. /**
  115857. * Specify the varyings to use with transform feedback
  115858. * @param program defines the associated webGL program
  115859. * @param value defines the list of strings representing the varying names
  115860. */
  115861. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  115862. /**
  115863. * Bind a webGL buffer for a transform feedback operation
  115864. * @param value defines the webGL buffer to bind
  115865. */
  115866. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  115867. }
  115868. }
  115869. declare module BABYLON {
  115870. /**
  115871. * Creation options of the multi render target texture.
  115872. */
  115873. export interface IMultiRenderTargetOptions {
  115874. /**
  115875. * Define if the texture needs to create mip maps after render.
  115876. */
  115877. generateMipMaps?: boolean;
  115878. /**
  115879. * Define the types of all the draw buffers we want to create
  115880. */
  115881. types?: number[];
  115882. /**
  115883. * Define the sampling modes of all the draw buffers we want to create
  115884. */
  115885. samplingModes?: number[];
  115886. /**
  115887. * Define if a depth buffer is required
  115888. */
  115889. generateDepthBuffer?: boolean;
  115890. /**
  115891. * Define if a stencil buffer is required
  115892. */
  115893. generateStencilBuffer?: boolean;
  115894. /**
  115895. * Define if a depth texture is required instead of a depth buffer
  115896. */
  115897. generateDepthTexture?: boolean;
  115898. /**
  115899. * Define the number of desired draw buffers
  115900. */
  115901. textureCount?: number;
  115902. /**
  115903. * Define if aspect ratio should be adapted to the texture or stay the scene one
  115904. */
  115905. doNotChangeAspectRatio?: boolean;
  115906. /**
  115907. * Define the default type of the buffers we are creating
  115908. */
  115909. defaultType?: number;
  115910. }
  115911. /**
  115912. * A multi render target, like a render target provides the ability to render to a texture.
  115913. * Unlike the render target, it can render to several draw buffers in one draw.
  115914. * This is specially interesting in deferred rendering or for any effects requiring more than
  115915. * just one color from a single pass.
  115916. */
  115917. export class MultiRenderTarget extends RenderTargetTexture {
  115918. private _internalTextures;
  115919. private _textures;
  115920. private _multiRenderTargetOptions;
  115921. /**
  115922. * Get if draw buffers are currently supported by the used hardware and browser.
  115923. */
  115924. readonly isSupported: boolean;
  115925. /**
  115926. * Get the list of textures generated by the multi render target.
  115927. */
  115928. readonly textures: Texture[];
  115929. /**
  115930. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  115931. */
  115932. readonly depthTexture: Texture;
  115933. /**
  115934. * Set the wrapping mode on U of all the textures we are rendering to.
  115935. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  115936. */
  115937. wrapU: number;
  115938. /**
  115939. * Set the wrapping mode on V of all the textures we are rendering to.
  115940. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  115941. */
  115942. wrapV: number;
  115943. /**
  115944. * Instantiate a new multi render target texture.
  115945. * A multi render target, like a render target provides the ability to render to a texture.
  115946. * Unlike the render target, it can render to several draw buffers in one draw.
  115947. * This is specially interesting in deferred rendering or for any effects requiring more than
  115948. * just one color from a single pass.
  115949. * @param name Define the name of the texture
  115950. * @param size Define the size of the buffers to render to
  115951. * @param count Define the number of target we are rendering into
  115952. * @param scene Define the scene the texture belongs to
  115953. * @param options Define the options used to create the multi render target
  115954. */
  115955. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  115956. /** @hidden */
  115957. _rebuild(): void;
  115958. private _createInternalTextures;
  115959. private _createTextures;
  115960. /**
  115961. * Define the number of samples used if MSAA is enabled.
  115962. */
  115963. samples: number;
  115964. /**
  115965. * Resize all the textures in the multi render target.
  115966. * Be carrefull as it will recreate all the data in the new texture.
  115967. * @param size Define the new size
  115968. */
  115969. resize(size: any): void;
  115970. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  115971. /**
  115972. * Dispose the render targets and their associated resources
  115973. */
  115974. dispose(): void;
  115975. /**
  115976. * Release all the underlying texture used as draw buffers.
  115977. */
  115978. releaseInternalTextures(): void;
  115979. }
  115980. }
  115981. declare module BABYLON {
  115982. interface ThinEngine {
  115983. /**
  115984. * Unbind a list of render target textures from the webGL context
  115985. * This is used only when drawBuffer extension or webGL2 are active
  115986. * @param textures defines the render target textures to unbind
  115987. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115988. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115989. */
  115990. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  115991. /**
  115992. * Create a multi render target texture
  115993. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  115994. * @param size defines the size of the texture
  115995. * @param options defines the creation options
  115996. * @returns the cube texture as an InternalTexture
  115997. */
  115998. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  115999. /**
  116000. * Update the sample count for a given multiple render target texture
  116001. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116002. * @param textures defines the textures to update
  116003. * @param samples defines the sample count to set
  116004. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116005. */
  116006. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  116007. }
  116008. }
  116009. declare module BABYLON {
  116010. /**
  116011. * Class used to define an additional view for the engine
  116012. * @see https://doc.babylonjs.com/how_to/multi_canvases
  116013. */
  116014. export class EngineView {
  116015. /** Defines the canvas where to render the view */
  116016. target: HTMLCanvasElement;
  116017. /** Defines an optional camera used to render the view (will use active camera else) */
  116018. camera?: Camera;
  116019. }
  116020. interface Engine {
  116021. /**
  116022. * Gets or sets the HTML element to use for attaching events
  116023. */
  116024. inputElement: Nullable<HTMLElement>;
  116025. /**
  116026. * Gets the current engine view
  116027. * @see https://doc.babylonjs.com/how_to/multi_canvases
  116028. */
  116029. activeView: Nullable<EngineView>;
  116030. /** Gets or sets the list of views */
  116031. views: EngineView[];
  116032. /**
  116033. * Register a new child canvas
  116034. * @param canvas defines the canvas to register
  116035. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  116036. * @returns the associated view
  116037. */
  116038. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  116039. /**
  116040. * Remove a registered child canvas
  116041. * @param canvas defines the canvas to remove
  116042. * @returns the current engine
  116043. */
  116044. unRegisterView(canvas: HTMLCanvasElement): Engine;
  116045. }
  116046. }
  116047. declare module BABYLON {
  116048. /**
  116049. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  116050. */
  116051. export interface CubeMapInfo {
  116052. /**
  116053. * The pixel array for the front face.
  116054. * This is stored in format, left to right, up to down format.
  116055. */
  116056. front: Nullable<ArrayBufferView>;
  116057. /**
  116058. * The pixel array for the back face.
  116059. * This is stored in format, left to right, up to down format.
  116060. */
  116061. back: Nullable<ArrayBufferView>;
  116062. /**
  116063. * The pixel array for the left face.
  116064. * This is stored in format, left to right, up to down format.
  116065. */
  116066. left: Nullable<ArrayBufferView>;
  116067. /**
  116068. * The pixel array for the right face.
  116069. * This is stored in format, left to right, up to down format.
  116070. */
  116071. right: Nullable<ArrayBufferView>;
  116072. /**
  116073. * The pixel array for the up face.
  116074. * This is stored in format, left to right, up to down format.
  116075. */
  116076. up: Nullable<ArrayBufferView>;
  116077. /**
  116078. * The pixel array for the down face.
  116079. * This is stored in format, left to right, up to down format.
  116080. */
  116081. down: Nullable<ArrayBufferView>;
  116082. /**
  116083. * The size of the cubemap stored.
  116084. *
  116085. * Each faces will be size * size pixels.
  116086. */
  116087. size: number;
  116088. /**
  116089. * The format of the texture.
  116090. *
  116091. * RGBA, RGB.
  116092. */
  116093. format: number;
  116094. /**
  116095. * The type of the texture data.
  116096. *
  116097. * UNSIGNED_INT, FLOAT.
  116098. */
  116099. type: number;
  116100. /**
  116101. * Specifies whether the texture is in gamma space.
  116102. */
  116103. gammaSpace: boolean;
  116104. }
  116105. /**
  116106. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  116107. */
  116108. export class PanoramaToCubeMapTools {
  116109. private static FACE_FRONT;
  116110. private static FACE_BACK;
  116111. private static FACE_RIGHT;
  116112. private static FACE_LEFT;
  116113. private static FACE_DOWN;
  116114. private static FACE_UP;
  116115. /**
  116116. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  116117. *
  116118. * @param float32Array The source data.
  116119. * @param inputWidth The width of the input panorama.
  116120. * @param inputHeight The height of the input panorama.
  116121. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  116122. * @return The cubemap data
  116123. */
  116124. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  116125. private static CreateCubemapTexture;
  116126. private static CalcProjectionSpherical;
  116127. }
  116128. }
  116129. declare module BABYLON {
  116130. /**
  116131. * Helper class dealing with the extraction of spherical polynomial dataArray
  116132. * from a cube map.
  116133. */
  116134. export class CubeMapToSphericalPolynomialTools {
  116135. private static FileFaces;
  116136. /**
  116137. * Converts a texture to the according Spherical Polynomial data.
  116138. * This extracts the first 3 orders only as they are the only one used in the lighting.
  116139. *
  116140. * @param texture The texture to extract the information from.
  116141. * @return The Spherical Polynomial data.
  116142. */
  116143. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  116144. /**
  116145. * Converts a cubemap to the according Spherical Polynomial data.
  116146. * This extracts the first 3 orders only as they are the only one used in the lighting.
  116147. *
  116148. * @param cubeInfo The Cube map to extract the information from.
  116149. * @return The Spherical Polynomial data.
  116150. */
  116151. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  116152. }
  116153. }
  116154. declare module BABYLON {
  116155. interface BaseTexture {
  116156. /**
  116157. * Get the polynomial representation of the texture data.
  116158. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  116159. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  116160. */
  116161. sphericalPolynomial: Nullable<SphericalPolynomial>;
  116162. }
  116163. }
  116164. declare module BABYLON {
  116165. /** @hidden */
  116166. export var rgbdEncodePixelShader: {
  116167. name: string;
  116168. shader: string;
  116169. };
  116170. }
  116171. declare module BABYLON {
  116172. /** @hidden */
  116173. export var rgbdDecodePixelShader: {
  116174. name: string;
  116175. shader: string;
  116176. };
  116177. }
  116178. declare module BABYLON {
  116179. /**
  116180. * Raw texture data and descriptor sufficient for WebGL texture upload
  116181. */
  116182. export interface EnvironmentTextureInfo {
  116183. /**
  116184. * Version of the environment map
  116185. */
  116186. version: number;
  116187. /**
  116188. * Width of image
  116189. */
  116190. width: number;
  116191. /**
  116192. * Irradiance information stored in the file.
  116193. */
  116194. irradiance: any;
  116195. /**
  116196. * Specular information stored in the file.
  116197. */
  116198. specular: any;
  116199. }
  116200. /**
  116201. * Defines One Image in the file. It requires only the position in the file
  116202. * as well as the length.
  116203. */
  116204. interface BufferImageData {
  116205. /**
  116206. * Length of the image data.
  116207. */
  116208. length: number;
  116209. /**
  116210. * Position of the data from the null terminator delimiting the end of the JSON.
  116211. */
  116212. position: number;
  116213. }
  116214. /**
  116215. * Defines the specular data enclosed in the file.
  116216. * This corresponds to the version 1 of the data.
  116217. */
  116218. export interface EnvironmentTextureSpecularInfoV1 {
  116219. /**
  116220. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  116221. */
  116222. specularDataPosition?: number;
  116223. /**
  116224. * This contains all the images data needed to reconstruct the cubemap.
  116225. */
  116226. mipmaps: Array<BufferImageData>;
  116227. /**
  116228. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  116229. */
  116230. lodGenerationScale: number;
  116231. }
  116232. /**
  116233. * Sets of helpers addressing the serialization and deserialization of environment texture
  116234. * stored in a BabylonJS env file.
  116235. * Those files are usually stored as .env files.
  116236. */
  116237. export class EnvironmentTextureTools {
  116238. /**
  116239. * Magic number identifying the env file.
  116240. */
  116241. private static _MagicBytes;
  116242. /**
  116243. * Gets the environment info from an env file.
  116244. * @param data The array buffer containing the .env bytes.
  116245. * @returns the environment file info (the json header) if successfully parsed.
  116246. */
  116247. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  116248. /**
  116249. * Creates an environment texture from a loaded cube texture.
  116250. * @param texture defines the cube texture to convert in env file
  116251. * @return a promise containing the environment data if succesfull.
  116252. */
  116253. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  116254. /**
  116255. * Creates a JSON representation of the spherical data.
  116256. * @param texture defines the texture containing the polynomials
  116257. * @return the JSON representation of the spherical info
  116258. */
  116259. private static _CreateEnvTextureIrradiance;
  116260. /**
  116261. * Creates the ArrayBufferViews used for initializing environment texture image data.
  116262. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  116263. * @param info parameters that determine what views will be created for accessing the underlying buffer
  116264. * @return the views described by info providing access to the underlying buffer
  116265. */
  116266. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  116267. /**
  116268. * Uploads the texture info contained in the env file to the GPU.
  116269. * @param texture defines the internal texture to upload to
  116270. * @param arrayBuffer defines the buffer cotaining the data to load
  116271. * @param info defines the texture info retrieved through the GetEnvInfo method
  116272. * @returns a promise
  116273. */
  116274. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  116275. private static _OnImageReadyAsync;
  116276. /**
  116277. * Uploads the levels of image data to the GPU.
  116278. * @param texture defines the internal texture to upload to
  116279. * @param imageData defines the array buffer views of image data [mipmap][face]
  116280. * @returns a promise
  116281. */
  116282. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  116283. /**
  116284. * Uploads spherical polynomials information to the texture.
  116285. * @param texture defines the texture we are trying to upload the information to
  116286. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  116287. */
  116288. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  116289. /** @hidden */
  116290. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116291. }
  116292. }
  116293. declare module BABYLON {
  116294. /**
  116295. * Contains position and normal vectors for a vertex
  116296. */
  116297. export class PositionNormalVertex {
  116298. /** the position of the vertex (defaut: 0,0,0) */
  116299. position: Vector3;
  116300. /** the normal of the vertex (defaut: 0,1,0) */
  116301. normal: Vector3;
  116302. /**
  116303. * Creates a PositionNormalVertex
  116304. * @param position the position of the vertex (defaut: 0,0,0)
  116305. * @param normal the normal of the vertex (defaut: 0,1,0)
  116306. */
  116307. constructor(
  116308. /** the position of the vertex (defaut: 0,0,0) */
  116309. position?: Vector3,
  116310. /** the normal of the vertex (defaut: 0,1,0) */
  116311. normal?: Vector3);
  116312. /**
  116313. * Clones the PositionNormalVertex
  116314. * @returns the cloned PositionNormalVertex
  116315. */
  116316. clone(): PositionNormalVertex;
  116317. }
  116318. /**
  116319. * Contains position, normal and uv vectors for a vertex
  116320. */
  116321. export class PositionNormalTextureVertex {
  116322. /** the position of the vertex (defaut: 0,0,0) */
  116323. position: Vector3;
  116324. /** the normal of the vertex (defaut: 0,1,0) */
  116325. normal: Vector3;
  116326. /** the uv of the vertex (default: 0,0) */
  116327. uv: Vector2;
  116328. /**
  116329. * Creates a PositionNormalTextureVertex
  116330. * @param position the position of the vertex (defaut: 0,0,0)
  116331. * @param normal the normal of the vertex (defaut: 0,1,0)
  116332. * @param uv the uv of the vertex (default: 0,0)
  116333. */
  116334. constructor(
  116335. /** the position of the vertex (defaut: 0,0,0) */
  116336. position?: Vector3,
  116337. /** the normal of the vertex (defaut: 0,1,0) */
  116338. normal?: Vector3,
  116339. /** the uv of the vertex (default: 0,0) */
  116340. uv?: Vector2);
  116341. /**
  116342. * Clones the PositionNormalTextureVertex
  116343. * @returns the cloned PositionNormalTextureVertex
  116344. */
  116345. clone(): PositionNormalTextureVertex;
  116346. }
  116347. }
  116348. declare module BABYLON {
  116349. /** @hidden */
  116350. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  116351. private _genericAttributeLocation;
  116352. private _varyingLocationCount;
  116353. private _varyingLocationMap;
  116354. private _replacements;
  116355. private _textureCount;
  116356. private _uniforms;
  116357. lineProcessor(line: string): string;
  116358. attributeProcessor(attribute: string): string;
  116359. varyingProcessor(varying: string, isFragment: boolean): string;
  116360. uniformProcessor(uniform: string): string;
  116361. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  116362. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  116363. }
  116364. }
  116365. declare module BABYLON {
  116366. /**
  116367. * Container for accessors for natively-stored mesh data buffers.
  116368. */
  116369. class NativeDataBuffer extends DataBuffer {
  116370. /**
  116371. * Accessor value used to identify/retrieve a natively-stored index buffer.
  116372. */
  116373. nativeIndexBuffer?: any;
  116374. /**
  116375. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  116376. */
  116377. nativeVertexBuffer?: any;
  116378. }
  116379. /** @hidden */
  116380. class NativeTexture extends InternalTexture {
  116381. getInternalTexture(): InternalTexture;
  116382. getViewCount(): number;
  116383. }
  116384. /** @hidden */
  116385. export class NativeEngine extends Engine {
  116386. private readonly _native;
  116387. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  116388. private readonly INVALID_HANDLE;
  116389. getHardwareScalingLevel(): number;
  116390. constructor();
  116391. /**
  116392. * Can be used to override the current requestAnimationFrame requester.
  116393. * @hidden
  116394. */
  116395. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  116396. /**
  116397. * Override default engine behavior.
  116398. * @param color
  116399. * @param backBuffer
  116400. * @param depth
  116401. * @param stencil
  116402. */
  116403. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116404. /**
  116405. * Gets host document
  116406. * @returns the host document object
  116407. */
  116408. getHostDocument(): Nullable<Document>;
  116409. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116410. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  116411. createVertexBuffer(data: DataArray): NativeDataBuffer;
  116412. recordVertexArrayObject(vertexBuffers: {
  116413. [key: string]: VertexBuffer;
  116414. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116415. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  116416. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  116417. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116418. /**
  116419. * Draw a list of indexed primitives
  116420. * @param fillMode defines the primitive to use
  116421. * @param indexStart defines the starting index
  116422. * @param indexCount defines the number of index to draw
  116423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116424. */
  116425. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116426. /**
  116427. * Draw a list of unindexed primitives
  116428. * @param fillMode defines the primitive to use
  116429. * @param verticesStart defines the index of first vertex to draw
  116430. * @param verticesCount defines the count of vertices to draw
  116431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116432. */
  116433. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116434. createPipelineContext(): IPipelineContext;
  116435. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116436. /** @hidden */
  116437. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116438. /** @hidden */
  116439. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116440. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  116441. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  116442. protected _setProgram(program: WebGLProgram): void;
  116443. _releaseEffect(effect: Effect): void;
  116444. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116445. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  116446. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  116447. bindSamplers(effect: Effect): void;
  116448. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  116449. getRenderWidth(useScreen?: boolean): number;
  116450. getRenderHeight(useScreen?: boolean): number;
  116451. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  116452. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116453. /**
  116454. * Set the z offset to apply to current rendering
  116455. * @param value defines the offset to apply
  116456. */
  116457. setZOffset(value: number): void;
  116458. /**
  116459. * Gets the current value of the zOffset
  116460. * @returns the current zOffset state
  116461. */
  116462. getZOffset(): number;
  116463. /**
  116464. * Enable or disable depth buffering
  116465. * @param enable defines the state to set
  116466. */
  116467. setDepthBuffer(enable: boolean): void;
  116468. /**
  116469. * Gets a boolean indicating if depth writing is enabled
  116470. * @returns the current depth writing state
  116471. */
  116472. getDepthWrite(): boolean;
  116473. /**
  116474. * Enable or disable depth writing
  116475. * @param enable defines the state to set
  116476. */
  116477. setDepthWrite(enable: boolean): void;
  116478. /**
  116479. * Enable or disable color writing
  116480. * @param enable defines the state to set
  116481. */
  116482. setColorWrite(enable: boolean): void;
  116483. /**
  116484. * Gets a boolean indicating if color writing is enabled
  116485. * @returns the current color writing state
  116486. */
  116487. getColorWrite(): boolean;
  116488. /**
  116489. * Sets alpha constants used by some alpha blending modes
  116490. * @param r defines the red component
  116491. * @param g defines the green component
  116492. * @param b defines the blue component
  116493. * @param a defines the alpha component
  116494. */
  116495. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  116496. /**
  116497. * Sets the current alpha mode
  116498. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  116499. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116500. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116501. */
  116502. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116503. /**
  116504. * Gets the current alpha mode
  116505. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116506. * @returns the current alpha mode
  116507. */
  116508. getAlphaMode(): number;
  116509. setInt(uniform: WebGLUniformLocation, int: number): void;
  116510. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116511. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116512. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116513. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116514. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116515. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116516. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116517. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116518. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116519. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116520. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116521. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116522. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116523. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116524. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116525. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116526. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116527. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116528. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116529. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  116530. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  116531. wipeCaches(bruteForce?: boolean): void;
  116532. _createTexture(): WebGLTexture;
  116533. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116534. /**
  116535. * Usually called from BABYLON.Texture.ts.
  116536. * Passed information to create a WebGLTexture
  116537. * @param urlArg defines a value which contains one of the following:
  116538. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116539. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116540. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116542. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  116543. * @param scene needed for loading to the correct scene
  116544. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  116545. * @param onLoad optional callback to be called upon successful completion
  116546. * @param onError optional callback to be called upon failure
  116547. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  116548. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116549. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116550. * @param forcedExtension defines the extension to use to pick the right loader
  116551. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116552. */
  116553. 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;
  116554. /**
  116555. * Creates a cube texture
  116556. * @param rootUrl defines the url where the files to load is located
  116557. * @param scene defines the current scene
  116558. * @param files defines the list of files to load (1 per face)
  116559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  116560. * @param onLoad defines an optional callback raised when the texture is loaded
  116561. * @param onError defines an optional callback raised if there is an issue to load the texture
  116562. * @param format defines the format of the data
  116563. * @param forcedExtension defines the extension to use to pick the right loader
  116564. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  116565. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116566. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116567. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  116568. * @returns the cube texture as an InternalTexture
  116569. */
  116570. 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;
  116571. private _getSamplingFilter;
  116572. private static _GetNativeTextureFormat;
  116573. createRenderTargetTexture(size: number | {
  116574. width: number;
  116575. height: number;
  116576. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  116577. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116578. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116579. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116580. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116581. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116582. /**
  116583. * Updates a dynamic vertex buffer.
  116584. * @param vertexBuffer the vertex buffer to update
  116585. * @param data the data used to update the vertex buffer
  116586. * @param byteOffset the byte offset of the data (optional)
  116587. * @param byteLength the byte length of the data (optional)
  116588. */
  116589. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116590. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116591. private _updateAnisotropicLevel;
  116592. private _getAddressMode;
  116593. /** @hidden */
  116594. _bindTexture(channel: number, texture: InternalTexture): void;
  116595. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  116596. releaseEffects(): void;
  116597. /** @hidden */
  116598. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116599. /** @hidden */
  116600. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116601. /** @hidden */
  116602. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116603. /** @hidden */
  116604. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116605. }
  116606. }
  116607. declare module BABYLON {
  116608. /**
  116609. * Gather the list of clipboard event types as constants.
  116610. */
  116611. export class ClipboardEventTypes {
  116612. /**
  116613. * The clipboard event is fired when a copy command is active (pressed).
  116614. */
  116615. static readonly COPY: number;
  116616. /**
  116617. * The clipboard event is fired when a cut command is active (pressed).
  116618. */
  116619. static readonly CUT: number;
  116620. /**
  116621. * The clipboard event is fired when a paste command is active (pressed).
  116622. */
  116623. static readonly PASTE: number;
  116624. }
  116625. /**
  116626. * This class is used to store clipboard related info for the onClipboardObservable event.
  116627. */
  116628. export class ClipboardInfo {
  116629. /**
  116630. * Defines the type of event (BABYLON.ClipboardEventTypes)
  116631. */
  116632. type: number;
  116633. /**
  116634. * Defines the related dom event
  116635. */
  116636. event: ClipboardEvent;
  116637. /**
  116638. *Creates an instance of ClipboardInfo.
  116639. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  116640. * @param event Defines the related dom event
  116641. */
  116642. constructor(
  116643. /**
  116644. * Defines the type of event (BABYLON.ClipboardEventTypes)
  116645. */
  116646. type: number,
  116647. /**
  116648. * Defines the related dom event
  116649. */
  116650. event: ClipboardEvent);
  116651. /**
  116652. * Get the clipboard event's type from the keycode.
  116653. * @param keyCode Defines the keyCode for the current keyboard event.
  116654. * @return {number}
  116655. */
  116656. static GetTypeFromCharacter(keyCode: number): number;
  116657. }
  116658. }
  116659. declare module BABYLON {
  116660. /**
  116661. * Google Daydream controller
  116662. */
  116663. export class DaydreamController extends WebVRController {
  116664. /**
  116665. * Base Url for the controller model.
  116666. */
  116667. static MODEL_BASE_URL: string;
  116668. /**
  116669. * File name for the controller model.
  116670. */
  116671. static MODEL_FILENAME: string;
  116672. /**
  116673. * Gamepad Id prefix used to identify Daydream Controller.
  116674. */
  116675. static readonly GAMEPAD_ID_PREFIX: string;
  116676. /**
  116677. * Creates a new DaydreamController from a gamepad
  116678. * @param vrGamepad the gamepad that the controller should be created from
  116679. */
  116680. constructor(vrGamepad: any);
  116681. /**
  116682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  116683. * @param scene scene in which to add meshes
  116684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  116685. */
  116686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  116687. /**
  116688. * Called once for each button that changed state since the last frame
  116689. * @param buttonIdx Which button index changed
  116690. * @param state New state of the button
  116691. * @param changes Which properties on the state changed since last frame
  116692. */
  116693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  116694. }
  116695. }
  116696. declare module BABYLON {
  116697. /**
  116698. * Gear VR Controller
  116699. */
  116700. export class GearVRController extends WebVRController {
  116701. /**
  116702. * Base Url for the controller model.
  116703. */
  116704. static MODEL_BASE_URL: string;
  116705. /**
  116706. * File name for the controller model.
  116707. */
  116708. static MODEL_FILENAME: string;
  116709. /**
  116710. * Gamepad Id prefix used to identify this controller.
  116711. */
  116712. static readonly GAMEPAD_ID_PREFIX: string;
  116713. private readonly _buttonIndexToObservableNameMap;
  116714. /**
  116715. * Creates a new GearVRController from a gamepad
  116716. * @param vrGamepad the gamepad that the controller should be created from
  116717. */
  116718. constructor(vrGamepad: any);
  116719. /**
  116720. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  116721. * @param scene scene in which to add meshes
  116722. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  116723. */
  116724. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  116725. /**
  116726. * Called once for each button that changed state since the last frame
  116727. * @param buttonIdx Which button index changed
  116728. * @param state New state of the button
  116729. * @param changes Which properties on the state changed since last frame
  116730. */
  116731. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  116732. }
  116733. }
  116734. declare module BABYLON {
  116735. /**
  116736. * Class containing static functions to help procedurally build meshes
  116737. */
  116738. export class PolyhedronBuilder {
  116739. /**
  116740. * Creates a polyhedron mesh
  116741. * * 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
  116742. * * The parameter `size` (positive float, default 1) sets the polygon size
  116743. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116744. * * 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`
  116745. * * 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
  116746. * * 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)`)
  116747. * * 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
  116748. * * 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
  116749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116752. * @param name defines the name of the mesh
  116753. * @param options defines the options used to create the mesh
  116754. * @param scene defines the hosting scene
  116755. * @returns the polyhedron mesh
  116756. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116757. */
  116758. static CreatePolyhedron(name: string, options: {
  116759. type?: number;
  116760. size?: number;
  116761. sizeX?: number;
  116762. sizeY?: number;
  116763. sizeZ?: number;
  116764. custom?: any;
  116765. faceUV?: Vector4[];
  116766. faceColors?: Color4[];
  116767. flat?: boolean;
  116768. updatable?: boolean;
  116769. sideOrientation?: number;
  116770. frontUVs?: Vector4;
  116771. backUVs?: Vector4;
  116772. }, scene?: Nullable<Scene>): Mesh;
  116773. }
  116774. }
  116775. declare module BABYLON {
  116776. /**
  116777. * Gizmo that enables scaling a mesh along 3 axis
  116778. */
  116779. export class ScaleGizmo extends Gizmo {
  116780. /**
  116781. * Internal gizmo used for interactions on the x axis
  116782. */
  116783. xGizmo: AxisScaleGizmo;
  116784. /**
  116785. * Internal gizmo used for interactions on the y axis
  116786. */
  116787. yGizmo: AxisScaleGizmo;
  116788. /**
  116789. * Internal gizmo used for interactions on the z axis
  116790. */
  116791. zGizmo: AxisScaleGizmo;
  116792. /**
  116793. * Internal gizmo used to scale all axis equally
  116794. */
  116795. uniformScaleGizmo: AxisScaleGizmo;
  116796. private _meshAttached;
  116797. private _updateGizmoRotationToMatchAttachedMesh;
  116798. private _snapDistance;
  116799. private _scaleRatio;
  116800. private _uniformScalingMesh;
  116801. private _octahedron;
  116802. private _sensitivity;
  116803. /** Fires an event when any of it's sub gizmos are dragged */
  116804. onDragStartObservable: Observable<unknown>;
  116805. /** Fires an event when any of it's sub gizmos are released from dragging */
  116806. onDragEndObservable: Observable<unknown>;
  116807. attachedMesh: Nullable<AbstractMesh>;
  116808. /**
  116809. * Creates a ScaleGizmo
  116810. * @param gizmoLayer The utility layer the gizmo will be added to
  116811. */
  116812. constructor(gizmoLayer?: UtilityLayerRenderer);
  116813. updateGizmoRotationToMatchAttachedMesh: boolean;
  116814. /**
  116815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116816. */
  116817. snapDistance: number;
  116818. /**
  116819. * Ratio for the scale of the gizmo (Default: 1)
  116820. */
  116821. scaleRatio: number;
  116822. /**
  116823. * Sensitivity factor for dragging (Default: 1)
  116824. */
  116825. sensitivity: number;
  116826. /**
  116827. * Disposes of the gizmo
  116828. */
  116829. dispose(): void;
  116830. }
  116831. }
  116832. declare module BABYLON {
  116833. /**
  116834. * Single axis scale gizmo
  116835. */
  116836. export class AxisScaleGizmo extends Gizmo {
  116837. /**
  116838. * Drag behavior responsible for the gizmos dragging interactions
  116839. */
  116840. dragBehavior: PointerDragBehavior;
  116841. private _pointerObserver;
  116842. /**
  116843. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116844. */
  116845. snapDistance: number;
  116846. /**
  116847. * Event that fires each time the gizmo snaps to a new location.
  116848. * * snapDistance is the the change in distance
  116849. */
  116850. onSnapObservable: Observable<{
  116851. snapDistance: number;
  116852. }>;
  116853. /**
  116854. * If the scaling operation should be done on all axis (default: false)
  116855. */
  116856. uniformScaling: boolean;
  116857. /**
  116858. * Custom sensitivity value for the drag strength
  116859. */
  116860. sensitivity: number;
  116861. private _isEnabled;
  116862. private _parent;
  116863. private _arrow;
  116864. private _coloredMaterial;
  116865. private _hoverMaterial;
  116866. /**
  116867. * Creates an AxisScaleGizmo
  116868. * @param gizmoLayer The utility layer the gizmo will be added to
  116869. * @param dragAxis The axis which the gizmo will be able to scale on
  116870. * @param color The color of the gizmo
  116871. */
  116872. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  116873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116874. /**
  116875. * If the gizmo is enabled
  116876. */
  116877. isEnabled: boolean;
  116878. /**
  116879. * Disposes of the gizmo
  116880. */
  116881. dispose(): void;
  116882. /**
  116883. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  116884. * @param mesh The mesh to replace the default mesh of the gizmo
  116885. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  116886. */
  116887. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  116888. }
  116889. }
  116890. declare module BABYLON {
  116891. /**
  116892. * Bounding box gizmo
  116893. */
  116894. export class BoundingBoxGizmo extends Gizmo {
  116895. private _lineBoundingBox;
  116896. private _rotateSpheresParent;
  116897. private _scaleBoxesParent;
  116898. private _boundingDimensions;
  116899. private _renderObserver;
  116900. private _pointerObserver;
  116901. private _scaleDragSpeed;
  116902. private _tmpQuaternion;
  116903. private _tmpVector;
  116904. private _tmpRotationMatrix;
  116905. /**
  116906. * 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)
  116907. */
  116908. ignoreChildren: boolean;
  116909. /**
  116910. * 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)
  116911. */
  116912. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  116913. /**
  116914. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  116915. */
  116916. rotationSphereSize: number;
  116917. /**
  116918. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  116919. */
  116920. scaleBoxSize: number;
  116921. /**
  116922. * 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)
  116923. */
  116924. fixedDragMeshScreenSize: boolean;
  116925. /**
  116926. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  116927. */
  116928. fixedDragMeshScreenSizeDistanceFactor: number;
  116929. /**
  116930. * Fired when a rotation sphere or scale box is dragged
  116931. */
  116932. onDragStartObservable: Observable<{}>;
  116933. /**
  116934. * Fired when a scale box is dragged
  116935. */
  116936. onScaleBoxDragObservable: Observable<{}>;
  116937. /**
  116938. * Fired when a scale box drag is ended
  116939. */
  116940. onScaleBoxDragEndObservable: Observable<{}>;
  116941. /**
  116942. * Fired when a rotation sphere is dragged
  116943. */
  116944. onRotationSphereDragObservable: Observable<{}>;
  116945. /**
  116946. * Fired when a rotation sphere drag is ended
  116947. */
  116948. onRotationSphereDragEndObservable: Observable<{}>;
  116949. /**
  116950. * 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)
  116951. */
  116952. scalePivot: Nullable<Vector3>;
  116953. /**
  116954. * Mesh used as a pivot to rotate the attached mesh
  116955. */
  116956. private _anchorMesh;
  116957. private _existingMeshScale;
  116958. private _dragMesh;
  116959. private pointerDragBehavior;
  116960. private coloredMaterial;
  116961. private hoverColoredMaterial;
  116962. /**
  116963. * Sets the color of the bounding box gizmo
  116964. * @param color the color to set
  116965. */
  116966. setColor(color: Color3): void;
  116967. /**
  116968. * Creates an BoundingBoxGizmo
  116969. * @param gizmoLayer The utility layer the gizmo will be added to
  116970. * @param color The color of the gizmo
  116971. */
  116972. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  116973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116974. private _selectNode;
  116975. /**
  116976. * Updates the bounding box information for the Gizmo
  116977. */
  116978. updateBoundingBox(): void;
  116979. private _updateRotationSpheres;
  116980. private _updateScaleBoxes;
  116981. /**
  116982. * Enables rotation on the specified axis and disables rotation on the others
  116983. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  116984. */
  116985. setEnabledRotationAxis(axis: string): void;
  116986. /**
  116987. * Enables/disables scaling
  116988. * @param enable if scaling should be enabled
  116989. */
  116990. setEnabledScaling(enable: boolean): void;
  116991. private _updateDummy;
  116992. /**
  116993. * Enables a pointer drag behavior on the bounding box of the gizmo
  116994. */
  116995. enableDragBehavior(): void;
  116996. /**
  116997. * Disposes of the gizmo
  116998. */
  116999. dispose(): void;
  117000. /**
  117001. * 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)
  117002. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  117003. * @returns the bounding box mesh with the passed in mesh as a child
  117004. */
  117005. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  117006. /**
  117007. * CustomMeshes are not supported by this gizmo
  117008. * @param mesh The mesh to replace the default mesh of the gizmo
  117009. */
  117010. setCustomMesh(mesh: Mesh): void;
  117011. }
  117012. }
  117013. declare module BABYLON {
  117014. /**
  117015. * Single plane rotation gizmo
  117016. */
  117017. export class PlaneRotationGizmo extends Gizmo {
  117018. /**
  117019. * Drag behavior responsible for the gizmos dragging interactions
  117020. */
  117021. dragBehavior: PointerDragBehavior;
  117022. private _pointerObserver;
  117023. /**
  117024. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  117025. */
  117026. snapDistance: number;
  117027. /**
  117028. * Event that fires each time the gizmo snaps to a new location.
  117029. * * snapDistance is the the change in distance
  117030. */
  117031. onSnapObservable: Observable<{
  117032. snapDistance: number;
  117033. }>;
  117034. private _isEnabled;
  117035. private _parent;
  117036. /**
  117037. * Creates a PlaneRotationGizmo
  117038. * @param gizmoLayer The utility layer the gizmo will be added to
  117039. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  117040. * @param color The color of the gizmo
  117041. * @param tessellation Amount of tessellation to be used when creating rotation circles
  117042. * @param useEulerRotation Use and update Euler angle instead of quaternion
  117043. */
  117044. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  117045. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117046. /**
  117047. * If the gizmo is enabled
  117048. */
  117049. isEnabled: boolean;
  117050. /**
  117051. * Disposes of the gizmo
  117052. */
  117053. dispose(): void;
  117054. }
  117055. }
  117056. declare module BABYLON {
  117057. /**
  117058. * Gizmo that enables rotating a mesh along 3 axis
  117059. */
  117060. export class RotationGizmo extends Gizmo {
  117061. /**
  117062. * Internal gizmo used for interactions on the x axis
  117063. */
  117064. xGizmo: PlaneRotationGizmo;
  117065. /**
  117066. * Internal gizmo used for interactions on the y axis
  117067. */
  117068. yGizmo: PlaneRotationGizmo;
  117069. /**
  117070. * Internal gizmo used for interactions on the z axis
  117071. */
  117072. zGizmo: PlaneRotationGizmo;
  117073. /** Fires an event when any of it's sub gizmos are dragged */
  117074. onDragStartObservable: Observable<unknown>;
  117075. /** Fires an event when any of it's sub gizmos are released from dragging */
  117076. onDragEndObservable: Observable<unknown>;
  117077. private _meshAttached;
  117078. attachedMesh: Nullable<AbstractMesh>;
  117079. /**
  117080. * Creates a RotationGizmo
  117081. * @param gizmoLayer The utility layer the gizmo will be added to
  117082. * @param tessellation Amount of tessellation to be used when creating rotation circles
  117083. * @param useEulerRotation Use and update Euler angle instead of quaternion
  117084. */
  117085. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  117086. updateGizmoRotationToMatchAttachedMesh: boolean;
  117087. /**
  117088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117089. */
  117090. snapDistance: number;
  117091. /**
  117092. * Ratio for the scale of the gizmo (Default: 1)
  117093. */
  117094. scaleRatio: number;
  117095. /**
  117096. * Disposes of the gizmo
  117097. */
  117098. dispose(): void;
  117099. /**
  117100. * CustomMeshes are not supported by this gizmo
  117101. * @param mesh The mesh to replace the default mesh of the gizmo
  117102. */
  117103. setCustomMesh(mesh: Mesh): void;
  117104. }
  117105. }
  117106. declare module BABYLON {
  117107. /**
  117108. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  117109. */
  117110. export class GizmoManager implements IDisposable {
  117111. private scene;
  117112. /**
  117113. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  117114. */
  117115. gizmos: {
  117116. positionGizmo: Nullable<PositionGizmo>;
  117117. rotationGizmo: Nullable<RotationGizmo>;
  117118. scaleGizmo: Nullable<ScaleGizmo>;
  117119. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  117120. };
  117121. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  117122. clearGizmoOnEmptyPointerEvent: boolean;
  117123. /** Fires an event when the manager is attached to a mesh */
  117124. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  117125. private _gizmosEnabled;
  117126. private _pointerObserver;
  117127. private _attachedMesh;
  117128. private _boundingBoxColor;
  117129. private _defaultUtilityLayer;
  117130. private _defaultKeepDepthUtilityLayer;
  117131. /**
  117132. * When bounding box gizmo is enabled, this can be used to track drag/end events
  117133. */
  117134. boundingBoxDragBehavior: SixDofDragBehavior;
  117135. /**
  117136. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  117137. */
  117138. attachableMeshes: Nullable<Array<AbstractMesh>>;
  117139. /**
  117140. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  117141. */
  117142. usePointerToAttachGizmos: boolean;
  117143. /**
  117144. * Utility layer that the bounding box gizmo belongs to
  117145. */
  117146. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  117147. /**
  117148. * Utility layer that all gizmos besides bounding box belong to
  117149. */
  117150. readonly utilityLayer: UtilityLayerRenderer;
  117151. /**
  117152. * Instatiates a gizmo manager
  117153. * @param scene the scene to overlay the gizmos on top of
  117154. */
  117155. constructor(scene: Scene);
  117156. /**
  117157. * Attaches a set of gizmos to the specified mesh
  117158. * @param mesh The mesh the gizmo's should be attached to
  117159. */
  117160. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117161. /**
  117162. * If the position gizmo is enabled
  117163. */
  117164. positionGizmoEnabled: boolean;
  117165. /**
  117166. * If the rotation gizmo is enabled
  117167. */
  117168. rotationGizmoEnabled: boolean;
  117169. /**
  117170. * If the scale gizmo is enabled
  117171. */
  117172. scaleGizmoEnabled: boolean;
  117173. /**
  117174. * If the boundingBox gizmo is enabled
  117175. */
  117176. boundingBoxGizmoEnabled: boolean;
  117177. /**
  117178. * Disposes of the gizmo manager
  117179. */
  117180. dispose(): void;
  117181. }
  117182. }
  117183. declare module BABYLON {
  117184. /**
  117185. * A directional light is defined by a direction (what a surprise!).
  117186. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  117187. * 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.
  117188. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117189. */
  117190. export class DirectionalLight extends ShadowLight {
  117191. private _shadowFrustumSize;
  117192. /**
  117193. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  117194. */
  117195. /**
  117196. * Specifies a fix frustum size for the shadow generation.
  117197. */
  117198. shadowFrustumSize: number;
  117199. private _shadowOrthoScale;
  117200. /**
  117201. * Gets the shadow projection scale against the optimal computed one.
  117202. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  117203. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  117204. */
  117205. /**
  117206. * Sets the shadow projection scale against the optimal computed one.
  117207. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  117208. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  117209. */
  117210. shadowOrthoScale: number;
  117211. /**
  117212. * Automatically compute the projection matrix to best fit (including all the casters)
  117213. * on each frame.
  117214. */
  117215. autoUpdateExtends: boolean;
  117216. private _orthoLeft;
  117217. private _orthoRight;
  117218. private _orthoTop;
  117219. private _orthoBottom;
  117220. /**
  117221. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  117222. * The directional light is emitted from everywhere in the given direction.
  117223. * It can cast shadows.
  117224. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117225. * @param name The friendly name of the light
  117226. * @param direction The direction of the light
  117227. * @param scene The scene the light belongs to
  117228. */
  117229. constructor(name: string, direction: Vector3, scene: Scene);
  117230. /**
  117231. * Returns the string "DirectionalLight".
  117232. * @return The class name
  117233. */
  117234. getClassName(): string;
  117235. /**
  117236. * Returns the integer 1.
  117237. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117238. */
  117239. getTypeID(): number;
  117240. /**
  117241. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  117242. * Returns the DirectionalLight Shadow projection matrix.
  117243. */
  117244. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117245. /**
  117246. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  117247. * Returns the DirectionalLight Shadow projection matrix.
  117248. */
  117249. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  117250. /**
  117251. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  117252. * Returns the DirectionalLight Shadow projection matrix.
  117253. */
  117254. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117255. protected _buildUniformLayout(): void;
  117256. /**
  117257. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  117258. * @param effect The effect to update
  117259. * @param lightIndex The index of the light in the effect to update
  117260. * @returns The directional light
  117261. */
  117262. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  117263. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  117264. /**
  117265. * Gets the minZ used for shadow according to both the scene and the light.
  117266. *
  117267. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  117268. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  117269. * @param activeCamera The camera we are returning the min for
  117270. * @returns the depth min z
  117271. */
  117272. getDepthMinZ(activeCamera: Camera): number;
  117273. /**
  117274. * Gets the maxZ used for shadow according to both the scene and the light.
  117275. *
  117276. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  117277. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  117278. * @param activeCamera The camera we are returning the max for
  117279. * @returns the depth max z
  117280. */
  117281. getDepthMaxZ(activeCamera: Camera): number;
  117282. /**
  117283. * Prepares the list of defines specific to the light type.
  117284. * @param defines the list of defines
  117285. * @param lightIndex defines the index of the light for the effect
  117286. */
  117287. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117288. }
  117289. }
  117290. declare module BABYLON {
  117291. /**
  117292. * Class containing static functions to help procedurally build meshes
  117293. */
  117294. export class HemisphereBuilder {
  117295. /**
  117296. * Creates a hemisphere mesh
  117297. * @param name defines the name of the mesh
  117298. * @param options defines the options used to create the mesh
  117299. * @param scene defines the hosting scene
  117300. * @returns the hemisphere mesh
  117301. */
  117302. static CreateHemisphere(name: string, options: {
  117303. segments?: number;
  117304. diameter?: number;
  117305. sideOrientation?: number;
  117306. }, scene: any): Mesh;
  117307. }
  117308. }
  117309. declare module BABYLON {
  117310. /**
  117311. * A spot light is defined by a position, a direction, an angle, and an exponent.
  117312. * These values define a cone of light starting from the position, emitting toward the direction.
  117313. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  117314. * and the exponent defines the speed of the decay of the light with distance (reach).
  117315. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117316. */
  117317. export class SpotLight extends ShadowLight {
  117318. private _angle;
  117319. private _innerAngle;
  117320. private _cosHalfAngle;
  117321. private _lightAngleScale;
  117322. private _lightAngleOffset;
  117323. /**
  117324. * Gets the cone angle of the spot light in Radians.
  117325. */
  117326. /**
  117327. * Sets the cone angle of the spot light in Radians.
  117328. */
  117329. angle: number;
  117330. /**
  117331. * Only used in gltf falloff mode, this defines the angle where
  117332. * the directional falloff will start before cutting at angle which could be seen
  117333. * as outer angle.
  117334. */
  117335. /**
  117336. * Only used in gltf falloff mode, this defines the angle where
  117337. * the directional falloff will start before cutting at angle which could be seen
  117338. * as outer angle.
  117339. */
  117340. innerAngle: number;
  117341. private _shadowAngleScale;
  117342. /**
  117343. * Allows scaling the angle of the light for shadow generation only.
  117344. */
  117345. /**
  117346. * Allows scaling the angle of the light for shadow generation only.
  117347. */
  117348. shadowAngleScale: number;
  117349. /**
  117350. * The light decay speed with the distance from the emission spot.
  117351. */
  117352. exponent: number;
  117353. private _projectionTextureMatrix;
  117354. /**
  117355. * Allows reading the projecton texture
  117356. */
  117357. readonly projectionTextureMatrix: Matrix;
  117358. protected _projectionTextureLightNear: number;
  117359. /**
  117360. * Gets the near clip of the Spotlight for texture projection.
  117361. */
  117362. /**
  117363. * Sets the near clip of the Spotlight for texture projection.
  117364. */
  117365. projectionTextureLightNear: number;
  117366. protected _projectionTextureLightFar: number;
  117367. /**
  117368. * Gets the far clip of the Spotlight for texture projection.
  117369. */
  117370. /**
  117371. * Sets the far clip of the Spotlight for texture projection.
  117372. */
  117373. projectionTextureLightFar: number;
  117374. protected _projectionTextureUpDirection: Vector3;
  117375. /**
  117376. * Gets the Up vector of the Spotlight for texture projection.
  117377. */
  117378. /**
  117379. * Sets the Up vector of the Spotlight for texture projection.
  117380. */
  117381. projectionTextureUpDirection: Vector3;
  117382. private _projectionTexture;
  117383. /**
  117384. * Gets the projection texture of the light.
  117385. */
  117386. /**
  117387. * Sets the projection texture of the light.
  117388. */
  117389. projectionTexture: Nullable<BaseTexture>;
  117390. private _projectionTextureViewLightDirty;
  117391. private _projectionTextureProjectionLightDirty;
  117392. private _projectionTextureDirty;
  117393. private _projectionTextureViewTargetVector;
  117394. private _projectionTextureViewLightMatrix;
  117395. private _projectionTextureProjectionLightMatrix;
  117396. private _projectionTextureScalingMatrix;
  117397. /**
  117398. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  117399. * It can cast shadows.
  117400. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117401. * @param name The light friendly name
  117402. * @param position The position of the spot light in the scene
  117403. * @param direction The direction of the light in the scene
  117404. * @param angle The cone angle of the light in Radians
  117405. * @param exponent The light decay speed with the distance from the emission spot
  117406. * @param scene The scene the lights belongs to
  117407. */
  117408. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  117409. /**
  117410. * Returns the string "SpotLight".
  117411. * @returns the class name
  117412. */
  117413. getClassName(): string;
  117414. /**
  117415. * Returns the integer 2.
  117416. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117417. */
  117418. getTypeID(): number;
  117419. /**
  117420. * Overrides the direction setter to recompute the projection texture view light Matrix.
  117421. */
  117422. protected _setDirection(value: Vector3): void;
  117423. /**
  117424. * Overrides the position setter to recompute the projection texture view light Matrix.
  117425. */
  117426. protected _setPosition(value: Vector3): void;
  117427. /**
  117428. * 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.
  117429. * Returns the SpotLight.
  117430. */
  117431. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117432. protected _computeProjectionTextureViewLightMatrix(): void;
  117433. protected _computeProjectionTextureProjectionLightMatrix(): void;
  117434. /**
  117435. * Main function for light texture projection matrix computing.
  117436. */
  117437. protected _computeProjectionTextureMatrix(): void;
  117438. protected _buildUniformLayout(): void;
  117439. private _computeAngleValues;
  117440. /**
  117441. * Sets the passed Effect "effect" with the Light textures.
  117442. * @param effect The effect to update
  117443. * @param lightIndex The index of the light in the effect to update
  117444. * @returns The light
  117445. */
  117446. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  117447. /**
  117448. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  117449. * @param effect The effect to update
  117450. * @param lightIndex The index of the light in the effect to update
  117451. * @returns The spot light
  117452. */
  117453. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  117454. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117455. /**
  117456. * Disposes the light and the associated resources.
  117457. */
  117458. dispose(): void;
  117459. /**
  117460. * Prepares the list of defines specific to the light type.
  117461. * @param defines the list of defines
  117462. * @param lightIndex defines the index of the light for the effect
  117463. */
  117464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117465. }
  117466. }
  117467. declare module BABYLON {
  117468. /**
  117469. * Gizmo that enables viewing a light
  117470. */
  117471. export class LightGizmo extends Gizmo {
  117472. private _lightMesh;
  117473. private _material;
  117474. private _cachedPosition;
  117475. private _cachedForward;
  117476. private _attachedMeshParent;
  117477. /**
  117478. * Creates a LightGizmo
  117479. * @param gizmoLayer The utility layer the gizmo will be added to
  117480. */
  117481. constructor(gizmoLayer?: UtilityLayerRenderer);
  117482. private _light;
  117483. /**
  117484. * The light that the gizmo is attached to
  117485. */
  117486. light: Nullable<Light>;
  117487. /**
  117488. * Gets the material used to render the light gizmo
  117489. */
  117490. readonly material: StandardMaterial;
  117491. /**
  117492. * @hidden
  117493. * Updates the gizmo to match the attached mesh's position/rotation
  117494. */
  117495. protected _update(): void;
  117496. private static _Scale;
  117497. /**
  117498. * Creates the lines for a light mesh
  117499. */
  117500. private static _CreateLightLines;
  117501. /**
  117502. * Disposes of the light gizmo
  117503. */
  117504. dispose(): void;
  117505. private static _CreateHemisphericLightMesh;
  117506. private static _CreatePointLightMesh;
  117507. private static _CreateSpotLightMesh;
  117508. private static _CreateDirectionalLightMesh;
  117509. }
  117510. }
  117511. declare module BABYLON {
  117512. /** @hidden */
  117513. export var backgroundFragmentDeclaration: {
  117514. name: string;
  117515. shader: string;
  117516. };
  117517. }
  117518. declare module BABYLON {
  117519. /** @hidden */
  117520. export var backgroundUboDeclaration: {
  117521. name: string;
  117522. shader: string;
  117523. };
  117524. }
  117525. declare module BABYLON {
  117526. /** @hidden */
  117527. export var backgroundPixelShader: {
  117528. name: string;
  117529. shader: string;
  117530. };
  117531. }
  117532. declare module BABYLON {
  117533. /** @hidden */
  117534. export var backgroundVertexDeclaration: {
  117535. name: string;
  117536. shader: string;
  117537. };
  117538. }
  117539. declare module BABYLON {
  117540. /** @hidden */
  117541. export var backgroundVertexShader: {
  117542. name: string;
  117543. shader: string;
  117544. };
  117545. }
  117546. declare module BABYLON {
  117547. /**
  117548. * Background material used to create an efficient environement around your scene.
  117549. */
  117550. export class BackgroundMaterial extends PushMaterial {
  117551. /**
  117552. * Standard reflectance value at parallel view angle.
  117553. */
  117554. static StandardReflectance0: number;
  117555. /**
  117556. * Standard reflectance value at grazing angle.
  117557. */
  117558. static StandardReflectance90: number;
  117559. protected _primaryColor: Color3;
  117560. /**
  117561. * Key light Color (multiply against the environement texture)
  117562. */
  117563. primaryColor: Color3;
  117564. protected __perceptualColor: Nullable<Color3>;
  117565. /**
  117566. * Experimental Internal Use Only.
  117567. *
  117568. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  117569. * This acts as a helper to set the primary color to a more "human friendly" value.
  117570. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  117571. * output color as close as possible from the chosen value.
  117572. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  117573. * part of lighting setup.)
  117574. */
  117575. _perceptualColor: Nullable<Color3>;
  117576. protected _primaryColorShadowLevel: float;
  117577. /**
  117578. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  117579. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  117580. */
  117581. primaryColorShadowLevel: float;
  117582. protected _primaryColorHighlightLevel: float;
  117583. /**
  117584. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  117585. * The primary color is used at the level chosen to define what the white area would look.
  117586. */
  117587. primaryColorHighlightLevel: float;
  117588. protected _reflectionTexture: Nullable<BaseTexture>;
  117589. /**
  117590. * Reflection Texture used in the material.
  117591. * Should be author in a specific way for the best result (refer to the documentation).
  117592. */
  117593. reflectionTexture: Nullable<BaseTexture>;
  117594. protected _reflectionBlur: float;
  117595. /**
  117596. * Reflection Texture level of blur.
  117597. *
  117598. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  117599. * texture twice.
  117600. */
  117601. reflectionBlur: float;
  117602. protected _diffuseTexture: Nullable<BaseTexture>;
  117603. /**
  117604. * Diffuse Texture used in the material.
  117605. * Should be author in a specific way for the best result (refer to the documentation).
  117606. */
  117607. diffuseTexture: Nullable<BaseTexture>;
  117608. protected _shadowLights: Nullable<IShadowLight[]>;
  117609. /**
  117610. * Specify the list of lights casting shadow on the material.
  117611. * All scene shadow lights will be included if null.
  117612. */
  117613. shadowLights: Nullable<IShadowLight[]>;
  117614. protected _shadowLevel: float;
  117615. /**
  117616. * Helps adjusting the shadow to a softer level if required.
  117617. * 0 means black shadows and 1 means no shadows.
  117618. */
  117619. shadowLevel: float;
  117620. protected _sceneCenter: Vector3;
  117621. /**
  117622. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  117623. * It is usually zero but might be interesting to modify according to your setup.
  117624. */
  117625. sceneCenter: Vector3;
  117626. protected _opacityFresnel: boolean;
  117627. /**
  117628. * This helps specifying that the material is falling off to the sky box at grazing angle.
  117629. * This helps ensuring a nice transition when the camera goes under the ground.
  117630. */
  117631. opacityFresnel: boolean;
  117632. protected _reflectionFresnel: boolean;
  117633. /**
  117634. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  117635. * This helps adding a mirror texture on the ground.
  117636. */
  117637. reflectionFresnel: boolean;
  117638. protected _reflectionFalloffDistance: number;
  117639. /**
  117640. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  117641. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  117642. */
  117643. reflectionFalloffDistance: number;
  117644. protected _reflectionAmount: number;
  117645. /**
  117646. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  117647. */
  117648. reflectionAmount: number;
  117649. protected _reflectionReflectance0: number;
  117650. /**
  117651. * This specifies the weight of the reflection at grazing angle.
  117652. */
  117653. reflectionReflectance0: number;
  117654. protected _reflectionReflectance90: number;
  117655. /**
  117656. * This specifies the weight of the reflection at a perpendicular point of view.
  117657. */
  117658. reflectionReflectance90: number;
  117659. /**
  117660. * Sets the reflection reflectance fresnel values according to the default standard
  117661. * empirically know to work well :-)
  117662. */
  117663. reflectionStandardFresnelWeight: number;
  117664. protected _useRGBColor: boolean;
  117665. /**
  117666. * Helps to directly use the maps channels instead of their level.
  117667. */
  117668. useRGBColor: boolean;
  117669. protected _enableNoise: boolean;
  117670. /**
  117671. * This helps reducing the banding effect that could occur on the background.
  117672. */
  117673. enableNoise: boolean;
  117674. /**
  117675. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117676. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  117677. * Recommended to be keep at 1.0 except for special cases.
  117678. */
  117679. fovMultiplier: number;
  117680. private _fovMultiplier;
  117681. /**
  117682. * Enable the FOV adjustment feature controlled by fovMultiplier.
  117683. */
  117684. useEquirectangularFOV: boolean;
  117685. private _maxSimultaneousLights;
  117686. /**
  117687. * Number of Simultaneous lights allowed on the material.
  117688. */
  117689. maxSimultaneousLights: int;
  117690. /**
  117691. * Default configuration related to image processing available in the Background Material.
  117692. */
  117693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117694. /**
  117695. * Keep track of the image processing observer to allow dispose and replace.
  117696. */
  117697. private _imageProcessingObserver;
  117698. /**
  117699. * Attaches a new image processing configuration to the PBR Material.
  117700. * @param configuration (if null the scene configuration will be use)
  117701. */
  117702. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117703. /**
  117704. * Gets the image processing configuration used either in this material.
  117705. */
  117706. /**
  117707. * Sets the Default image processing configuration used either in the this material.
  117708. *
  117709. * If sets to null, the scene one is in use.
  117710. */
  117711. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  117712. /**
  117713. * Gets wether the color curves effect is enabled.
  117714. */
  117715. /**
  117716. * Sets wether the color curves effect is enabled.
  117717. */
  117718. cameraColorCurvesEnabled: boolean;
  117719. /**
  117720. * Gets wether the color grading effect is enabled.
  117721. */
  117722. /**
  117723. * Gets wether the color grading effect is enabled.
  117724. */
  117725. cameraColorGradingEnabled: boolean;
  117726. /**
  117727. * Gets wether tonemapping is enabled or not.
  117728. */
  117729. /**
  117730. * Sets wether tonemapping is enabled or not
  117731. */
  117732. cameraToneMappingEnabled: boolean;
  117733. /**
  117734. * The camera exposure used on this material.
  117735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117736. * This corresponds to a photographic exposure.
  117737. */
  117738. /**
  117739. * The camera exposure used on this material.
  117740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117741. * This corresponds to a photographic exposure.
  117742. */
  117743. cameraExposure: float;
  117744. /**
  117745. * Gets The camera contrast used on this material.
  117746. */
  117747. /**
  117748. * Sets The camera contrast used on this material.
  117749. */
  117750. cameraContrast: float;
  117751. /**
  117752. * Gets the Color Grading 2D Lookup Texture.
  117753. */
  117754. /**
  117755. * Sets the Color Grading 2D Lookup Texture.
  117756. */
  117757. cameraColorGradingTexture: Nullable<BaseTexture>;
  117758. /**
  117759. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117760. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117761. * 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;
  117762. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117763. */
  117764. /**
  117765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117767. * 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;
  117768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117769. */
  117770. cameraColorCurves: Nullable<ColorCurves>;
  117771. /**
  117772. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  117773. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  117774. */
  117775. switchToBGR: boolean;
  117776. private _renderTargets;
  117777. private _reflectionControls;
  117778. private _white;
  117779. private _primaryShadowColor;
  117780. private _primaryHighlightColor;
  117781. /**
  117782. * Instantiates a Background Material in the given scene
  117783. * @param name The friendly name of the material
  117784. * @param scene The scene to add the material to
  117785. */
  117786. constructor(name: string, scene: Scene);
  117787. /**
  117788. * Gets a boolean indicating that current material needs to register RTT
  117789. */
  117790. readonly hasRenderTargetTextures: boolean;
  117791. /**
  117792. * The entire material has been created in order to prevent overdraw.
  117793. * @returns false
  117794. */
  117795. needAlphaTesting(): boolean;
  117796. /**
  117797. * The entire material has been created in order to prevent overdraw.
  117798. * @returns true if blending is enable
  117799. */
  117800. needAlphaBlending(): boolean;
  117801. /**
  117802. * Checks wether the material is ready to be rendered for a given mesh.
  117803. * @param mesh The mesh to render
  117804. * @param subMesh The submesh to check against
  117805. * @param useInstances Specify wether or not the material is used with instances
  117806. * @returns true if all the dependencies are ready (Textures, Effects...)
  117807. */
  117808. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117809. /**
  117810. * Compute the primary color according to the chosen perceptual color.
  117811. */
  117812. private _computePrimaryColorFromPerceptualColor;
  117813. /**
  117814. * Compute the highlights and shadow colors according to their chosen levels.
  117815. */
  117816. private _computePrimaryColors;
  117817. /**
  117818. * Build the uniform buffer used in the material.
  117819. */
  117820. buildUniformLayout(): void;
  117821. /**
  117822. * Unbind the material.
  117823. */
  117824. unbind(): void;
  117825. /**
  117826. * Bind only the world matrix to the material.
  117827. * @param world The world matrix to bind.
  117828. */
  117829. bindOnlyWorldMatrix(world: Matrix): void;
  117830. /**
  117831. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  117832. * @param world The world matrix to bind.
  117833. * @param subMesh The submesh to bind for.
  117834. */
  117835. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117836. /**
  117837. * Checks to see if a texture is used in the material.
  117838. * @param texture - Base texture to use.
  117839. * @returns - Boolean specifying if a texture is used in the material.
  117840. */
  117841. hasTexture(texture: BaseTexture): boolean;
  117842. /**
  117843. * Dispose the material.
  117844. * @param forceDisposeEffect Force disposal of the associated effect.
  117845. * @param forceDisposeTextures Force disposal of the associated textures.
  117846. */
  117847. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117848. /**
  117849. * Clones the material.
  117850. * @param name The cloned name.
  117851. * @returns The cloned material.
  117852. */
  117853. clone(name: string): BackgroundMaterial;
  117854. /**
  117855. * Serializes the current material to its JSON representation.
  117856. * @returns The JSON representation.
  117857. */
  117858. serialize(): any;
  117859. /**
  117860. * Gets the class name of the material
  117861. * @returns "BackgroundMaterial"
  117862. */
  117863. getClassName(): string;
  117864. /**
  117865. * Parse a JSON input to create back a background material.
  117866. * @param source The JSON data to parse
  117867. * @param scene The scene to create the parsed material in
  117868. * @param rootUrl The root url of the assets the material depends upon
  117869. * @returns the instantiated BackgroundMaterial.
  117870. */
  117871. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  117872. }
  117873. }
  117874. declare module BABYLON {
  117875. /**
  117876. * Represents the different options available during the creation of
  117877. * a Environment helper.
  117878. *
  117879. * This can control the default ground, skybox and image processing setup of your scene.
  117880. */
  117881. export interface IEnvironmentHelperOptions {
  117882. /**
  117883. * Specifies wether or not to create a ground.
  117884. * True by default.
  117885. */
  117886. createGround: boolean;
  117887. /**
  117888. * Specifies the ground size.
  117889. * 15 by default.
  117890. */
  117891. groundSize: number;
  117892. /**
  117893. * The texture used on the ground for the main color.
  117894. * Comes from the BabylonJS CDN by default.
  117895. *
  117896. * Remarks: Can be either a texture or a url.
  117897. */
  117898. groundTexture: string | BaseTexture;
  117899. /**
  117900. * The color mixed in the ground texture by default.
  117901. * BabylonJS clearColor by default.
  117902. */
  117903. groundColor: Color3;
  117904. /**
  117905. * Specifies the ground opacity.
  117906. * 1 by default.
  117907. */
  117908. groundOpacity: number;
  117909. /**
  117910. * Enables the ground to receive shadows.
  117911. * True by default.
  117912. */
  117913. enableGroundShadow: boolean;
  117914. /**
  117915. * Helps preventing the shadow to be fully black on the ground.
  117916. * 0.5 by default.
  117917. */
  117918. groundShadowLevel: number;
  117919. /**
  117920. * Creates a mirror texture attach to the ground.
  117921. * false by default.
  117922. */
  117923. enableGroundMirror: boolean;
  117924. /**
  117925. * Specifies the ground mirror size ratio.
  117926. * 0.3 by default as the default kernel is 64.
  117927. */
  117928. groundMirrorSizeRatio: number;
  117929. /**
  117930. * Specifies the ground mirror blur kernel size.
  117931. * 64 by default.
  117932. */
  117933. groundMirrorBlurKernel: number;
  117934. /**
  117935. * Specifies the ground mirror visibility amount.
  117936. * 1 by default
  117937. */
  117938. groundMirrorAmount: number;
  117939. /**
  117940. * Specifies the ground mirror reflectance weight.
  117941. * This uses the standard weight of the background material to setup the fresnel effect
  117942. * of the mirror.
  117943. * 1 by default.
  117944. */
  117945. groundMirrorFresnelWeight: number;
  117946. /**
  117947. * Specifies the ground mirror Falloff distance.
  117948. * This can helps reducing the size of the reflection.
  117949. * 0 by Default.
  117950. */
  117951. groundMirrorFallOffDistance: number;
  117952. /**
  117953. * Specifies the ground mirror texture type.
  117954. * Unsigned Int by Default.
  117955. */
  117956. groundMirrorTextureType: number;
  117957. /**
  117958. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  117959. * the shown objects.
  117960. */
  117961. groundYBias: number;
  117962. /**
  117963. * Specifies wether or not to create a skybox.
  117964. * True by default.
  117965. */
  117966. createSkybox: boolean;
  117967. /**
  117968. * Specifies the skybox size.
  117969. * 20 by default.
  117970. */
  117971. skyboxSize: number;
  117972. /**
  117973. * The texture used on the skybox for the main color.
  117974. * Comes from the BabylonJS CDN by default.
  117975. *
  117976. * Remarks: Can be either a texture or a url.
  117977. */
  117978. skyboxTexture: string | BaseTexture;
  117979. /**
  117980. * The color mixed in the skybox texture by default.
  117981. * BabylonJS clearColor by default.
  117982. */
  117983. skyboxColor: Color3;
  117984. /**
  117985. * The background rotation around the Y axis of the scene.
  117986. * This helps aligning the key lights of your scene with the background.
  117987. * 0 by default.
  117988. */
  117989. backgroundYRotation: number;
  117990. /**
  117991. * Compute automatically the size of the elements to best fit with the scene.
  117992. */
  117993. sizeAuto: boolean;
  117994. /**
  117995. * Default position of the rootMesh if autoSize is not true.
  117996. */
  117997. rootPosition: Vector3;
  117998. /**
  117999. * Sets up the image processing in the scene.
  118000. * true by default.
  118001. */
  118002. setupImageProcessing: boolean;
  118003. /**
  118004. * The texture used as your environment texture in the scene.
  118005. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  118006. *
  118007. * Remarks: Can be either a texture or a url.
  118008. */
  118009. environmentTexture: string | BaseTexture;
  118010. /**
  118011. * The value of the exposure to apply to the scene.
  118012. * 0.6 by default if setupImageProcessing is true.
  118013. */
  118014. cameraExposure: number;
  118015. /**
  118016. * The value of the contrast to apply to the scene.
  118017. * 1.6 by default if setupImageProcessing is true.
  118018. */
  118019. cameraContrast: number;
  118020. /**
  118021. * Specifies wether or not tonemapping should be enabled in the scene.
  118022. * true by default if setupImageProcessing is true.
  118023. */
  118024. toneMappingEnabled: boolean;
  118025. }
  118026. /**
  118027. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  118028. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  118029. * It also helps with the default setup of your imageProcessing configuration.
  118030. */
  118031. export class EnvironmentHelper {
  118032. /**
  118033. * Default ground texture URL.
  118034. */
  118035. private static _groundTextureCDNUrl;
  118036. /**
  118037. * Default skybox texture URL.
  118038. */
  118039. private static _skyboxTextureCDNUrl;
  118040. /**
  118041. * Default environment texture URL.
  118042. */
  118043. private static _environmentTextureCDNUrl;
  118044. /**
  118045. * Creates the default options for the helper.
  118046. */
  118047. private static _getDefaultOptions;
  118048. private _rootMesh;
  118049. /**
  118050. * Gets the root mesh created by the helper.
  118051. */
  118052. readonly rootMesh: Mesh;
  118053. private _skybox;
  118054. /**
  118055. * Gets the skybox created by the helper.
  118056. */
  118057. readonly skybox: Nullable<Mesh>;
  118058. private _skyboxTexture;
  118059. /**
  118060. * Gets the skybox texture created by the helper.
  118061. */
  118062. readonly skyboxTexture: Nullable<BaseTexture>;
  118063. private _skyboxMaterial;
  118064. /**
  118065. * Gets the skybox material created by the helper.
  118066. */
  118067. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  118068. private _ground;
  118069. /**
  118070. * Gets the ground mesh created by the helper.
  118071. */
  118072. readonly ground: Nullable<Mesh>;
  118073. private _groundTexture;
  118074. /**
  118075. * Gets the ground texture created by the helper.
  118076. */
  118077. readonly groundTexture: Nullable<BaseTexture>;
  118078. private _groundMirror;
  118079. /**
  118080. * Gets the ground mirror created by the helper.
  118081. */
  118082. readonly groundMirror: Nullable<MirrorTexture>;
  118083. /**
  118084. * Gets the ground mirror render list to helps pushing the meshes
  118085. * you wish in the ground reflection.
  118086. */
  118087. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  118088. private _groundMaterial;
  118089. /**
  118090. * Gets the ground material created by the helper.
  118091. */
  118092. readonly groundMaterial: Nullable<BackgroundMaterial>;
  118093. /**
  118094. * Stores the creation options.
  118095. */
  118096. private readonly _scene;
  118097. private _options;
  118098. /**
  118099. * This observable will be notified with any error during the creation of the environment,
  118100. * mainly texture creation errors.
  118101. */
  118102. onErrorObservable: Observable<{
  118103. message?: string;
  118104. exception?: any;
  118105. }>;
  118106. /**
  118107. * constructor
  118108. * @param options Defines the options we want to customize the helper
  118109. * @param scene The scene to add the material to
  118110. */
  118111. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  118112. /**
  118113. * Updates the background according to the new options
  118114. * @param options
  118115. */
  118116. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  118117. /**
  118118. * Sets the primary color of all the available elements.
  118119. * @param color the main color to affect to the ground and the background
  118120. */
  118121. setMainColor(color: Color3): void;
  118122. /**
  118123. * Setup the image processing according to the specified options.
  118124. */
  118125. private _setupImageProcessing;
  118126. /**
  118127. * Setup the environment texture according to the specified options.
  118128. */
  118129. private _setupEnvironmentTexture;
  118130. /**
  118131. * Setup the background according to the specified options.
  118132. */
  118133. private _setupBackground;
  118134. /**
  118135. * Get the scene sizes according to the setup.
  118136. */
  118137. private _getSceneSize;
  118138. /**
  118139. * Setup the ground according to the specified options.
  118140. */
  118141. private _setupGround;
  118142. /**
  118143. * Setup the ground material according to the specified options.
  118144. */
  118145. private _setupGroundMaterial;
  118146. /**
  118147. * Setup the ground diffuse texture according to the specified options.
  118148. */
  118149. private _setupGroundDiffuseTexture;
  118150. /**
  118151. * Setup the ground mirror texture according to the specified options.
  118152. */
  118153. private _setupGroundMirrorTexture;
  118154. /**
  118155. * Setup the ground to receive the mirror texture.
  118156. */
  118157. private _setupMirrorInGroundMaterial;
  118158. /**
  118159. * Setup the skybox according to the specified options.
  118160. */
  118161. private _setupSkybox;
  118162. /**
  118163. * Setup the skybox material according to the specified options.
  118164. */
  118165. private _setupSkyboxMaterial;
  118166. /**
  118167. * Setup the skybox reflection texture according to the specified options.
  118168. */
  118169. private _setupSkyboxReflectionTexture;
  118170. private _errorHandler;
  118171. /**
  118172. * Dispose all the elements created by the Helper.
  118173. */
  118174. dispose(): void;
  118175. }
  118176. }
  118177. declare module BABYLON {
  118178. /**
  118179. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  118180. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  118181. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  118182. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118183. */
  118184. export class PhotoDome extends TransformNode {
  118185. /**
  118186. * Define the image as a Monoscopic panoramic 360 image.
  118187. */
  118188. static readonly MODE_MONOSCOPIC: number;
  118189. /**
  118190. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  118191. */
  118192. static readonly MODE_TOPBOTTOM: number;
  118193. /**
  118194. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  118195. */
  118196. static readonly MODE_SIDEBYSIDE: number;
  118197. private _useDirectMapping;
  118198. /**
  118199. * The texture being displayed on the sphere
  118200. */
  118201. protected _photoTexture: Texture;
  118202. /**
  118203. * Gets or sets the texture being displayed on the sphere
  118204. */
  118205. photoTexture: Texture;
  118206. /**
  118207. * Observable raised when an error occured while loading the 360 image
  118208. */
  118209. onLoadErrorObservable: Observable<string>;
  118210. /**
  118211. * The skybox material
  118212. */
  118213. protected _material: BackgroundMaterial;
  118214. /**
  118215. * The surface used for the skybox
  118216. */
  118217. protected _mesh: Mesh;
  118218. /**
  118219. * Gets the mesh used for the skybox.
  118220. */
  118221. readonly mesh: Mesh;
  118222. /**
  118223. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118224. * Also see the options.resolution property.
  118225. */
  118226. fovMultiplier: number;
  118227. private _imageMode;
  118228. /**
  118229. * Gets or set the current video mode for the video. It can be:
  118230. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  118231. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  118232. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  118233. */
  118234. imageMode: number;
  118235. /**
  118236. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  118237. * @param name Element's name, child elements will append suffixes for their own names.
  118238. * @param urlsOfPhoto defines the url of the photo to display
  118239. * @param options defines an object containing optional or exposed sub element properties
  118240. * @param onError defines a callback called when an error occured while loading the texture
  118241. */
  118242. constructor(name: string, urlOfPhoto: string, options: {
  118243. resolution?: number;
  118244. size?: number;
  118245. useDirectMapping?: boolean;
  118246. faceForward?: boolean;
  118247. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  118248. private _onBeforeCameraRenderObserver;
  118249. private _changeImageMode;
  118250. /**
  118251. * Releases resources associated with this node.
  118252. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118253. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118254. */
  118255. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118256. }
  118257. }
  118258. declare module BABYLON {
  118259. /**
  118260. * Class used to host RGBD texture specific utilities
  118261. */
  118262. export class RGBDTextureTools {
  118263. /**
  118264. * Expand the RGBD Texture from RGBD to Half Float if possible.
  118265. * @param texture the texture to expand.
  118266. */
  118267. static ExpandRGBDTexture(texture: Texture): void;
  118268. }
  118269. }
  118270. declare module BABYLON {
  118271. /**
  118272. * Class used to host texture specific utilities
  118273. */
  118274. export class BRDFTextureTools {
  118275. /**
  118276. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  118277. * @param scene defines the hosting scene
  118278. * @returns the environment BRDF texture
  118279. */
  118280. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  118281. private static _environmentBRDFBase64Texture;
  118282. }
  118283. }
  118284. declare module BABYLON {
  118285. /**
  118286. * @hidden
  118287. */
  118288. export interface IMaterialClearCoatDefines {
  118289. CLEARCOAT: boolean;
  118290. CLEARCOAT_DEFAULTIOR: boolean;
  118291. CLEARCOAT_TEXTURE: boolean;
  118292. CLEARCOAT_TEXTUREDIRECTUV: number;
  118293. CLEARCOAT_BUMP: boolean;
  118294. CLEARCOAT_BUMPDIRECTUV: number;
  118295. CLEARCOAT_TINT: boolean;
  118296. CLEARCOAT_TINT_TEXTURE: boolean;
  118297. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  118298. /** @hidden */
  118299. _areTexturesDirty: boolean;
  118300. }
  118301. /**
  118302. * Define the code related to the clear coat parameters of the pbr material.
  118303. */
  118304. export class PBRClearCoatConfiguration {
  118305. /**
  118306. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  118307. * The default fits with a polyurethane material.
  118308. */
  118309. private static readonly _DefaultIndexOfRefraction;
  118310. private _isEnabled;
  118311. /**
  118312. * Defines if the clear coat is enabled in the material.
  118313. */
  118314. isEnabled: boolean;
  118315. /**
  118316. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  118317. */
  118318. intensity: number;
  118319. /**
  118320. * Defines the clear coat layer roughness.
  118321. */
  118322. roughness: number;
  118323. private _indexOfRefraction;
  118324. /**
  118325. * Defines the index of refraction of the clear coat.
  118326. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  118327. * The default fits with a polyurethane material.
  118328. * Changing the default value is more performance intensive.
  118329. */
  118330. indexOfRefraction: number;
  118331. private _texture;
  118332. /**
  118333. * Stores the clear coat values in a texture.
  118334. */
  118335. texture: Nullable<BaseTexture>;
  118336. private _bumpTexture;
  118337. /**
  118338. * Define the clear coat specific bump texture.
  118339. */
  118340. bumpTexture: Nullable<BaseTexture>;
  118341. private _isTintEnabled;
  118342. /**
  118343. * Defines if the clear coat tint is enabled in the material.
  118344. */
  118345. isTintEnabled: boolean;
  118346. /**
  118347. * Defines the clear coat tint of the material.
  118348. * This is only use if tint is enabled
  118349. */
  118350. tintColor: Color3;
  118351. /**
  118352. * Defines the distance at which the tint color should be found in the
  118353. * clear coat media.
  118354. * This is only use if tint is enabled
  118355. */
  118356. tintColorAtDistance: number;
  118357. /**
  118358. * Defines the clear coat layer thickness.
  118359. * This is only use if tint is enabled
  118360. */
  118361. tintThickness: number;
  118362. private _tintTexture;
  118363. /**
  118364. * Stores the clear tint values in a texture.
  118365. * rgb is tint
  118366. * a is a thickness factor
  118367. */
  118368. tintTexture: Nullable<BaseTexture>;
  118369. /** @hidden */
  118370. private _internalMarkAllSubMeshesAsTexturesDirty;
  118371. /** @hidden */
  118372. _markAllSubMeshesAsTexturesDirty(): void;
  118373. /**
  118374. * Instantiate a new istance of clear coat configuration.
  118375. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  118376. */
  118377. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  118378. /**
  118379. * Gets wehter the submesh is ready to be used or not.
  118380. * @param defines the list of "defines" to update.
  118381. * @param scene defines the scene the material belongs to.
  118382. * @param engine defines the engine the material belongs to.
  118383. * @param disableBumpMap defines wether the material disables bump or not.
  118384. * @returns - boolean indicating that the submesh is ready or not.
  118385. */
  118386. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  118387. /**
  118388. * Checks to see if a texture is used in the material.
  118389. * @param defines the list of "defines" to update.
  118390. * @param scene defines the scene to the material belongs to.
  118391. */
  118392. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  118393. /**
  118394. * Binds the material data.
  118395. * @param uniformBuffer defines the Uniform buffer to fill in.
  118396. * @param scene defines the scene the material belongs to.
  118397. * @param engine defines the engine the material belongs to.
  118398. * @param disableBumpMap defines wether the material disables bump or not.
  118399. * @param isFrozen defines wether the material is frozen or not.
  118400. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  118401. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  118402. */
  118403. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  118404. /**
  118405. * Checks to see if a texture is used in the material.
  118406. * @param texture - Base texture to use.
  118407. * @returns - Boolean specifying if a texture is used in the material.
  118408. */
  118409. hasTexture(texture: BaseTexture): boolean;
  118410. /**
  118411. * Returns an array of the actively used textures.
  118412. * @param activeTextures Array of BaseTextures
  118413. */
  118414. getActiveTextures(activeTextures: BaseTexture[]): void;
  118415. /**
  118416. * Returns the animatable textures.
  118417. * @param animatables Array of animatable textures.
  118418. */
  118419. getAnimatables(animatables: IAnimatable[]): void;
  118420. /**
  118421. * Disposes the resources of the material.
  118422. * @param forceDisposeTextures - Forces the disposal of all textures.
  118423. */
  118424. dispose(forceDisposeTextures?: boolean): void;
  118425. /**
  118426. * Get the current class name of the texture useful for serialization or dynamic coding.
  118427. * @returns "PBRClearCoatConfiguration"
  118428. */
  118429. getClassName(): string;
  118430. /**
  118431. * Add fallbacks to the effect fallbacks list.
  118432. * @param defines defines the Base texture to use.
  118433. * @param fallbacks defines the current fallback list.
  118434. * @param currentRank defines the current fallback rank.
  118435. * @returns the new fallback rank.
  118436. */
  118437. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  118438. /**
  118439. * Add the required uniforms to the current list.
  118440. * @param uniforms defines the current uniform list.
  118441. */
  118442. static AddUniforms(uniforms: string[]): void;
  118443. /**
  118444. * Add the required samplers to the current list.
  118445. * @param samplers defines the current sampler list.
  118446. */
  118447. static AddSamplers(samplers: string[]): void;
  118448. /**
  118449. * Add the required uniforms to the current buffer.
  118450. * @param uniformBuffer defines the current uniform buffer.
  118451. */
  118452. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  118453. /**
  118454. * Makes a duplicate of the current configuration into another one.
  118455. * @param clearCoatConfiguration define the config where to copy the info
  118456. */
  118457. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  118458. /**
  118459. * Serializes this clear coat configuration.
  118460. * @returns - An object with the serialized config.
  118461. */
  118462. serialize(): any;
  118463. /**
  118464. * Parses a anisotropy Configuration from a serialized object.
  118465. * @param source - Serialized object.
  118466. * @param scene Defines the scene we are parsing for
  118467. * @param rootUrl Defines the rootUrl to load from
  118468. */
  118469. parse(source: any, scene: Scene, rootUrl: string): void;
  118470. }
  118471. }
  118472. declare module BABYLON {
  118473. /**
  118474. * @hidden
  118475. */
  118476. export interface IMaterialAnisotropicDefines {
  118477. ANISOTROPIC: boolean;
  118478. ANISOTROPIC_TEXTURE: boolean;
  118479. ANISOTROPIC_TEXTUREDIRECTUV: number;
  118480. MAINUV1: boolean;
  118481. _areTexturesDirty: boolean;
  118482. _needUVs: boolean;
  118483. }
  118484. /**
  118485. * Define the code related to the anisotropic parameters of the pbr material.
  118486. */
  118487. export class PBRAnisotropicConfiguration {
  118488. private _isEnabled;
  118489. /**
  118490. * Defines if the anisotropy is enabled in the material.
  118491. */
  118492. isEnabled: boolean;
  118493. /**
  118494. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  118495. */
  118496. intensity: number;
  118497. /**
  118498. * Defines if the effect is along the tangents, bitangents or in between.
  118499. * By default, the effect is "strectching" the highlights along the tangents.
  118500. */
  118501. direction: Vector2;
  118502. private _texture;
  118503. /**
  118504. * Stores the anisotropy values in a texture.
  118505. * rg is direction (like normal from -1 to 1)
  118506. * b is a intensity
  118507. */
  118508. texture: Nullable<BaseTexture>;
  118509. /** @hidden */
  118510. private _internalMarkAllSubMeshesAsTexturesDirty;
  118511. /** @hidden */
  118512. _markAllSubMeshesAsTexturesDirty(): void;
  118513. /**
  118514. * Instantiate a new istance of anisotropy configuration.
  118515. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  118516. */
  118517. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  118518. /**
  118519. * Specifies that the submesh is ready to be used.
  118520. * @param defines the list of "defines" to update.
  118521. * @param scene defines the scene the material belongs to.
  118522. * @returns - boolean indicating that the submesh is ready or not.
  118523. */
  118524. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  118525. /**
  118526. * Checks to see if a texture is used in the material.
  118527. * @param defines the list of "defines" to update.
  118528. * @param mesh the mesh we are preparing the defines for.
  118529. * @param scene defines the scene the material belongs to.
  118530. */
  118531. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  118532. /**
  118533. * Binds the material data.
  118534. * @param uniformBuffer defines the Uniform buffer to fill in.
  118535. * @param scene defines the scene the material belongs to.
  118536. * @param isFrozen defines wether the material is frozen or not.
  118537. */
  118538. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  118539. /**
  118540. * Checks to see if a texture is used in the material.
  118541. * @param texture - Base texture to use.
  118542. * @returns - Boolean specifying if a texture is used in the material.
  118543. */
  118544. hasTexture(texture: BaseTexture): boolean;
  118545. /**
  118546. * Returns an array of the actively used textures.
  118547. * @param activeTextures Array of BaseTextures
  118548. */
  118549. getActiveTextures(activeTextures: BaseTexture[]): void;
  118550. /**
  118551. * Returns the animatable textures.
  118552. * @param animatables Array of animatable textures.
  118553. */
  118554. getAnimatables(animatables: IAnimatable[]): void;
  118555. /**
  118556. * Disposes the resources of the material.
  118557. * @param forceDisposeTextures - Forces the disposal of all textures.
  118558. */
  118559. dispose(forceDisposeTextures?: boolean): void;
  118560. /**
  118561. * Get the current class name of the texture useful for serialization or dynamic coding.
  118562. * @returns "PBRAnisotropicConfiguration"
  118563. */
  118564. getClassName(): string;
  118565. /**
  118566. * Add fallbacks to the effect fallbacks list.
  118567. * @param defines defines the Base texture to use.
  118568. * @param fallbacks defines the current fallback list.
  118569. * @param currentRank defines the current fallback rank.
  118570. * @returns the new fallback rank.
  118571. */
  118572. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  118573. /**
  118574. * Add the required uniforms to the current list.
  118575. * @param uniforms defines the current uniform list.
  118576. */
  118577. static AddUniforms(uniforms: string[]): void;
  118578. /**
  118579. * Add the required uniforms to the current buffer.
  118580. * @param uniformBuffer defines the current uniform buffer.
  118581. */
  118582. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  118583. /**
  118584. * Add the required samplers to the current list.
  118585. * @param samplers defines the current sampler list.
  118586. */
  118587. static AddSamplers(samplers: string[]): void;
  118588. /**
  118589. * Makes a duplicate of the current configuration into another one.
  118590. * @param anisotropicConfiguration define the config where to copy the info
  118591. */
  118592. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  118593. /**
  118594. * Serializes this anisotropy configuration.
  118595. * @returns - An object with the serialized config.
  118596. */
  118597. serialize(): any;
  118598. /**
  118599. * Parses a anisotropy Configuration from a serialized object.
  118600. * @param source - Serialized object.
  118601. * @param scene Defines the scene we are parsing for
  118602. * @param rootUrl Defines the rootUrl to load from
  118603. */
  118604. parse(source: any, scene: Scene, rootUrl: string): void;
  118605. }
  118606. }
  118607. declare module BABYLON {
  118608. /**
  118609. * @hidden
  118610. */
  118611. export interface IMaterialBRDFDefines {
  118612. BRDF_V_HEIGHT_CORRELATED: boolean;
  118613. MS_BRDF_ENERGY_CONSERVATION: boolean;
  118614. SPHERICAL_HARMONICS: boolean;
  118615. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  118616. /** @hidden */
  118617. _areMiscDirty: boolean;
  118618. }
  118619. /**
  118620. * Define the code related to the BRDF parameters of the pbr material.
  118621. */
  118622. export class PBRBRDFConfiguration {
  118623. /**
  118624. * Default value used for the energy conservation.
  118625. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  118626. */
  118627. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  118628. /**
  118629. * Default value used for the Smith Visibility Height Correlated mode.
  118630. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  118631. */
  118632. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  118633. /**
  118634. * Default value used for the IBL diffuse part.
  118635. * This can help switching back to the polynomials mode globally which is a tiny bit
  118636. * less GPU intensive at the drawback of a lower quality.
  118637. */
  118638. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  118639. /**
  118640. * Default value used for activating energy conservation for the specular workflow.
  118641. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  118642. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  118643. */
  118644. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  118645. private _useEnergyConservation;
  118646. /**
  118647. * Defines if the material uses energy conservation.
  118648. */
  118649. useEnergyConservation: boolean;
  118650. private _useSmithVisibilityHeightCorrelated;
  118651. /**
  118652. * LEGACY Mode set to false
  118653. * Defines if the material uses height smith correlated visibility term.
  118654. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  118655. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  118656. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  118657. * Not relying on height correlated will also disable energy conservation.
  118658. */
  118659. useSmithVisibilityHeightCorrelated: boolean;
  118660. private _useSphericalHarmonics;
  118661. /**
  118662. * LEGACY Mode set to false
  118663. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  118664. * diffuse part of the IBL.
  118665. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  118666. * to the ground truth.
  118667. */
  118668. useSphericalHarmonics: boolean;
  118669. private _useSpecularGlossinessInputEnergyConservation;
  118670. /**
  118671. * Defines if the material uses energy conservation, when the specular workflow is active.
  118672. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  118673. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  118674. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  118675. */
  118676. useSpecularGlossinessInputEnergyConservation: boolean;
  118677. /** @hidden */
  118678. private _internalMarkAllSubMeshesAsMiscDirty;
  118679. /** @hidden */
  118680. _markAllSubMeshesAsMiscDirty(): void;
  118681. /**
  118682. * Instantiate a new istance of clear coat configuration.
  118683. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  118684. */
  118685. constructor(markAllSubMeshesAsMiscDirty: () => void);
  118686. /**
  118687. * Checks to see if a texture is used in the material.
  118688. * @param defines the list of "defines" to update.
  118689. */
  118690. prepareDefines(defines: IMaterialBRDFDefines): void;
  118691. /**
  118692. * Get the current class name of the texture useful for serialization or dynamic coding.
  118693. * @returns "PBRClearCoatConfiguration"
  118694. */
  118695. getClassName(): string;
  118696. /**
  118697. * Makes a duplicate of the current configuration into another one.
  118698. * @param brdfConfiguration define the config where to copy the info
  118699. */
  118700. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  118701. /**
  118702. * Serializes this BRDF configuration.
  118703. * @returns - An object with the serialized config.
  118704. */
  118705. serialize(): any;
  118706. /**
  118707. * Parses a anisotropy Configuration from a serialized object.
  118708. * @param source - Serialized object.
  118709. * @param scene Defines the scene we are parsing for
  118710. * @param rootUrl Defines the rootUrl to load from
  118711. */
  118712. parse(source: any, scene: Scene, rootUrl: string): void;
  118713. }
  118714. }
  118715. declare module BABYLON {
  118716. /**
  118717. * @hidden
  118718. */
  118719. export interface IMaterialSheenDefines {
  118720. SHEEN: boolean;
  118721. SHEEN_TEXTURE: boolean;
  118722. SHEEN_TEXTUREDIRECTUV: number;
  118723. SHEEN_LINKWITHALBEDO: boolean;
  118724. /** @hidden */
  118725. _areTexturesDirty: boolean;
  118726. }
  118727. /**
  118728. * Define the code related to the Sheen parameters of the pbr material.
  118729. */
  118730. export class PBRSheenConfiguration {
  118731. private _isEnabled;
  118732. /**
  118733. * Defines if the material uses sheen.
  118734. */
  118735. isEnabled: boolean;
  118736. private _linkSheenWithAlbedo;
  118737. /**
  118738. * Defines if the sheen is linked to the sheen color.
  118739. */
  118740. linkSheenWithAlbedo: boolean;
  118741. /**
  118742. * Defines the sheen intensity.
  118743. */
  118744. intensity: number;
  118745. /**
  118746. * Defines the sheen color.
  118747. */
  118748. color: Color3;
  118749. private _texture;
  118750. /**
  118751. * Stores the sheen tint values in a texture.
  118752. * rgb is tint
  118753. * a is a intensity
  118754. */
  118755. texture: Nullable<BaseTexture>;
  118756. /** @hidden */
  118757. private _internalMarkAllSubMeshesAsTexturesDirty;
  118758. /** @hidden */
  118759. _markAllSubMeshesAsTexturesDirty(): void;
  118760. /**
  118761. * Instantiate a new istance of clear coat configuration.
  118762. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  118763. */
  118764. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  118765. /**
  118766. * Specifies that the submesh is ready to be used.
  118767. * @param defines the list of "defines" to update.
  118768. * @param scene defines the scene the material belongs to.
  118769. * @returns - boolean indicating that the submesh is ready or not.
  118770. */
  118771. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  118772. /**
  118773. * Checks to see if a texture is used in the material.
  118774. * @param defines the list of "defines" to update.
  118775. * @param scene defines the scene the material belongs to.
  118776. */
  118777. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  118778. /**
  118779. * Binds the material data.
  118780. * @param uniformBuffer defines the Uniform buffer to fill in.
  118781. * @param scene defines the scene the material belongs to.
  118782. * @param isFrozen defines wether the material is frozen or not.
  118783. */
  118784. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  118785. /**
  118786. * Checks to see if a texture is used in the material.
  118787. * @param texture - Base texture to use.
  118788. * @returns - Boolean specifying if a texture is used in the material.
  118789. */
  118790. hasTexture(texture: BaseTexture): boolean;
  118791. /**
  118792. * Returns an array of the actively used textures.
  118793. * @param activeTextures Array of BaseTextures
  118794. */
  118795. getActiveTextures(activeTextures: BaseTexture[]): void;
  118796. /**
  118797. * Returns the animatable textures.
  118798. * @param animatables Array of animatable textures.
  118799. */
  118800. getAnimatables(animatables: IAnimatable[]): void;
  118801. /**
  118802. * Disposes the resources of the material.
  118803. * @param forceDisposeTextures - Forces the disposal of all textures.
  118804. */
  118805. dispose(forceDisposeTextures?: boolean): void;
  118806. /**
  118807. * Get the current class name of the texture useful for serialization or dynamic coding.
  118808. * @returns "PBRSheenConfiguration"
  118809. */
  118810. getClassName(): string;
  118811. /**
  118812. * Add fallbacks to the effect fallbacks list.
  118813. * @param defines defines the Base texture to use.
  118814. * @param fallbacks defines the current fallback list.
  118815. * @param currentRank defines the current fallback rank.
  118816. * @returns the new fallback rank.
  118817. */
  118818. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  118819. /**
  118820. * Add the required uniforms to the current list.
  118821. * @param uniforms defines the current uniform list.
  118822. */
  118823. static AddUniforms(uniforms: string[]): void;
  118824. /**
  118825. * Add the required uniforms to the current buffer.
  118826. * @param uniformBuffer defines the current uniform buffer.
  118827. */
  118828. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  118829. /**
  118830. * Add the required samplers to the current list.
  118831. * @param samplers defines the current sampler list.
  118832. */
  118833. static AddSamplers(samplers: string[]): void;
  118834. /**
  118835. * Makes a duplicate of the current configuration into another one.
  118836. * @param sheenConfiguration define the config where to copy the info
  118837. */
  118838. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  118839. /**
  118840. * Serializes this BRDF configuration.
  118841. * @returns - An object with the serialized config.
  118842. */
  118843. serialize(): any;
  118844. /**
  118845. * Parses a anisotropy Configuration from a serialized object.
  118846. * @param source - Serialized object.
  118847. * @param scene Defines the scene we are parsing for
  118848. * @param rootUrl Defines the rootUrl to load from
  118849. */
  118850. parse(source: any, scene: Scene, rootUrl: string): void;
  118851. }
  118852. }
  118853. declare module BABYLON {
  118854. /**
  118855. * @hidden
  118856. */
  118857. export interface IMaterialSubSurfaceDefines {
  118858. SUBSURFACE: boolean;
  118859. SS_REFRACTION: boolean;
  118860. SS_TRANSLUCENCY: boolean;
  118861. SS_SCATERRING: boolean;
  118862. SS_THICKNESSANDMASK_TEXTURE: boolean;
  118863. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  118864. SS_REFRACTIONMAP_3D: boolean;
  118865. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  118866. SS_LODINREFRACTIONALPHA: boolean;
  118867. SS_GAMMAREFRACTION: boolean;
  118868. SS_RGBDREFRACTION: boolean;
  118869. SS_LINEARSPECULARREFRACTION: boolean;
  118870. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  118871. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  118872. /** @hidden */
  118873. _areTexturesDirty: boolean;
  118874. }
  118875. /**
  118876. * Define the code related to the sub surface parameters of the pbr material.
  118877. */
  118878. export class PBRSubSurfaceConfiguration {
  118879. private _isRefractionEnabled;
  118880. /**
  118881. * Defines if the refraction is enabled in the material.
  118882. */
  118883. isRefractionEnabled: boolean;
  118884. private _isTranslucencyEnabled;
  118885. /**
  118886. * Defines if the translucency is enabled in the material.
  118887. */
  118888. isTranslucencyEnabled: boolean;
  118889. private _isScatteringEnabled;
  118890. /**
  118891. * Defines the refraction intensity of the material.
  118892. * The refraction when enabled replaces the Diffuse part of the material.
  118893. * The intensity helps transitionning between diffuse and refraction.
  118894. */
  118895. refractionIntensity: number;
  118896. /**
  118897. * Defines the translucency intensity of the material.
  118898. * When translucency has been enabled, this defines how much of the "translucency"
  118899. * is addded to the diffuse part of the material.
  118900. */
  118901. translucencyIntensity: number;
  118902. /**
  118903. * Defines the scattering intensity of the material.
  118904. * When scattering has been enabled, this defines how much of the "scattered light"
  118905. * is addded to the diffuse part of the material.
  118906. */
  118907. scatteringIntensity: number;
  118908. private _thicknessTexture;
  118909. /**
  118910. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  118911. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  118912. * 0 would mean minimumThickness
  118913. * 1 would mean maximumThickness
  118914. * The other channels might be use as a mask to vary the different effects intensity.
  118915. */
  118916. thicknessTexture: Nullable<BaseTexture>;
  118917. private _refractionTexture;
  118918. /**
  118919. * Defines the texture to use for refraction.
  118920. */
  118921. refractionTexture: Nullable<BaseTexture>;
  118922. private _indexOfRefraction;
  118923. /**
  118924. * Defines the index of refraction used in the material.
  118925. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  118926. */
  118927. indexOfRefraction: number;
  118928. private _invertRefractionY;
  118929. /**
  118930. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118931. */
  118932. invertRefractionY: boolean;
  118933. private _linkRefractionWithTransparency;
  118934. /**
  118935. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118936. * Materials half opaque for instance using refraction could benefit from this control.
  118937. */
  118938. linkRefractionWithTransparency: boolean;
  118939. /**
  118940. * Defines the minimum thickness stored in the thickness map.
  118941. * If no thickness map is defined, this value will be used to simulate thickness.
  118942. */
  118943. minimumThickness: number;
  118944. /**
  118945. * Defines the maximum thickness stored in the thickness map.
  118946. */
  118947. maximumThickness: number;
  118948. /**
  118949. * Defines the volume tint of the material.
  118950. * This is used for both translucency and scattering.
  118951. */
  118952. tintColor: Color3;
  118953. /**
  118954. * Defines the distance at which the tint color should be found in the media.
  118955. * This is used for refraction only.
  118956. */
  118957. tintColorAtDistance: number;
  118958. /**
  118959. * Defines how far each channel transmit through the media.
  118960. * It is defined as a color to simplify it selection.
  118961. */
  118962. diffusionDistance: Color3;
  118963. private _useMaskFromThicknessTexture;
  118964. /**
  118965. * Stores the intensity of the different subsurface effects in the thickness texture.
  118966. * * the green channel is the translucency intensity.
  118967. * * the blue channel is the scattering intensity.
  118968. * * the alpha channel is the refraction intensity.
  118969. */
  118970. useMaskFromThicknessTexture: boolean;
  118971. /** @hidden */
  118972. private _internalMarkAllSubMeshesAsTexturesDirty;
  118973. /** @hidden */
  118974. _markAllSubMeshesAsTexturesDirty(): void;
  118975. /**
  118976. * Instantiate a new istance of sub surface configuration.
  118977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  118978. */
  118979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  118980. /**
  118981. * Gets wehter the submesh is ready to be used or not.
  118982. * @param defines the list of "defines" to update.
  118983. * @param scene defines the scene the material belongs to.
  118984. * @returns - boolean indicating that the submesh is ready or not.
  118985. */
  118986. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  118987. /**
  118988. * Checks to see if a texture is used in the material.
  118989. * @param defines the list of "defines" to update.
  118990. * @param scene defines the scene to the material belongs to.
  118991. */
  118992. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  118993. /**
  118994. * Binds the material data.
  118995. * @param uniformBuffer defines the Uniform buffer to fill in.
  118996. * @param scene defines the scene the material belongs to.
  118997. * @param engine defines the engine the material belongs to.
  118998. * @param isFrozen defines wether the material is frozen or not.
  118999. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  119000. */
  119001. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  119002. /**
  119003. * Unbinds the material from the mesh.
  119004. * @param activeEffect defines the effect that should be unbound from.
  119005. * @returns true if unbound, otherwise false
  119006. */
  119007. unbind(activeEffect: Effect): boolean;
  119008. /**
  119009. * Returns the texture used for refraction or null if none is used.
  119010. * @param scene defines the scene the material belongs to.
  119011. * @returns - Refraction texture if present. If no refraction texture and refraction
  119012. * is linked with transparency, returns environment texture. Otherwise, returns null.
  119013. */
  119014. private _getRefractionTexture;
  119015. /**
  119016. * Returns true if alpha blending should be disabled.
  119017. */
  119018. readonly disableAlphaBlending: boolean;
  119019. /**
  119020. * Fills the list of render target textures.
  119021. * @param renderTargets the list of render targets to update
  119022. */
  119023. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  119024. /**
  119025. * Checks to see if a texture is used in the material.
  119026. * @param texture - Base texture to use.
  119027. * @returns - Boolean specifying if a texture is used in the material.
  119028. */
  119029. hasTexture(texture: BaseTexture): boolean;
  119030. /**
  119031. * Gets a boolean indicating that current material needs to register RTT
  119032. * @returns true if this uses a render target otherwise false.
  119033. */
  119034. hasRenderTargetTextures(): boolean;
  119035. /**
  119036. * Returns an array of the actively used textures.
  119037. * @param activeTextures Array of BaseTextures
  119038. */
  119039. getActiveTextures(activeTextures: BaseTexture[]): void;
  119040. /**
  119041. * Returns the animatable textures.
  119042. * @param animatables Array of animatable textures.
  119043. */
  119044. getAnimatables(animatables: IAnimatable[]): void;
  119045. /**
  119046. * Disposes the resources of the material.
  119047. * @param forceDisposeTextures - Forces the disposal of all textures.
  119048. */
  119049. dispose(forceDisposeTextures?: boolean): void;
  119050. /**
  119051. * Get the current class name of the texture useful for serialization or dynamic coding.
  119052. * @returns "PBRSubSurfaceConfiguration"
  119053. */
  119054. getClassName(): string;
  119055. /**
  119056. * Add fallbacks to the effect fallbacks list.
  119057. * @param defines defines the Base texture to use.
  119058. * @param fallbacks defines the current fallback list.
  119059. * @param currentRank defines the current fallback rank.
  119060. * @returns the new fallback rank.
  119061. */
  119062. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119063. /**
  119064. * Add the required uniforms to the current list.
  119065. * @param uniforms defines the current uniform list.
  119066. */
  119067. static AddUniforms(uniforms: string[]): void;
  119068. /**
  119069. * Add the required samplers to the current list.
  119070. * @param samplers defines the current sampler list.
  119071. */
  119072. static AddSamplers(samplers: string[]): void;
  119073. /**
  119074. * Add the required uniforms to the current buffer.
  119075. * @param uniformBuffer defines the current uniform buffer.
  119076. */
  119077. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119078. /**
  119079. * Makes a duplicate of the current configuration into another one.
  119080. * @param configuration define the config where to copy the info
  119081. */
  119082. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  119083. /**
  119084. * Serializes this Sub Surface configuration.
  119085. * @returns - An object with the serialized config.
  119086. */
  119087. serialize(): any;
  119088. /**
  119089. * Parses a anisotropy Configuration from a serialized object.
  119090. * @param source - Serialized object.
  119091. * @param scene Defines the scene we are parsing for
  119092. * @param rootUrl Defines the rootUrl to load from
  119093. */
  119094. parse(source: any, scene: Scene, rootUrl: string): void;
  119095. }
  119096. }
  119097. declare module BABYLON {
  119098. /** @hidden */
  119099. export var pbrFragmentDeclaration: {
  119100. name: string;
  119101. shader: string;
  119102. };
  119103. }
  119104. declare module BABYLON {
  119105. /** @hidden */
  119106. export var pbrUboDeclaration: {
  119107. name: string;
  119108. shader: string;
  119109. };
  119110. }
  119111. declare module BABYLON {
  119112. /** @hidden */
  119113. export var pbrFragmentExtraDeclaration: {
  119114. name: string;
  119115. shader: string;
  119116. };
  119117. }
  119118. declare module BABYLON {
  119119. /** @hidden */
  119120. export var pbrFragmentSamplersDeclaration: {
  119121. name: string;
  119122. shader: string;
  119123. };
  119124. }
  119125. declare module BABYLON {
  119126. /** @hidden */
  119127. export var pbrHelperFunctions: {
  119128. name: string;
  119129. shader: string;
  119130. };
  119131. }
  119132. declare module BABYLON {
  119133. /** @hidden */
  119134. export var harmonicsFunctions: {
  119135. name: string;
  119136. shader: string;
  119137. };
  119138. }
  119139. declare module BABYLON {
  119140. /** @hidden */
  119141. export var pbrDirectLightingSetupFunctions: {
  119142. name: string;
  119143. shader: string;
  119144. };
  119145. }
  119146. declare module BABYLON {
  119147. /** @hidden */
  119148. export var pbrDirectLightingFalloffFunctions: {
  119149. name: string;
  119150. shader: string;
  119151. };
  119152. }
  119153. declare module BABYLON {
  119154. /** @hidden */
  119155. export var pbrBRDFFunctions: {
  119156. name: string;
  119157. shader: string;
  119158. };
  119159. }
  119160. declare module BABYLON {
  119161. /** @hidden */
  119162. export var pbrDirectLightingFunctions: {
  119163. name: string;
  119164. shader: string;
  119165. };
  119166. }
  119167. declare module BABYLON {
  119168. /** @hidden */
  119169. export var pbrIBLFunctions: {
  119170. name: string;
  119171. shader: string;
  119172. };
  119173. }
  119174. declare module BABYLON {
  119175. /** @hidden */
  119176. export var pbrDebug: {
  119177. name: string;
  119178. shader: string;
  119179. };
  119180. }
  119181. declare module BABYLON {
  119182. /** @hidden */
  119183. export var pbrPixelShader: {
  119184. name: string;
  119185. shader: string;
  119186. };
  119187. }
  119188. declare module BABYLON {
  119189. /** @hidden */
  119190. export var pbrVertexDeclaration: {
  119191. name: string;
  119192. shader: string;
  119193. };
  119194. }
  119195. declare module BABYLON {
  119196. /** @hidden */
  119197. export var pbrVertexShader: {
  119198. name: string;
  119199. shader: string;
  119200. };
  119201. }
  119202. declare module BABYLON {
  119203. /**
  119204. * Manages the defines for the PBR Material.
  119205. * @hidden
  119206. */
  119207. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  119208. PBR: boolean;
  119209. MAINUV1: boolean;
  119210. MAINUV2: boolean;
  119211. UV1: boolean;
  119212. UV2: boolean;
  119213. ALBEDO: boolean;
  119214. ALBEDODIRECTUV: number;
  119215. VERTEXCOLOR: boolean;
  119216. AMBIENT: boolean;
  119217. AMBIENTDIRECTUV: number;
  119218. AMBIENTINGRAYSCALE: boolean;
  119219. OPACITY: boolean;
  119220. VERTEXALPHA: boolean;
  119221. OPACITYDIRECTUV: number;
  119222. OPACITYRGB: boolean;
  119223. ALPHATEST: boolean;
  119224. DEPTHPREPASS: boolean;
  119225. ALPHABLEND: boolean;
  119226. ALPHAFROMALBEDO: boolean;
  119227. ALPHATESTVALUE: string;
  119228. SPECULAROVERALPHA: boolean;
  119229. RADIANCEOVERALPHA: boolean;
  119230. ALPHAFRESNEL: boolean;
  119231. LINEARALPHAFRESNEL: boolean;
  119232. PREMULTIPLYALPHA: boolean;
  119233. EMISSIVE: boolean;
  119234. EMISSIVEDIRECTUV: number;
  119235. REFLECTIVITY: boolean;
  119236. REFLECTIVITYDIRECTUV: number;
  119237. SPECULARTERM: boolean;
  119238. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  119239. MICROSURFACEAUTOMATIC: boolean;
  119240. LODBASEDMICROSFURACE: boolean;
  119241. MICROSURFACEMAP: boolean;
  119242. MICROSURFACEMAPDIRECTUV: number;
  119243. METALLICWORKFLOW: boolean;
  119244. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  119245. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  119246. METALLNESSSTOREINMETALMAPBLUE: boolean;
  119247. AOSTOREINMETALMAPRED: boolean;
  119248. METALLICF0FACTORFROMMETALLICMAP: boolean;
  119249. ENVIRONMENTBRDF: boolean;
  119250. ENVIRONMENTBRDF_RGBD: boolean;
  119251. NORMAL: boolean;
  119252. TANGENT: boolean;
  119253. BUMP: boolean;
  119254. BUMPDIRECTUV: number;
  119255. OBJECTSPACE_NORMALMAP: boolean;
  119256. PARALLAX: boolean;
  119257. PARALLAXOCCLUSION: boolean;
  119258. NORMALXYSCALE: boolean;
  119259. LIGHTMAP: boolean;
  119260. LIGHTMAPDIRECTUV: number;
  119261. USELIGHTMAPASSHADOWMAP: boolean;
  119262. GAMMALIGHTMAP: boolean;
  119263. RGBDLIGHTMAP: boolean;
  119264. REFLECTION: boolean;
  119265. REFLECTIONMAP_3D: boolean;
  119266. REFLECTIONMAP_SPHERICAL: boolean;
  119267. REFLECTIONMAP_PLANAR: boolean;
  119268. REFLECTIONMAP_CUBIC: boolean;
  119269. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  119270. REFLECTIONMAP_PROJECTION: boolean;
  119271. REFLECTIONMAP_SKYBOX: boolean;
  119272. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  119273. REFLECTIONMAP_EXPLICIT: boolean;
  119274. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  119275. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  119276. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  119277. INVERTCUBICMAP: boolean;
  119278. USESPHERICALFROMREFLECTIONMAP: boolean;
  119279. USEIRRADIANCEMAP: boolean;
  119280. SPHERICAL_HARMONICS: boolean;
  119281. USESPHERICALINVERTEX: boolean;
  119282. REFLECTIONMAP_OPPOSITEZ: boolean;
  119283. LODINREFLECTIONALPHA: boolean;
  119284. GAMMAREFLECTION: boolean;
  119285. RGBDREFLECTION: boolean;
  119286. LINEARSPECULARREFLECTION: boolean;
  119287. RADIANCEOCCLUSION: boolean;
  119288. HORIZONOCCLUSION: boolean;
  119289. INSTANCES: boolean;
  119290. NUM_BONE_INFLUENCERS: number;
  119291. BonesPerMesh: number;
  119292. BONETEXTURE: boolean;
  119293. NONUNIFORMSCALING: boolean;
  119294. MORPHTARGETS: boolean;
  119295. MORPHTARGETS_NORMAL: boolean;
  119296. MORPHTARGETS_TANGENT: boolean;
  119297. MORPHTARGETS_UV: boolean;
  119298. NUM_MORPH_INFLUENCERS: number;
  119299. IMAGEPROCESSING: boolean;
  119300. VIGNETTE: boolean;
  119301. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119302. VIGNETTEBLENDMODEOPAQUE: boolean;
  119303. TONEMAPPING: boolean;
  119304. TONEMAPPING_ACES: boolean;
  119305. CONTRAST: boolean;
  119306. COLORCURVES: boolean;
  119307. COLORGRADING: boolean;
  119308. COLORGRADING3D: boolean;
  119309. SAMPLER3DGREENDEPTH: boolean;
  119310. SAMPLER3DBGRMAP: boolean;
  119311. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119312. EXPOSURE: boolean;
  119313. MULTIVIEW: boolean;
  119314. USEPHYSICALLIGHTFALLOFF: boolean;
  119315. USEGLTFLIGHTFALLOFF: boolean;
  119316. TWOSIDEDLIGHTING: boolean;
  119317. SHADOWFLOAT: boolean;
  119318. CLIPPLANE: boolean;
  119319. CLIPPLANE2: boolean;
  119320. CLIPPLANE3: boolean;
  119321. CLIPPLANE4: boolean;
  119322. POINTSIZE: boolean;
  119323. FOG: boolean;
  119324. LOGARITHMICDEPTH: boolean;
  119325. FORCENORMALFORWARD: boolean;
  119326. SPECULARAA: boolean;
  119327. CLEARCOAT: boolean;
  119328. CLEARCOAT_DEFAULTIOR: boolean;
  119329. CLEARCOAT_TEXTURE: boolean;
  119330. CLEARCOAT_TEXTUREDIRECTUV: number;
  119331. CLEARCOAT_BUMP: boolean;
  119332. CLEARCOAT_BUMPDIRECTUV: number;
  119333. CLEARCOAT_TINT: boolean;
  119334. CLEARCOAT_TINT_TEXTURE: boolean;
  119335. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119336. ANISOTROPIC: boolean;
  119337. ANISOTROPIC_TEXTURE: boolean;
  119338. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119339. BRDF_V_HEIGHT_CORRELATED: boolean;
  119340. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119341. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119342. SHEEN: boolean;
  119343. SHEEN_TEXTURE: boolean;
  119344. SHEEN_TEXTUREDIRECTUV: number;
  119345. SHEEN_LINKWITHALBEDO: boolean;
  119346. SUBSURFACE: boolean;
  119347. SS_REFRACTION: boolean;
  119348. SS_TRANSLUCENCY: boolean;
  119349. SS_SCATERRING: boolean;
  119350. SS_THICKNESSANDMASK_TEXTURE: boolean;
  119351. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  119352. SS_REFRACTIONMAP_3D: boolean;
  119353. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  119354. SS_LODINREFRACTIONALPHA: boolean;
  119355. SS_GAMMAREFRACTION: boolean;
  119356. SS_RGBDREFRACTION: boolean;
  119357. SS_LINEARSPECULARREFRACTION: boolean;
  119358. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  119359. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  119360. UNLIT: boolean;
  119361. DEBUGMODE: number;
  119362. /**
  119363. * Initializes the PBR Material defines.
  119364. */
  119365. constructor();
  119366. /**
  119367. * Resets the PBR Material defines.
  119368. */
  119369. reset(): void;
  119370. }
  119371. /**
  119372. * The Physically based material base class of BJS.
  119373. *
  119374. * This offers the main features of a standard PBR material.
  119375. * For more information, please refer to the documentation :
  119376. * https://doc.babylonjs.com/how_to/physically_based_rendering
  119377. */
  119378. export abstract class PBRBaseMaterial extends PushMaterial {
  119379. /**
  119380. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  119381. */
  119382. static readonly PBRMATERIAL_OPAQUE: number;
  119383. /**
  119384. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  119385. */
  119386. static readonly PBRMATERIAL_ALPHATEST: number;
  119387. /**
  119388. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  119389. */
  119390. static readonly PBRMATERIAL_ALPHABLEND: number;
  119391. /**
  119392. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  119393. * They are also discarded below the alpha cutoff threshold to improve performances.
  119394. */
  119395. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  119396. /**
  119397. * Defines the default value of how much AO map is occluding the analytical lights
  119398. * (point spot...).
  119399. */
  119400. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  119401. /**
  119402. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  119403. */
  119404. static readonly LIGHTFALLOFF_PHYSICAL: number;
  119405. /**
  119406. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  119407. * to enhance interoperability with other engines.
  119408. */
  119409. static readonly LIGHTFALLOFF_GLTF: number;
  119410. /**
  119411. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  119412. * to enhance interoperability with other materials.
  119413. */
  119414. static readonly LIGHTFALLOFF_STANDARD: number;
  119415. /**
  119416. * Intensity of the direct lights e.g. the four lights available in your scene.
  119417. * This impacts both the direct diffuse and specular highlights.
  119418. */
  119419. protected _directIntensity: number;
  119420. /**
  119421. * Intensity of the emissive part of the material.
  119422. * This helps controlling the emissive effect without modifying the emissive color.
  119423. */
  119424. protected _emissiveIntensity: number;
  119425. /**
  119426. * Intensity of the environment e.g. how much the environment will light the object
  119427. * either through harmonics for rough material or through the refelction for shiny ones.
  119428. */
  119429. protected _environmentIntensity: number;
  119430. /**
  119431. * This is a special control allowing the reduction of the specular highlights coming from the
  119432. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  119433. */
  119434. protected _specularIntensity: number;
  119435. /**
  119436. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  119437. */
  119438. private _lightingInfos;
  119439. /**
  119440. * Debug Control allowing disabling the bump map on this material.
  119441. */
  119442. protected _disableBumpMap: boolean;
  119443. /**
  119444. * AKA Diffuse Texture in standard nomenclature.
  119445. */
  119446. protected _albedoTexture: Nullable<BaseTexture>;
  119447. /**
  119448. * AKA Occlusion Texture in other nomenclature.
  119449. */
  119450. protected _ambientTexture: Nullable<BaseTexture>;
  119451. /**
  119452. * AKA Occlusion Texture Intensity in other nomenclature.
  119453. */
  119454. protected _ambientTextureStrength: number;
  119455. /**
  119456. * Defines how much the AO map is occluding the analytical lights (point spot...).
  119457. * 1 means it completely occludes it
  119458. * 0 mean it has no impact
  119459. */
  119460. protected _ambientTextureImpactOnAnalyticalLights: number;
  119461. /**
  119462. * Stores the alpha values in a texture.
  119463. */
  119464. protected _opacityTexture: Nullable<BaseTexture>;
  119465. /**
  119466. * Stores the reflection values in a texture.
  119467. */
  119468. protected _reflectionTexture: Nullable<BaseTexture>;
  119469. /**
  119470. * Stores the emissive values in a texture.
  119471. */
  119472. protected _emissiveTexture: Nullable<BaseTexture>;
  119473. /**
  119474. * AKA Specular texture in other nomenclature.
  119475. */
  119476. protected _reflectivityTexture: Nullable<BaseTexture>;
  119477. /**
  119478. * Used to switch from specular/glossiness to metallic/roughness workflow.
  119479. */
  119480. protected _metallicTexture: Nullable<BaseTexture>;
  119481. /**
  119482. * Specifies the metallic scalar of the metallic/roughness workflow.
  119483. * Can also be used to scale the metalness values of the metallic texture.
  119484. */
  119485. protected _metallic: Nullable<number>;
  119486. /**
  119487. * Specifies the roughness scalar of the metallic/roughness workflow.
  119488. * Can also be used to scale the roughness values of the metallic texture.
  119489. */
  119490. protected _roughness: Nullable<number>;
  119491. /**
  119492. * Specifies the an F0 factor to help configuring the material F0.
  119493. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  119494. * to 0.5 the previously hard coded value stays the same.
  119495. * Can also be used to scale the F0 values of the metallic texture.
  119496. */
  119497. protected _metallicF0Factor: number;
  119498. /**
  119499. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  119500. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  119501. * your expectation as it multiplies with the texture data.
  119502. */
  119503. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  119504. /**
  119505. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  119506. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  119507. */
  119508. protected _microSurfaceTexture: Nullable<BaseTexture>;
  119509. /**
  119510. * Stores surface normal data used to displace a mesh in a texture.
  119511. */
  119512. protected _bumpTexture: Nullable<BaseTexture>;
  119513. /**
  119514. * Stores the pre-calculated light information of a mesh in a texture.
  119515. */
  119516. protected _lightmapTexture: Nullable<BaseTexture>;
  119517. /**
  119518. * The color of a material in ambient lighting.
  119519. */
  119520. protected _ambientColor: Color3;
  119521. /**
  119522. * AKA Diffuse Color in other nomenclature.
  119523. */
  119524. protected _albedoColor: Color3;
  119525. /**
  119526. * AKA Specular Color in other nomenclature.
  119527. */
  119528. protected _reflectivityColor: Color3;
  119529. /**
  119530. * The color applied when light is reflected from a material.
  119531. */
  119532. protected _reflectionColor: Color3;
  119533. /**
  119534. * The color applied when light is emitted from a material.
  119535. */
  119536. protected _emissiveColor: Color3;
  119537. /**
  119538. * AKA Glossiness in other nomenclature.
  119539. */
  119540. protected _microSurface: number;
  119541. /**
  119542. * Specifies that the material will use the light map as a show map.
  119543. */
  119544. protected _useLightmapAsShadowmap: boolean;
  119545. /**
  119546. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  119547. * makes the reflect vector face the model (under horizon).
  119548. */
  119549. protected _useHorizonOcclusion: boolean;
  119550. /**
  119551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  119552. * too much the area relying on ambient texture to define their ambient occlusion.
  119553. */
  119554. protected _useRadianceOcclusion: boolean;
  119555. /**
  119556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  119557. */
  119558. protected _useAlphaFromAlbedoTexture: boolean;
  119559. /**
  119560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  119561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  119562. */
  119563. protected _useSpecularOverAlpha: boolean;
  119564. /**
  119565. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  119566. */
  119567. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  119568. /**
  119569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  119570. */
  119571. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  119572. /**
  119573. * Specifies if the metallic texture contains the roughness information in its green channel.
  119574. */
  119575. protected _useRoughnessFromMetallicTextureGreen: boolean;
  119576. /**
  119577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  119578. */
  119579. protected _useMetallnessFromMetallicTextureBlue: boolean;
  119580. /**
  119581. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  119582. */
  119583. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  119584. /**
  119585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  119586. */
  119587. protected _useAmbientInGrayScale: boolean;
  119588. /**
  119589. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  119590. * The material will try to infer what glossiness each pixel should be.
  119591. */
  119592. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  119593. /**
  119594. * Defines the falloff type used in this material.
  119595. * It by default is Physical.
  119596. */
  119597. protected _lightFalloff: number;
  119598. /**
  119599. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  119600. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  119601. */
  119602. protected _useRadianceOverAlpha: boolean;
  119603. /**
  119604. * Allows using an object space normal map (instead of tangent space).
  119605. */
  119606. protected _useObjectSpaceNormalMap: boolean;
  119607. /**
  119608. * Allows using the bump map in parallax mode.
  119609. */
  119610. protected _useParallax: boolean;
  119611. /**
  119612. * Allows using the bump map in parallax occlusion mode.
  119613. */
  119614. protected _useParallaxOcclusion: boolean;
  119615. /**
  119616. * Controls the scale bias of the parallax mode.
  119617. */
  119618. protected _parallaxScaleBias: number;
  119619. /**
  119620. * If sets to true, disables all the lights affecting the material.
  119621. */
  119622. protected _disableLighting: boolean;
  119623. /**
  119624. * Number of Simultaneous lights allowed on the material.
  119625. */
  119626. protected _maxSimultaneousLights: number;
  119627. /**
  119628. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119629. */
  119630. protected _invertNormalMapX: boolean;
  119631. /**
  119632. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119633. */
  119634. protected _invertNormalMapY: boolean;
  119635. /**
  119636. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119637. */
  119638. protected _twoSidedLighting: boolean;
  119639. /**
  119640. * Defines the alpha limits in alpha test mode.
  119641. */
  119642. protected _alphaCutOff: number;
  119643. /**
  119644. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  119645. */
  119646. protected _forceAlphaTest: boolean;
  119647. /**
  119648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  119649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  119650. */
  119651. protected _useAlphaFresnel: boolean;
  119652. /**
  119653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  119654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  119655. */
  119656. protected _useLinearAlphaFresnel: boolean;
  119657. /**
  119658. * The transparency mode of the material.
  119659. */
  119660. protected _transparencyMode: Nullable<number>;
  119661. /**
  119662. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  119663. * from cos thetav and roughness:
  119664. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  119665. */
  119666. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  119667. /**
  119668. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  119669. */
  119670. protected _forceIrradianceInFragment: boolean;
  119671. /**
  119672. * Force normal to face away from face.
  119673. */
  119674. protected _forceNormalForward: boolean;
  119675. /**
  119676. * Enables specular anti aliasing in the PBR shader.
  119677. * It will both interacts on the Geometry for analytical and IBL lighting.
  119678. * It also prefilter the roughness map based on the bump values.
  119679. */
  119680. protected _enableSpecularAntiAliasing: boolean;
  119681. /**
  119682. * Default configuration related to image processing available in the PBR Material.
  119683. */
  119684. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119685. /**
  119686. * Keep track of the image processing observer to allow dispose and replace.
  119687. */
  119688. private _imageProcessingObserver;
  119689. /**
  119690. * Attaches a new image processing configuration to the PBR Material.
  119691. * @param configuration
  119692. */
  119693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119694. /**
  119695. * Stores the available render targets.
  119696. */
  119697. private _renderTargets;
  119698. /**
  119699. * Sets the global ambient color for the material used in lighting calculations.
  119700. */
  119701. private _globalAmbientColor;
  119702. /**
  119703. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  119704. */
  119705. private _useLogarithmicDepth;
  119706. /**
  119707. * If set to true, no lighting calculations will be applied.
  119708. */
  119709. private _unlit;
  119710. private _debugMode;
  119711. /**
  119712. * @hidden
  119713. * This is reserved for the inspector.
  119714. * Defines the material debug mode.
  119715. * It helps seeing only some components of the material while troubleshooting.
  119716. */
  119717. debugMode: number;
  119718. /**
  119719. * @hidden
  119720. * This is reserved for the inspector.
  119721. * Specify from where on screen the debug mode should start.
  119722. * The value goes from -1 (full screen) to 1 (not visible)
  119723. * It helps with side by side comparison against the final render
  119724. * This defaults to -1
  119725. */
  119726. private debugLimit;
  119727. /**
  119728. * @hidden
  119729. * This is reserved for the inspector.
  119730. * As the default viewing range might not be enough (if the ambient is really small for instance)
  119731. * You can use the factor to better multiply the final value.
  119732. */
  119733. private debugFactor;
  119734. /**
  119735. * Defines the clear coat layer parameters for the material.
  119736. */
  119737. readonly clearCoat: PBRClearCoatConfiguration;
  119738. /**
  119739. * Defines the anisotropic parameters for the material.
  119740. */
  119741. readonly anisotropy: PBRAnisotropicConfiguration;
  119742. /**
  119743. * Defines the BRDF parameters for the material.
  119744. */
  119745. readonly brdf: PBRBRDFConfiguration;
  119746. /**
  119747. * Defines the Sheen parameters for the material.
  119748. */
  119749. readonly sheen: PBRSheenConfiguration;
  119750. /**
  119751. * Defines the SubSurface parameters for the material.
  119752. */
  119753. readonly subSurface: PBRSubSurfaceConfiguration;
  119754. /**
  119755. * Custom callback helping to override the default shader used in the material.
  119756. */
  119757. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  119758. protected _rebuildInParallel: boolean;
  119759. /**
  119760. * Instantiates a new PBRMaterial instance.
  119761. *
  119762. * @param name The material name
  119763. * @param scene The scene the material will be use in.
  119764. */
  119765. constructor(name: string, scene: Scene);
  119766. /**
  119767. * Gets a boolean indicating that current material needs to register RTT
  119768. */
  119769. readonly hasRenderTargetTextures: boolean;
  119770. /**
  119771. * Gets the name of the material class.
  119772. */
  119773. getClassName(): string;
  119774. /**
  119775. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  119776. */
  119777. /**
  119778. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  119779. */
  119780. useLogarithmicDepth: boolean;
  119781. /**
  119782. * Gets the current transparency mode.
  119783. */
  119784. /**
  119785. * Sets the transparency mode of the material.
  119786. *
  119787. * | Value | Type | Description |
  119788. * | ----- | ----------------------------------- | ----------- |
  119789. * | 0 | OPAQUE | |
  119790. * | 1 | ALPHATEST | |
  119791. * | 2 | ALPHABLEND | |
  119792. * | 3 | ALPHATESTANDBLEND | |
  119793. *
  119794. */
  119795. transparencyMode: Nullable<number>;
  119796. /**
  119797. * Returns true if alpha blending should be disabled.
  119798. */
  119799. private readonly _disableAlphaBlending;
  119800. /**
  119801. * Specifies whether or not this material should be rendered in alpha blend mode.
  119802. */
  119803. needAlphaBlending(): boolean;
  119804. /**
  119805. * Specifies if the mesh will require alpha blending.
  119806. * @param mesh - BJS mesh.
  119807. */
  119808. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  119809. /**
  119810. * Specifies whether or not this material should be rendered in alpha test mode.
  119811. */
  119812. needAlphaTesting(): boolean;
  119813. /**
  119814. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  119815. */
  119816. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  119817. /**
  119818. * Gets the texture used for the alpha test.
  119819. */
  119820. getAlphaTestTexture(): Nullable<BaseTexture>;
  119821. /**
  119822. * Specifies that the submesh is ready to be used.
  119823. * @param mesh - BJS mesh.
  119824. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  119825. * @param useInstances - Specifies that instances should be used.
  119826. * @returns - boolean indicating that the submesh is ready or not.
  119827. */
  119828. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119829. /**
  119830. * Specifies if the material uses metallic roughness workflow.
  119831. * @returns boolean specifiying if the material uses metallic roughness workflow.
  119832. */
  119833. isMetallicWorkflow(): boolean;
  119834. private _prepareEffect;
  119835. private _prepareDefines;
  119836. /**
  119837. * Force shader compilation
  119838. */
  119839. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  119840. /**
  119841. * Initializes the uniform buffer layout for the shader.
  119842. */
  119843. buildUniformLayout(): void;
  119844. /**
  119845. * Unbinds the material from the mesh
  119846. */
  119847. unbind(): void;
  119848. /**
  119849. * Binds the submesh data.
  119850. * @param world - The world matrix.
  119851. * @param mesh - The BJS mesh.
  119852. * @param subMesh - A submesh of the BJS mesh.
  119853. */
  119854. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119855. /**
  119856. * Returns the animatable textures.
  119857. * @returns - Array of animatable textures.
  119858. */
  119859. getAnimatables(): IAnimatable[];
  119860. /**
  119861. * Returns the texture used for reflections.
  119862. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  119863. */
  119864. private _getReflectionTexture;
  119865. /**
  119866. * Returns an array of the actively used textures.
  119867. * @returns - Array of BaseTextures
  119868. */
  119869. getActiveTextures(): BaseTexture[];
  119870. /**
  119871. * Checks to see if a texture is used in the material.
  119872. * @param texture - Base texture to use.
  119873. * @returns - Boolean specifying if a texture is used in the material.
  119874. */
  119875. hasTexture(texture: BaseTexture): boolean;
  119876. /**
  119877. * Disposes the resources of the material.
  119878. * @param forceDisposeEffect - Forces the disposal of effects.
  119879. * @param forceDisposeTextures - Forces the disposal of all textures.
  119880. */
  119881. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  119882. }
  119883. }
  119884. declare module BABYLON {
  119885. /**
  119886. * The Physically based material of BJS.
  119887. *
  119888. * This offers the main features of a standard PBR material.
  119889. * For more information, please refer to the documentation :
  119890. * https://doc.babylonjs.com/how_to/physically_based_rendering
  119891. */
  119892. export class PBRMaterial extends PBRBaseMaterial {
  119893. /**
  119894. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  119895. */
  119896. static readonly PBRMATERIAL_OPAQUE: number;
  119897. /**
  119898. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  119899. */
  119900. static readonly PBRMATERIAL_ALPHATEST: number;
  119901. /**
  119902. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  119903. */
  119904. static readonly PBRMATERIAL_ALPHABLEND: number;
  119905. /**
  119906. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  119907. * They are also discarded below the alpha cutoff threshold to improve performances.
  119908. */
  119909. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  119910. /**
  119911. * Defines the default value of how much AO map is occluding the analytical lights
  119912. * (point spot...).
  119913. */
  119914. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  119915. /**
  119916. * Intensity of the direct lights e.g. the four lights available in your scene.
  119917. * This impacts both the direct diffuse and specular highlights.
  119918. */
  119919. directIntensity: number;
  119920. /**
  119921. * Intensity of the emissive part of the material.
  119922. * This helps controlling the emissive effect without modifying the emissive color.
  119923. */
  119924. emissiveIntensity: number;
  119925. /**
  119926. * Intensity of the environment e.g. how much the environment will light the object
  119927. * either through harmonics for rough material or through the refelction for shiny ones.
  119928. */
  119929. environmentIntensity: number;
  119930. /**
  119931. * This is a special control allowing the reduction of the specular highlights coming from the
  119932. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  119933. */
  119934. specularIntensity: number;
  119935. /**
  119936. * Debug Control allowing disabling the bump map on this material.
  119937. */
  119938. disableBumpMap: boolean;
  119939. /**
  119940. * AKA Diffuse Texture in standard nomenclature.
  119941. */
  119942. albedoTexture: BaseTexture;
  119943. /**
  119944. * AKA Occlusion Texture in other nomenclature.
  119945. */
  119946. ambientTexture: BaseTexture;
  119947. /**
  119948. * AKA Occlusion Texture Intensity in other nomenclature.
  119949. */
  119950. ambientTextureStrength: number;
  119951. /**
  119952. * Defines how much the AO map is occluding the analytical lights (point spot...).
  119953. * 1 means it completely occludes it
  119954. * 0 mean it has no impact
  119955. */
  119956. ambientTextureImpactOnAnalyticalLights: number;
  119957. /**
  119958. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  119959. */
  119960. opacityTexture: BaseTexture;
  119961. /**
  119962. * Stores the reflection values in a texture.
  119963. */
  119964. reflectionTexture: Nullable<BaseTexture>;
  119965. /**
  119966. * Stores the emissive values in a texture.
  119967. */
  119968. emissiveTexture: BaseTexture;
  119969. /**
  119970. * AKA Specular texture in other nomenclature.
  119971. */
  119972. reflectivityTexture: BaseTexture;
  119973. /**
  119974. * Used to switch from specular/glossiness to metallic/roughness workflow.
  119975. */
  119976. metallicTexture: BaseTexture;
  119977. /**
  119978. * Specifies the metallic scalar of the metallic/roughness workflow.
  119979. * Can also be used to scale the metalness values of the metallic texture.
  119980. */
  119981. metallic: Nullable<number>;
  119982. /**
  119983. * Specifies the roughness scalar of the metallic/roughness workflow.
  119984. * Can also be used to scale the roughness values of the metallic texture.
  119985. */
  119986. roughness: Nullable<number>;
  119987. /**
  119988. * Specifies the an F0 factor to help configuring the material F0.
  119989. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  119990. * to 0.5 the previously hard coded value stays the same.
  119991. * Can also be used to scale the F0 values of the metallic texture.
  119992. */
  119993. metallicF0Factor: number;
  119994. /**
  119995. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  119996. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  119997. * your expectation as it multiplies with the texture data.
  119998. */
  119999. useMetallicF0FactorFromMetallicTexture: boolean;
  120000. /**
  120001. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120002. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120003. */
  120004. microSurfaceTexture: BaseTexture;
  120005. /**
  120006. * Stores surface normal data used to displace a mesh in a texture.
  120007. */
  120008. bumpTexture: BaseTexture;
  120009. /**
  120010. * Stores the pre-calculated light information of a mesh in a texture.
  120011. */
  120012. lightmapTexture: BaseTexture;
  120013. /**
  120014. * Stores the refracted light information in a texture.
  120015. */
  120016. refractionTexture: Nullable<BaseTexture>;
  120017. /**
  120018. * The color of a material in ambient lighting.
  120019. */
  120020. ambientColor: Color3;
  120021. /**
  120022. * AKA Diffuse Color in other nomenclature.
  120023. */
  120024. albedoColor: Color3;
  120025. /**
  120026. * AKA Specular Color in other nomenclature.
  120027. */
  120028. reflectivityColor: Color3;
  120029. /**
  120030. * The color reflected from the material.
  120031. */
  120032. reflectionColor: Color3;
  120033. /**
  120034. * The color emitted from the material.
  120035. */
  120036. emissiveColor: Color3;
  120037. /**
  120038. * AKA Glossiness in other nomenclature.
  120039. */
  120040. microSurface: number;
  120041. /**
  120042. * source material index of refraction (IOR)' / 'destination material IOR.
  120043. */
  120044. indexOfRefraction: number;
  120045. /**
  120046. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120047. */
  120048. invertRefractionY: boolean;
  120049. /**
  120050. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120051. * Materials half opaque for instance using refraction could benefit from this control.
  120052. */
  120053. linkRefractionWithTransparency: boolean;
  120054. /**
  120055. * If true, the light map contains occlusion information instead of lighting info.
  120056. */
  120057. useLightmapAsShadowmap: boolean;
  120058. /**
  120059. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120060. */
  120061. useAlphaFromAlbedoTexture: boolean;
  120062. /**
  120063. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120064. */
  120065. forceAlphaTest: boolean;
  120066. /**
  120067. * Defines the alpha limits in alpha test mode.
  120068. */
  120069. alphaCutOff: number;
  120070. /**
  120071. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  120072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120073. */
  120074. useSpecularOverAlpha: boolean;
  120075. /**
  120076. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120077. */
  120078. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120079. /**
  120080. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120081. */
  120082. useRoughnessFromMetallicTextureAlpha: boolean;
  120083. /**
  120084. * Specifies if the metallic texture contains the roughness information in its green channel.
  120085. */
  120086. useRoughnessFromMetallicTextureGreen: boolean;
  120087. /**
  120088. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120089. */
  120090. useMetallnessFromMetallicTextureBlue: boolean;
  120091. /**
  120092. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120093. */
  120094. useAmbientOcclusionFromMetallicTextureRed: boolean;
  120095. /**
  120096. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120097. */
  120098. useAmbientInGrayScale: boolean;
  120099. /**
  120100. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120101. * The material will try to infer what glossiness each pixel should be.
  120102. */
  120103. useAutoMicroSurfaceFromReflectivityMap: boolean;
  120104. /**
  120105. * BJS is using an harcoded light falloff based on a manually sets up range.
  120106. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  120107. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  120108. */
  120109. /**
  120110. * BJS is using an harcoded light falloff based on a manually sets up range.
  120111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  120112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  120113. */
  120114. usePhysicalLightFalloff: boolean;
  120115. /**
  120116. * In order to support the falloff compatibility with gltf, a special mode has been added
  120117. * to reproduce the gltf light falloff.
  120118. */
  120119. /**
  120120. * In order to support the falloff compatibility with gltf, a special mode has been added
  120121. * to reproduce the gltf light falloff.
  120122. */
  120123. useGLTFLightFalloff: boolean;
  120124. /**
  120125. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120126. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120127. */
  120128. useRadianceOverAlpha: boolean;
  120129. /**
  120130. * Allows using an object space normal map (instead of tangent space).
  120131. */
  120132. useObjectSpaceNormalMap: boolean;
  120133. /**
  120134. * Allows using the bump map in parallax mode.
  120135. */
  120136. useParallax: boolean;
  120137. /**
  120138. * Allows using the bump map in parallax occlusion mode.
  120139. */
  120140. useParallaxOcclusion: boolean;
  120141. /**
  120142. * Controls the scale bias of the parallax mode.
  120143. */
  120144. parallaxScaleBias: number;
  120145. /**
  120146. * If sets to true, disables all the lights affecting the material.
  120147. */
  120148. disableLighting: boolean;
  120149. /**
  120150. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120151. */
  120152. forceIrradianceInFragment: boolean;
  120153. /**
  120154. * Number of Simultaneous lights allowed on the material.
  120155. */
  120156. maxSimultaneousLights: number;
  120157. /**
  120158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120159. */
  120160. invertNormalMapX: boolean;
  120161. /**
  120162. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120163. */
  120164. invertNormalMapY: boolean;
  120165. /**
  120166. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120167. */
  120168. twoSidedLighting: boolean;
  120169. /**
  120170. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120171. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120172. */
  120173. useAlphaFresnel: boolean;
  120174. /**
  120175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120176. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120177. */
  120178. useLinearAlphaFresnel: boolean;
  120179. /**
  120180. * Let user defines the brdf lookup texture used for IBL.
  120181. * A default 8bit version is embedded but you could point at :
  120182. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  120183. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  120184. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  120185. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  120186. */
  120187. environmentBRDFTexture: Nullable<BaseTexture>;
  120188. /**
  120189. * Force normal to face away from face.
  120190. */
  120191. forceNormalForward: boolean;
  120192. /**
  120193. * Enables specular anti aliasing in the PBR shader.
  120194. * It will both interacts on the Geometry for analytical and IBL lighting.
  120195. * It also prefilter the roughness map based on the bump values.
  120196. */
  120197. enableSpecularAntiAliasing: boolean;
  120198. /**
  120199. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120200. * makes the reflect vector face the model (under horizon).
  120201. */
  120202. useHorizonOcclusion: boolean;
  120203. /**
  120204. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120205. * too much the area relying on ambient texture to define their ambient occlusion.
  120206. */
  120207. useRadianceOcclusion: boolean;
  120208. /**
  120209. * If set to true, no lighting calculations will be applied.
  120210. */
  120211. unlit: boolean;
  120212. /**
  120213. * Gets the image processing configuration used either in this material.
  120214. */
  120215. /**
  120216. * Sets the Default image processing configuration used either in the this material.
  120217. *
  120218. * If sets to null, the scene one is in use.
  120219. */
  120220. imageProcessingConfiguration: ImageProcessingConfiguration;
  120221. /**
  120222. * Gets wether the color curves effect is enabled.
  120223. */
  120224. /**
  120225. * Sets wether the color curves effect is enabled.
  120226. */
  120227. cameraColorCurvesEnabled: boolean;
  120228. /**
  120229. * Gets wether the color grading effect is enabled.
  120230. */
  120231. /**
  120232. * Gets wether the color grading effect is enabled.
  120233. */
  120234. cameraColorGradingEnabled: boolean;
  120235. /**
  120236. * Gets wether tonemapping is enabled or not.
  120237. */
  120238. /**
  120239. * Sets wether tonemapping is enabled or not
  120240. */
  120241. cameraToneMappingEnabled: boolean;
  120242. /**
  120243. * The camera exposure used on this material.
  120244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120245. * This corresponds to a photographic exposure.
  120246. */
  120247. /**
  120248. * The camera exposure used on this material.
  120249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120250. * This corresponds to a photographic exposure.
  120251. */
  120252. cameraExposure: number;
  120253. /**
  120254. * Gets The camera contrast used on this material.
  120255. */
  120256. /**
  120257. * Sets The camera contrast used on this material.
  120258. */
  120259. cameraContrast: number;
  120260. /**
  120261. * Gets the Color Grading 2D Lookup Texture.
  120262. */
  120263. /**
  120264. * Sets the Color Grading 2D Lookup Texture.
  120265. */
  120266. cameraColorGradingTexture: Nullable<BaseTexture>;
  120267. /**
  120268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120270. * 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;
  120271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120272. */
  120273. /**
  120274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120276. * 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;
  120277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120278. */
  120279. cameraColorCurves: Nullable<ColorCurves>;
  120280. /**
  120281. * Instantiates a new PBRMaterial instance.
  120282. *
  120283. * @param name The material name
  120284. * @param scene The scene the material will be use in.
  120285. */
  120286. constructor(name: string, scene: Scene);
  120287. /**
  120288. * Returns the name of this material class.
  120289. */
  120290. getClassName(): string;
  120291. /**
  120292. * Makes a duplicate of the current material.
  120293. * @param name - name to use for the new material.
  120294. */
  120295. clone(name: string): PBRMaterial;
  120296. /**
  120297. * Serializes this PBR Material.
  120298. * @returns - An object with the serialized material.
  120299. */
  120300. serialize(): any;
  120301. /**
  120302. * Parses a PBR Material from a serialized object.
  120303. * @param source - Serialized object.
  120304. * @param scene - BJS scene instance.
  120305. * @param rootUrl - url for the scene object
  120306. * @returns - PBRMaterial
  120307. */
  120308. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  120309. }
  120310. }
  120311. declare module BABYLON {
  120312. /**
  120313. * Direct draw surface info
  120314. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  120315. */
  120316. export interface DDSInfo {
  120317. /**
  120318. * Width of the texture
  120319. */
  120320. width: number;
  120321. /**
  120322. * Width of the texture
  120323. */
  120324. height: number;
  120325. /**
  120326. * Number of Mipmaps for the texture
  120327. * @see https://en.wikipedia.org/wiki/Mipmap
  120328. */
  120329. mipmapCount: number;
  120330. /**
  120331. * If the textures format is a known fourCC format
  120332. * @see https://www.fourcc.org/
  120333. */
  120334. isFourCC: boolean;
  120335. /**
  120336. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  120337. */
  120338. isRGB: boolean;
  120339. /**
  120340. * If the texture is a lumincance format
  120341. */
  120342. isLuminance: boolean;
  120343. /**
  120344. * If this is a cube texture
  120345. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  120346. */
  120347. isCube: boolean;
  120348. /**
  120349. * If the texture is a compressed format eg. FOURCC_DXT1
  120350. */
  120351. isCompressed: boolean;
  120352. /**
  120353. * The dxgiFormat of the texture
  120354. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  120355. */
  120356. dxgiFormat: number;
  120357. /**
  120358. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  120359. */
  120360. textureType: number;
  120361. /**
  120362. * Sphericle polynomial created for the dds texture
  120363. */
  120364. sphericalPolynomial?: SphericalPolynomial;
  120365. }
  120366. /**
  120367. * Class used to provide DDS decompression tools
  120368. */
  120369. export class DDSTools {
  120370. /**
  120371. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  120372. */
  120373. static StoreLODInAlphaChannel: boolean;
  120374. /**
  120375. * Gets DDS information from an array buffer
  120376. * @param arrayBuffer defines the array buffer to read data from
  120377. * @returns the DDS information
  120378. */
  120379. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  120380. private static _FloatView;
  120381. private static _Int32View;
  120382. private static _ToHalfFloat;
  120383. private static _FromHalfFloat;
  120384. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  120385. private static _GetHalfFloatRGBAArrayBuffer;
  120386. private static _GetFloatRGBAArrayBuffer;
  120387. private static _GetFloatAsUIntRGBAArrayBuffer;
  120388. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  120389. private static _GetRGBAArrayBuffer;
  120390. private static _ExtractLongWordOrder;
  120391. private static _GetRGBArrayBuffer;
  120392. private static _GetLuminanceArrayBuffer;
  120393. /**
  120394. * Uploads DDS Levels to a Babylon Texture
  120395. * @hidden
  120396. */
  120397. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  120398. }
  120399. interface ThinEngine {
  120400. /**
  120401. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  120402. * @param rootUrl defines the url where the file to load is located
  120403. * @param scene defines the current scene
  120404. * @param lodScale defines scale to apply to the mip map selection
  120405. * @param lodOffset defines offset to apply to the mip map selection
  120406. * @param onLoad defines an optional callback raised when the texture is loaded
  120407. * @param onError defines an optional callback raised if there is an issue to load the texture
  120408. * @param format defines the format of the data
  120409. * @param forcedExtension defines the extension to use to pick the right loader
  120410. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  120411. * @returns the cube texture as an InternalTexture
  120412. */
  120413. 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;
  120414. }
  120415. }
  120416. declare module BABYLON {
  120417. /**
  120418. * Implementation of the DDS Texture Loader.
  120419. * @hidden
  120420. */
  120421. export class _DDSTextureLoader implements IInternalTextureLoader {
  120422. /**
  120423. * Defines wether the loader supports cascade loading the different faces.
  120424. */
  120425. readonly supportCascades: boolean;
  120426. /**
  120427. * This returns if the loader support the current file information.
  120428. * @param extension defines the file extension of the file being loaded
  120429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120430. * @param fallback defines the fallback internal texture if any
  120431. * @param isBase64 defines whether the texture is encoded as a base64
  120432. * @param isBuffer defines whether the texture data are stored as a buffer
  120433. * @returns true if the loader can load the specified file
  120434. */
  120435. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120436. /**
  120437. * Transform the url before loading if required.
  120438. * @param rootUrl the url of the texture
  120439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120440. * @returns the transformed texture
  120441. */
  120442. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120443. /**
  120444. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120445. * @param rootUrl the url of the texture
  120446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120447. * @returns the fallback texture
  120448. */
  120449. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120450. /**
  120451. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120452. * @param data contains the texture data
  120453. * @param texture defines the BabylonJS internal texture
  120454. * @param createPolynomials will be true if polynomials have been requested
  120455. * @param onLoad defines the callback to trigger once the texture is ready
  120456. * @param onError defines the callback to trigger in case of error
  120457. */
  120458. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120459. /**
  120460. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120461. * @param data contains the texture data
  120462. * @param texture defines the BabylonJS internal texture
  120463. * @param callback defines the method to call once ready to upload
  120464. */
  120465. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120466. }
  120467. }
  120468. declare module BABYLON {
  120469. /**
  120470. * Implementation of the ENV Texture Loader.
  120471. * @hidden
  120472. */
  120473. export class _ENVTextureLoader implements IInternalTextureLoader {
  120474. /**
  120475. * Defines wether the loader supports cascade loading the different faces.
  120476. */
  120477. readonly supportCascades: boolean;
  120478. /**
  120479. * This returns if the loader support the current file information.
  120480. * @param extension defines the file extension of the file being loaded
  120481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120482. * @param fallback defines the fallback internal texture if any
  120483. * @param isBase64 defines whether the texture is encoded as a base64
  120484. * @param isBuffer defines whether the texture data are stored as a buffer
  120485. * @returns true if the loader can load the specified file
  120486. */
  120487. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120488. /**
  120489. * Transform the url before loading if required.
  120490. * @param rootUrl the url of the texture
  120491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120492. * @returns the transformed texture
  120493. */
  120494. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120495. /**
  120496. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120497. * @param rootUrl the url of the texture
  120498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120499. * @returns the fallback texture
  120500. */
  120501. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120502. /**
  120503. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120504. * @param data contains the texture data
  120505. * @param texture defines the BabylonJS internal texture
  120506. * @param createPolynomials will be true if polynomials have been requested
  120507. * @param onLoad defines the callback to trigger once the texture is ready
  120508. * @param onError defines the callback to trigger in case of error
  120509. */
  120510. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120511. /**
  120512. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120513. * @param data contains the texture data
  120514. * @param texture defines the BabylonJS internal texture
  120515. * @param callback defines the method to call once ready to upload
  120516. */
  120517. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120518. }
  120519. }
  120520. declare module BABYLON {
  120521. /**
  120522. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  120523. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  120524. */
  120525. export class KhronosTextureContainer {
  120526. /** contents of the KTX container file */
  120527. arrayBuffer: any;
  120528. private static HEADER_LEN;
  120529. private static COMPRESSED_2D;
  120530. private static COMPRESSED_3D;
  120531. private static TEX_2D;
  120532. private static TEX_3D;
  120533. /**
  120534. * Gets the openGL type
  120535. */
  120536. glType: number;
  120537. /**
  120538. * Gets the openGL type size
  120539. */
  120540. glTypeSize: number;
  120541. /**
  120542. * Gets the openGL format
  120543. */
  120544. glFormat: number;
  120545. /**
  120546. * Gets the openGL internal format
  120547. */
  120548. glInternalFormat: number;
  120549. /**
  120550. * Gets the base internal format
  120551. */
  120552. glBaseInternalFormat: number;
  120553. /**
  120554. * Gets image width in pixel
  120555. */
  120556. pixelWidth: number;
  120557. /**
  120558. * Gets image height in pixel
  120559. */
  120560. pixelHeight: number;
  120561. /**
  120562. * Gets image depth in pixels
  120563. */
  120564. pixelDepth: number;
  120565. /**
  120566. * Gets the number of array elements
  120567. */
  120568. numberOfArrayElements: number;
  120569. /**
  120570. * Gets the number of faces
  120571. */
  120572. numberOfFaces: number;
  120573. /**
  120574. * Gets the number of mipmap levels
  120575. */
  120576. numberOfMipmapLevels: number;
  120577. /**
  120578. * Gets the bytes of key value data
  120579. */
  120580. bytesOfKeyValueData: number;
  120581. /**
  120582. * Gets the load type
  120583. */
  120584. loadType: number;
  120585. /**
  120586. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  120587. */
  120588. isInvalid: boolean;
  120589. /**
  120590. * Creates a new KhronosTextureContainer
  120591. * @param arrayBuffer contents of the KTX container file
  120592. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  120593. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  120594. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  120595. */
  120596. constructor(
  120597. /** contents of the KTX container file */
  120598. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  120599. /**
  120600. * Uploads KTX content to a Babylon Texture.
  120601. * It is assumed that the texture has already been created & is currently bound
  120602. * @hidden
  120603. */
  120604. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  120605. private _upload2DCompressedLevels;
  120606. }
  120607. }
  120608. declare module BABYLON {
  120609. /**
  120610. * Implementation of the KTX Texture Loader.
  120611. * @hidden
  120612. */
  120613. export class _KTXTextureLoader implements IInternalTextureLoader {
  120614. /**
  120615. * Defines wether the loader supports cascade loading the different faces.
  120616. */
  120617. readonly supportCascades: boolean;
  120618. /**
  120619. * This returns if the loader support the current file information.
  120620. * @param extension defines the file extension of the file being loaded
  120621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120622. * @param fallback defines the fallback internal texture if any
  120623. * @param isBase64 defines whether the texture is encoded as a base64
  120624. * @param isBuffer defines whether the texture data are stored as a buffer
  120625. * @returns true if the loader can load the specified file
  120626. */
  120627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120628. /**
  120629. * Transform the url before loading if required.
  120630. * @param rootUrl the url of the texture
  120631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120632. * @returns the transformed texture
  120633. */
  120634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120635. /**
  120636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120637. * @param rootUrl the url of the texture
  120638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120639. * @returns the fallback texture
  120640. */
  120641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120642. /**
  120643. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120644. * @param data contains the texture data
  120645. * @param texture defines the BabylonJS internal texture
  120646. * @param createPolynomials will be true if polynomials have been requested
  120647. * @param onLoad defines the callback to trigger once the texture is ready
  120648. * @param onError defines the callback to trigger in case of error
  120649. */
  120650. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120651. /**
  120652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120653. * @param data contains the texture data
  120654. * @param texture defines the BabylonJS internal texture
  120655. * @param callback defines the method to call once ready to upload
  120656. */
  120657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  120658. }
  120659. }
  120660. declare module BABYLON {
  120661. /** @hidden */
  120662. export var _forceSceneHelpersToBundle: boolean;
  120663. interface Scene {
  120664. /**
  120665. * Creates a default light for the scene.
  120666. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  120667. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  120668. */
  120669. createDefaultLight(replace?: boolean): void;
  120670. /**
  120671. * Creates a default camera for the scene.
  120672. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  120673. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  120674. * @param replace has default false, when true replaces the active camera in the scene
  120675. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  120676. */
  120677. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  120678. /**
  120679. * Creates a default camera and a default light.
  120680. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  120681. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  120682. * @param replace has the default false, when true replaces the active camera/light in the scene
  120683. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  120684. */
  120685. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  120686. /**
  120687. * Creates a new sky box
  120688. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  120689. * @param environmentTexture defines the texture to use as environment texture
  120690. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  120691. * @param scale defines the overall scale of the skybox
  120692. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  120693. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  120694. * @returns a new mesh holding the sky box
  120695. */
  120696. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  120697. /**
  120698. * Creates a new environment
  120699. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  120700. * @param options defines the options you can use to configure the environment
  120701. * @returns the new EnvironmentHelper
  120702. */
  120703. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  120704. /**
  120705. * Creates a new VREXperienceHelper
  120706. * @see http://doc.babylonjs.com/how_to/webvr_helper
  120707. * @param webVROptions defines the options used to create the new VREXperienceHelper
  120708. * @returns a new VREXperienceHelper
  120709. */
  120710. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  120711. /**
  120712. * Creates a new WebXRDefaultExperience
  120713. * @see http://doc.babylonjs.com/how_to/webxr
  120714. * @param options experience options
  120715. * @returns a promise for a new WebXRDefaultExperience
  120716. */
  120717. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  120718. }
  120719. }
  120720. declare module BABYLON {
  120721. /**
  120722. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  120723. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  120724. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  120725. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  120726. */
  120727. export class VideoDome extends TransformNode {
  120728. /**
  120729. * Define the video source as a Monoscopic panoramic 360 video.
  120730. */
  120731. static readonly MODE_MONOSCOPIC: number;
  120732. /**
  120733. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  120734. */
  120735. static readonly MODE_TOPBOTTOM: number;
  120736. /**
  120737. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  120738. */
  120739. static readonly MODE_SIDEBYSIDE: number;
  120740. private _halfDome;
  120741. private _useDirectMapping;
  120742. /**
  120743. * The video texture being displayed on the sphere
  120744. */
  120745. protected _videoTexture: VideoTexture;
  120746. /**
  120747. * Gets the video texture being displayed on the sphere
  120748. */
  120749. readonly videoTexture: VideoTexture;
  120750. /**
  120751. * The skybox material
  120752. */
  120753. protected _material: BackgroundMaterial;
  120754. /**
  120755. * The surface used for the skybox
  120756. */
  120757. protected _mesh: Mesh;
  120758. /**
  120759. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  120760. */
  120761. private _halfDomeMask;
  120762. /**
  120763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120764. * Also see the options.resolution property.
  120765. */
  120766. fovMultiplier: number;
  120767. private _videoMode;
  120768. /**
  120769. * Gets or set the current video mode for the video. It can be:
  120770. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  120771. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  120772. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  120773. */
  120774. videoMode: number;
  120775. /**
  120776. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  120777. *
  120778. */
  120779. /**
  120780. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  120781. */
  120782. halfDome: boolean;
  120783. /**
  120784. * Oberserver used in Stereoscopic VR Mode.
  120785. */
  120786. private _onBeforeCameraRenderObserver;
  120787. /**
  120788. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  120789. * @param name Element's name, child elements will append suffixes for their own names.
  120790. * @param urlsOrVideo defines the url(s) or the video element to use
  120791. * @param options An object containing optional or exposed sub element properties
  120792. */
  120793. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  120794. resolution?: number;
  120795. clickToPlay?: boolean;
  120796. autoPlay?: boolean;
  120797. loop?: boolean;
  120798. size?: number;
  120799. poster?: string;
  120800. faceForward?: boolean;
  120801. useDirectMapping?: boolean;
  120802. halfDomeMode?: boolean;
  120803. }, scene: Scene);
  120804. private _changeVideoMode;
  120805. /**
  120806. * Releases resources associated with this node.
  120807. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  120808. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  120809. */
  120810. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  120811. }
  120812. }
  120813. declare module BABYLON {
  120814. /**
  120815. * This class can be used to get instrumentation data from a Babylon engine
  120816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  120817. */
  120818. export class EngineInstrumentation implements IDisposable {
  120819. /**
  120820. * Define the instrumented engine.
  120821. */
  120822. engine: Engine;
  120823. private _captureGPUFrameTime;
  120824. private _gpuFrameTimeToken;
  120825. private _gpuFrameTime;
  120826. private _captureShaderCompilationTime;
  120827. private _shaderCompilationTime;
  120828. private _onBeginFrameObserver;
  120829. private _onEndFrameObserver;
  120830. private _onBeforeShaderCompilationObserver;
  120831. private _onAfterShaderCompilationObserver;
  120832. /**
  120833. * Gets the perf counter used for GPU frame time
  120834. */
  120835. readonly gpuFrameTimeCounter: PerfCounter;
  120836. /**
  120837. * Gets the GPU frame time capture status
  120838. */
  120839. /**
  120840. * Enable or disable the GPU frame time capture
  120841. */
  120842. captureGPUFrameTime: boolean;
  120843. /**
  120844. * Gets the perf counter used for shader compilation time
  120845. */
  120846. readonly shaderCompilationTimeCounter: PerfCounter;
  120847. /**
  120848. * Gets the shader compilation time capture status
  120849. */
  120850. /**
  120851. * Enable or disable the shader compilation time capture
  120852. */
  120853. captureShaderCompilationTime: boolean;
  120854. /**
  120855. * Instantiates a new engine instrumentation.
  120856. * This class can be used to get instrumentation data from a Babylon engine
  120857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  120858. * @param engine Defines the engine to instrument
  120859. */
  120860. constructor(
  120861. /**
  120862. * Define the instrumented engine.
  120863. */
  120864. engine: Engine);
  120865. /**
  120866. * Dispose and release associated resources.
  120867. */
  120868. dispose(): void;
  120869. }
  120870. }
  120871. declare module BABYLON {
  120872. /**
  120873. * This class can be used to get instrumentation data from a Babylon engine
  120874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  120875. */
  120876. export class SceneInstrumentation implements IDisposable {
  120877. /**
  120878. * Defines the scene to instrument
  120879. */
  120880. scene: Scene;
  120881. private _captureActiveMeshesEvaluationTime;
  120882. private _activeMeshesEvaluationTime;
  120883. private _captureRenderTargetsRenderTime;
  120884. private _renderTargetsRenderTime;
  120885. private _captureFrameTime;
  120886. private _frameTime;
  120887. private _captureRenderTime;
  120888. private _renderTime;
  120889. private _captureInterFrameTime;
  120890. private _interFrameTime;
  120891. private _captureParticlesRenderTime;
  120892. private _particlesRenderTime;
  120893. private _captureSpritesRenderTime;
  120894. private _spritesRenderTime;
  120895. private _capturePhysicsTime;
  120896. private _physicsTime;
  120897. private _captureAnimationsTime;
  120898. private _animationsTime;
  120899. private _captureCameraRenderTime;
  120900. private _cameraRenderTime;
  120901. private _onBeforeActiveMeshesEvaluationObserver;
  120902. private _onAfterActiveMeshesEvaluationObserver;
  120903. private _onBeforeRenderTargetsRenderObserver;
  120904. private _onAfterRenderTargetsRenderObserver;
  120905. private _onAfterRenderObserver;
  120906. private _onBeforeDrawPhaseObserver;
  120907. private _onAfterDrawPhaseObserver;
  120908. private _onBeforeAnimationsObserver;
  120909. private _onBeforeParticlesRenderingObserver;
  120910. private _onAfterParticlesRenderingObserver;
  120911. private _onBeforeSpritesRenderingObserver;
  120912. private _onAfterSpritesRenderingObserver;
  120913. private _onBeforePhysicsObserver;
  120914. private _onAfterPhysicsObserver;
  120915. private _onAfterAnimationsObserver;
  120916. private _onBeforeCameraRenderObserver;
  120917. private _onAfterCameraRenderObserver;
  120918. /**
  120919. * Gets the perf counter used for active meshes evaluation time
  120920. */
  120921. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  120922. /**
  120923. * Gets the active meshes evaluation time capture status
  120924. */
  120925. /**
  120926. * Enable or disable the active meshes evaluation time capture
  120927. */
  120928. captureActiveMeshesEvaluationTime: boolean;
  120929. /**
  120930. * Gets the perf counter used for render targets render time
  120931. */
  120932. readonly renderTargetsRenderTimeCounter: PerfCounter;
  120933. /**
  120934. * Gets the render targets render time capture status
  120935. */
  120936. /**
  120937. * Enable or disable the render targets render time capture
  120938. */
  120939. captureRenderTargetsRenderTime: boolean;
  120940. /**
  120941. * Gets the perf counter used for particles render time
  120942. */
  120943. readonly particlesRenderTimeCounter: PerfCounter;
  120944. /**
  120945. * Gets the particles render time capture status
  120946. */
  120947. /**
  120948. * Enable or disable the particles render time capture
  120949. */
  120950. captureParticlesRenderTime: boolean;
  120951. /**
  120952. * Gets the perf counter used for sprites render time
  120953. */
  120954. readonly spritesRenderTimeCounter: PerfCounter;
  120955. /**
  120956. * Gets the sprites render time capture status
  120957. */
  120958. /**
  120959. * Enable or disable the sprites render time capture
  120960. */
  120961. captureSpritesRenderTime: boolean;
  120962. /**
  120963. * Gets the perf counter used for physics time
  120964. */
  120965. readonly physicsTimeCounter: PerfCounter;
  120966. /**
  120967. * Gets the physics time capture status
  120968. */
  120969. /**
  120970. * Enable or disable the physics time capture
  120971. */
  120972. capturePhysicsTime: boolean;
  120973. /**
  120974. * Gets the perf counter used for animations time
  120975. */
  120976. readonly animationsTimeCounter: PerfCounter;
  120977. /**
  120978. * Gets the animations time capture status
  120979. */
  120980. /**
  120981. * Enable or disable the animations time capture
  120982. */
  120983. captureAnimationsTime: boolean;
  120984. /**
  120985. * Gets the perf counter used for frame time capture
  120986. */
  120987. readonly frameTimeCounter: PerfCounter;
  120988. /**
  120989. * Gets the frame time capture status
  120990. */
  120991. /**
  120992. * Enable or disable the frame time capture
  120993. */
  120994. captureFrameTime: boolean;
  120995. /**
  120996. * Gets the perf counter used for inter-frames time capture
  120997. */
  120998. readonly interFrameTimeCounter: PerfCounter;
  120999. /**
  121000. * Gets the inter-frames time capture status
  121001. */
  121002. /**
  121003. * Enable or disable the inter-frames time capture
  121004. */
  121005. captureInterFrameTime: boolean;
  121006. /**
  121007. * Gets the perf counter used for render time capture
  121008. */
  121009. readonly renderTimeCounter: PerfCounter;
  121010. /**
  121011. * Gets the render time capture status
  121012. */
  121013. /**
  121014. * Enable or disable the render time capture
  121015. */
  121016. captureRenderTime: boolean;
  121017. /**
  121018. * Gets the perf counter used for camera render time capture
  121019. */
  121020. readonly cameraRenderTimeCounter: PerfCounter;
  121021. /**
  121022. * Gets the camera render time capture status
  121023. */
  121024. /**
  121025. * Enable or disable the camera render time capture
  121026. */
  121027. captureCameraRenderTime: boolean;
  121028. /**
  121029. * Gets the perf counter used for draw calls
  121030. */
  121031. readonly drawCallsCounter: PerfCounter;
  121032. /**
  121033. * Instantiates a new scene instrumentation.
  121034. * This class can be used to get instrumentation data from a Babylon engine
  121035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  121036. * @param scene Defines the scene to instrument
  121037. */
  121038. constructor(
  121039. /**
  121040. * Defines the scene to instrument
  121041. */
  121042. scene: Scene);
  121043. /**
  121044. * Dispose and release associated resources.
  121045. */
  121046. dispose(): void;
  121047. }
  121048. }
  121049. declare module BABYLON {
  121050. /** @hidden */
  121051. export var glowMapGenerationPixelShader: {
  121052. name: string;
  121053. shader: string;
  121054. };
  121055. }
  121056. declare module BABYLON {
  121057. /** @hidden */
  121058. export var glowMapGenerationVertexShader: {
  121059. name: string;
  121060. shader: string;
  121061. };
  121062. }
  121063. declare module BABYLON {
  121064. /**
  121065. * Effect layer options. This helps customizing the behaviour
  121066. * of the effect layer.
  121067. */
  121068. export interface IEffectLayerOptions {
  121069. /**
  121070. * Multiplication factor apply to the canvas size to compute the render target size
  121071. * used to generated the objects (the smaller the faster).
  121072. */
  121073. mainTextureRatio: number;
  121074. /**
  121075. * Enforces a fixed size texture to ensure effect stability across devices.
  121076. */
  121077. mainTextureFixedSize?: number;
  121078. /**
  121079. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  121080. */
  121081. alphaBlendingMode: number;
  121082. /**
  121083. * The camera attached to the layer.
  121084. */
  121085. camera: Nullable<Camera>;
  121086. /**
  121087. * The rendering group to draw the layer in.
  121088. */
  121089. renderingGroupId: number;
  121090. }
  121091. /**
  121092. * The effect layer Helps adding post process effect blended with the main pass.
  121093. *
  121094. * This can be for instance use to generate glow or higlight effects on the scene.
  121095. *
  121096. * The effect layer class can not be used directly and is intented to inherited from to be
  121097. * customized per effects.
  121098. */
  121099. export abstract class EffectLayer {
  121100. private _vertexBuffers;
  121101. private _indexBuffer;
  121102. private _cachedDefines;
  121103. private _effectLayerMapGenerationEffect;
  121104. private _effectLayerOptions;
  121105. private _mergeEffect;
  121106. protected _scene: Scene;
  121107. protected _engine: Engine;
  121108. protected _maxSize: number;
  121109. protected _mainTextureDesiredSize: ISize;
  121110. protected _mainTexture: RenderTargetTexture;
  121111. protected _shouldRender: boolean;
  121112. protected _postProcesses: PostProcess[];
  121113. protected _textures: BaseTexture[];
  121114. protected _emissiveTextureAndColor: {
  121115. texture: Nullable<BaseTexture>;
  121116. color: Color4;
  121117. };
  121118. /**
  121119. * The name of the layer
  121120. */
  121121. name: string;
  121122. /**
  121123. * The clear color of the texture used to generate the glow map.
  121124. */
  121125. neutralColor: Color4;
  121126. /**
  121127. * Specifies wether the highlight layer is enabled or not.
  121128. */
  121129. isEnabled: boolean;
  121130. /**
  121131. * Gets the camera attached to the layer.
  121132. */
  121133. readonly camera: Nullable<Camera>;
  121134. /**
  121135. * Gets the rendering group id the layer should render in.
  121136. */
  121137. renderingGroupId: number;
  121138. /**
  121139. * An event triggered when the effect layer has been disposed.
  121140. */
  121141. onDisposeObservable: Observable<EffectLayer>;
  121142. /**
  121143. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  121144. */
  121145. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  121146. /**
  121147. * An event triggered when the generated texture is being merged in the scene.
  121148. */
  121149. onBeforeComposeObservable: Observable<EffectLayer>;
  121150. /**
  121151. * An event triggered when the mesh is rendered into the effect render target.
  121152. */
  121153. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  121154. /**
  121155. * An event triggered after the mesh has been rendered into the effect render target.
  121156. */
  121157. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  121158. /**
  121159. * An event triggered when the generated texture has been merged in the scene.
  121160. */
  121161. onAfterComposeObservable: Observable<EffectLayer>;
  121162. /**
  121163. * An event triggered when the efffect layer changes its size.
  121164. */
  121165. onSizeChangedObservable: Observable<EffectLayer>;
  121166. /** @hidden */
  121167. static _SceneComponentInitialization: (scene: Scene) => void;
  121168. /**
  121169. * Instantiates a new effect Layer and references it in the scene.
  121170. * @param name The name of the layer
  121171. * @param scene The scene to use the layer in
  121172. */
  121173. constructor(
  121174. /** The Friendly of the effect in the scene */
  121175. name: string, scene: Scene);
  121176. /**
  121177. * Get the effect name of the layer.
  121178. * @return The effect name
  121179. */
  121180. abstract getEffectName(): string;
  121181. /**
  121182. * Checks for the readiness of the element composing the layer.
  121183. * @param subMesh the mesh to check for
  121184. * @param useInstances specify wether or not to use instances to render the mesh
  121185. * @return true if ready otherwise, false
  121186. */
  121187. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121188. /**
  121189. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  121190. * @returns true if the effect requires stencil during the main canvas render pass.
  121191. */
  121192. abstract needStencil(): boolean;
  121193. /**
  121194. * Create the merge effect. This is the shader use to blit the information back
  121195. * to the main canvas at the end of the scene rendering.
  121196. * @returns The effect containing the shader used to merge the effect on the main canvas
  121197. */
  121198. protected abstract _createMergeEffect(): Effect;
  121199. /**
  121200. * Creates the render target textures and post processes used in the effect layer.
  121201. */
  121202. protected abstract _createTextureAndPostProcesses(): void;
  121203. /**
  121204. * Implementation specific of rendering the generating effect on the main canvas.
  121205. * @param effect The effect used to render through
  121206. */
  121207. protected abstract _internalRender(effect: Effect): void;
  121208. /**
  121209. * Sets the required values for both the emissive texture and and the main color.
  121210. */
  121211. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  121212. /**
  121213. * Free any resources and references associated to a mesh.
  121214. * Internal use
  121215. * @param mesh The mesh to free.
  121216. */
  121217. abstract _disposeMesh(mesh: Mesh): void;
  121218. /**
  121219. * Serializes this layer (Glow or Highlight for example)
  121220. * @returns a serialized layer object
  121221. */
  121222. abstract serialize?(): any;
  121223. /**
  121224. * Initializes the effect layer with the required options.
  121225. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  121226. */
  121227. protected _init(options: Partial<IEffectLayerOptions>): void;
  121228. /**
  121229. * Generates the index buffer of the full screen quad blending to the main canvas.
  121230. */
  121231. private _generateIndexBuffer;
  121232. /**
  121233. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  121234. */
  121235. private _generateVertexBuffer;
  121236. /**
  121237. * Sets the main texture desired size which is the closest power of two
  121238. * of the engine canvas size.
  121239. */
  121240. private _setMainTextureSize;
  121241. /**
  121242. * Creates the main texture for the effect layer.
  121243. */
  121244. protected _createMainTexture(): void;
  121245. /**
  121246. * Adds specific effects defines.
  121247. * @param defines The defines to add specifics to.
  121248. */
  121249. protected _addCustomEffectDefines(defines: string[]): void;
  121250. /**
  121251. * Checks for the readiness of the element composing the layer.
  121252. * @param subMesh the mesh to check for
  121253. * @param useInstances specify wether or not to use instances to render the mesh
  121254. * @param emissiveTexture the associated emissive texture used to generate the glow
  121255. * @return true if ready otherwise, false
  121256. */
  121257. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  121258. /**
  121259. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  121260. */
  121261. render(): void;
  121262. /**
  121263. * Determine if a given mesh will be used in the current effect.
  121264. * @param mesh mesh to test
  121265. * @returns true if the mesh will be used
  121266. */
  121267. hasMesh(mesh: AbstractMesh): boolean;
  121268. /**
  121269. * Returns true if the layer contains information to display, otherwise false.
  121270. * @returns true if the glow layer should be rendered
  121271. */
  121272. shouldRender(): boolean;
  121273. /**
  121274. * Returns true if the mesh should render, otherwise false.
  121275. * @param mesh The mesh to render
  121276. * @returns true if it should render otherwise false
  121277. */
  121278. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  121279. /**
  121280. * Returns true if the mesh can be rendered, otherwise false.
  121281. * @param mesh The mesh to render
  121282. * @param material The material used on the mesh
  121283. * @returns true if it can be rendered otherwise false
  121284. */
  121285. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  121286. /**
  121287. * Returns true if the mesh should render, otherwise false.
  121288. * @param mesh The mesh to render
  121289. * @returns true if it should render otherwise false
  121290. */
  121291. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  121292. /**
  121293. * Renders the submesh passed in parameter to the generation map.
  121294. */
  121295. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  121296. /**
  121297. * Defines wether the current material of the mesh should be use to render the effect.
  121298. * @param mesh defines the current mesh to render
  121299. */
  121300. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  121301. /**
  121302. * Rebuild the required buffers.
  121303. * @hidden Internal use only.
  121304. */
  121305. _rebuild(): void;
  121306. /**
  121307. * Dispose only the render target textures and post process.
  121308. */
  121309. private _disposeTextureAndPostProcesses;
  121310. /**
  121311. * Dispose the highlight layer and free resources.
  121312. */
  121313. dispose(): void;
  121314. /**
  121315. * Gets the class name of the effect layer
  121316. * @returns the string with the class name of the effect layer
  121317. */
  121318. getClassName(): string;
  121319. /**
  121320. * Creates an effect layer from parsed effect layer data
  121321. * @param parsedEffectLayer defines effect layer data
  121322. * @param scene defines the current scene
  121323. * @param rootUrl defines the root URL containing the effect layer information
  121324. * @returns a parsed effect Layer
  121325. */
  121326. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  121327. }
  121328. }
  121329. declare module BABYLON {
  121330. interface AbstractScene {
  121331. /**
  121332. * The list of effect layers (highlights/glow) added to the scene
  121333. * @see http://doc.babylonjs.com/how_to/highlight_layer
  121334. * @see http://doc.babylonjs.com/how_to/glow_layer
  121335. */
  121336. effectLayers: Array<EffectLayer>;
  121337. /**
  121338. * Removes the given effect layer from this scene.
  121339. * @param toRemove defines the effect layer to remove
  121340. * @returns the index of the removed effect layer
  121341. */
  121342. removeEffectLayer(toRemove: EffectLayer): number;
  121343. /**
  121344. * Adds the given effect layer to this scene
  121345. * @param newEffectLayer defines the effect layer to add
  121346. */
  121347. addEffectLayer(newEffectLayer: EffectLayer): void;
  121348. }
  121349. /**
  121350. * Defines the layer scene component responsible to manage any effect layers
  121351. * in a given scene.
  121352. */
  121353. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  121354. /**
  121355. * The component name helpfull to identify the component in the list of scene components.
  121356. */
  121357. readonly name: string;
  121358. /**
  121359. * The scene the component belongs to.
  121360. */
  121361. scene: Scene;
  121362. private _engine;
  121363. private _renderEffects;
  121364. private _needStencil;
  121365. private _previousStencilState;
  121366. /**
  121367. * Creates a new instance of the component for the given scene
  121368. * @param scene Defines the scene to register the component in
  121369. */
  121370. constructor(scene: Scene);
  121371. /**
  121372. * Registers the component in a given scene
  121373. */
  121374. register(): void;
  121375. /**
  121376. * Rebuilds the elements related to this component in case of
  121377. * context lost for instance.
  121378. */
  121379. rebuild(): void;
  121380. /**
  121381. * Serializes the component data to the specified json object
  121382. * @param serializationObject The object to serialize to
  121383. */
  121384. serialize(serializationObject: any): void;
  121385. /**
  121386. * Adds all the elements from the container to the scene
  121387. * @param container the container holding the elements
  121388. */
  121389. addFromContainer(container: AbstractScene): void;
  121390. /**
  121391. * Removes all the elements in the container from the scene
  121392. * @param container contains the elements to remove
  121393. * @param dispose if the removed element should be disposed (default: false)
  121394. */
  121395. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121396. /**
  121397. * Disposes the component and the associated ressources.
  121398. */
  121399. dispose(): void;
  121400. private _isReadyForMesh;
  121401. private _renderMainTexture;
  121402. private _setStencil;
  121403. private _setStencilBack;
  121404. private _draw;
  121405. private _drawCamera;
  121406. private _drawRenderingGroup;
  121407. }
  121408. }
  121409. declare module BABYLON {
  121410. /** @hidden */
  121411. export var glowMapMergePixelShader: {
  121412. name: string;
  121413. shader: string;
  121414. };
  121415. }
  121416. declare module BABYLON {
  121417. /** @hidden */
  121418. export var glowMapMergeVertexShader: {
  121419. name: string;
  121420. shader: string;
  121421. };
  121422. }
  121423. declare module BABYLON {
  121424. interface AbstractScene {
  121425. /**
  121426. * Return a the first highlight layer of the scene with a given name.
  121427. * @param name The name of the highlight layer to look for.
  121428. * @return The highlight layer if found otherwise null.
  121429. */
  121430. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  121431. }
  121432. /**
  121433. * Glow layer options. This helps customizing the behaviour
  121434. * of the glow layer.
  121435. */
  121436. export interface IGlowLayerOptions {
  121437. /**
  121438. * Multiplication factor apply to the canvas size to compute the render target size
  121439. * used to generated the glowing objects (the smaller the faster).
  121440. */
  121441. mainTextureRatio: number;
  121442. /**
  121443. * Enforces a fixed size texture to ensure resize independant blur.
  121444. */
  121445. mainTextureFixedSize?: number;
  121446. /**
  121447. * How big is the kernel of the blur texture.
  121448. */
  121449. blurKernelSize: number;
  121450. /**
  121451. * The camera attached to the layer.
  121452. */
  121453. camera: Nullable<Camera>;
  121454. /**
  121455. * Enable MSAA by chosing the number of samples.
  121456. */
  121457. mainTextureSamples?: number;
  121458. /**
  121459. * The rendering group to draw the layer in.
  121460. */
  121461. renderingGroupId: number;
  121462. }
  121463. /**
  121464. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  121465. *
  121466. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  121467. *
  121468. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  121469. */
  121470. export class GlowLayer extends EffectLayer {
  121471. /**
  121472. * Effect Name of the layer.
  121473. */
  121474. static readonly EffectName: string;
  121475. /**
  121476. * The default blur kernel size used for the glow.
  121477. */
  121478. static DefaultBlurKernelSize: number;
  121479. /**
  121480. * The default texture size ratio used for the glow.
  121481. */
  121482. static DefaultTextureRatio: number;
  121483. /**
  121484. * Sets the kernel size of the blur.
  121485. */
  121486. /**
  121487. * Gets the kernel size of the blur.
  121488. */
  121489. blurKernelSize: number;
  121490. /**
  121491. * Sets the glow intensity.
  121492. */
  121493. /**
  121494. * Gets the glow intensity.
  121495. */
  121496. intensity: number;
  121497. private _options;
  121498. private _intensity;
  121499. private _horizontalBlurPostprocess1;
  121500. private _verticalBlurPostprocess1;
  121501. private _horizontalBlurPostprocess2;
  121502. private _verticalBlurPostprocess2;
  121503. private _blurTexture1;
  121504. private _blurTexture2;
  121505. private _postProcesses1;
  121506. private _postProcesses2;
  121507. private _includedOnlyMeshes;
  121508. private _excludedMeshes;
  121509. private _meshesUsingTheirOwnMaterials;
  121510. /**
  121511. * Callback used to let the user override the color selection on a per mesh basis
  121512. */
  121513. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  121514. /**
  121515. * Callback used to let the user override the texture selection on a per mesh basis
  121516. */
  121517. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  121518. /**
  121519. * Instantiates a new glow Layer and references it to the scene.
  121520. * @param name The name of the layer
  121521. * @param scene The scene to use the layer in
  121522. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  121523. */
  121524. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  121525. /**
  121526. * Get the effect name of the layer.
  121527. * @return The effect name
  121528. */
  121529. getEffectName(): string;
  121530. /**
  121531. * Create the merge effect. This is the shader use to blit the information back
  121532. * to the main canvas at the end of the scene rendering.
  121533. */
  121534. protected _createMergeEffect(): Effect;
  121535. /**
  121536. * Creates the render target textures and post processes used in the glow layer.
  121537. */
  121538. protected _createTextureAndPostProcesses(): void;
  121539. /**
  121540. * Checks for the readiness of the element composing the layer.
  121541. * @param subMesh the mesh to check for
  121542. * @param useInstances specify wether or not to use instances to render the mesh
  121543. * @param emissiveTexture the associated emissive texture used to generate the glow
  121544. * @return true if ready otherwise, false
  121545. */
  121546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121547. /**
  121548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  121549. */
  121550. needStencil(): boolean;
  121551. /**
  121552. * Returns true if the mesh can be rendered, otherwise false.
  121553. * @param mesh The mesh to render
  121554. * @param material The material used on the mesh
  121555. * @returns true if it can be rendered otherwise false
  121556. */
  121557. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  121558. /**
  121559. * Implementation specific of rendering the generating effect on the main canvas.
  121560. * @param effect The effect used to render through
  121561. */
  121562. protected _internalRender(effect: Effect): void;
  121563. /**
  121564. * Sets the required values for both the emissive texture and and the main color.
  121565. */
  121566. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  121567. /**
  121568. * Returns true if the mesh should render, otherwise false.
  121569. * @param mesh The mesh to render
  121570. * @returns true if it should render otherwise false
  121571. */
  121572. protected _shouldRenderMesh(mesh: Mesh): boolean;
  121573. /**
  121574. * Adds specific effects defines.
  121575. * @param defines The defines to add specifics to.
  121576. */
  121577. protected _addCustomEffectDefines(defines: string[]): void;
  121578. /**
  121579. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  121580. * @param mesh The mesh to exclude from the glow layer
  121581. */
  121582. addExcludedMesh(mesh: Mesh): void;
  121583. /**
  121584. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  121585. * @param mesh The mesh to remove
  121586. */
  121587. removeExcludedMesh(mesh: Mesh): void;
  121588. /**
  121589. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  121590. * @param mesh The mesh to include in the glow layer
  121591. */
  121592. addIncludedOnlyMesh(mesh: Mesh): void;
  121593. /**
  121594. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  121595. * @param mesh The mesh to remove
  121596. */
  121597. removeIncludedOnlyMesh(mesh: Mesh): void;
  121598. /**
  121599. * Determine if a given mesh will be used in the glow layer
  121600. * @param mesh The mesh to test
  121601. * @returns true if the mesh will be highlighted by the current glow layer
  121602. */
  121603. hasMesh(mesh: AbstractMesh): boolean;
  121604. /**
  121605. * Defines wether the current material of the mesh should be use to render the effect.
  121606. * @param mesh defines the current mesh to render
  121607. */
  121608. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  121609. /**
  121610. * Add a mesh to be rendered through its own material and not with emissive only.
  121611. * @param mesh The mesh for which we need to use its material
  121612. */
  121613. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  121614. /**
  121615. * Remove a mesh from being rendered through its own material and not with emissive only.
  121616. * @param mesh The mesh for which we need to not use its material
  121617. */
  121618. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  121619. /**
  121620. * Free any resources and references associated to a mesh.
  121621. * Internal use
  121622. * @param mesh The mesh to free.
  121623. * @hidden
  121624. */
  121625. _disposeMesh(mesh: Mesh): void;
  121626. /**
  121627. * Gets the class name of the effect layer
  121628. * @returns the string with the class name of the effect layer
  121629. */
  121630. getClassName(): string;
  121631. /**
  121632. * Serializes this glow layer
  121633. * @returns a serialized glow layer object
  121634. */
  121635. serialize(): any;
  121636. /**
  121637. * Creates a Glow Layer from parsed glow layer data
  121638. * @param parsedGlowLayer defines glow layer data
  121639. * @param scene defines the current scene
  121640. * @param rootUrl defines the root URL containing the glow layer information
  121641. * @returns a parsed Glow Layer
  121642. */
  121643. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  121644. }
  121645. }
  121646. declare module BABYLON {
  121647. /** @hidden */
  121648. export var glowBlurPostProcessPixelShader: {
  121649. name: string;
  121650. shader: string;
  121651. };
  121652. }
  121653. declare module BABYLON {
  121654. interface AbstractScene {
  121655. /**
  121656. * Return a the first highlight layer of the scene with a given name.
  121657. * @param name The name of the highlight layer to look for.
  121658. * @return The highlight layer if found otherwise null.
  121659. */
  121660. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  121661. }
  121662. /**
  121663. * Highlight layer options. This helps customizing the behaviour
  121664. * of the highlight layer.
  121665. */
  121666. export interface IHighlightLayerOptions {
  121667. /**
  121668. * Multiplication factor apply to the canvas size to compute the render target size
  121669. * used to generated the glowing objects (the smaller the faster).
  121670. */
  121671. mainTextureRatio: number;
  121672. /**
  121673. * Enforces a fixed size texture to ensure resize independant blur.
  121674. */
  121675. mainTextureFixedSize?: number;
  121676. /**
  121677. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  121678. * of the picture to blur (the smaller the faster).
  121679. */
  121680. blurTextureSizeRatio: number;
  121681. /**
  121682. * How big in texel of the blur texture is the vertical blur.
  121683. */
  121684. blurVerticalSize: number;
  121685. /**
  121686. * How big in texel of the blur texture is the horizontal blur.
  121687. */
  121688. blurHorizontalSize: number;
  121689. /**
  121690. * Alpha blending mode used to apply the blur. Default is combine.
  121691. */
  121692. alphaBlendingMode: number;
  121693. /**
  121694. * The camera attached to the layer.
  121695. */
  121696. camera: Nullable<Camera>;
  121697. /**
  121698. * Should we display highlight as a solid stroke?
  121699. */
  121700. isStroke?: boolean;
  121701. /**
  121702. * The rendering group to draw the layer in.
  121703. */
  121704. renderingGroupId: number;
  121705. }
  121706. /**
  121707. * The highlight layer Helps adding a glow effect around a mesh.
  121708. *
  121709. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  121710. * glowy meshes to your scene.
  121711. *
  121712. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  121713. */
  121714. export class HighlightLayer extends EffectLayer {
  121715. name: string;
  121716. /**
  121717. * Effect Name of the highlight layer.
  121718. */
  121719. static readonly EffectName: string;
  121720. /**
  121721. * The neutral color used during the preparation of the glow effect.
  121722. * This is black by default as the blend operation is a blend operation.
  121723. */
  121724. static NeutralColor: Color4;
  121725. /**
  121726. * Stencil value used for glowing meshes.
  121727. */
  121728. static GlowingMeshStencilReference: number;
  121729. /**
  121730. * Stencil value used for the other meshes in the scene.
  121731. */
  121732. static NormalMeshStencilReference: number;
  121733. /**
  121734. * Specifies whether or not the inner glow is ACTIVE in the layer.
  121735. */
  121736. innerGlow: boolean;
  121737. /**
  121738. * Specifies whether or not the outer glow is ACTIVE in the layer.
  121739. */
  121740. outerGlow: boolean;
  121741. /**
  121742. * Specifies the horizontal size of the blur.
  121743. */
  121744. /**
  121745. * Gets the horizontal size of the blur.
  121746. */
  121747. blurHorizontalSize: number;
  121748. /**
  121749. * Specifies the vertical size of the blur.
  121750. */
  121751. /**
  121752. * Gets the vertical size of the blur.
  121753. */
  121754. blurVerticalSize: number;
  121755. /**
  121756. * An event triggered when the highlight layer is being blurred.
  121757. */
  121758. onBeforeBlurObservable: Observable<HighlightLayer>;
  121759. /**
  121760. * An event triggered when the highlight layer has been blurred.
  121761. */
  121762. onAfterBlurObservable: Observable<HighlightLayer>;
  121763. private _instanceGlowingMeshStencilReference;
  121764. private _options;
  121765. private _downSamplePostprocess;
  121766. private _horizontalBlurPostprocess;
  121767. private _verticalBlurPostprocess;
  121768. private _blurTexture;
  121769. private _meshes;
  121770. private _excludedMeshes;
  121771. /**
  121772. * Instantiates a new highlight Layer and references it to the scene..
  121773. * @param name The name of the layer
  121774. * @param scene The scene to use the layer in
  121775. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  121776. */
  121777. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  121778. /**
  121779. * Get the effect name of the layer.
  121780. * @return The effect name
  121781. */
  121782. getEffectName(): string;
  121783. /**
  121784. * Create the merge effect. This is the shader use to blit the information back
  121785. * to the main canvas at the end of the scene rendering.
  121786. */
  121787. protected _createMergeEffect(): Effect;
  121788. /**
  121789. * Creates the render target textures and post processes used in the highlight layer.
  121790. */
  121791. protected _createTextureAndPostProcesses(): void;
  121792. /**
  121793. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  121794. */
  121795. needStencil(): boolean;
  121796. /**
  121797. * Checks for the readiness of the element composing the layer.
  121798. * @param subMesh the mesh to check for
  121799. * @param useInstances specify wether or not to use instances to render the mesh
  121800. * @param emissiveTexture the associated emissive texture used to generate the glow
  121801. * @return true if ready otherwise, false
  121802. */
  121803. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121804. /**
  121805. * Implementation specific of rendering the generating effect on the main canvas.
  121806. * @param effect The effect used to render through
  121807. */
  121808. protected _internalRender(effect: Effect): void;
  121809. /**
  121810. * Returns true if the layer contains information to display, otherwise false.
  121811. */
  121812. shouldRender(): boolean;
  121813. /**
  121814. * Returns true if the mesh should render, otherwise false.
  121815. * @param mesh The mesh to render
  121816. * @returns true if it should render otherwise false
  121817. */
  121818. protected _shouldRenderMesh(mesh: Mesh): boolean;
  121819. /**
  121820. * Sets the required values for both the emissive texture and and the main color.
  121821. */
  121822. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  121823. /**
  121824. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  121825. * @param mesh The mesh to exclude from the highlight layer
  121826. */
  121827. addExcludedMesh(mesh: Mesh): void;
  121828. /**
  121829. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  121830. * @param mesh The mesh to highlight
  121831. */
  121832. removeExcludedMesh(mesh: Mesh): void;
  121833. /**
  121834. * Determine if a given mesh will be highlighted by the current HighlightLayer
  121835. * @param mesh mesh to test
  121836. * @returns true if the mesh will be highlighted by the current HighlightLayer
  121837. */
  121838. hasMesh(mesh: AbstractMesh): boolean;
  121839. /**
  121840. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  121841. * @param mesh The mesh to highlight
  121842. * @param color The color of the highlight
  121843. * @param glowEmissiveOnly Extract the glow from the emissive texture
  121844. */
  121845. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  121846. /**
  121847. * Remove a mesh from the highlight layer in order to make it stop glowing.
  121848. * @param mesh The mesh to highlight
  121849. */
  121850. removeMesh(mesh: Mesh): void;
  121851. /**
  121852. * Force the stencil to the normal expected value for none glowing parts
  121853. */
  121854. private _defaultStencilReference;
  121855. /**
  121856. * Free any resources and references associated to a mesh.
  121857. * Internal use
  121858. * @param mesh The mesh to free.
  121859. * @hidden
  121860. */
  121861. _disposeMesh(mesh: Mesh): void;
  121862. /**
  121863. * Dispose the highlight layer and free resources.
  121864. */
  121865. dispose(): void;
  121866. /**
  121867. * Gets the class name of the effect layer
  121868. * @returns the string with the class name of the effect layer
  121869. */
  121870. getClassName(): string;
  121871. /**
  121872. * Serializes this Highlight layer
  121873. * @returns a serialized Highlight layer object
  121874. */
  121875. serialize(): any;
  121876. /**
  121877. * Creates a Highlight layer from parsed Highlight layer data
  121878. * @param parsedHightlightLayer defines the Highlight layer data
  121879. * @param scene defines the current scene
  121880. * @param rootUrl defines the root URL containing the Highlight layer information
  121881. * @returns a parsed Highlight layer
  121882. */
  121883. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  121884. }
  121885. }
  121886. declare module BABYLON {
  121887. interface AbstractScene {
  121888. /**
  121889. * The list of layers (background and foreground) of the scene
  121890. */
  121891. layers: Array<Layer>;
  121892. }
  121893. /**
  121894. * Defines the layer scene component responsible to manage any layers
  121895. * in a given scene.
  121896. */
  121897. export class LayerSceneComponent implements ISceneComponent {
  121898. /**
  121899. * The component name helpfull to identify the component in the list of scene components.
  121900. */
  121901. readonly name: string;
  121902. /**
  121903. * The scene the component belongs to.
  121904. */
  121905. scene: Scene;
  121906. private _engine;
  121907. /**
  121908. * Creates a new instance of the component for the given scene
  121909. * @param scene Defines the scene to register the component in
  121910. */
  121911. constructor(scene: Scene);
  121912. /**
  121913. * Registers the component in a given scene
  121914. */
  121915. register(): void;
  121916. /**
  121917. * Rebuilds the elements related to this component in case of
  121918. * context lost for instance.
  121919. */
  121920. rebuild(): void;
  121921. /**
  121922. * Disposes the component and the associated ressources.
  121923. */
  121924. dispose(): void;
  121925. private _draw;
  121926. private _drawCameraPredicate;
  121927. private _drawCameraBackground;
  121928. private _drawCameraForeground;
  121929. private _drawRenderTargetPredicate;
  121930. private _drawRenderTargetBackground;
  121931. private _drawRenderTargetForeground;
  121932. /**
  121933. * Adds all the elements from the container to the scene
  121934. * @param container the container holding the elements
  121935. */
  121936. addFromContainer(container: AbstractScene): void;
  121937. /**
  121938. * Removes all the elements in the container from the scene
  121939. * @param container contains the elements to remove
  121940. * @param dispose if the removed element should be disposed (default: false)
  121941. */
  121942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121943. }
  121944. }
  121945. declare module BABYLON {
  121946. /** @hidden */
  121947. export var layerPixelShader: {
  121948. name: string;
  121949. shader: string;
  121950. };
  121951. }
  121952. declare module BABYLON {
  121953. /** @hidden */
  121954. export var layerVertexShader: {
  121955. name: string;
  121956. shader: string;
  121957. };
  121958. }
  121959. declare module BABYLON {
  121960. /**
  121961. * This represents a full screen 2d layer.
  121962. * This can be useful to display a picture in the background of your scene for instance.
  121963. * @see https://www.babylonjs-playground.com/#08A2BS#1
  121964. */
  121965. export class Layer {
  121966. /**
  121967. * Define the name of the layer.
  121968. */
  121969. name: string;
  121970. /**
  121971. * Define the texture the layer should display.
  121972. */
  121973. texture: Nullable<Texture>;
  121974. /**
  121975. * Is the layer in background or foreground.
  121976. */
  121977. isBackground: boolean;
  121978. /**
  121979. * Define the color of the layer (instead of texture).
  121980. */
  121981. color: Color4;
  121982. /**
  121983. * Define the scale of the layer in order to zoom in out of the texture.
  121984. */
  121985. scale: Vector2;
  121986. /**
  121987. * Define an offset for the layer in order to shift the texture.
  121988. */
  121989. offset: Vector2;
  121990. /**
  121991. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  121992. */
  121993. alphaBlendingMode: number;
  121994. /**
  121995. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  121996. * Alpha test will not mix with the background color in case of transparency.
  121997. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  121998. */
  121999. alphaTest: boolean;
  122000. /**
  122001. * Define a mask to restrict the layer to only some of the scene cameras.
  122002. */
  122003. layerMask: number;
  122004. /**
  122005. * Define the list of render target the layer is visible into.
  122006. */
  122007. renderTargetTextures: RenderTargetTexture[];
  122008. /**
  122009. * Define if the layer is only used in renderTarget or if it also
  122010. * renders in the main frame buffer of the canvas.
  122011. */
  122012. renderOnlyInRenderTargetTextures: boolean;
  122013. private _scene;
  122014. private _vertexBuffers;
  122015. private _indexBuffer;
  122016. private _effect;
  122017. private _previousDefines;
  122018. /**
  122019. * An event triggered when the layer is disposed.
  122020. */
  122021. onDisposeObservable: Observable<Layer>;
  122022. private _onDisposeObserver;
  122023. /**
  122024. * Back compatibility with callback before the onDisposeObservable existed.
  122025. * The set callback will be triggered when the layer has been disposed.
  122026. */
  122027. onDispose: () => void;
  122028. /**
  122029. * An event triggered before rendering the scene
  122030. */
  122031. onBeforeRenderObservable: Observable<Layer>;
  122032. private _onBeforeRenderObserver;
  122033. /**
  122034. * Back compatibility with callback before the onBeforeRenderObservable existed.
  122035. * The set callback will be triggered just before rendering the layer.
  122036. */
  122037. onBeforeRender: () => void;
  122038. /**
  122039. * An event triggered after rendering the scene
  122040. */
  122041. onAfterRenderObservable: Observable<Layer>;
  122042. private _onAfterRenderObserver;
  122043. /**
  122044. * Back compatibility with callback before the onAfterRenderObservable existed.
  122045. * The set callback will be triggered just after rendering the layer.
  122046. */
  122047. onAfterRender: () => void;
  122048. /**
  122049. * Instantiates a new layer.
  122050. * This represents a full screen 2d layer.
  122051. * This can be useful to display a picture in the background of your scene for instance.
  122052. * @see https://www.babylonjs-playground.com/#08A2BS#1
  122053. * @param name Define the name of the layer in the scene
  122054. * @param imgUrl Define the url of the texture to display in the layer
  122055. * @param scene Define the scene the layer belongs to
  122056. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  122057. * @param color Defines a color for the layer
  122058. */
  122059. constructor(
  122060. /**
  122061. * Define the name of the layer.
  122062. */
  122063. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  122064. private _createIndexBuffer;
  122065. /** @hidden */
  122066. _rebuild(): void;
  122067. /**
  122068. * Renders the layer in the scene.
  122069. */
  122070. render(): void;
  122071. /**
  122072. * Disposes and releases the associated ressources.
  122073. */
  122074. dispose(): void;
  122075. }
  122076. }
  122077. declare module BABYLON {
  122078. /** @hidden */
  122079. export var lensFlarePixelShader: {
  122080. name: string;
  122081. shader: string;
  122082. };
  122083. }
  122084. declare module BABYLON {
  122085. /** @hidden */
  122086. export var lensFlareVertexShader: {
  122087. name: string;
  122088. shader: string;
  122089. };
  122090. }
  122091. declare module BABYLON {
  122092. /**
  122093. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  122094. * It is usually composed of several `lensFlare`.
  122095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122096. */
  122097. export class LensFlareSystem {
  122098. /**
  122099. * Define the name of the lens flare system
  122100. */
  122101. name: string;
  122102. /**
  122103. * List of lens flares used in this system.
  122104. */
  122105. lensFlares: LensFlare[];
  122106. /**
  122107. * Define a limit from the border the lens flare can be visible.
  122108. */
  122109. borderLimit: number;
  122110. /**
  122111. * Define a viewport border we do not want to see the lens flare in.
  122112. */
  122113. viewportBorder: number;
  122114. /**
  122115. * Define a predicate which could limit the list of meshes able to occlude the effect.
  122116. */
  122117. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  122118. /**
  122119. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  122120. */
  122121. layerMask: number;
  122122. /**
  122123. * Define the id of the lens flare system in the scene.
  122124. * (equal to name by default)
  122125. */
  122126. id: string;
  122127. private _scene;
  122128. private _emitter;
  122129. private _vertexBuffers;
  122130. private _indexBuffer;
  122131. private _effect;
  122132. private _positionX;
  122133. private _positionY;
  122134. private _isEnabled;
  122135. /** @hidden */
  122136. static _SceneComponentInitialization: (scene: Scene) => void;
  122137. /**
  122138. * Instantiates a lens flare system.
  122139. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  122140. * It is usually composed of several `lensFlare`.
  122141. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122142. * @param name Define the name of the lens flare system in the scene
  122143. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  122144. * @param scene Define the scene the lens flare system belongs to
  122145. */
  122146. constructor(
  122147. /**
  122148. * Define the name of the lens flare system
  122149. */
  122150. name: string, emitter: any, scene: Scene);
  122151. /**
  122152. * Define if the lens flare system is enabled.
  122153. */
  122154. isEnabled: boolean;
  122155. /**
  122156. * Get the scene the effects belongs to.
  122157. * @returns the scene holding the lens flare system
  122158. */
  122159. getScene(): Scene;
  122160. /**
  122161. * Get the emitter of the lens flare system.
  122162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  122163. * @returns the emitter of the lens flare system
  122164. */
  122165. getEmitter(): any;
  122166. /**
  122167. * Set the emitter of the lens flare system.
  122168. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  122169. * @param newEmitter Define the new emitter of the system
  122170. */
  122171. setEmitter(newEmitter: any): void;
  122172. /**
  122173. * Get the lens flare system emitter position.
  122174. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  122175. * @returns the position
  122176. */
  122177. getEmitterPosition(): Vector3;
  122178. /**
  122179. * @hidden
  122180. */
  122181. computeEffectivePosition(globalViewport: Viewport): boolean;
  122182. /** @hidden */
  122183. _isVisible(): boolean;
  122184. /**
  122185. * @hidden
  122186. */
  122187. render(): boolean;
  122188. /**
  122189. * Dispose and release the lens flare with its associated resources.
  122190. */
  122191. dispose(): void;
  122192. /**
  122193. * Parse a lens flare system from a JSON repressentation
  122194. * @param parsedLensFlareSystem Define the JSON to parse
  122195. * @param scene Define the scene the parsed system should be instantiated in
  122196. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  122197. * @returns the parsed system
  122198. */
  122199. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  122200. /**
  122201. * Serialize the current Lens Flare System into a JSON representation.
  122202. * @returns the serialized JSON
  122203. */
  122204. serialize(): any;
  122205. }
  122206. }
  122207. declare module BABYLON {
  122208. /**
  122209. * This represents one of the lens effect in a `lensFlareSystem`.
  122210. * It controls one of the indiviual texture used in the effect.
  122211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122212. */
  122213. export class LensFlare {
  122214. /**
  122215. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  122216. */
  122217. size: number;
  122218. /**
  122219. * 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.
  122220. */
  122221. position: number;
  122222. /**
  122223. * Define the lens color.
  122224. */
  122225. color: Color3;
  122226. /**
  122227. * Define the lens texture.
  122228. */
  122229. texture: Nullable<Texture>;
  122230. /**
  122231. * Define the alpha mode to render this particular lens.
  122232. */
  122233. alphaMode: number;
  122234. private _system;
  122235. /**
  122236. * Creates a new Lens Flare.
  122237. * This represents one of the lens effect in a `lensFlareSystem`.
  122238. * It controls one of the indiviual texture used in the effect.
  122239. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122240. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  122241. * @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.
  122242. * @param color Define the lens color
  122243. * @param imgUrl Define the lens texture url
  122244. * @param system Define the `lensFlareSystem` this flare is part of
  122245. * @returns The newly created Lens Flare
  122246. */
  122247. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  122248. /**
  122249. * Instantiates a new Lens Flare.
  122250. * This represents one of the lens effect in a `lensFlareSystem`.
  122251. * It controls one of the indiviual texture used in the effect.
  122252. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122253. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  122254. * @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.
  122255. * @param color Define the lens color
  122256. * @param imgUrl Define the lens texture url
  122257. * @param system Define the `lensFlareSystem` this flare is part of
  122258. */
  122259. constructor(
  122260. /**
  122261. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  122262. */
  122263. size: number,
  122264. /**
  122265. * 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.
  122266. */
  122267. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  122268. /**
  122269. * Dispose and release the lens flare with its associated resources.
  122270. */
  122271. dispose(): void;
  122272. }
  122273. }
  122274. declare module BABYLON {
  122275. interface AbstractScene {
  122276. /**
  122277. * The list of lens flare system added to the scene
  122278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  122279. */
  122280. lensFlareSystems: Array<LensFlareSystem>;
  122281. /**
  122282. * Removes the given lens flare system from this scene.
  122283. * @param toRemove The lens flare system to remove
  122284. * @returns The index of the removed lens flare system
  122285. */
  122286. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  122287. /**
  122288. * Adds the given lens flare system to this scene
  122289. * @param newLensFlareSystem The lens flare system to add
  122290. */
  122291. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  122292. /**
  122293. * Gets a lens flare system using its name
  122294. * @param name defines the name to look for
  122295. * @returns the lens flare system or null if not found
  122296. */
  122297. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  122298. /**
  122299. * Gets a lens flare system using its id
  122300. * @param id defines the id to look for
  122301. * @returns the lens flare system or null if not found
  122302. */
  122303. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  122304. }
  122305. /**
  122306. * Defines the lens flare scene component responsible to manage any lens flares
  122307. * in a given scene.
  122308. */
  122309. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  122310. /**
  122311. * The component name helpfull to identify the component in the list of scene components.
  122312. */
  122313. readonly name: string;
  122314. /**
  122315. * The scene the component belongs to.
  122316. */
  122317. scene: Scene;
  122318. /**
  122319. * Creates a new instance of the component for the given scene
  122320. * @param scene Defines the scene to register the component in
  122321. */
  122322. constructor(scene: Scene);
  122323. /**
  122324. * Registers the component in a given scene
  122325. */
  122326. register(): void;
  122327. /**
  122328. * Rebuilds the elements related to this component in case of
  122329. * context lost for instance.
  122330. */
  122331. rebuild(): void;
  122332. /**
  122333. * Adds all the elements from the container to the scene
  122334. * @param container the container holding the elements
  122335. */
  122336. addFromContainer(container: AbstractScene): void;
  122337. /**
  122338. * Removes all the elements in the container from the scene
  122339. * @param container contains the elements to remove
  122340. * @param dispose if the removed element should be disposed (default: false)
  122341. */
  122342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122343. /**
  122344. * Serializes the component data to the specified json object
  122345. * @param serializationObject The object to serialize to
  122346. */
  122347. serialize(serializationObject: any): void;
  122348. /**
  122349. * Disposes the component and the associated ressources.
  122350. */
  122351. dispose(): void;
  122352. private _draw;
  122353. }
  122354. }
  122355. declare module BABYLON {
  122356. /**
  122357. * Defines the shadow generator component responsible to manage any shadow generators
  122358. * in a given scene.
  122359. */
  122360. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  122361. /**
  122362. * The component name helpfull to identify the component in the list of scene components.
  122363. */
  122364. readonly name: string;
  122365. /**
  122366. * The scene the component belongs to.
  122367. */
  122368. scene: Scene;
  122369. /**
  122370. * Creates a new instance of the component for the given scene
  122371. * @param scene Defines the scene to register the component in
  122372. */
  122373. constructor(scene: Scene);
  122374. /**
  122375. * Registers the component in a given scene
  122376. */
  122377. register(): void;
  122378. /**
  122379. * Rebuilds the elements related to this component in case of
  122380. * context lost for instance.
  122381. */
  122382. rebuild(): void;
  122383. /**
  122384. * Serializes the component data to the specified json object
  122385. * @param serializationObject The object to serialize to
  122386. */
  122387. serialize(serializationObject: any): void;
  122388. /**
  122389. * Adds all the elements from the container to the scene
  122390. * @param container the container holding the elements
  122391. */
  122392. addFromContainer(container: AbstractScene): void;
  122393. /**
  122394. * Removes all the elements in the container from the scene
  122395. * @param container contains the elements to remove
  122396. * @param dispose if the removed element should be disposed (default: false)
  122397. */
  122398. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122399. /**
  122400. * Rebuilds the elements related to this component in case of
  122401. * context lost for instance.
  122402. */
  122403. dispose(): void;
  122404. private _gatherRenderTargets;
  122405. }
  122406. }
  122407. declare module BABYLON {
  122408. /**
  122409. * A point light is a light defined by an unique point in world space.
  122410. * The light is emitted in every direction from this point.
  122411. * A good example of a point light is a standard light bulb.
  122412. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122413. */
  122414. export class PointLight extends ShadowLight {
  122415. private _shadowAngle;
  122416. /**
  122417. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  122418. * This specifies what angle the shadow will use to be created.
  122419. *
  122420. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  122421. */
  122422. /**
  122423. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  122424. * This specifies what angle the shadow will use to be created.
  122425. *
  122426. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  122427. */
  122428. shadowAngle: number;
  122429. /**
  122430. * Gets the direction if it has been set.
  122431. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  122432. */
  122433. /**
  122434. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  122435. */
  122436. direction: Vector3;
  122437. /**
  122438. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  122439. * A PointLight emits the light in every direction.
  122440. * It can cast shadows.
  122441. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  122442. * ```javascript
  122443. * var pointLight = new PointLight("pl", camera.position, scene);
  122444. * ```
  122445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122446. * @param name The light friendly name
  122447. * @param position The position of the point light in the scene
  122448. * @param scene The scene the lights belongs to
  122449. */
  122450. constructor(name: string, position: Vector3, scene: Scene);
  122451. /**
  122452. * Returns the string "PointLight"
  122453. * @returns the class name
  122454. */
  122455. getClassName(): string;
  122456. /**
  122457. * Returns the integer 0.
  122458. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122459. */
  122460. getTypeID(): number;
  122461. /**
  122462. * Specifies wether or not the shadowmap should be a cube texture.
  122463. * @returns true if the shadowmap needs to be a cube texture.
  122464. */
  122465. needCube(): boolean;
  122466. /**
  122467. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  122468. * @param faceIndex The index of the face we are computed the direction to generate shadow
  122469. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  122470. */
  122471. getShadowDirection(faceIndex?: number): Vector3;
  122472. /**
  122473. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  122474. * - fov = PI / 2
  122475. * - aspect ratio : 1.0
  122476. * - z-near and far equal to the active camera minZ and maxZ.
  122477. * Returns the PointLight.
  122478. */
  122479. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122480. protected _buildUniformLayout(): void;
  122481. /**
  122482. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  122483. * @param effect The effect to update
  122484. * @param lightIndex The index of the light in the effect to update
  122485. * @returns The point light
  122486. */
  122487. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  122488. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122489. /**
  122490. * Prepares the list of defines specific to the light type.
  122491. * @param defines the list of defines
  122492. * @param lightIndex defines the index of the light for the effect
  122493. */
  122494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122495. }
  122496. }
  122497. declare module BABYLON {
  122498. /**
  122499. * Header information of HDR texture files.
  122500. */
  122501. export interface HDRInfo {
  122502. /**
  122503. * The height of the texture in pixels.
  122504. */
  122505. height: number;
  122506. /**
  122507. * The width of the texture in pixels.
  122508. */
  122509. width: number;
  122510. /**
  122511. * The index of the beginning of the data in the binary file.
  122512. */
  122513. dataPosition: number;
  122514. }
  122515. /**
  122516. * This groups tools to convert HDR texture to native colors array.
  122517. */
  122518. export class HDRTools {
  122519. private static Ldexp;
  122520. private static Rgbe2float;
  122521. private static readStringLine;
  122522. /**
  122523. * Reads header information from an RGBE texture stored in a native array.
  122524. * More information on this format are available here:
  122525. * https://en.wikipedia.org/wiki/RGBE_image_format
  122526. *
  122527. * @param uint8array The binary file stored in native array.
  122528. * @return The header information.
  122529. */
  122530. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  122531. /**
  122532. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  122533. * This RGBE texture needs to store the information as a panorama.
  122534. *
  122535. * More information on this format are available here:
  122536. * https://en.wikipedia.org/wiki/RGBE_image_format
  122537. *
  122538. * @param buffer The binary file stored in an array buffer.
  122539. * @param size The expected size of the extracted cubemap.
  122540. * @return The Cube Map information.
  122541. */
  122542. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  122543. /**
  122544. * Returns the pixels data extracted from an RGBE texture.
  122545. * This pixels will be stored left to right up to down in the R G B order in one array.
  122546. *
  122547. * More information on this format are available here:
  122548. * https://en.wikipedia.org/wiki/RGBE_image_format
  122549. *
  122550. * @param uint8array The binary file stored in an array buffer.
  122551. * @param hdrInfo The header information of the file.
  122552. * @return The pixels data in RGB right to left up to down order.
  122553. */
  122554. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  122555. private static RGBE_ReadPixels_RLE;
  122556. }
  122557. }
  122558. declare module BABYLON {
  122559. /**
  122560. * This represents a texture coming from an HDR input.
  122561. *
  122562. * The only supported format is currently panorama picture stored in RGBE format.
  122563. * Example of such files can be found on HDRLib: http://hdrlib.com/
  122564. */
  122565. export class HDRCubeTexture extends BaseTexture {
  122566. private static _facesMapping;
  122567. private _generateHarmonics;
  122568. private _noMipmap;
  122569. private _textureMatrix;
  122570. private _size;
  122571. private _onLoad;
  122572. private _onError;
  122573. /**
  122574. * The texture URL.
  122575. */
  122576. url: string;
  122577. /**
  122578. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  122579. */
  122580. coordinatesMode: number;
  122581. protected _isBlocking: boolean;
  122582. /**
  122583. * Sets wether or not the texture is blocking during loading.
  122584. */
  122585. /**
  122586. * Gets wether or not the texture is blocking during loading.
  122587. */
  122588. isBlocking: boolean;
  122589. protected _rotationY: number;
  122590. /**
  122591. * Sets texture matrix rotation angle around Y axis in radians.
  122592. */
  122593. /**
  122594. * Gets texture matrix rotation angle around Y axis radians.
  122595. */
  122596. rotationY: number;
  122597. /**
  122598. * Gets or sets the center of the bounding box associated with the cube texture
  122599. * It must define where the camera used to render the texture was set
  122600. */
  122601. boundingBoxPosition: Vector3;
  122602. private _boundingBoxSize;
  122603. /**
  122604. * Gets or sets the size of the bounding box associated with the cube texture
  122605. * When defined, the cubemap will switch to local mode
  122606. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  122607. * @example https://www.babylonjs-playground.com/#RNASML
  122608. */
  122609. boundingBoxSize: Vector3;
  122610. /**
  122611. * Instantiates an HDRTexture from the following parameters.
  122612. *
  122613. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  122614. * @param scene The scene the texture will be used in
  122615. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122616. * @param noMipmap Forces to not generate the mipmap if true
  122617. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  122618. * @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)
  122619. * @param reserved Reserved flag for internal use.
  122620. */
  122621. 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>);
  122622. /**
  122623. * Get the current class name of the texture useful for serialization or dynamic coding.
  122624. * @returns "HDRCubeTexture"
  122625. */
  122626. getClassName(): string;
  122627. /**
  122628. * Occurs when the file is raw .hdr file.
  122629. */
  122630. private loadTexture;
  122631. clone(): HDRCubeTexture;
  122632. delayLoad(): void;
  122633. /**
  122634. * Get the texture reflection matrix used to rotate/transform the reflection.
  122635. * @returns the reflection matrix
  122636. */
  122637. getReflectionTextureMatrix(): Matrix;
  122638. /**
  122639. * Set the texture reflection matrix used to rotate/transform the reflection.
  122640. * @param value Define the reflection matrix to set
  122641. */
  122642. setReflectionTextureMatrix(value: Matrix): void;
  122643. /**
  122644. * Parses a JSON representation of an HDR Texture in order to create the texture
  122645. * @param parsedTexture Define the JSON representation
  122646. * @param scene Define the scene the texture should be created in
  122647. * @param rootUrl Define the root url in case we need to load relative dependencies
  122648. * @returns the newly created texture after parsing
  122649. */
  122650. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  122651. serialize(): any;
  122652. }
  122653. }
  122654. declare module BABYLON {
  122655. /**
  122656. * Class used to control physics engine
  122657. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  122658. */
  122659. export class PhysicsEngine implements IPhysicsEngine {
  122660. private _physicsPlugin;
  122661. /**
  122662. * Global value used to control the smallest number supported by the simulation
  122663. */
  122664. static Epsilon: number;
  122665. private _impostors;
  122666. private _joints;
  122667. private _subTimeStep;
  122668. /**
  122669. * Gets the gravity vector used by the simulation
  122670. */
  122671. gravity: Vector3;
  122672. /**
  122673. * Factory used to create the default physics plugin.
  122674. * @returns The default physics plugin
  122675. */
  122676. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  122677. /**
  122678. * Creates a new Physics Engine
  122679. * @param gravity defines the gravity vector used by the simulation
  122680. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  122681. */
  122682. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  122683. /**
  122684. * Sets the gravity vector used by the simulation
  122685. * @param gravity defines the gravity vector to use
  122686. */
  122687. setGravity(gravity: Vector3): void;
  122688. /**
  122689. * Set the time step of the physics engine.
  122690. * Default is 1/60.
  122691. * To slow it down, enter 1/600 for example.
  122692. * To speed it up, 1/30
  122693. * @param newTimeStep defines the new timestep to apply to this world.
  122694. */
  122695. setTimeStep(newTimeStep?: number): void;
  122696. /**
  122697. * Get the time step of the physics engine.
  122698. * @returns the current time step
  122699. */
  122700. getTimeStep(): number;
  122701. /**
  122702. * Set the sub time step of the physics engine.
  122703. * Default is 0 meaning there is no sub steps
  122704. * To increase physics resolution precision, set a small value (like 1 ms)
  122705. * @param subTimeStep defines the new sub timestep used for physics resolution.
  122706. */
  122707. setSubTimeStep(subTimeStep?: number): void;
  122708. /**
  122709. * Get the sub time step of the physics engine.
  122710. * @returns the current sub time step
  122711. */
  122712. getSubTimeStep(): number;
  122713. /**
  122714. * Release all resources
  122715. */
  122716. dispose(): void;
  122717. /**
  122718. * Gets the name of the current physics plugin
  122719. * @returns the name of the plugin
  122720. */
  122721. getPhysicsPluginName(): string;
  122722. /**
  122723. * Adding a new impostor for the impostor tracking.
  122724. * This will be done by the impostor itself.
  122725. * @param impostor the impostor to add
  122726. */
  122727. addImpostor(impostor: PhysicsImpostor): void;
  122728. /**
  122729. * Remove an impostor from the engine.
  122730. * This impostor and its mesh will not longer be updated by the physics engine.
  122731. * @param impostor the impostor to remove
  122732. */
  122733. removeImpostor(impostor: PhysicsImpostor): void;
  122734. /**
  122735. * Add a joint to the physics engine
  122736. * @param mainImpostor defines the main impostor to which the joint is added.
  122737. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  122738. * @param joint defines the joint that will connect both impostors.
  122739. */
  122740. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  122741. /**
  122742. * Removes a joint from the simulation
  122743. * @param mainImpostor defines the impostor used with the joint
  122744. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  122745. * @param joint defines the joint to remove
  122746. */
  122747. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  122748. /**
  122749. * Called by the scene. No need to call it.
  122750. * @param delta defines the timespam between frames
  122751. */
  122752. _step(delta: number): void;
  122753. /**
  122754. * Gets the current plugin used to run the simulation
  122755. * @returns current plugin
  122756. */
  122757. getPhysicsPlugin(): IPhysicsEnginePlugin;
  122758. /**
  122759. * Gets the list of physic impostors
  122760. * @returns an array of PhysicsImpostor
  122761. */
  122762. getImpostors(): Array<PhysicsImpostor>;
  122763. /**
  122764. * Gets the impostor for a physics enabled object
  122765. * @param object defines the object impersonated by the impostor
  122766. * @returns the PhysicsImpostor or null if not found
  122767. */
  122768. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  122769. /**
  122770. * Gets the impostor for a physics body object
  122771. * @param body defines physics body used by the impostor
  122772. * @returns the PhysicsImpostor or null if not found
  122773. */
  122774. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  122775. /**
  122776. * Does a raycast in the physics world
  122777. * @param from when should the ray start?
  122778. * @param to when should the ray end?
  122779. * @returns PhysicsRaycastResult
  122780. */
  122781. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  122782. }
  122783. }
  122784. declare module BABYLON {
  122785. /** @hidden */
  122786. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  122787. private _useDeltaForWorldStep;
  122788. world: any;
  122789. name: string;
  122790. private _physicsMaterials;
  122791. private _fixedTimeStep;
  122792. private _cannonRaycastResult;
  122793. private _raycastResult;
  122794. private _physicsBodysToRemoveAfterStep;
  122795. BJSCANNON: any;
  122796. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  122797. setGravity(gravity: Vector3): void;
  122798. setTimeStep(timeStep: number): void;
  122799. getTimeStep(): number;
  122800. executeStep(delta: number): void;
  122801. private _removeMarkedPhysicsBodiesFromWorld;
  122802. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  122803. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  122804. generatePhysicsBody(impostor: PhysicsImpostor): void;
  122805. private _processChildMeshes;
  122806. removePhysicsBody(impostor: PhysicsImpostor): void;
  122807. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  122808. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  122809. private _addMaterial;
  122810. private _checkWithEpsilon;
  122811. private _createShape;
  122812. private _createHeightmap;
  122813. private _minus90X;
  122814. private _plus90X;
  122815. private _tmpPosition;
  122816. private _tmpDeltaPosition;
  122817. private _tmpUnityRotation;
  122818. private _updatePhysicsBodyTransformation;
  122819. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  122820. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  122821. isSupported(): boolean;
  122822. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122823. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  122827. getBodyMass(impostor: PhysicsImpostor): number;
  122828. getBodyFriction(impostor: PhysicsImpostor): number;
  122829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  122830. getBodyRestitution(impostor: PhysicsImpostor): number;
  122831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  122832. sleepBody(impostor: PhysicsImpostor): void;
  122833. wakeUpBody(impostor: PhysicsImpostor): void;
  122834. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  122835. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  122836. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  122837. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  122838. getRadius(impostor: PhysicsImpostor): number;
  122839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  122840. dispose(): void;
  122841. private _extendNamespace;
  122842. /**
  122843. * Does a raycast in the physics world
  122844. * @param from when should the ray start?
  122845. * @param to when should the ray end?
  122846. * @returns PhysicsRaycastResult
  122847. */
  122848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  122849. }
  122850. }
  122851. declare module BABYLON {
  122852. /** @hidden */
  122853. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  122854. world: any;
  122855. name: string;
  122856. BJSOIMO: any;
  122857. private _raycastResult;
  122858. constructor(iterations?: number, oimoInjection?: any);
  122859. setGravity(gravity: Vector3): void;
  122860. setTimeStep(timeStep: number): void;
  122861. getTimeStep(): number;
  122862. private _tmpImpostorsArray;
  122863. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  122864. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  122865. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  122866. generatePhysicsBody(impostor: PhysicsImpostor): void;
  122867. private _tmpPositionVector;
  122868. removePhysicsBody(impostor: PhysicsImpostor): void;
  122869. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  122870. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  122871. isSupported(): boolean;
  122872. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  122873. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  122874. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122875. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122876. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122878. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  122879. getBodyMass(impostor: PhysicsImpostor): number;
  122880. getBodyFriction(impostor: PhysicsImpostor): number;
  122881. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  122882. getBodyRestitution(impostor: PhysicsImpostor): number;
  122883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  122884. sleepBody(impostor: PhysicsImpostor): void;
  122885. wakeUpBody(impostor: PhysicsImpostor): void;
  122886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  122887. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  122888. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  122889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  122890. getRadius(impostor: PhysicsImpostor): number;
  122891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  122892. dispose(): void;
  122893. /**
  122894. * Does a raycast in the physics world
  122895. * @param from when should the ray start?
  122896. * @param to when should the ray end?
  122897. * @returns PhysicsRaycastResult
  122898. */
  122899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  122900. }
  122901. }
  122902. declare module BABYLON {
  122903. /**
  122904. * Class containing static functions to help procedurally build meshes
  122905. */
  122906. export class RibbonBuilder {
  122907. /**
  122908. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122909. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122910. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  122911. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  122912. * * 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
  122913. * * 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
  122914. * * 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
  122915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122918. * * 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
  122919. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  122920. * * 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
  122921. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  122922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122923. * @param name defines the name of the mesh
  122924. * @param options defines the options used to create the mesh
  122925. * @param scene defines the hosting scene
  122926. * @returns the ribbon mesh
  122927. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  122928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122929. */
  122930. static CreateRibbon(name: string, options: {
  122931. pathArray: Vector3[][];
  122932. closeArray?: boolean;
  122933. closePath?: boolean;
  122934. offset?: number;
  122935. updatable?: boolean;
  122936. sideOrientation?: number;
  122937. frontUVs?: Vector4;
  122938. backUVs?: Vector4;
  122939. instance?: Mesh;
  122940. invertUV?: boolean;
  122941. uvs?: Vector2[];
  122942. colors?: Color4[];
  122943. }, scene?: Nullable<Scene>): Mesh;
  122944. }
  122945. }
  122946. declare module BABYLON {
  122947. /**
  122948. * Class containing static functions to help procedurally build meshes
  122949. */
  122950. export class ShapeBuilder {
  122951. /**
  122952. * 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.
  122953. * * 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.
  122954. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122955. * * 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.
  122956. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  122957. * * 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
  122958. * * 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
  122959. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  122960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  122963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122964. * @param name defines the name of the mesh
  122965. * @param options defines the options used to create the mesh
  122966. * @param scene defines the hosting scene
  122967. * @returns the extruded shape mesh
  122968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122970. */
  122971. static ExtrudeShape(name: string, options: {
  122972. shape: Vector3[];
  122973. path: Vector3[];
  122974. scale?: number;
  122975. rotation?: number;
  122976. cap?: number;
  122977. updatable?: boolean;
  122978. sideOrientation?: number;
  122979. frontUVs?: Vector4;
  122980. backUVs?: Vector4;
  122981. instance?: Mesh;
  122982. invertUV?: boolean;
  122983. }, scene?: Nullable<Scene>): Mesh;
  122984. /**
  122985. * Creates an custom extruded shape mesh.
  122986. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  122987. * * 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.
  122988. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122989. * * 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
  122990. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  122991. * * 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
  122992. * * It must returns a float value that will be the scale value applied to the shape on each path point
  122993. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  122994. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  122995. * * 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
  122996. * * 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
  122997. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  122998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123002. * @param name defines the name of the mesh
  123003. * @param options defines the options used to create the mesh
  123004. * @param scene defines the hosting scene
  123005. * @returns the custom extruded shape mesh
  123006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123009. */
  123010. static ExtrudeShapeCustom(name: string, options: {
  123011. shape: Vector3[];
  123012. path: Vector3[];
  123013. scaleFunction?: any;
  123014. rotationFunction?: any;
  123015. ribbonCloseArray?: boolean;
  123016. ribbonClosePath?: boolean;
  123017. cap?: number;
  123018. updatable?: boolean;
  123019. sideOrientation?: number;
  123020. frontUVs?: Vector4;
  123021. backUVs?: Vector4;
  123022. instance?: Mesh;
  123023. invertUV?: boolean;
  123024. }, scene?: Nullable<Scene>): Mesh;
  123025. private static _ExtrudeShapeGeneric;
  123026. }
  123027. }
  123028. declare module BABYLON {
  123029. /**
  123030. * AmmoJS Physics plugin
  123031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  123032. * @see https://github.com/kripken/ammo.js/
  123033. */
  123034. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  123035. private _useDeltaForWorldStep;
  123036. /**
  123037. * Reference to the Ammo library
  123038. */
  123039. bjsAMMO: any;
  123040. /**
  123041. * Created ammoJS world which physics bodies are added to
  123042. */
  123043. world: any;
  123044. /**
  123045. * Name of the plugin
  123046. */
  123047. name: string;
  123048. private _timeStep;
  123049. private _fixedTimeStep;
  123050. private _maxSteps;
  123051. private _tmpQuaternion;
  123052. private _tmpAmmoTransform;
  123053. private _tmpAmmoQuaternion;
  123054. private _tmpAmmoConcreteContactResultCallback;
  123055. private _collisionConfiguration;
  123056. private _dispatcher;
  123057. private _overlappingPairCache;
  123058. private _solver;
  123059. private _softBodySolver;
  123060. private _tmpAmmoVectorA;
  123061. private _tmpAmmoVectorB;
  123062. private _tmpAmmoVectorC;
  123063. private _tmpAmmoVectorD;
  123064. private _tmpContactCallbackResult;
  123065. private _tmpAmmoVectorRCA;
  123066. private _tmpAmmoVectorRCB;
  123067. private _raycastResult;
  123068. private static readonly DISABLE_COLLISION_FLAG;
  123069. private static readonly KINEMATIC_FLAG;
  123070. private static readonly DISABLE_DEACTIVATION_FLAG;
  123071. /**
  123072. * Initializes the ammoJS plugin
  123073. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  123074. * @param ammoInjection can be used to inject your own ammo reference
  123075. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  123076. */
  123077. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  123078. /**
  123079. * Sets the gravity of the physics world (m/(s^2))
  123080. * @param gravity Gravity to set
  123081. */
  123082. setGravity(gravity: Vector3): void;
  123083. /**
  123084. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  123085. * @param timeStep timestep to use in seconds
  123086. */
  123087. setTimeStep(timeStep: number): void;
  123088. /**
  123089. * 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)
  123090. * @param fixedTimeStep fixedTimeStep to use in seconds
  123091. */
  123092. setFixedTimeStep(fixedTimeStep: number): void;
  123093. /**
  123094. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  123095. * @param maxSteps the maximum number of steps by the physics engine per frame
  123096. */
  123097. setMaxSteps(maxSteps: number): void;
  123098. /**
  123099. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  123100. * @returns the current timestep in seconds
  123101. */
  123102. getTimeStep(): number;
  123103. /**
  123104. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  123105. */
  123106. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  123107. private _isImpostorInContact;
  123108. private _isImpostorPairInContact;
  123109. private _stepSimulation;
  123110. /**
  123111. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  123112. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  123113. * After the step the babylon meshes are set to the position of the physics imposters
  123114. * @param delta amount of time to step forward
  123115. * @param impostors array of imposters to update before/after the step
  123116. */
  123117. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  123118. /**
  123119. * Update babylon mesh to match physics world object
  123120. * @param impostor imposter to match
  123121. */
  123122. private _afterSoftStep;
  123123. /**
  123124. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  123125. * @param impostor imposter to match
  123126. */
  123127. private _ropeStep;
  123128. /**
  123129. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  123130. * @param impostor imposter to match
  123131. */
  123132. private _softbodyOrClothStep;
  123133. private _tmpVector;
  123134. private _tmpMatrix;
  123135. /**
  123136. * Applies an impulse on the imposter
  123137. * @param impostor imposter to apply impulse to
  123138. * @param force amount of force to be applied to the imposter
  123139. * @param contactPoint the location to apply the impulse on the imposter
  123140. */
  123141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123142. /**
  123143. * Applies a force on the imposter
  123144. * @param impostor imposter to apply force
  123145. * @param force amount of force to be applied to the imposter
  123146. * @param contactPoint the location to apply the force on the imposter
  123147. */
  123148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123149. /**
  123150. * Creates a physics body using the plugin
  123151. * @param impostor the imposter to create the physics body on
  123152. */
  123153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123154. /**
  123155. * Removes the physics body from the imposter and disposes of the body's memory
  123156. * @param impostor imposter to remove the physics body from
  123157. */
  123158. removePhysicsBody(impostor: PhysicsImpostor): void;
  123159. /**
  123160. * Generates a joint
  123161. * @param impostorJoint the imposter joint to create the joint with
  123162. */
  123163. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123164. /**
  123165. * Removes a joint
  123166. * @param impostorJoint the imposter joint to remove the joint from
  123167. */
  123168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123169. private _addMeshVerts;
  123170. /**
  123171. * Initialise the soft body vertices to match its object's (mesh) vertices
  123172. * Softbody vertices (nodes) are in world space and to match this
  123173. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  123174. * @param impostor to create the softbody for
  123175. */
  123176. private _softVertexData;
  123177. /**
  123178. * Create an impostor's soft body
  123179. * @param impostor to create the softbody for
  123180. */
  123181. private _createSoftbody;
  123182. /**
  123183. * Create cloth for an impostor
  123184. * @param impostor to create the softbody for
  123185. */
  123186. private _createCloth;
  123187. /**
  123188. * Create rope for an impostor
  123189. * @param impostor to create the softbody for
  123190. */
  123191. private _createRope;
  123192. /**
  123193. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  123194. * @param impostor to create the custom physics shape for
  123195. */
  123196. private _createCustom;
  123197. private _addHullVerts;
  123198. private _createShape;
  123199. /**
  123200. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  123201. * @param impostor imposter containing the physics body and babylon object
  123202. */
  123203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123204. /**
  123205. * Sets the babylon object's position/rotation from the physics body's position/rotation
  123206. * @param impostor imposter containing the physics body and babylon object
  123207. * @param newPosition new position
  123208. * @param newRotation new rotation
  123209. */
  123210. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123211. /**
  123212. * If this plugin is supported
  123213. * @returns true if its supported
  123214. */
  123215. isSupported(): boolean;
  123216. /**
  123217. * Sets the linear velocity of the physics body
  123218. * @param impostor imposter to set the velocity on
  123219. * @param velocity velocity to set
  123220. */
  123221. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123222. /**
  123223. * Sets the angular velocity of the physics body
  123224. * @param impostor imposter to set the velocity on
  123225. * @param velocity velocity to set
  123226. */
  123227. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123228. /**
  123229. * gets the linear velocity
  123230. * @param impostor imposter to get linear velocity from
  123231. * @returns linear velocity
  123232. */
  123233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123234. /**
  123235. * gets the angular velocity
  123236. * @param impostor imposter to get angular velocity from
  123237. * @returns angular velocity
  123238. */
  123239. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123240. /**
  123241. * Sets the mass of physics body
  123242. * @param impostor imposter to set the mass on
  123243. * @param mass mass to set
  123244. */
  123245. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123246. /**
  123247. * Gets the mass of the physics body
  123248. * @param impostor imposter to get the mass from
  123249. * @returns mass
  123250. */
  123251. getBodyMass(impostor: PhysicsImpostor): number;
  123252. /**
  123253. * Gets friction of the impostor
  123254. * @param impostor impostor to get friction from
  123255. * @returns friction value
  123256. */
  123257. getBodyFriction(impostor: PhysicsImpostor): number;
  123258. /**
  123259. * Sets friction of the impostor
  123260. * @param impostor impostor to set friction on
  123261. * @param friction friction value
  123262. */
  123263. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123264. /**
  123265. * Gets restitution of the impostor
  123266. * @param impostor impostor to get restitution from
  123267. * @returns restitution value
  123268. */
  123269. getBodyRestitution(impostor: PhysicsImpostor): number;
  123270. /**
  123271. * Sets resitution of the impostor
  123272. * @param impostor impostor to set resitution on
  123273. * @param restitution resitution value
  123274. */
  123275. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123276. /**
  123277. * Gets pressure inside the impostor
  123278. * @param impostor impostor to get pressure from
  123279. * @returns pressure value
  123280. */
  123281. getBodyPressure(impostor: PhysicsImpostor): number;
  123282. /**
  123283. * Sets pressure inside a soft body impostor
  123284. * Cloth and rope must remain 0 pressure
  123285. * @param impostor impostor to set pressure on
  123286. * @param pressure pressure value
  123287. */
  123288. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  123289. /**
  123290. * Gets stiffness of the impostor
  123291. * @param impostor impostor to get stiffness from
  123292. * @returns pressure value
  123293. */
  123294. getBodyStiffness(impostor: PhysicsImpostor): number;
  123295. /**
  123296. * Sets stiffness of the impostor
  123297. * @param impostor impostor to set stiffness on
  123298. * @param stiffness stiffness value from 0 to 1
  123299. */
  123300. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  123301. /**
  123302. * Gets velocityIterations of the impostor
  123303. * @param impostor impostor to get velocity iterations from
  123304. * @returns velocityIterations value
  123305. */
  123306. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  123307. /**
  123308. * Sets velocityIterations of the impostor
  123309. * @param impostor impostor to set velocity iterations on
  123310. * @param velocityIterations velocityIterations value
  123311. */
  123312. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  123313. /**
  123314. * Gets positionIterations of the impostor
  123315. * @param impostor impostor to get position iterations from
  123316. * @returns positionIterations value
  123317. */
  123318. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  123319. /**
  123320. * Sets positionIterations of the impostor
  123321. * @param impostor impostor to set position on
  123322. * @param positionIterations positionIterations value
  123323. */
  123324. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  123325. /**
  123326. * Append an anchor to a cloth object
  123327. * @param impostor is the cloth impostor to add anchor to
  123328. * @param otherImpostor is the rigid impostor to anchor to
  123329. * @param width ratio across width from 0 to 1
  123330. * @param height ratio up height from 0 to 1
  123331. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  123332. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  123333. */
  123334. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  123335. /**
  123336. * Append an hook to a rope object
  123337. * @param impostor is the rope impostor to add hook to
  123338. * @param otherImpostor is the rigid impostor to hook to
  123339. * @param length ratio along the rope from 0 to 1
  123340. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  123341. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  123342. */
  123343. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  123344. /**
  123345. * Sleeps the physics body and stops it from being active
  123346. * @param impostor impostor to sleep
  123347. */
  123348. sleepBody(impostor: PhysicsImpostor): void;
  123349. /**
  123350. * Activates the physics body
  123351. * @param impostor impostor to activate
  123352. */
  123353. wakeUpBody(impostor: PhysicsImpostor): void;
  123354. /**
  123355. * Updates the distance parameters of the joint
  123356. * @param joint joint to update
  123357. * @param maxDistance maximum distance of the joint
  123358. * @param minDistance minimum distance of the joint
  123359. */
  123360. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  123361. /**
  123362. * Sets a motor on the joint
  123363. * @param joint joint to set motor on
  123364. * @param speed speed of the motor
  123365. * @param maxForce maximum force of the motor
  123366. * @param motorIndex index of the motor
  123367. */
  123368. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  123369. /**
  123370. * Sets the motors limit
  123371. * @param joint joint to set limit on
  123372. * @param upperLimit upper limit
  123373. * @param lowerLimit lower limit
  123374. */
  123375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  123376. /**
  123377. * Syncs the position and rotation of a mesh with the impostor
  123378. * @param mesh mesh to sync
  123379. * @param impostor impostor to update the mesh with
  123380. */
  123381. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123382. /**
  123383. * Gets the radius of the impostor
  123384. * @param impostor impostor to get radius from
  123385. * @returns the radius
  123386. */
  123387. getRadius(impostor: PhysicsImpostor): number;
  123388. /**
  123389. * Gets the box size of the impostor
  123390. * @param impostor impostor to get box size from
  123391. * @param result the resulting box size
  123392. */
  123393. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123394. /**
  123395. * Disposes of the impostor
  123396. */
  123397. dispose(): void;
  123398. /**
  123399. * Does a raycast in the physics world
  123400. * @param from when should the ray start?
  123401. * @param to when should the ray end?
  123402. * @returns PhysicsRaycastResult
  123403. */
  123404. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123405. }
  123406. }
  123407. declare module BABYLON {
  123408. interface AbstractScene {
  123409. /**
  123410. * The list of reflection probes added to the scene
  123411. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  123412. */
  123413. reflectionProbes: Array<ReflectionProbe>;
  123414. /**
  123415. * Removes the given reflection probe from this scene.
  123416. * @param toRemove The reflection probe to remove
  123417. * @returns The index of the removed reflection probe
  123418. */
  123419. removeReflectionProbe(toRemove: ReflectionProbe): number;
  123420. /**
  123421. * Adds the given reflection probe to this scene.
  123422. * @param newReflectionProbe The reflection probe to add
  123423. */
  123424. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  123425. }
  123426. /**
  123427. * Class used to generate realtime reflection / refraction cube textures
  123428. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  123429. */
  123430. export class ReflectionProbe {
  123431. /** defines the name of the probe */
  123432. name: string;
  123433. private _scene;
  123434. private _renderTargetTexture;
  123435. private _projectionMatrix;
  123436. private _viewMatrix;
  123437. private _target;
  123438. private _add;
  123439. private _attachedMesh;
  123440. private _invertYAxis;
  123441. /** Gets or sets probe position (center of the cube map) */
  123442. position: Vector3;
  123443. /**
  123444. * Creates a new reflection probe
  123445. * @param name defines the name of the probe
  123446. * @param size defines the texture resolution (for each face)
  123447. * @param scene defines the hosting scene
  123448. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  123449. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  123450. */
  123451. constructor(
  123452. /** defines the name of the probe */
  123453. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  123454. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  123455. samples: number;
  123456. /** Gets or sets the refresh rate to use (on every frame by default) */
  123457. refreshRate: number;
  123458. /**
  123459. * Gets the hosting scene
  123460. * @returns a Scene
  123461. */
  123462. getScene(): Scene;
  123463. /** Gets the internal CubeTexture used to render to */
  123464. readonly cubeTexture: RenderTargetTexture;
  123465. /** Gets the list of meshes to render */
  123466. readonly renderList: Nullable<AbstractMesh[]>;
  123467. /**
  123468. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  123469. * @param mesh defines the mesh to attach to
  123470. */
  123471. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123472. /**
  123473. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  123474. * @param renderingGroupId The rendering group id corresponding to its index
  123475. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123476. */
  123477. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  123478. /**
  123479. * Clean all associated resources
  123480. */
  123481. dispose(): void;
  123482. /**
  123483. * Converts the reflection probe information to a readable string for debug purpose.
  123484. * @param fullDetails Supports for multiple levels of logging within scene loading
  123485. * @returns the human readable reflection probe info
  123486. */
  123487. toString(fullDetails?: boolean): string;
  123488. /**
  123489. * Get the class name of the relfection probe.
  123490. * @returns "ReflectionProbe"
  123491. */
  123492. getClassName(): string;
  123493. /**
  123494. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  123495. * @returns The JSON representation of the texture
  123496. */
  123497. serialize(): any;
  123498. /**
  123499. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  123500. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  123501. * @param scene Define the scene the parsed reflection probe should be instantiated in
  123502. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  123503. * @returns The parsed reflection probe if successful
  123504. */
  123505. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  123506. }
  123507. }
  123508. declare module BABYLON {
  123509. /** @hidden */
  123510. export var _BabylonLoaderRegistered: boolean;
  123511. /**
  123512. * Helps setting up some configuration for the babylon file loader.
  123513. */
  123514. export class BabylonFileLoaderConfiguration {
  123515. /**
  123516. * The loader does not allow injecting custom physix engine into the plugins.
  123517. * Unfortunately in ES6, we need to manually inject them into the plugin.
  123518. * So you could set this variable to your engine import to make it work.
  123519. */
  123520. static LoaderInjectedPhysicsEngine: any;
  123521. }
  123522. }
  123523. declare module BABYLON {
  123524. /**
  123525. * The Physically based simple base material of BJS.
  123526. *
  123527. * This enables better naming and convention enforcements on top of the pbrMaterial.
  123528. * It is used as the base class for both the specGloss and metalRough conventions.
  123529. */
  123530. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  123531. /**
  123532. * Number of Simultaneous lights allowed on the material.
  123533. */
  123534. maxSimultaneousLights: number;
  123535. /**
  123536. * If sets to true, disables all the lights affecting the material.
  123537. */
  123538. disableLighting: boolean;
  123539. /**
  123540. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  123541. */
  123542. environmentTexture: BaseTexture;
  123543. /**
  123544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  123545. */
  123546. invertNormalMapX: boolean;
  123547. /**
  123548. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  123549. */
  123550. invertNormalMapY: boolean;
  123551. /**
  123552. * Normal map used in the model.
  123553. */
  123554. normalTexture: BaseTexture;
  123555. /**
  123556. * Emissivie color used to self-illuminate the model.
  123557. */
  123558. emissiveColor: Color3;
  123559. /**
  123560. * Emissivie texture used to self-illuminate the model.
  123561. */
  123562. emissiveTexture: BaseTexture;
  123563. /**
  123564. * Occlusion Channel Strenght.
  123565. */
  123566. occlusionStrength: number;
  123567. /**
  123568. * Occlusion Texture of the material (adding extra occlusion effects).
  123569. */
  123570. occlusionTexture: BaseTexture;
  123571. /**
  123572. * Defines the alpha limits in alpha test mode.
  123573. */
  123574. alphaCutOff: number;
  123575. /**
  123576. * Gets the current double sided mode.
  123577. */
  123578. /**
  123579. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123580. */
  123581. doubleSided: boolean;
  123582. /**
  123583. * Stores the pre-calculated light information of a mesh in a texture.
  123584. */
  123585. lightmapTexture: BaseTexture;
  123586. /**
  123587. * If true, the light map contains occlusion information instead of lighting info.
  123588. */
  123589. useLightmapAsShadowmap: boolean;
  123590. /**
  123591. * Instantiates a new PBRMaterial instance.
  123592. *
  123593. * @param name The material name
  123594. * @param scene The scene the material will be use in.
  123595. */
  123596. constructor(name: string, scene: Scene);
  123597. getClassName(): string;
  123598. }
  123599. }
  123600. declare module BABYLON {
  123601. /**
  123602. * The PBR material of BJS following the metal roughness convention.
  123603. *
  123604. * This fits to the PBR convention in the GLTF definition:
  123605. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  123606. */
  123607. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  123608. /**
  123609. * The base color has two different interpretations depending on the value of metalness.
  123610. * When the material is a metal, the base color is the specific measured reflectance value
  123611. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  123612. * of the material.
  123613. */
  123614. baseColor: Color3;
  123615. /**
  123616. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  123617. * well as opacity information in the alpha channel.
  123618. */
  123619. baseTexture: BaseTexture;
  123620. /**
  123621. * Specifies the metallic scalar value of the material.
  123622. * Can also be used to scale the metalness values of the metallic texture.
  123623. */
  123624. metallic: number;
  123625. /**
  123626. * Specifies the roughness scalar value of the material.
  123627. * Can also be used to scale the roughness values of the metallic texture.
  123628. */
  123629. roughness: number;
  123630. /**
  123631. * Texture containing both the metallic value in the B channel and the
  123632. * roughness value in the G channel to keep better precision.
  123633. */
  123634. metallicRoughnessTexture: BaseTexture;
  123635. /**
  123636. * Instantiates a new PBRMetalRoughnessMaterial instance.
  123637. *
  123638. * @param name The material name
  123639. * @param scene The scene the material will be use in.
  123640. */
  123641. constructor(name: string, scene: Scene);
  123642. /**
  123643. * Return the currrent class name of the material.
  123644. */
  123645. getClassName(): string;
  123646. /**
  123647. * Makes a duplicate of the current material.
  123648. * @param name - name to use for the new material.
  123649. */
  123650. clone(name: string): PBRMetallicRoughnessMaterial;
  123651. /**
  123652. * Serialize the material to a parsable JSON object.
  123653. */
  123654. serialize(): any;
  123655. /**
  123656. * Parses a JSON object correponding to the serialize function.
  123657. */
  123658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  123659. }
  123660. }
  123661. declare module BABYLON {
  123662. /**
  123663. * The PBR material of BJS following the specular glossiness convention.
  123664. *
  123665. * This fits to the PBR convention in the GLTF definition:
  123666. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  123667. */
  123668. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  123669. /**
  123670. * Specifies the diffuse color of the material.
  123671. */
  123672. diffuseColor: Color3;
  123673. /**
  123674. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  123675. * channel.
  123676. */
  123677. diffuseTexture: BaseTexture;
  123678. /**
  123679. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  123680. */
  123681. specularColor: Color3;
  123682. /**
  123683. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  123684. */
  123685. glossiness: number;
  123686. /**
  123687. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  123688. */
  123689. specularGlossinessTexture: BaseTexture;
  123690. /**
  123691. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  123692. *
  123693. * @param name The material name
  123694. * @param scene The scene the material will be use in.
  123695. */
  123696. constructor(name: string, scene: Scene);
  123697. /**
  123698. * Return the currrent class name of the material.
  123699. */
  123700. getClassName(): string;
  123701. /**
  123702. * Makes a duplicate of the current material.
  123703. * @param name - name to use for the new material.
  123704. */
  123705. clone(name: string): PBRSpecularGlossinessMaterial;
  123706. /**
  123707. * Serialize the material to a parsable JSON object.
  123708. */
  123709. serialize(): any;
  123710. /**
  123711. * Parses a JSON object correponding to the serialize function.
  123712. */
  123713. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  123714. }
  123715. }
  123716. declare module BABYLON {
  123717. /**
  123718. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  123719. * It can help converting any input color in a desired output one. This can then be used to create effects
  123720. * from sepia, black and white to sixties or futuristic rendering...
  123721. *
  123722. * The only supported format is currently 3dl.
  123723. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  123724. */
  123725. export class ColorGradingTexture extends BaseTexture {
  123726. /**
  123727. * The current texture matrix. (will always be identity in color grading texture)
  123728. */
  123729. private _textureMatrix;
  123730. /**
  123731. * The texture URL.
  123732. */
  123733. url: string;
  123734. /**
  123735. * Empty line regex stored for GC.
  123736. */
  123737. private static _noneEmptyLineRegex;
  123738. private _engine;
  123739. /**
  123740. * Instantiates a ColorGradingTexture from the following parameters.
  123741. *
  123742. * @param url The location of the color gradind data (currently only supporting 3dl)
  123743. * @param scene The scene the texture will be used in
  123744. */
  123745. constructor(url: string, scene: Scene);
  123746. /**
  123747. * Returns the texture matrix used in most of the material.
  123748. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  123749. */
  123750. getTextureMatrix(): Matrix;
  123751. /**
  123752. * Occurs when the file being loaded is a .3dl LUT file.
  123753. */
  123754. private load3dlTexture;
  123755. /**
  123756. * Starts the loading process of the texture.
  123757. */
  123758. private loadTexture;
  123759. /**
  123760. * Clones the color gradind texture.
  123761. */
  123762. clone(): ColorGradingTexture;
  123763. /**
  123764. * Called during delayed load for textures.
  123765. */
  123766. delayLoad(): void;
  123767. /**
  123768. * Parses a color grading texture serialized by Babylon.
  123769. * @param parsedTexture The texture information being parsedTexture
  123770. * @param scene The scene to load the texture in
  123771. * @param rootUrl The root url of the data assets to load
  123772. * @return A color gradind texture
  123773. */
  123774. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  123775. /**
  123776. * Serializes the LUT texture to json format.
  123777. */
  123778. serialize(): any;
  123779. }
  123780. }
  123781. declare module BABYLON {
  123782. /**
  123783. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  123784. */
  123785. export class EquiRectangularCubeTexture extends BaseTexture {
  123786. /** The six faces of the cube. */
  123787. private static _FacesMapping;
  123788. private _noMipmap;
  123789. private _onLoad;
  123790. private _onError;
  123791. /** The size of the cubemap. */
  123792. private _size;
  123793. /** The buffer of the image. */
  123794. private _buffer;
  123795. /** The width of the input image. */
  123796. private _width;
  123797. /** The height of the input image. */
  123798. private _height;
  123799. /** The URL to the image. */
  123800. url: string;
  123801. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  123802. coordinatesMode: number;
  123803. /**
  123804. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  123805. * @param url The location of the image
  123806. * @param scene The scene the texture will be used in
  123807. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123808. * @param noMipmap Forces to not generate the mipmap if true
  123809. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123810. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123811. * @param onLoad — defines a callback called when texture is loaded
  123812. * @param onError — defines a callback called if there is an error
  123813. */
  123814. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  123815. /**
  123816. * Load the image data, by putting the image on a canvas and extracting its buffer.
  123817. */
  123818. private loadImage;
  123819. /**
  123820. * Convert the image buffer into a cubemap and create a CubeTexture.
  123821. */
  123822. private loadTexture;
  123823. /**
  123824. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  123825. * @param buffer The ArrayBuffer that should be converted.
  123826. * @returns The buffer as Float32Array.
  123827. */
  123828. private getFloat32ArrayFromArrayBuffer;
  123829. /**
  123830. * Get the current class name of the texture useful for serialization or dynamic coding.
  123831. * @returns "EquiRectangularCubeTexture"
  123832. */
  123833. getClassName(): string;
  123834. /**
  123835. * Create a clone of the current EquiRectangularCubeTexture and return it.
  123836. * @returns A clone of the current EquiRectangularCubeTexture.
  123837. */
  123838. clone(): EquiRectangularCubeTexture;
  123839. }
  123840. }
  123841. declare module BABYLON {
  123842. /**
  123843. * Based on jsTGALoader - Javascript loader for TGA file
  123844. * By Vincent Thibault
  123845. * @see http://blog.robrowser.com/javascript-tga-loader.html
  123846. */
  123847. export class TGATools {
  123848. private static _TYPE_INDEXED;
  123849. private static _TYPE_RGB;
  123850. private static _TYPE_GREY;
  123851. private static _TYPE_RLE_INDEXED;
  123852. private static _TYPE_RLE_RGB;
  123853. private static _TYPE_RLE_GREY;
  123854. private static _ORIGIN_MASK;
  123855. private static _ORIGIN_SHIFT;
  123856. private static _ORIGIN_BL;
  123857. private static _ORIGIN_BR;
  123858. private static _ORIGIN_UL;
  123859. private static _ORIGIN_UR;
  123860. /**
  123861. * Gets the header of a TGA file
  123862. * @param data defines the TGA data
  123863. * @returns the header
  123864. */
  123865. static GetTGAHeader(data: Uint8Array): any;
  123866. /**
  123867. * Uploads TGA content to a Babylon Texture
  123868. * @hidden
  123869. */
  123870. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  123871. /** @hidden */
  123872. 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;
  123873. /** @hidden */
  123874. 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;
  123875. /** @hidden */
  123876. 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;
  123877. /** @hidden */
  123878. 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;
  123879. /** @hidden */
  123880. 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;
  123881. /** @hidden */
  123882. 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;
  123883. }
  123884. }
  123885. declare module BABYLON {
  123886. /**
  123887. * Implementation of the TGA Texture Loader.
  123888. * @hidden
  123889. */
  123890. export class _TGATextureLoader implements IInternalTextureLoader {
  123891. /**
  123892. * Defines wether the loader supports cascade loading the different faces.
  123893. */
  123894. readonly supportCascades: boolean;
  123895. /**
  123896. * This returns if the loader support the current file information.
  123897. * @param extension defines the file extension of the file being loaded
  123898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123899. * @param fallback defines the fallback internal texture if any
  123900. * @param isBase64 defines whether the texture is encoded as a base64
  123901. * @param isBuffer defines whether the texture data are stored as a buffer
  123902. * @returns true if the loader can load the specified file
  123903. */
  123904. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123905. /**
  123906. * Transform the url before loading if required.
  123907. * @param rootUrl the url of the texture
  123908. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123909. * @returns the transformed texture
  123910. */
  123911. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123912. /**
  123913. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123914. * @param rootUrl the url of the texture
  123915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123916. * @returns the fallback texture
  123917. */
  123918. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123919. /**
  123920. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123921. * @param data contains the texture data
  123922. * @param texture defines the BabylonJS internal texture
  123923. * @param createPolynomials will be true if polynomials have been requested
  123924. * @param onLoad defines the callback to trigger once the texture is ready
  123925. * @param onError defines the callback to trigger in case of error
  123926. */
  123927. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123928. /**
  123929. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123930. * @param data contains the texture data
  123931. * @param texture defines the BabylonJS internal texture
  123932. * @param callback defines the method to call once ready to upload
  123933. */
  123934. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123935. }
  123936. }
  123937. declare module BABYLON {
  123938. /**
  123939. * Info about the .basis files
  123940. */
  123941. class BasisFileInfo {
  123942. /**
  123943. * If the file has alpha
  123944. */
  123945. hasAlpha: boolean;
  123946. /**
  123947. * Info about each image of the basis file
  123948. */
  123949. images: Array<{
  123950. levels: Array<{
  123951. width: number;
  123952. height: number;
  123953. transcodedPixels: ArrayBufferView;
  123954. }>;
  123955. }>;
  123956. }
  123957. /**
  123958. * Result of transcoding a basis file
  123959. */
  123960. class TranscodeResult {
  123961. /**
  123962. * Info about the .basis file
  123963. */
  123964. fileInfo: BasisFileInfo;
  123965. /**
  123966. * Format to use when loading the file
  123967. */
  123968. format: number;
  123969. }
  123970. /**
  123971. * Configuration options for the Basis transcoder
  123972. */
  123973. export class BasisTranscodeConfiguration {
  123974. /**
  123975. * Supported compression formats used to determine the supported output format of the transcoder
  123976. */
  123977. supportedCompressionFormats?: {
  123978. /**
  123979. * etc1 compression format
  123980. */
  123981. etc1?: boolean;
  123982. /**
  123983. * s3tc compression format
  123984. */
  123985. s3tc?: boolean;
  123986. /**
  123987. * pvrtc compression format
  123988. */
  123989. pvrtc?: boolean;
  123990. /**
  123991. * etc2 compression format
  123992. */
  123993. etc2?: boolean;
  123994. };
  123995. /**
  123996. * If mipmap levels should be loaded for transcoded images (Default: true)
  123997. */
  123998. loadMipmapLevels?: boolean;
  123999. /**
  124000. * Index of a single image to load (Default: all images)
  124001. */
  124002. loadSingleImage?: number;
  124003. }
  124004. /**
  124005. * Used to load .Basis files
  124006. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  124007. */
  124008. export class BasisTools {
  124009. private static _IgnoreSupportedFormats;
  124010. /**
  124011. * URL to use when loading the basis transcoder
  124012. */
  124013. static JSModuleURL: string;
  124014. /**
  124015. * URL to use when loading the wasm module for the transcoder
  124016. */
  124017. static WasmModuleURL: string;
  124018. /**
  124019. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  124020. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  124021. * @returns internal format corresponding to the Basis format
  124022. */
  124023. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  124024. private static _WorkerPromise;
  124025. private static _Worker;
  124026. private static _actionId;
  124027. private static _CreateWorkerAsync;
  124028. /**
  124029. * Transcodes a loaded image file to compressed pixel data
  124030. * @param imageData image data to transcode
  124031. * @param config configuration options for the transcoding
  124032. * @returns a promise resulting in the transcoded image
  124033. */
  124034. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  124035. /**
  124036. * Loads a texture from the transcode result
  124037. * @param texture texture load to
  124038. * @param transcodeResult the result of transcoding the basis file to load from
  124039. */
  124040. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  124041. }
  124042. }
  124043. declare module BABYLON {
  124044. /**
  124045. * Loader for .basis file format
  124046. */
  124047. export class _BasisTextureLoader implements IInternalTextureLoader {
  124048. /**
  124049. * Defines whether the loader supports cascade loading the different faces.
  124050. */
  124051. readonly supportCascades: boolean;
  124052. /**
  124053. * This returns if the loader support the current file information.
  124054. * @param extension defines the file extension of the file being loaded
  124055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124056. * @param fallback defines the fallback internal texture if any
  124057. * @param isBase64 defines whether the texture is encoded as a base64
  124058. * @param isBuffer defines whether the texture data are stored as a buffer
  124059. * @returns true if the loader can load the specified file
  124060. */
  124061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124062. /**
  124063. * Transform the url before loading if required.
  124064. * @param rootUrl the url of the texture
  124065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124066. * @returns the transformed texture
  124067. */
  124068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124069. /**
  124070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124071. * @param rootUrl the url of the texture
  124072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124073. * @returns the fallback texture
  124074. */
  124075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124076. /**
  124077. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  124078. * @param data contains the texture data
  124079. * @param texture defines the BabylonJS internal texture
  124080. * @param createPolynomials will be true if polynomials have been requested
  124081. * @param onLoad defines the callback to trigger once the texture is ready
  124082. * @param onError defines the callback to trigger in case of error
  124083. */
  124084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124085. /**
  124086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124087. * @param data contains the texture data
  124088. * @param texture defines the BabylonJS internal texture
  124089. * @param callback defines the method to call once ready to upload
  124090. */
  124091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124092. }
  124093. }
  124094. declare module BABYLON {
  124095. /**
  124096. * 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.
  124097. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  124098. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  124099. */
  124100. export class CustomProceduralTexture extends ProceduralTexture {
  124101. private _animate;
  124102. private _time;
  124103. private _config;
  124104. private _texturePath;
  124105. /**
  124106. * Instantiates a new Custom Procedural Texture.
  124107. * 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.
  124108. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  124109. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  124110. * @param name Define the name of the texture
  124111. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  124112. * @param size Define the size of the texture to create
  124113. * @param scene Define the scene the texture belongs to
  124114. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  124115. * @param generateMipMaps Define if the texture should creates mip maps or not
  124116. */
  124117. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  124118. private _loadJson;
  124119. /**
  124120. * Is the texture ready to be used ? (rendered at least once)
  124121. * @returns true if ready, otherwise, false.
  124122. */
  124123. isReady(): boolean;
  124124. /**
  124125. * Render the texture to its associated render target.
  124126. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  124127. */
  124128. render(useCameraPostProcess?: boolean): void;
  124129. /**
  124130. * Update the list of dependant textures samplers in the shader.
  124131. */
  124132. updateTextures(): void;
  124133. /**
  124134. * Update the uniform values of the procedural texture in the shader.
  124135. */
  124136. updateShaderUniforms(): void;
  124137. /**
  124138. * Define if the texture animates or not.
  124139. */
  124140. animate: boolean;
  124141. }
  124142. }
  124143. declare module BABYLON {
  124144. /** @hidden */
  124145. export var noisePixelShader: {
  124146. name: string;
  124147. shader: string;
  124148. };
  124149. }
  124150. declare module BABYLON {
  124151. /**
  124152. * Class used to generate noise procedural textures
  124153. */
  124154. export class NoiseProceduralTexture extends ProceduralTexture {
  124155. private _time;
  124156. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  124157. brightness: number;
  124158. /** Defines the number of octaves to process */
  124159. octaves: number;
  124160. /** Defines the level of persistence (0.8 by default) */
  124161. persistence: number;
  124162. /** Gets or sets animation speed factor (default is 1) */
  124163. animationSpeedFactor: number;
  124164. /**
  124165. * Creates a new NoiseProceduralTexture
  124166. * @param name defines the name fo the texture
  124167. * @param size defines the size of the texture (default is 256)
  124168. * @param scene defines the hosting scene
  124169. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  124170. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  124171. */
  124172. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  124173. private _updateShaderUniforms;
  124174. protected _getDefines(): string;
  124175. /** Generate the current state of the procedural texture */
  124176. render(useCameraPostProcess?: boolean): void;
  124177. /**
  124178. * Serializes this noise procedural texture
  124179. * @returns a serialized noise procedural texture object
  124180. */
  124181. serialize(): any;
  124182. /**
  124183. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  124184. * @param parsedTexture defines parsed texture data
  124185. * @param scene defines the current scene
  124186. * @param rootUrl defines the root URL containing noise procedural texture information
  124187. * @returns a parsed NoiseProceduralTexture
  124188. */
  124189. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  124190. }
  124191. }
  124192. declare module BABYLON {
  124193. /**
  124194. * Raw cube texture where the raw buffers are passed in
  124195. */
  124196. export class RawCubeTexture extends CubeTexture {
  124197. /**
  124198. * Creates a cube texture where the raw buffers are passed in.
  124199. * @param scene defines the scene the texture is attached to
  124200. * @param data defines the array of data to use to create each face
  124201. * @param size defines the size of the textures
  124202. * @param format defines the format of the data
  124203. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  124204. * @param generateMipMaps defines if the engine should generate the mip levels
  124205. * @param invertY defines if data must be stored with Y axis inverted
  124206. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  124207. * @param compression defines the compression used (null by default)
  124208. */
  124209. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  124210. /**
  124211. * Updates the raw cube texture.
  124212. * @param data defines the data to store
  124213. * @param format defines the data format
  124214. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124215. * @param invertY defines if data must be stored with Y axis inverted
  124216. * @param compression defines the compression used (null by default)
  124217. * @param level defines which level of the texture to update
  124218. */
  124219. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  124220. /**
  124221. * Updates a raw cube texture with RGBD encoded data.
  124222. * @param data defines the array of data [mipmap][face] to use to create each face
  124223. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  124224. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124225. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124226. * @returns a promsie that resolves when the operation is complete
  124227. */
  124228. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  124229. /**
  124230. * Clones the raw cube texture.
  124231. * @return a new cube texture
  124232. */
  124233. clone(): CubeTexture;
  124234. /** @hidden */
  124235. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  124236. }
  124237. }
  124238. declare module BABYLON {
  124239. /**
  124240. * Class used to store 3D textures containing user data
  124241. */
  124242. export class RawTexture3D extends Texture {
  124243. /** Gets or sets the texture format to use */
  124244. format: number;
  124245. private _engine;
  124246. /**
  124247. * Create a new RawTexture3D
  124248. * @param data defines the data of the texture
  124249. * @param width defines the width of the texture
  124250. * @param height defines the height of the texture
  124251. * @param depth defines the depth of the texture
  124252. * @param format defines the texture format to use
  124253. * @param scene defines the hosting scene
  124254. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  124255. * @param invertY defines if texture must be stored with Y axis inverted
  124256. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124257. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  124258. */
  124259. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  124260. /** Gets or sets the texture format to use */
  124261. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  124262. /**
  124263. * Update the texture with new data
  124264. * @param data defines the data to store in the texture
  124265. */
  124266. update(data: ArrayBufferView): void;
  124267. }
  124268. }
  124269. declare module BABYLON {
  124270. /**
  124271. * Class used to store 2D array textures containing user data
  124272. */
  124273. export class RawTexture2DArray extends Texture {
  124274. /** Gets or sets the texture format to use */
  124275. format: number;
  124276. private _engine;
  124277. /**
  124278. * Create a new RawTexture2DArray
  124279. * @param data defines the data of the texture
  124280. * @param width defines the width of the texture
  124281. * @param height defines the height of the texture
  124282. * @param depth defines the number of layers of the texture
  124283. * @param format defines the texture format to use
  124284. * @param scene defines the hosting scene
  124285. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  124286. * @param invertY defines if texture must be stored with Y axis inverted
  124287. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124288. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  124289. */
  124290. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  124291. /** Gets or sets the texture format to use */
  124292. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  124293. /**
  124294. * Update the texture with new data
  124295. * @param data defines the data to store in the texture
  124296. */
  124297. update(data: ArrayBufferView): void;
  124298. }
  124299. }
  124300. declare module BABYLON {
  124301. /**
  124302. * Creates a refraction texture used by refraction channel of the standard material.
  124303. * It is like a mirror but to see through a material.
  124304. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  124305. */
  124306. export class RefractionTexture extends RenderTargetTexture {
  124307. /**
  124308. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  124309. * 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.
  124310. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  124311. */
  124312. refractionPlane: Plane;
  124313. /**
  124314. * Define how deep under the surface we should see.
  124315. */
  124316. depth: number;
  124317. /**
  124318. * Creates a refraction texture used by refraction channel of the standard material.
  124319. * It is like a mirror but to see through a material.
  124320. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  124321. * @param name Define the texture name
  124322. * @param size Define the size of the underlying texture
  124323. * @param scene Define the scene the refraction belongs to
  124324. * @param generateMipMaps Define if we need to generate mips level for the refraction
  124325. */
  124326. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  124327. /**
  124328. * Clone the refraction texture.
  124329. * @returns the cloned texture
  124330. */
  124331. clone(): RefractionTexture;
  124332. /**
  124333. * Serialize the texture to a JSON representation you could use in Parse later on
  124334. * @returns the serialized JSON representation
  124335. */
  124336. serialize(): any;
  124337. }
  124338. }
  124339. declare module BABYLON {
  124340. /**
  124341. * Defines the options related to the creation of an HtmlElementTexture
  124342. */
  124343. export interface IHtmlElementTextureOptions {
  124344. /**
  124345. * Defines wether mip maps should be created or not.
  124346. */
  124347. generateMipMaps?: boolean;
  124348. /**
  124349. * Defines the sampling mode of the texture.
  124350. */
  124351. samplingMode?: number;
  124352. /**
  124353. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  124354. */
  124355. engine: Nullable<ThinEngine>;
  124356. /**
  124357. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  124358. */
  124359. scene: Nullable<Scene>;
  124360. }
  124361. /**
  124362. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  124363. * To be as efficient as possible depending on your constraints nothing aside the first upload
  124364. * is automatically managed.
  124365. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  124366. * in your application.
  124367. *
  124368. * As the update is not automatic, you need to call them manually.
  124369. */
  124370. export class HtmlElementTexture extends BaseTexture {
  124371. /**
  124372. * The texture URL.
  124373. */
  124374. element: HTMLVideoElement | HTMLCanvasElement;
  124375. private static readonly DefaultOptions;
  124376. private _textureMatrix;
  124377. private _engine;
  124378. private _isVideo;
  124379. private _generateMipMaps;
  124380. private _samplingMode;
  124381. /**
  124382. * Instantiates a HtmlElementTexture from the following parameters.
  124383. *
  124384. * @param name Defines the name of the texture
  124385. * @param element Defines the video or canvas the texture is filled with
  124386. * @param options Defines the other none mandatory texture creation options
  124387. */
  124388. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  124389. private _createInternalTexture;
  124390. /**
  124391. * Returns the texture matrix used in most of the material.
  124392. */
  124393. getTextureMatrix(): Matrix;
  124394. /**
  124395. * Updates the content of the texture.
  124396. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  124397. */
  124398. update(invertY?: Nullable<boolean>): void;
  124399. }
  124400. }
  124401. declare module BABYLON {
  124402. /**
  124403. * Enum used to define the target of a block
  124404. */
  124405. export enum NodeMaterialBlockTargets {
  124406. /** Vertex shader */
  124407. Vertex = 1,
  124408. /** Fragment shader */
  124409. Fragment = 2,
  124410. /** Neutral */
  124411. Neutral = 4,
  124412. /** Vertex and Fragment */
  124413. VertexAndFragment = 3
  124414. }
  124415. }
  124416. declare module BABYLON {
  124417. /**
  124418. * Defines the kind of connection point for node based material
  124419. */
  124420. export enum NodeMaterialBlockConnectionPointTypes {
  124421. /** Float */
  124422. Float = 1,
  124423. /** Int */
  124424. Int = 2,
  124425. /** Vector2 */
  124426. Vector2 = 4,
  124427. /** Vector3 */
  124428. Vector3 = 8,
  124429. /** Vector4 */
  124430. Vector4 = 16,
  124431. /** Color3 */
  124432. Color3 = 32,
  124433. /** Color4 */
  124434. Color4 = 64,
  124435. /** Matrix */
  124436. Matrix = 128,
  124437. /** Detect type based on connection */
  124438. AutoDetect = 1024,
  124439. /** Output type that will be defined by input type */
  124440. BasedOnInput = 2048
  124441. }
  124442. }
  124443. declare module BABYLON {
  124444. /**
  124445. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  124446. */
  124447. export enum NodeMaterialBlockConnectionPointMode {
  124448. /** Value is an uniform */
  124449. Uniform = 0,
  124450. /** Value is a mesh attribute */
  124451. Attribute = 1,
  124452. /** Value is a varying between vertex and fragment shaders */
  124453. Varying = 2,
  124454. /** Mode is undefined */
  124455. Undefined = 3
  124456. }
  124457. }
  124458. declare module BABYLON {
  124459. /**
  124460. * Enum used to define system values e.g. values automatically provided by the system
  124461. */
  124462. export enum NodeMaterialSystemValues {
  124463. /** World */
  124464. World = 1,
  124465. /** View */
  124466. View = 2,
  124467. /** Projection */
  124468. Projection = 3,
  124469. /** ViewProjection */
  124470. ViewProjection = 4,
  124471. /** WorldView */
  124472. WorldView = 5,
  124473. /** WorldViewProjection */
  124474. WorldViewProjection = 6,
  124475. /** CameraPosition */
  124476. CameraPosition = 7,
  124477. /** Fog Color */
  124478. FogColor = 8,
  124479. /** Delta time */
  124480. DeltaTime = 9
  124481. }
  124482. }
  124483. declare module BABYLON {
  124484. /**
  124485. * Root class for all node material optimizers
  124486. */
  124487. export class NodeMaterialOptimizer {
  124488. /**
  124489. * Function used to optimize a NodeMaterial graph
  124490. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  124491. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  124492. */
  124493. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  124494. }
  124495. }
  124496. declare module BABYLON {
  124497. /**
  124498. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  124499. */
  124500. export class TransformBlock extends NodeMaterialBlock {
  124501. /**
  124502. * Defines the value to use to complement W value to transform it to a Vector4
  124503. */
  124504. complementW: number;
  124505. /**
  124506. * Defines the value to use to complement z value to transform it to a Vector4
  124507. */
  124508. complementZ: number;
  124509. /**
  124510. * Creates a new TransformBlock
  124511. * @param name defines the block name
  124512. */
  124513. constructor(name: string);
  124514. /**
  124515. * Gets the current class name
  124516. * @returns the class name
  124517. */
  124518. getClassName(): string;
  124519. /**
  124520. * Gets the vector input
  124521. */
  124522. readonly vector: NodeMaterialConnectionPoint;
  124523. /**
  124524. * Gets the output component
  124525. */
  124526. readonly output: NodeMaterialConnectionPoint;
  124527. /**
  124528. * Gets the matrix transform input
  124529. */
  124530. readonly transform: NodeMaterialConnectionPoint;
  124531. protected _buildBlock(state: NodeMaterialBuildState): this;
  124532. serialize(): any;
  124533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124534. protected _dumpPropertiesCode(): string;
  124535. }
  124536. }
  124537. declare module BABYLON {
  124538. /**
  124539. * Block used to output the vertex position
  124540. */
  124541. export class VertexOutputBlock extends NodeMaterialBlock {
  124542. /**
  124543. * Creates a new VertexOutputBlock
  124544. * @param name defines the block name
  124545. */
  124546. constructor(name: string);
  124547. /**
  124548. * Gets the current class name
  124549. * @returns the class name
  124550. */
  124551. getClassName(): string;
  124552. /**
  124553. * Gets the vector input component
  124554. */
  124555. readonly vector: NodeMaterialConnectionPoint;
  124556. protected _buildBlock(state: NodeMaterialBuildState): this;
  124557. }
  124558. }
  124559. declare module BABYLON {
  124560. /**
  124561. * Block used to output the final color
  124562. */
  124563. export class FragmentOutputBlock extends NodeMaterialBlock {
  124564. /**
  124565. * Create a new FragmentOutputBlock
  124566. * @param name defines the block name
  124567. */
  124568. constructor(name: string);
  124569. /**
  124570. * Gets the current class name
  124571. * @returns the class name
  124572. */
  124573. getClassName(): string;
  124574. /**
  124575. * Gets the rgba input component
  124576. */
  124577. readonly rgba: NodeMaterialConnectionPoint;
  124578. /**
  124579. * Gets the rgb input component
  124580. */
  124581. readonly rgb: NodeMaterialConnectionPoint;
  124582. /**
  124583. * Gets the a input component
  124584. */
  124585. readonly a: NodeMaterialConnectionPoint;
  124586. protected _buildBlock(state: NodeMaterialBuildState): this;
  124587. }
  124588. }
  124589. declare module BABYLON {
  124590. /**
  124591. * Block used to read a reflection texture from a sampler
  124592. */
  124593. export class ReflectionTextureBlock extends NodeMaterialBlock {
  124594. private _define3DName;
  124595. private _defineCubicName;
  124596. private _defineExplicitName;
  124597. private _defineProjectionName;
  124598. private _defineLocalCubicName;
  124599. private _defineSphericalName;
  124600. private _definePlanarName;
  124601. private _defineEquirectangularName;
  124602. private _defineMirroredEquirectangularFixedName;
  124603. private _defineEquirectangularFixedName;
  124604. private _defineSkyboxName;
  124605. private _cubeSamplerName;
  124606. private _2DSamplerName;
  124607. private _positionUVWName;
  124608. private _directionWName;
  124609. private _reflectionCoordsName;
  124610. private _reflection2DCoordsName;
  124611. private _reflectionColorName;
  124612. private _reflectionMatrixName;
  124613. /**
  124614. * Gets or sets the texture associated with the node
  124615. */
  124616. texture: Nullable<BaseTexture>;
  124617. /**
  124618. * Create a new TextureBlock
  124619. * @param name defines the block name
  124620. */
  124621. constructor(name: string);
  124622. /**
  124623. * Gets the current class name
  124624. * @returns the class name
  124625. */
  124626. getClassName(): string;
  124627. /**
  124628. * Gets the world position input component
  124629. */
  124630. readonly position: NodeMaterialConnectionPoint;
  124631. /**
  124632. * Gets the world position input component
  124633. */
  124634. readonly worldPosition: NodeMaterialConnectionPoint;
  124635. /**
  124636. * Gets the world normal input component
  124637. */
  124638. readonly worldNormal: NodeMaterialConnectionPoint;
  124639. /**
  124640. * Gets the world input component
  124641. */
  124642. readonly world: NodeMaterialConnectionPoint;
  124643. /**
  124644. * Gets the camera (or eye) position component
  124645. */
  124646. readonly cameraPosition: NodeMaterialConnectionPoint;
  124647. /**
  124648. * Gets the view input component
  124649. */
  124650. readonly view: NodeMaterialConnectionPoint;
  124651. /**
  124652. * Gets the rgb output component
  124653. */
  124654. readonly rgb: NodeMaterialConnectionPoint;
  124655. /**
  124656. * Gets the r output component
  124657. */
  124658. readonly r: NodeMaterialConnectionPoint;
  124659. /**
  124660. * Gets the g output component
  124661. */
  124662. readonly g: NodeMaterialConnectionPoint;
  124663. /**
  124664. * Gets the b output component
  124665. */
  124666. readonly b: NodeMaterialConnectionPoint;
  124667. autoConfigure(material: NodeMaterial): void;
  124668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124669. isReady(): boolean;
  124670. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124671. private _injectVertexCode;
  124672. private _writeOutput;
  124673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124674. protected _dumpPropertiesCode(): string;
  124675. serialize(): any;
  124676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124677. }
  124678. }
  124679. declare module BABYLON {
  124680. /**
  124681. * Interface used to configure the node material editor
  124682. */
  124683. export interface INodeMaterialEditorOptions {
  124684. /** Define the URl to load node editor script */
  124685. editorURL?: string;
  124686. }
  124687. /** @hidden */
  124688. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  124689. /** BONES */
  124690. NUM_BONE_INFLUENCERS: number;
  124691. BonesPerMesh: number;
  124692. BONETEXTURE: boolean;
  124693. /** MORPH TARGETS */
  124694. MORPHTARGETS: boolean;
  124695. MORPHTARGETS_NORMAL: boolean;
  124696. MORPHTARGETS_TANGENT: boolean;
  124697. MORPHTARGETS_UV: boolean;
  124698. NUM_MORPH_INFLUENCERS: number;
  124699. /** IMAGE PROCESSING */
  124700. IMAGEPROCESSING: boolean;
  124701. VIGNETTE: boolean;
  124702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124703. VIGNETTEBLENDMODEOPAQUE: boolean;
  124704. TONEMAPPING: boolean;
  124705. TONEMAPPING_ACES: boolean;
  124706. CONTRAST: boolean;
  124707. EXPOSURE: boolean;
  124708. COLORCURVES: boolean;
  124709. COLORGRADING: boolean;
  124710. COLORGRADING3D: boolean;
  124711. SAMPLER3DGREENDEPTH: boolean;
  124712. SAMPLER3DBGRMAP: boolean;
  124713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124714. /** MISC. */
  124715. BUMPDIRECTUV: number;
  124716. constructor();
  124717. setValue(name: string, value: boolean): void;
  124718. }
  124719. /**
  124720. * Class used to configure NodeMaterial
  124721. */
  124722. export interface INodeMaterialOptions {
  124723. /**
  124724. * Defines if blocks should emit comments
  124725. */
  124726. emitComments: boolean;
  124727. }
  124728. /**
  124729. * Class used to create a node based material built by assembling shader blocks
  124730. */
  124731. export class NodeMaterial extends PushMaterial {
  124732. private static _BuildIdGenerator;
  124733. private _options;
  124734. private _vertexCompilationState;
  124735. private _fragmentCompilationState;
  124736. private _sharedData;
  124737. private _buildId;
  124738. private _buildWasSuccessful;
  124739. private _cachedWorldViewMatrix;
  124740. private _cachedWorldViewProjectionMatrix;
  124741. private _optimizers;
  124742. private _animationFrame;
  124743. /** Define the URl to load node editor script */
  124744. static EditorURL: string;
  124745. private BJSNODEMATERIALEDITOR;
  124746. /** Get the inspector from bundle or global */
  124747. private _getGlobalNodeMaterialEditor;
  124748. /**
  124749. * Gets or sets data used by visual editor
  124750. * @see https://nme.babylonjs.com
  124751. */
  124752. editorData: any;
  124753. /**
  124754. * 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)
  124755. */
  124756. ignoreAlpha: boolean;
  124757. /**
  124758. * Defines the maximum number of lights that can be used in the material
  124759. */
  124760. maxSimultaneousLights: number;
  124761. /**
  124762. * Observable raised when the material is built
  124763. */
  124764. onBuildObservable: Observable<NodeMaterial>;
  124765. /**
  124766. * Gets or sets the root nodes of the material vertex shader
  124767. */
  124768. _vertexOutputNodes: NodeMaterialBlock[];
  124769. /**
  124770. * Gets or sets the root nodes of the material fragment (pixel) shader
  124771. */
  124772. _fragmentOutputNodes: NodeMaterialBlock[];
  124773. /** Gets or sets options to control the node material overall behavior */
  124774. options: INodeMaterialOptions;
  124775. /**
  124776. * Default configuration related to image processing available in the standard Material.
  124777. */
  124778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124779. /**
  124780. * Gets the image processing configuration used either in this material.
  124781. */
  124782. /**
  124783. * Sets the Default image processing configuration used either in the this material.
  124784. *
  124785. * If sets to null, the scene one is in use.
  124786. */
  124787. imageProcessingConfiguration: ImageProcessingConfiguration;
  124788. /**
  124789. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  124790. */
  124791. attachedBlocks: NodeMaterialBlock[];
  124792. /**
  124793. * Create a new node based material
  124794. * @param name defines the material name
  124795. * @param scene defines the hosting scene
  124796. * @param options defines creation option
  124797. */
  124798. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  124799. /**
  124800. * Gets the current class name of the material e.g. "NodeMaterial"
  124801. * @returns the class name
  124802. */
  124803. getClassName(): string;
  124804. /**
  124805. * Keep track of the image processing observer to allow dispose and replace.
  124806. */
  124807. private _imageProcessingObserver;
  124808. /**
  124809. * Attaches a new image processing configuration to the Standard Material.
  124810. * @param configuration
  124811. */
  124812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124813. /**
  124814. * Get a block by its name
  124815. * @param name defines the name of the block to retrieve
  124816. * @returns the required block or null if not found
  124817. */
  124818. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  124819. /**
  124820. * Get a block by its name
  124821. * @param predicate defines the predicate used to find the good candidate
  124822. * @returns the required block or null if not found
  124823. */
  124824. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  124825. /**
  124826. * Get an input block by its name
  124827. * @param predicate defines the predicate used to find the good candidate
  124828. * @returns the required input block or null if not found
  124829. */
  124830. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  124831. /**
  124832. * Gets the list of input blocks attached to this material
  124833. * @returns an array of InputBlocks
  124834. */
  124835. getInputBlocks(): InputBlock[];
  124836. /**
  124837. * Adds a new optimizer to the list of optimizers
  124838. * @param optimizer defines the optimizers to add
  124839. * @returns the current material
  124840. */
  124841. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  124842. /**
  124843. * Remove an optimizer from the list of optimizers
  124844. * @param optimizer defines the optimizers to remove
  124845. * @returns the current material
  124846. */
  124847. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  124848. /**
  124849. * Add a new block to the list of output nodes
  124850. * @param node defines the node to add
  124851. * @returns the current material
  124852. */
  124853. addOutputNode(node: NodeMaterialBlock): this;
  124854. /**
  124855. * Remove a block from the list of root nodes
  124856. * @param node defines the node to remove
  124857. * @returns the current material
  124858. */
  124859. removeOutputNode(node: NodeMaterialBlock): this;
  124860. private _addVertexOutputNode;
  124861. private _removeVertexOutputNode;
  124862. private _addFragmentOutputNode;
  124863. private _removeFragmentOutputNode;
  124864. /**
  124865. * Specifies if the material will require alpha blending
  124866. * @returns a boolean specifying if alpha blending is needed
  124867. */
  124868. needAlphaBlending(): boolean;
  124869. /**
  124870. * Specifies if this material should be rendered in alpha test mode
  124871. * @returns a boolean specifying if an alpha test is needed.
  124872. */
  124873. needAlphaTesting(): boolean;
  124874. private _initializeBlock;
  124875. private _resetDualBlocks;
  124876. /**
  124877. * Remove a block from the current node material
  124878. * @param block defines the block to remove
  124879. */
  124880. removeBlock(block: NodeMaterialBlock): void;
  124881. /**
  124882. * Build the material and generates the inner effect
  124883. * @param verbose defines if the build should log activity
  124884. */
  124885. build(verbose?: boolean): void;
  124886. /**
  124887. * Runs an otpimization phase to try to improve the shader code
  124888. */
  124889. optimize(): void;
  124890. private _prepareDefinesForAttributes;
  124891. /**
  124892. * Get if the submesh is ready to be used and all its information available.
  124893. * Child classes can use it to update shaders
  124894. * @param mesh defines the mesh to check
  124895. * @param subMesh defines which submesh to check
  124896. * @param useInstances specifies that instances should be used
  124897. * @returns a boolean indicating that the submesh is ready or not
  124898. */
  124899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124900. /**
  124901. * Get a string representing the shaders built by the current node graph
  124902. */
  124903. readonly compiledShaders: string;
  124904. /**
  124905. * Binds the world matrix to the material
  124906. * @param world defines the world transformation matrix
  124907. */
  124908. bindOnlyWorldMatrix(world: Matrix): void;
  124909. /**
  124910. * Binds the submesh to this material by preparing the effect and shader to draw
  124911. * @param world defines the world transformation matrix
  124912. * @param mesh defines the mesh containing the submesh
  124913. * @param subMesh defines the submesh to bind the material to
  124914. */
  124915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124916. /**
  124917. * Gets the active textures from the material
  124918. * @returns an array of textures
  124919. */
  124920. getActiveTextures(): BaseTexture[];
  124921. /**
  124922. * Gets the list of texture blocks
  124923. * @returns an array of texture blocks
  124924. */
  124925. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  124926. /**
  124927. * Specifies if the material uses a texture
  124928. * @param texture defines the texture to check against the material
  124929. * @returns a boolean specifying if the material uses the texture
  124930. */
  124931. hasTexture(texture: BaseTexture): boolean;
  124932. /**
  124933. * Disposes the material
  124934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  124935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  124936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  124937. */
  124938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  124939. /** Creates the node editor window. */
  124940. private _createNodeEditor;
  124941. /**
  124942. * Launch the node material editor
  124943. * @param config Define the configuration of the editor
  124944. * @return a promise fulfilled when the node editor is visible
  124945. */
  124946. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  124947. /**
  124948. * Clear the current material
  124949. */
  124950. clear(): void;
  124951. /**
  124952. * Clear the current material and set it to a default state
  124953. */
  124954. setToDefault(): void;
  124955. /**
  124956. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  124957. * @param url defines the url to load from
  124958. * @returns a promise that will fullfil when the material is fully loaded
  124959. */
  124960. loadAsync(url: string): Promise<void>;
  124961. private _gatherBlocks;
  124962. /**
  124963. * Generate a string containing the code declaration required to create an equivalent of this material
  124964. * @returns a string
  124965. */
  124966. generateCode(): string;
  124967. /**
  124968. * Serializes this material in a JSON representation
  124969. * @returns the serialized material object
  124970. */
  124971. serialize(): any;
  124972. private _restoreConnections;
  124973. /**
  124974. * Clear the current graph and load a new one from a serialization object
  124975. * @param source defines the JSON representation of the material
  124976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  124977. */
  124978. loadFromSerialization(source: any, rootUrl?: string): void;
  124979. /**
  124980. * Creates a node material from parsed material data
  124981. * @param source defines the JSON representation of the material
  124982. * @param scene defines the hosting scene
  124983. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  124984. * @returns a new node material
  124985. */
  124986. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  124987. /**
  124988. * Creates a new node material set to default basic configuration
  124989. * @param name defines the name of the material
  124990. * @param scene defines the hosting scene
  124991. * @returns a new NodeMaterial
  124992. */
  124993. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  124994. }
  124995. }
  124996. declare module BABYLON {
  124997. /**
  124998. * Block used to read a texture from a sampler
  124999. */
  125000. export class TextureBlock extends NodeMaterialBlock {
  125001. private _defineName;
  125002. private _linearDefineName;
  125003. private _tempTextureRead;
  125004. private _samplerName;
  125005. private _transformedUVName;
  125006. private _textureTransformName;
  125007. private _textureInfoName;
  125008. private _mainUVName;
  125009. private _mainUVDefineName;
  125010. /**
  125011. * Gets or sets the texture associated with the node
  125012. */
  125013. texture: Nullable<Texture>;
  125014. /**
  125015. * Create a new TextureBlock
  125016. * @param name defines the block name
  125017. */
  125018. constructor(name: string);
  125019. /**
  125020. * Gets the current class name
  125021. * @returns the class name
  125022. */
  125023. getClassName(): string;
  125024. /**
  125025. * Gets the uv input component
  125026. */
  125027. readonly uv: NodeMaterialConnectionPoint;
  125028. /**
  125029. * Gets the rgba output component
  125030. */
  125031. readonly rgba: NodeMaterialConnectionPoint;
  125032. /**
  125033. * Gets the rgb output component
  125034. */
  125035. readonly rgb: NodeMaterialConnectionPoint;
  125036. /**
  125037. * Gets the r output component
  125038. */
  125039. readonly r: NodeMaterialConnectionPoint;
  125040. /**
  125041. * Gets the g output component
  125042. */
  125043. readonly g: NodeMaterialConnectionPoint;
  125044. /**
  125045. * Gets the b output component
  125046. */
  125047. readonly b: NodeMaterialConnectionPoint;
  125048. /**
  125049. * Gets the a output component
  125050. */
  125051. readonly a: NodeMaterialConnectionPoint;
  125052. readonly target: NodeMaterialBlockTargets;
  125053. autoConfigure(material: NodeMaterial): void;
  125054. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  125055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125056. private _getTextureBase;
  125057. isReady(): boolean;
  125058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125059. private readonly _isMixed;
  125060. private _injectVertexCode;
  125061. private _writeTextureRead;
  125062. private _writeOutput;
  125063. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125064. protected _dumpPropertiesCode(): string;
  125065. serialize(): any;
  125066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125067. }
  125068. }
  125069. declare module BABYLON {
  125070. /**
  125071. * Class used to store shared data between 2 NodeMaterialBuildState
  125072. */
  125073. export class NodeMaterialBuildStateSharedData {
  125074. /**
  125075. * Gets the list of emitted varyings
  125076. */
  125077. temps: string[];
  125078. /**
  125079. * Gets the list of emitted varyings
  125080. */
  125081. varyings: string[];
  125082. /**
  125083. * Gets the varying declaration string
  125084. */
  125085. varyingDeclaration: string;
  125086. /**
  125087. * Input blocks
  125088. */
  125089. inputBlocks: InputBlock[];
  125090. /**
  125091. * Input blocks
  125092. */
  125093. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  125094. /**
  125095. * Bindable blocks (Blocks that need to set data to the effect)
  125096. */
  125097. bindableBlocks: NodeMaterialBlock[];
  125098. /**
  125099. * List of blocks that can provide a compilation fallback
  125100. */
  125101. blocksWithFallbacks: NodeMaterialBlock[];
  125102. /**
  125103. * List of blocks that can provide a define update
  125104. */
  125105. blocksWithDefines: NodeMaterialBlock[];
  125106. /**
  125107. * List of blocks that can provide a repeatable content
  125108. */
  125109. repeatableContentBlocks: NodeMaterialBlock[];
  125110. /**
  125111. * List of blocks that can provide a dynamic list of uniforms
  125112. */
  125113. dynamicUniformBlocks: NodeMaterialBlock[];
  125114. /**
  125115. * List of blocks that can block the isReady function for the material
  125116. */
  125117. blockingBlocks: NodeMaterialBlock[];
  125118. /**
  125119. * Gets the list of animated inputs
  125120. */
  125121. animatedInputs: InputBlock[];
  125122. /**
  125123. * Build Id used to avoid multiple recompilations
  125124. */
  125125. buildId: number;
  125126. /** List of emitted variables */
  125127. variableNames: {
  125128. [key: string]: number;
  125129. };
  125130. /** List of emitted defines */
  125131. defineNames: {
  125132. [key: string]: number;
  125133. };
  125134. /** Should emit comments? */
  125135. emitComments: boolean;
  125136. /** Emit build activity */
  125137. verbose: boolean;
  125138. /** Gets or sets the hosting scene */
  125139. scene: Scene;
  125140. /**
  125141. * Gets the compilation hints emitted at compilation time
  125142. */
  125143. hints: {
  125144. needWorldViewMatrix: boolean;
  125145. needWorldViewProjectionMatrix: boolean;
  125146. needAlphaBlending: boolean;
  125147. needAlphaTesting: boolean;
  125148. };
  125149. /**
  125150. * List of compilation checks
  125151. */
  125152. checks: {
  125153. emitVertex: boolean;
  125154. emitFragment: boolean;
  125155. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  125156. };
  125157. /** Creates a new shared data */
  125158. constructor();
  125159. /**
  125160. * Emits console errors and exceptions if there is a failing check
  125161. */
  125162. emitErrors(): void;
  125163. }
  125164. }
  125165. declare module BABYLON {
  125166. /**
  125167. * Class used to store node based material build state
  125168. */
  125169. export class NodeMaterialBuildState {
  125170. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  125171. supportUniformBuffers: boolean;
  125172. /**
  125173. * Gets the list of emitted attributes
  125174. */
  125175. attributes: string[];
  125176. /**
  125177. * Gets the list of emitted uniforms
  125178. */
  125179. uniforms: string[];
  125180. /**
  125181. * Gets the list of emitted constants
  125182. */
  125183. constants: string[];
  125184. /**
  125185. * Gets the list of emitted samplers
  125186. */
  125187. samplers: string[];
  125188. /**
  125189. * Gets the list of emitted functions
  125190. */
  125191. functions: {
  125192. [key: string]: string;
  125193. };
  125194. /**
  125195. * Gets the list of emitted extensions
  125196. */
  125197. extensions: {
  125198. [key: string]: string;
  125199. };
  125200. /**
  125201. * Gets the target of the compilation state
  125202. */
  125203. target: NodeMaterialBlockTargets;
  125204. /**
  125205. * Gets the list of emitted counters
  125206. */
  125207. counters: {
  125208. [key: string]: number;
  125209. };
  125210. /**
  125211. * Shared data between multiple NodeMaterialBuildState instances
  125212. */
  125213. sharedData: NodeMaterialBuildStateSharedData;
  125214. /** @hidden */
  125215. _vertexState: NodeMaterialBuildState;
  125216. /** @hidden */
  125217. _attributeDeclaration: string;
  125218. /** @hidden */
  125219. _uniformDeclaration: string;
  125220. /** @hidden */
  125221. _constantDeclaration: string;
  125222. /** @hidden */
  125223. _samplerDeclaration: string;
  125224. /** @hidden */
  125225. _varyingTransfer: string;
  125226. private _repeatableContentAnchorIndex;
  125227. /** @hidden */
  125228. _builtCompilationString: string;
  125229. /**
  125230. * Gets the emitted compilation strings
  125231. */
  125232. compilationString: string;
  125233. /**
  125234. * Finalize the compilation strings
  125235. * @param state defines the current compilation state
  125236. */
  125237. finalize(state: NodeMaterialBuildState): void;
  125238. /** @hidden */
  125239. readonly _repeatableContentAnchor: string;
  125240. /** @hidden */
  125241. _getFreeVariableName(prefix: string): string;
  125242. /** @hidden */
  125243. _getFreeDefineName(prefix: string): string;
  125244. /** @hidden */
  125245. _excludeVariableName(name: string): void;
  125246. /** @hidden */
  125247. _emit2DSampler(name: string): void;
  125248. /** @hidden */
  125249. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  125250. /** @hidden */
  125251. _emitExtension(name: string, extension: string): void;
  125252. /** @hidden */
  125253. _emitFunction(name: string, code: string, comments: string): void;
  125254. /** @hidden */
  125255. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  125256. replaceStrings?: {
  125257. search: RegExp;
  125258. replace: string;
  125259. }[];
  125260. repeatKey?: string;
  125261. }): string;
  125262. /** @hidden */
  125263. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  125264. repeatKey?: string;
  125265. removeAttributes?: boolean;
  125266. removeUniforms?: boolean;
  125267. removeVaryings?: boolean;
  125268. removeIfDef?: boolean;
  125269. replaceStrings?: {
  125270. search: RegExp;
  125271. replace: string;
  125272. }[];
  125273. }, storeKey?: string): void;
  125274. /** @hidden */
  125275. _registerTempVariable(name: string): boolean;
  125276. /** @hidden */
  125277. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  125278. /** @hidden */
  125279. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  125280. /** @hidden */
  125281. _emitFloat(value: number): string;
  125282. }
  125283. }
  125284. declare module BABYLON {
  125285. /**
  125286. * Defines a block that can be used inside a node based material
  125287. */
  125288. export class NodeMaterialBlock {
  125289. private _buildId;
  125290. private _buildTarget;
  125291. private _target;
  125292. private _isFinalMerger;
  125293. private _isInput;
  125294. protected _isUnique: boolean;
  125295. /** @hidden */
  125296. _codeVariableName: string;
  125297. /** @hidden */
  125298. _inputs: NodeMaterialConnectionPoint[];
  125299. /** @hidden */
  125300. _outputs: NodeMaterialConnectionPoint[];
  125301. /** @hidden */
  125302. _preparationId: number;
  125303. /**
  125304. * Gets or sets the name of the block
  125305. */
  125306. name: string;
  125307. /**
  125308. * Gets or sets the unique id of the node
  125309. */
  125310. uniqueId: number;
  125311. /**
  125312. * Gets or sets the comments associated with this block
  125313. */
  125314. comments: string;
  125315. /**
  125316. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  125317. */
  125318. readonly isUnique: boolean;
  125319. /**
  125320. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  125321. */
  125322. readonly isFinalMerger: boolean;
  125323. /**
  125324. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  125325. */
  125326. readonly isInput: boolean;
  125327. /**
  125328. * Gets or sets the build Id
  125329. */
  125330. buildId: number;
  125331. /**
  125332. * Gets or sets the target of the block
  125333. */
  125334. target: NodeMaterialBlockTargets;
  125335. /**
  125336. * Gets the list of input points
  125337. */
  125338. readonly inputs: NodeMaterialConnectionPoint[];
  125339. /** Gets the list of output points */
  125340. readonly outputs: NodeMaterialConnectionPoint[];
  125341. /**
  125342. * Find an input by its name
  125343. * @param name defines the name of the input to look for
  125344. * @returns the input or null if not found
  125345. */
  125346. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  125347. /**
  125348. * Find an output by its name
  125349. * @param name defines the name of the outputto look for
  125350. * @returns the output or null if not found
  125351. */
  125352. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  125353. /**
  125354. * Creates a new NodeMaterialBlock
  125355. * @param name defines the block name
  125356. * @param target defines the target of that block (Vertex by default)
  125357. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  125358. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  125359. */
  125360. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  125361. /**
  125362. * Initialize the block and prepare the context for build
  125363. * @param state defines the state that will be used for the build
  125364. */
  125365. initialize(state: NodeMaterialBuildState): void;
  125366. /**
  125367. * Bind data to effect. Will only be called for blocks with isBindable === true
  125368. * @param effect defines the effect to bind data to
  125369. * @param nodeMaterial defines the hosting NodeMaterial
  125370. * @param mesh defines the mesh that will be rendered
  125371. */
  125372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125373. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  125374. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  125375. protected _writeFloat(value: number): string;
  125376. /**
  125377. * Gets the current class name e.g. "NodeMaterialBlock"
  125378. * @returns the class name
  125379. */
  125380. getClassName(): string;
  125381. /**
  125382. * Register a new input. Must be called inside a block constructor
  125383. * @param name defines the connection point name
  125384. * @param type defines the connection point type
  125385. * @param isOptional defines a boolean indicating that this input can be omitted
  125386. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  125387. * @returns the current block
  125388. */
  125389. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  125390. /**
  125391. * Register a new output. Must be called inside a block constructor
  125392. * @param name defines the connection point name
  125393. * @param type defines the connection point type
  125394. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  125395. * @returns the current block
  125396. */
  125397. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  125398. /**
  125399. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  125400. * @param forOutput defines an optional connection point to check compatibility with
  125401. * @returns the first available input or null
  125402. */
  125403. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  125404. /**
  125405. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  125406. * @param forBlock defines an optional block to check compatibility with
  125407. * @returns the first available input or null
  125408. */
  125409. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  125410. /**
  125411. * Gets the sibling of the given output
  125412. * @param current defines the current output
  125413. * @returns the next output in the list or null
  125414. */
  125415. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  125416. /**
  125417. * Connect current block with another block
  125418. * @param other defines the block to connect with
  125419. * @param options define the various options to help pick the right connections
  125420. * @returns the current block
  125421. */
  125422. connectTo(other: NodeMaterialBlock, options?: {
  125423. input?: string;
  125424. output?: string;
  125425. outputSwizzle?: string;
  125426. }): this | undefined;
  125427. protected _buildBlock(state: NodeMaterialBuildState): void;
  125428. /**
  125429. * Add uniforms, samplers and uniform buffers at compilation time
  125430. * @param state defines the state to update
  125431. * @param nodeMaterial defines the node material requesting the update
  125432. * @param defines defines the material defines to update
  125433. * @param uniformBuffers defines the list of uniform buffer names
  125434. */
  125435. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  125436. /**
  125437. * Add potential fallbacks if shader compilation fails
  125438. * @param mesh defines the mesh to be rendered
  125439. * @param fallbacks defines the current prioritized list of fallbacks
  125440. */
  125441. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  125442. /**
  125443. * Initialize defines for shader compilation
  125444. * @param mesh defines the mesh to be rendered
  125445. * @param nodeMaterial defines the node material requesting the update
  125446. * @param defines defines the material defines to update
  125447. * @param useInstances specifies that instances should be used
  125448. */
  125449. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  125450. /**
  125451. * Update defines for shader compilation
  125452. * @param mesh defines the mesh to be rendered
  125453. * @param nodeMaterial defines the node material requesting the update
  125454. * @param defines defines the material defines to update
  125455. * @param useInstances specifies that instances should be used
  125456. */
  125457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  125458. /**
  125459. * Lets the block try to connect some inputs automatically
  125460. * @param material defines the hosting NodeMaterial
  125461. */
  125462. autoConfigure(material: NodeMaterial): void;
  125463. /**
  125464. * Function called when a block is declared as repeatable content generator
  125465. * @param vertexShaderState defines the current compilation state for the vertex shader
  125466. * @param fragmentShaderState defines the current compilation state for the fragment shader
  125467. * @param mesh defines the mesh to be rendered
  125468. * @param defines defines the material defines to update
  125469. */
  125470. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  125471. /**
  125472. * Checks if the block is ready
  125473. * @param mesh defines the mesh to be rendered
  125474. * @param nodeMaterial defines the node material requesting the update
  125475. * @param defines defines the material defines to update
  125476. * @param useInstances specifies that instances should be used
  125477. * @returns true if the block is ready
  125478. */
  125479. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  125480. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  125481. private _processBuild;
  125482. /**
  125483. * Compile the current node and generate the shader code
  125484. * @param state defines the current compilation state (uniforms, samplers, current string)
  125485. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  125486. * @returns true if already built
  125487. */
  125488. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  125489. protected _inputRename(name: string): string;
  125490. protected _outputRename(name: string): string;
  125491. protected _dumpPropertiesCode(): string;
  125492. /** @hidden */
  125493. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  125494. /** @hidden */
  125495. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  125496. /**
  125497. * Clone the current block to a new identical block
  125498. * @param scene defines the hosting scene
  125499. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  125500. * @returns a copy of the current block
  125501. */
  125502. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  125503. /**
  125504. * Serializes this block in a JSON representation
  125505. * @returns the serialized block object
  125506. */
  125507. serialize(): any;
  125508. /** @hidden */
  125509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125510. /**
  125511. * Release resources
  125512. */
  125513. dispose(): void;
  125514. }
  125515. }
  125516. declare module BABYLON {
  125517. /**
  125518. * Enum defining the type of animations supported by InputBlock
  125519. */
  125520. export enum AnimatedInputBlockTypes {
  125521. /** No animation */
  125522. None = 0,
  125523. /** Time based animation. Will only work for floats */
  125524. Time = 1
  125525. }
  125526. }
  125527. declare module BABYLON {
  125528. /**
  125529. * Block used to expose an input value
  125530. */
  125531. export class InputBlock extends NodeMaterialBlock {
  125532. private _mode;
  125533. private _associatedVariableName;
  125534. private _storedValue;
  125535. private _valueCallback;
  125536. private _type;
  125537. private _animationType;
  125538. /** Gets or set a value used to limit the range of float values */
  125539. min: number;
  125540. /** Gets or set a value used to limit the range of float values */
  125541. max: number;
  125542. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  125543. matrixMode: number;
  125544. /** @hidden */
  125545. _systemValue: Nullable<NodeMaterialSystemValues>;
  125546. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  125547. visibleInInspector: boolean;
  125548. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  125549. isConstant: boolean;
  125550. /** Gets or sets the group to use to display this block in the Inspector */
  125551. groupInInspector: string;
  125552. /**
  125553. * Gets or sets the connection point type (default is float)
  125554. */
  125555. readonly type: NodeMaterialBlockConnectionPointTypes;
  125556. /**
  125557. * Creates a new InputBlock
  125558. * @param name defines the block name
  125559. * @param target defines the target of that block (Vertex by default)
  125560. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  125561. */
  125562. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  125563. /**
  125564. * Gets the output component
  125565. */
  125566. readonly output: NodeMaterialConnectionPoint;
  125567. /**
  125568. * Set the source of this connection point to a vertex attribute
  125569. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  125570. * @returns the current connection point
  125571. */
  125572. setAsAttribute(attributeName?: string): InputBlock;
  125573. /**
  125574. * Set the source of this connection point to a system value
  125575. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  125576. * @returns the current connection point
  125577. */
  125578. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  125579. /**
  125580. * Gets or sets the value of that point.
  125581. * Please note that this value will be ignored if valueCallback is defined
  125582. */
  125583. value: any;
  125584. /**
  125585. * Gets or sets a callback used to get the value of that point.
  125586. * Please note that setting this value will force the connection point to ignore the value property
  125587. */
  125588. valueCallback: () => any;
  125589. /**
  125590. * Gets or sets the associated variable name in the shader
  125591. */
  125592. associatedVariableName: string;
  125593. /** Gets or sets the type of animation applied to the input */
  125594. animationType: AnimatedInputBlockTypes;
  125595. /**
  125596. * Gets a boolean indicating that this connection point not defined yet
  125597. */
  125598. readonly isUndefined: boolean;
  125599. /**
  125600. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  125601. * In this case the connection point name must be the name of the uniform to use.
  125602. * Can only be set on inputs
  125603. */
  125604. isUniform: boolean;
  125605. /**
  125606. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  125607. * In this case the connection point name must be the name of the attribute to use
  125608. * Can only be set on inputs
  125609. */
  125610. isAttribute: boolean;
  125611. /**
  125612. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  125613. * Can only be set on exit points
  125614. */
  125615. isVarying: boolean;
  125616. /**
  125617. * Gets a boolean indicating that the current connection point is a system value
  125618. */
  125619. readonly isSystemValue: boolean;
  125620. /**
  125621. * Gets or sets the current well known value or null if not defined as a system value
  125622. */
  125623. systemValue: Nullable<NodeMaterialSystemValues>;
  125624. /**
  125625. * Gets the current class name
  125626. * @returns the class name
  125627. */
  125628. getClassName(): string;
  125629. /**
  125630. * Animate the input if animationType !== None
  125631. * @param scene defines the rendering scene
  125632. */
  125633. animate(scene: Scene): void;
  125634. private _emitDefine;
  125635. initialize(state: NodeMaterialBuildState): void;
  125636. /**
  125637. * Set the input block to its default value (based on its type)
  125638. */
  125639. setDefaultValue(): void;
  125640. private _emitConstant;
  125641. private _emit;
  125642. /** @hidden */
  125643. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  125644. /** @hidden */
  125645. _transmit(effect: Effect, scene: Scene): void;
  125646. protected _buildBlock(state: NodeMaterialBuildState): void;
  125647. protected _dumpPropertiesCode(): string;
  125648. serialize(): any;
  125649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125650. }
  125651. }
  125652. declare module BABYLON {
  125653. /**
  125654. * Enum used to define the compatibility state between two connection points
  125655. */
  125656. export enum NodeMaterialConnectionPointCompatibilityStates {
  125657. /** Points are compatibles */
  125658. Compatible = 0,
  125659. /** Points are incompatible because of their types */
  125660. TypeIncompatible = 1,
  125661. /** Points are incompatible because of their targets (vertex vs fragment) */
  125662. TargetIncompatible = 2
  125663. }
  125664. /**
  125665. * Defines the direction of a connection point
  125666. */
  125667. export enum NodeMaterialConnectionPointDirection {
  125668. /** Input */
  125669. Input = 0,
  125670. /** Output */
  125671. Output = 1
  125672. }
  125673. /**
  125674. * Defines a connection point for a block
  125675. */
  125676. export class NodeMaterialConnectionPoint {
  125677. /** @hidden */
  125678. _ownerBlock: NodeMaterialBlock;
  125679. /** @hidden */
  125680. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  125681. private _endpoints;
  125682. private _associatedVariableName;
  125683. private _direction;
  125684. /** @hidden */
  125685. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  125686. /** @hidden */
  125687. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  125688. private _type;
  125689. /** @hidden */
  125690. _enforceAssociatedVariableName: boolean;
  125691. /** Gets the direction of the point */
  125692. readonly direction: NodeMaterialConnectionPointDirection;
  125693. /**
  125694. * Gets or sets the additional types supported by this connection point
  125695. */
  125696. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  125697. /**
  125698. * Gets or sets the additional types excluded by this connection point
  125699. */
  125700. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  125701. /**
  125702. * Observable triggered when this point is connected
  125703. */
  125704. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  125705. /**
  125706. * Gets or sets the associated variable name in the shader
  125707. */
  125708. associatedVariableName: string;
  125709. /**
  125710. * Gets or sets the connection point type (default is float)
  125711. */
  125712. type: NodeMaterialBlockConnectionPointTypes;
  125713. /**
  125714. * Gets or sets the connection point name
  125715. */
  125716. name: string;
  125717. /**
  125718. * Gets or sets a boolean indicating that this connection point can be omitted
  125719. */
  125720. isOptional: boolean;
  125721. /**
  125722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  125723. */
  125724. define: string;
  125725. /** @hidden */
  125726. _prioritizeVertex: boolean;
  125727. private _target;
  125728. /** Gets or sets the target of that connection point */
  125729. target: NodeMaterialBlockTargets;
  125730. /**
  125731. * Gets a boolean indicating that the current point is connected
  125732. */
  125733. readonly isConnected: boolean;
  125734. /**
  125735. * Gets a boolean indicating that the current point is connected to an input block
  125736. */
  125737. readonly isConnectedToInputBlock: boolean;
  125738. /**
  125739. * Gets a the connected input block (if any)
  125740. */
  125741. readonly connectInputBlock: Nullable<InputBlock>;
  125742. /** Get the other side of the connection (if any) */
  125743. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  125744. /** Get the block that owns this connection point */
  125745. readonly ownerBlock: NodeMaterialBlock;
  125746. /** Get the block connected on the other side of this connection (if any) */
  125747. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  125748. /** Get the block connected on the endpoints of this connection (if any) */
  125749. readonly connectedBlocks: Array<NodeMaterialBlock>;
  125750. /** Gets the list of connected endpoints */
  125751. readonly endpoints: NodeMaterialConnectionPoint[];
  125752. /** Gets a boolean indicating if that output point is connected to at least one input */
  125753. readonly hasEndpoints: boolean;
  125754. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  125755. readonly isConnectedInVertexShader: boolean;
  125756. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  125757. readonly isConnectedInFragmentShader: boolean;
  125758. /**
  125759. * Creates a new connection point
  125760. * @param name defines the connection point name
  125761. * @param ownerBlock defines the block hosting this connection point
  125762. * @param direction defines the direction of the connection point
  125763. */
  125764. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  125765. /**
  125766. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  125767. * @returns the class name
  125768. */
  125769. getClassName(): string;
  125770. /**
  125771. * Gets a boolean indicating if the current point can be connected to another point
  125772. * @param connectionPoint defines the other connection point
  125773. * @returns a boolean
  125774. */
  125775. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  125776. /**
  125777. * Gets a number indicating if the current point can be connected to another point
  125778. * @param connectionPoint defines the other connection point
  125779. * @returns a number defining the compatibility state
  125780. */
  125781. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  125782. /**
  125783. * Connect this point to another connection point
  125784. * @param connectionPoint defines the other connection point
  125785. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  125786. * @returns the current connection point
  125787. */
  125788. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  125789. /**
  125790. * Disconnect this point from one of his endpoint
  125791. * @param endpoint defines the other connection point
  125792. * @returns the current connection point
  125793. */
  125794. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  125795. /**
  125796. * Serializes this point in a JSON representation
  125797. * @returns the serialized point object
  125798. */
  125799. serialize(): any;
  125800. /**
  125801. * Release resources
  125802. */
  125803. dispose(): void;
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. * Block used to add support for vertex skinning (bones)
  125809. */
  125810. export class BonesBlock extends NodeMaterialBlock {
  125811. /**
  125812. * Creates a new BonesBlock
  125813. * @param name defines the block name
  125814. */
  125815. constructor(name: string);
  125816. /**
  125817. * Initialize the block and prepare the context for build
  125818. * @param state defines the state that will be used for the build
  125819. */
  125820. initialize(state: NodeMaterialBuildState): void;
  125821. /**
  125822. * Gets the current class name
  125823. * @returns the class name
  125824. */
  125825. getClassName(): string;
  125826. /**
  125827. * Gets the matrix indices input component
  125828. */
  125829. readonly matricesIndices: NodeMaterialConnectionPoint;
  125830. /**
  125831. * Gets the matrix weights input component
  125832. */
  125833. readonly matricesWeights: NodeMaterialConnectionPoint;
  125834. /**
  125835. * Gets the extra matrix indices input component
  125836. */
  125837. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  125838. /**
  125839. * Gets the extra matrix weights input component
  125840. */
  125841. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  125842. /**
  125843. * Gets the world input component
  125844. */
  125845. readonly world: NodeMaterialConnectionPoint;
  125846. /**
  125847. * Gets the output component
  125848. */
  125849. readonly output: NodeMaterialConnectionPoint;
  125850. autoConfigure(material: NodeMaterial): void;
  125851. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  125852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125854. protected _buildBlock(state: NodeMaterialBuildState): this;
  125855. }
  125856. }
  125857. declare module BABYLON {
  125858. /**
  125859. * Block used to add support for instances
  125860. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  125861. */
  125862. export class InstancesBlock extends NodeMaterialBlock {
  125863. /**
  125864. * Creates a new InstancesBlock
  125865. * @param name defines the block name
  125866. */
  125867. constructor(name: string);
  125868. /**
  125869. * Gets the current class name
  125870. * @returns the class name
  125871. */
  125872. getClassName(): string;
  125873. /**
  125874. * Gets the first world row input component
  125875. */
  125876. readonly world0: NodeMaterialConnectionPoint;
  125877. /**
  125878. * Gets the second world row input component
  125879. */
  125880. readonly world1: NodeMaterialConnectionPoint;
  125881. /**
  125882. * Gets the third world row input component
  125883. */
  125884. readonly world2: NodeMaterialConnectionPoint;
  125885. /**
  125886. * Gets the forth world row input component
  125887. */
  125888. readonly world3: NodeMaterialConnectionPoint;
  125889. /**
  125890. * Gets the world input component
  125891. */
  125892. readonly world: NodeMaterialConnectionPoint;
  125893. /**
  125894. * Gets the output component
  125895. */
  125896. readonly output: NodeMaterialConnectionPoint;
  125897. autoConfigure(material: NodeMaterial): void;
  125898. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  125899. protected _buildBlock(state: NodeMaterialBuildState): this;
  125900. }
  125901. }
  125902. declare module BABYLON {
  125903. /**
  125904. * Block used to add morph targets support to vertex shader
  125905. */
  125906. export class MorphTargetsBlock extends NodeMaterialBlock {
  125907. private _repeatableContentAnchor;
  125908. private _repeatebleContentGenerated;
  125909. /**
  125910. * Create a new MorphTargetsBlock
  125911. * @param name defines the block name
  125912. */
  125913. constructor(name: string);
  125914. /**
  125915. * Gets the current class name
  125916. * @returns the class name
  125917. */
  125918. getClassName(): string;
  125919. /**
  125920. * Gets the position input component
  125921. */
  125922. readonly position: NodeMaterialConnectionPoint;
  125923. /**
  125924. * Gets the normal input component
  125925. */
  125926. readonly normal: NodeMaterialConnectionPoint;
  125927. /**
  125928. * Gets the tangent input component
  125929. */
  125930. readonly tangent: NodeMaterialConnectionPoint;
  125931. /**
  125932. * Gets the tangent input component
  125933. */
  125934. readonly uv: NodeMaterialConnectionPoint;
  125935. /**
  125936. * Gets the position output component
  125937. */
  125938. readonly positionOutput: NodeMaterialConnectionPoint;
  125939. /**
  125940. * Gets the normal output component
  125941. */
  125942. readonly normalOutput: NodeMaterialConnectionPoint;
  125943. /**
  125944. * Gets the tangent output component
  125945. */
  125946. readonly tangentOutput: NodeMaterialConnectionPoint;
  125947. /**
  125948. * Gets the tangent output component
  125949. */
  125950. readonly uvOutput: NodeMaterialConnectionPoint;
  125951. initialize(state: NodeMaterialBuildState): void;
  125952. autoConfigure(material: NodeMaterial): void;
  125953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125955. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  125956. protected _buildBlock(state: NodeMaterialBuildState): this;
  125957. }
  125958. }
  125959. declare module BABYLON {
  125960. /**
  125961. * Block used to get data information from a light
  125962. */
  125963. export class LightInformationBlock extends NodeMaterialBlock {
  125964. private _lightDataUniformName;
  125965. private _lightColorUniformName;
  125966. private _lightTypeDefineName;
  125967. /**
  125968. * Gets or sets the light associated with this block
  125969. */
  125970. light: Nullable<Light>;
  125971. /**
  125972. * Creates a new LightInformationBlock
  125973. * @param name defines the block name
  125974. */
  125975. constructor(name: string);
  125976. /**
  125977. * Gets the current class name
  125978. * @returns the class name
  125979. */
  125980. getClassName(): string;
  125981. /**
  125982. * Gets the world position input component
  125983. */
  125984. readonly worldPosition: NodeMaterialConnectionPoint;
  125985. /**
  125986. * Gets the direction output component
  125987. */
  125988. readonly direction: NodeMaterialConnectionPoint;
  125989. /**
  125990. * Gets the direction output component
  125991. */
  125992. readonly color: NodeMaterialConnectionPoint;
  125993. /**
  125994. * Gets the direction output component
  125995. */
  125996. readonly intensity: NodeMaterialConnectionPoint;
  125997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125999. protected _buildBlock(state: NodeMaterialBuildState): this;
  126000. serialize(): any;
  126001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126002. }
  126003. }
  126004. declare module BABYLON {
  126005. /**
  126006. * Block used to add image processing support to fragment shader
  126007. */
  126008. export class ImageProcessingBlock extends NodeMaterialBlock {
  126009. /**
  126010. * Create a new ImageProcessingBlock
  126011. * @param name defines the block name
  126012. */
  126013. constructor(name: string);
  126014. /**
  126015. * Gets the current class name
  126016. * @returns the class name
  126017. */
  126018. getClassName(): string;
  126019. /**
  126020. * Gets the color input component
  126021. */
  126022. readonly color: NodeMaterialConnectionPoint;
  126023. /**
  126024. * Gets the output component
  126025. */
  126026. readonly output: NodeMaterialConnectionPoint;
  126027. /**
  126028. * Initialize the block and prepare the context for build
  126029. * @param state defines the state that will be used for the build
  126030. */
  126031. initialize(state: NodeMaterialBuildState): void;
  126032. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  126033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126035. protected _buildBlock(state: NodeMaterialBuildState): this;
  126036. }
  126037. }
  126038. declare module BABYLON {
  126039. /**
  126040. * Block used to pertub normals based on a normal map
  126041. */
  126042. export class PerturbNormalBlock extends NodeMaterialBlock {
  126043. private _tangentSpaceParameterName;
  126044. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  126045. invertX: boolean;
  126046. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  126047. invertY: boolean;
  126048. /**
  126049. * Create a new PerturbNormalBlock
  126050. * @param name defines the block name
  126051. */
  126052. constructor(name: string);
  126053. /**
  126054. * Gets the current class name
  126055. * @returns the class name
  126056. */
  126057. getClassName(): string;
  126058. /**
  126059. * Gets the world position input component
  126060. */
  126061. readonly worldPosition: NodeMaterialConnectionPoint;
  126062. /**
  126063. * Gets the world normal input component
  126064. */
  126065. readonly worldNormal: NodeMaterialConnectionPoint;
  126066. /**
  126067. * Gets the uv input component
  126068. */
  126069. readonly uv: NodeMaterialConnectionPoint;
  126070. /**
  126071. * Gets the normal map color input component
  126072. */
  126073. readonly normalMapColor: NodeMaterialConnectionPoint;
  126074. /**
  126075. * Gets the strength input component
  126076. */
  126077. readonly strength: NodeMaterialConnectionPoint;
  126078. /**
  126079. * Gets the output component
  126080. */
  126081. readonly output: NodeMaterialConnectionPoint;
  126082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126084. autoConfigure(material: NodeMaterial): void;
  126085. protected _buildBlock(state: NodeMaterialBuildState): this;
  126086. protected _dumpPropertiesCode(): string;
  126087. serialize(): any;
  126088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126089. }
  126090. }
  126091. declare module BABYLON {
  126092. /**
  126093. * Block used to discard a pixel if a value is smaller than a cutoff
  126094. */
  126095. export class DiscardBlock extends NodeMaterialBlock {
  126096. /**
  126097. * Create a new DiscardBlock
  126098. * @param name defines the block name
  126099. */
  126100. constructor(name: string);
  126101. /**
  126102. * Gets the current class name
  126103. * @returns the class name
  126104. */
  126105. getClassName(): string;
  126106. /**
  126107. * Gets the color input component
  126108. */
  126109. readonly value: NodeMaterialConnectionPoint;
  126110. /**
  126111. * Gets the cutoff input component
  126112. */
  126113. readonly cutoff: NodeMaterialConnectionPoint;
  126114. protected _buildBlock(state: NodeMaterialBuildState): this;
  126115. }
  126116. }
  126117. declare module BABYLON {
  126118. /**
  126119. * Block used to test if the fragment shader is front facing
  126120. */
  126121. export class FrontFacingBlock extends NodeMaterialBlock {
  126122. /**
  126123. * Creates a new FrontFacingBlock
  126124. * @param name defines the block name
  126125. */
  126126. constructor(name: string);
  126127. /**
  126128. * Gets the current class name
  126129. * @returns the class name
  126130. */
  126131. getClassName(): string;
  126132. /**
  126133. * Gets the output component
  126134. */
  126135. readonly output: NodeMaterialConnectionPoint;
  126136. protected _buildBlock(state: NodeMaterialBuildState): this;
  126137. }
  126138. }
  126139. declare module BABYLON {
  126140. /**
  126141. * Block used to get the derivative value on x and y of a given input
  126142. */
  126143. export class DerivativeBlock extends NodeMaterialBlock {
  126144. /**
  126145. * Create a new DerivativeBlock
  126146. * @param name defines the block name
  126147. */
  126148. constructor(name: string);
  126149. /**
  126150. * Gets the current class name
  126151. * @returns the class name
  126152. */
  126153. getClassName(): string;
  126154. /**
  126155. * Gets the input component
  126156. */
  126157. readonly input: NodeMaterialConnectionPoint;
  126158. /**
  126159. * Gets the derivative output on x
  126160. */
  126161. readonly dx: NodeMaterialConnectionPoint;
  126162. /**
  126163. * Gets the derivative output on y
  126164. */
  126165. readonly dy: NodeMaterialConnectionPoint;
  126166. protected _buildBlock(state: NodeMaterialBuildState): this;
  126167. }
  126168. }
  126169. declare module BABYLON {
  126170. /**
  126171. * Block used to add support for scene fog
  126172. */
  126173. export class FogBlock extends NodeMaterialBlock {
  126174. private _fogDistanceName;
  126175. private _fogParameters;
  126176. /**
  126177. * Create a new FogBlock
  126178. * @param name defines the block name
  126179. */
  126180. constructor(name: string);
  126181. /**
  126182. * Gets the current class name
  126183. * @returns the class name
  126184. */
  126185. getClassName(): string;
  126186. /**
  126187. * Gets the world position input component
  126188. */
  126189. readonly worldPosition: NodeMaterialConnectionPoint;
  126190. /**
  126191. * Gets the view input component
  126192. */
  126193. readonly view: NodeMaterialConnectionPoint;
  126194. /**
  126195. * Gets the color input component
  126196. */
  126197. readonly input: NodeMaterialConnectionPoint;
  126198. /**
  126199. * Gets the fog color input component
  126200. */
  126201. readonly fogColor: NodeMaterialConnectionPoint;
  126202. /**
  126203. * Gets the output component
  126204. */
  126205. readonly output: NodeMaterialConnectionPoint;
  126206. autoConfigure(material: NodeMaterial): void;
  126207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126208. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126209. protected _buildBlock(state: NodeMaterialBuildState): this;
  126210. }
  126211. }
  126212. declare module BABYLON {
  126213. /**
  126214. * Block used to add light in the fragment shader
  126215. */
  126216. export class LightBlock extends NodeMaterialBlock {
  126217. private _lightId;
  126218. /**
  126219. * Gets or sets the light associated with this block
  126220. */
  126221. light: Nullable<Light>;
  126222. /**
  126223. * Create a new LightBlock
  126224. * @param name defines the block name
  126225. */
  126226. constructor(name: string);
  126227. /**
  126228. * Gets the current class name
  126229. * @returns the class name
  126230. */
  126231. getClassName(): string;
  126232. /**
  126233. * Gets the world position input component
  126234. */
  126235. readonly worldPosition: NodeMaterialConnectionPoint;
  126236. /**
  126237. * Gets the world normal input component
  126238. */
  126239. readonly worldNormal: NodeMaterialConnectionPoint;
  126240. /**
  126241. * Gets the camera (or eye) position component
  126242. */
  126243. readonly cameraPosition: NodeMaterialConnectionPoint;
  126244. /**
  126245. * Gets the glossiness component
  126246. */
  126247. readonly glossiness: NodeMaterialConnectionPoint;
  126248. /**
  126249. * Gets the glossinness power component
  126250. */
  126251. readonly glossPower: NodeMaterialConnectionPoint;
  126252. /**
  126253. * Gets the diffuse color component
  126254. */
  126255. readonly diffuseColor: NodeMaterialConnectionPoint;
  126256. /**
  126257. * Gets the specular color component
  126258. */
  126259. readonly specularColor: NodeMaterialConnectionPoint;
  126260. /**
  126261. * Gets the diffuse output component
  126262. */
  126263. readonly diffuseOutput: NodeMaterialConnectionPoint;
  126264. /**
  126265. * Gets the specular output component
  126266. */
  126267. readonly specularOutput: NodeMaterialConnectionPoint;
  126268. autoConfigure(material: NodeMaterial): void;
  126269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126270. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126271. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126272. private _injectVertexCode;
  126273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126274. serialize(): any;
  126275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126276. }
  126277. }
  126278. declare module BABYLON {
  126279. /**
  126280. * Block used to multiply 2 values
  126281. */
  126282. export class MultiplyBlock extends NodeMaterialBlock {
  126283. /**
  126284. * Creates a new MultiplyBlock
  126285. * @param name defines the block name
  126286. */
  126287. constructor(name: string);
  126288. /**
  126289. * Gets the current class name
  126290. * @returns the class name
  126291. */
  126292. getClassName(): string;
  126293. /**
  126294. * Gets the left operand input component
  126295. */
  126296. readonly left: NodeMaterialConnectionPoint;
  126297. /**
  126298. * Gets the right operand input component
  126299. */
  126300. readonly right: NodeMaterialConnectionPoint;
  126301. /**
  126302. * Gets the output component
  126303. */
  126304. readonly output: NodeMaterialConnectionPoint;
  126305. protected _buildBlock(state: NodeMaterialBuildState): this;
  126306. }
  126307. }
  126308. declare module BABYLON {
  126309. /**
  126310. * Block used to add 2 vectors
  126311. */
  126312. export class AddBlock extends NodeMaterialBlock {
  126313. /**
  126314. * Creates a new AddBlock
  126315. * @param name defines the block name
  126316. */
  126317. constructor(name: string);
  126318. /**
  126319. * Gets the current class name
  126320. * @returns the class name
  126321. */
  126322. getClassName(): string;
  126323. /**
  126324. * Gets the left operand input component
  126325. */
  126326. readonly left: NodeMaterialConnectionPoint;
  126327. /**
  126328. * Gets the right operand input component
  126329. */
  126330. readonly right: NodeMaterialConnectionPoint;
  126331. /**
  126332. * Gets the output component
  126333. */
  126334. readonly output: NodeMaterialConnectionPoint;
  126335. protected _buildBlock(state: NodeMaterialBuildState): this;
  126336. }
  126337. }
  126338. declare module BABYLON {
  126339. /**
  126340. * Block used to scale a vector by a float
  126341. */
  126342. export class ScaleBlock extends NodeMaterialBlock {
  126343. /**
  126344. * Creates a new ScaleBlock
  126345. * @param name defines the block name
  126346. */
  126347. constructor(name: string);
  126348. /**
  126349. * Gets the current class name
  126350. * @returns the class name
  126351. */
  126352. getClassName(): string;
  126353. /**
  126354. * Gets the input component
  126355. */
  126356. readonly input: NodeMaterialConnectionPoint;
  126357. /**
  126358. * Gets the factor input component
  126359. */
  126360. readonly factor: NodeMaterialConnectionPoint;
  126361. /**
  126362. * Gets the output component
  126363. */
  126364. readonly output: NodeMaterialConnectionPoint;
  126365. protected _buildBlock(state: NodeMaterialBuildState): this;
  126366. }
  126367. }
  126368. declare module BABYLON {
  126369. /**
  126370. * Block used to clamp a float
  126371. */
  126372. export class ClampBlock extends NodeMaterialBlock {
  126373. /** Gets or sets the minimum range */
  126374. minimum: number;
  126375. /** Gets or sets the maximum range */
  126376. maximum: number;
  126377. /**
  126378. * Creates a new ClampBlock
  126379. * @param name defines the block name
  126380. */
  126381. constructor(name: string);
  126382. /**
  126383. * Gets the current class name
  126384. * @returns the class name
  126385. */
  126386. getClassName(): string;
  126387. /**
  126388. * Gets the value input component
  126389. */
  126390. readonly value: NodeMaterialConnectionPoint;
  126391. /**
  126392. * Gets the output component
  126393. */
  126394. readonly output: NodeMaterialConnectionPoint;
  126395. protected _buildBlock(state: NodeMaterialBuildState): this;
  126396. protected _dumpPropertiesCode(): string;
  126397. serialize(): any;
  126398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126399. }
  126400. }
  126401. declare module BABYLON {
  126402. /**
  126403. * Block used to apply a cross product between 2 vectors
  126404. */
  126405. export class CrossBlock extends NodeMaterialBlock {
  126406. /**
  126407. * Creates a new CrossBlock
  126408. * @param name defines the block name
  126409. */
  126410. constructor(name: string);
  126411. /**
  126412. * Gets the current class name
  126413. * @returns the class name
  126414. */
  126415. getClassName(): string;
  126416. /**
  126417. * Gets the left operand input component
  126418. */
  126419. readonly left: NodeMaterialConnectionPoint;
  126420. /**
  126421. * Gets the right operand input component
  126422. */
  126423. readonly right: NodeMaterialConnectionPoint;
  126424. /**
  126425. * Gets the output component
  126426. */
  126427. readonly output: NodeMaterialConnectionPoint;
  126428. protected _buildBlock(state: NodeMaterialBuildState): this;
  126429. }
  126430. }
  126431. declare module BABYLON {
  126432. /**
  126433. * Block used to apply a dot product between 2 vectors
  126434. */
  126435. export class DotBlock extends NodeMaterialBlock {
  126436. /**
  126437. * Creates a new DotBlock
  126438. * @param name defines the block name
  126439. */
  126440. constructor(name: string);
  126441. /**
  126442. * Gets the current class name
  126443. * @returns the class name
  126444. */
  126445. getClassName(): string;
  126446. /**
  126447. * Gets the left operand input component
  126448. */
  126449. readonly left: NodeMaterialConnectionPoint;
  126450. /**
  126451. * Gets the right operand input component
  126452. */
  126453. readonly right: NodeMaterialConnectionPoint;
  126454. /**
  126455. * Gets the output component
  126456. */
  126457. readonly output: NodeMaterialConnectionPoint;
  126458. protected _buildBlock(state: NodeMaterialBuildState): this;
  126459. }
  126460. }
  126461. declare module BABYLON {
  126462. /**
  126463. * Block used to remap a float from a range to a new one
  126464. */
  126465. export class RemapBlock extends NodeMaterialBlock {
  126466. /**
  126467. * Gets or sets the source range
  126468. */
  126469. sourceRange: Vector2;
  126470. /**
  126471. * Gets or sets the target range
  126472. */
  126473. targetRange: Vector2;
  126474. /**
  126475. * Creates a new RemapBlock
  126476. * @param name defines the block name
  126477. */
  126478. constructor(name: string);
  126479. /**
  126480. * Gets the current class name
  126481. * @returns the class name
  126482. */
  126483. getClassName(): string;
  126484. /**
  126485. * Gets the input component
  126486. */
  126487. readonly input: NodeMaterialConnectionPoint;
  126488. /**
  126489. * Gets the source min input component
  126490. */
  126491. readonly sourceMin: NodeMaterialConnectionPoint;
  126492. /**
  126493. * Gets the source max input component
  126494. */
  126495. readonly sourceMax: NodeMaterialConnectionPoint;
  126496. /**
  126497. * Gets the target min input component
  126498. */
  126499. readonly targetMin: NodeMaterialConnectionPoint;
  126500. /**
  126501. * Gets the target max input component
  126502. */
  126503. readonly targetMax: NodeMaterialConnectionPoint;
  126504. /**
  126505. * Gets the output component
  126506. */
  126507. readonly output: NodeMaterialConnectionPoint;
  126508. protected _buildBlock(state: NodeMaterialBuildState): this;
  126509. protected _dumpPropertiesCode(): string;
  126510. serialize(): any;
  126511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126512. }
  126513. }
  126514. declare module BABYLON {
  126515. /**
  126516. * Block used to normalize a vector
  126517. */
  126518. export class NormalizeBlock extends NodeMaterialBlock {
  126519. /**
  126520. * Creates a new NormalizeBlock
  126521. * @param name defines the block name
  126522. */
  126523. constructor(name: string);
  126524. /**
  126525. * Gets the current class name
  126526. * @returns the class name
  126527. */
  126528. getClassName(): string;
  126529. /**
  126530. * Gets the input component
  126531. */
  126532. readonly input: NodeMaterialConnectionPoint;
  126533. /**
  126534. * Gets the output component
  126535. */
  126536. readonly output: NodeMaterialConnectionPoint;
  126537. protected _buildBlock(state: NodeMaterialBuildState): this;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Operations supported by the Trigonometry block
  126543. */
  126544. export enum TrigonometryBlockOperations {
  126545. /** Cos */
  126546. Cos = 0,
  126547. /** Sin */
  126548. Sin = 1,
  126549. /** Abs */
  126550. Abs = 2,
  126551. /** Exp */
  126552. Exp = 3,
  126553. /** Exp2 */
  126554. Exp2 = 4,
  126555. /** Round */
  126556. Round = 5,
  126557. /** Floor */
  126558. Floor = 6,
  126559. /** Ceiling */
  126560. Ceiling = 7,
  126561. /** Square root */
  126562. Sqrt = 8,
  126563. /** Log */
  126564. Log = 9,
  126565. /** Tangent */
  126566. Tan = 10,
  126567. /** Arc tangent */
  126568. ArcTan = 11,
  126569. /** Arc cosinus */
  126570. ArcCos = 12,
  126571. /** Arc sinus */
  126572. ArcSin = 13,
  126573. /** Fraction */
  126574. Fract = 14,
  126575. /** Sign */
  126576. Sign = 15,
  126577. /** To radians (from degrees) */
  126578. Radians = 16,
  126579. /** To degrees (from radians) */
  126580. Degrees = 17
  126581. }
  126582. /**
  126583. * Block used to apply trigonometry operation to floats
  126584. */
  126585. export class TrigonometryBlock extends NodeMaterialBlock {
  126586. /**
  126587. * Gets or sets the operation applied by the block
  126588. */
  126589. operation: TrigonometryBlockOperations;
  126590. /**
  126591. * Creates a new TrigonometryBlock
  126592. * @param name defines the block name
  126593. */
  126594. constructor(name: string);
  126595. /**
  126596. * Gets the current class name
  126597. * @returns the class name
  126598. */
  126599. getClassName(): string;
  126600. /**
  126601. * Gets the input component
  126602. */
  126603. readonly input: NodeMaterialConnectionPoint;
  126604. /**
  126605. * Gets the output component
  126606. */
  126607. readonly output: NodeMaterialConnectionPoint;
  126608. protected _buildBlock(state: NodeMaterialBuildState): this;
  126609. serialize(): any;
  126610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126611. protected _dumpPropertiesCode(): string;
  126612. }
  126613. }
  126614. declare module BABYLON {
  126615. /**
  126616. * Block used to create a Color3/4 out of individual inputs (one for each component)
  126617. */
  126618. export class ColorMergerBlock extends NodeMaterialBlock {
  126619. /**
  126620. * Create a new ColorMergerBlock
  126621. * @param name defines the block name
  126622. */
  126623. constructor(name: string);
  126624. /**
  126625. * Gets the current class name
  126626. * @returns the class name
  126627. */
  126628. getClassName(): string;
  126629. /**
  126630. * Gets the rgb component (input)
  126631. */
  126632. readonly rgbIn: NodeMaterialConnectionPoint;
  126633. /**
  126634. * Gets the r component (input)
  126635. */
  126636. readonly r: NodeMaterialConnectionPoint;
  126637. /**
  126638. * Gets the g component (input)
  126639. */
  126640. readonly g: NodeMaterialConnectionPoint;
  126641. /**
  126642. * Gets the b component (input)
  126643. */
  126644. readonly b: NodeMaterialConnectionPoint;
  126645. /**
  126646. * Gets the a component (input)
  126647. */
  126648. readonly a: NodeMaterialConnectionPoint;
  126649. /**
  126650. * Gets the rgba component (output)
  126651. */
  126652. readonly rgba: NodeMaterialConnectionPoint;
  126653. /**
  126654. * Gets the rgb component (output)
  126655. */
  126656. readonly rgbOut: NodeMaterialConnectionPoint;
  126657. /**
  126658. * Gets the rgb component (output)
  126659. * @deprecated Please use rgbOut instead.
  126660. */
  126661. readonly rgb: NodeMaterialConnectionPoint;
  126662. protected _buildBlock(state: NodeMaterialBuildState): this;
  126663. }
  126664. }
  126665. declare module BABYLON {
  126666. /**
  126667. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  126668. */
  126669. export class VectorMergerBlock extends NodeMaterialBlock {
  126670. /**
  126671. * Create a new VectorMergerBlock
  126672. * @param name defines the block name
  126673. */
  126674. constructor(name: string);
  126675. /**
  126676. * Gets the current class name
  126677. * @returns the class name
  126678. */
  126679. getClassName(): string;
  126680. /**
  126681. * Gets the xyz component (input)
  126682. */
  126683. readonly xyzIn: NodeMaterialConnectionPoint;
  126684. /**
  126685. * Gets the xy component (input)
  126686. */
  126687. readonly xyIn: NodeMaterialConnectionPoint;
  126688. /**
  126689. * Gets the x component (input)
  126690. */
  126691. readonly x: NodeMaterialConnectionPoint;
  126692. /**
  126693. * Gets the y component (input)
  126694. */
  126695. readonly y: NodeMaterialConnectionPoint;
  126696. /**
  126697. * Gets the z component (input)
  126698. */
  126699. readonly z: NodeMaterialConnectionPoint;
  126700. /**
  126701. * Gets the w component (input)
  126702. */
  126703. readonly w: NodeMaterialConnectionPoint;
  126704. /**
  126705. * Gets the xyzw component (output)
  126706. */
  126707. readonly xyzw: NodeMaterialConnectionPoint;
  126708. /**
  126709. * Gets the xyz component (output)
  126710. */
  126711. readonly xyzOut: NodeMaterialConnectionPoint;
  126712. /**
  126713. * Gets the xy component (output)
  126714. */
  126715. readonly xyOut: NodeMaterialConnectionPoint;
  126716. /**
  126717. * Gets the xy component (output)
  126718. * @deprecated Please use xyOut instead.
  126719. */
  126720. readonly xy: NodeMaterialConnectionPoint;
  126721. /**
  126722. * Gets the xyz component (output)
  126723. * @deprecated Please use xyzOut instead.
  126724. */
  126725. readonly xyz: NodeMaterialConnectionPoint;
  126726. protected _buildBlock(state: NodeMaterialBuildState): this;
  126727. }
  126728. }
  126729. declare module BABYLON {
  126730. /**
  126731. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  126732. */
  126733. export class ColorSplitterBlock extends NodeMaterialBlock {
  126734. /**
  126735. * Create a new ColorSplitterBlock
  126736. * @param name defines the block name
  126737. */
  126738. constructor(name: string);
  126739. /**
  126740. * Gets the current class name
  126741. * @returns the class name
  126742. */
  126743. getClassName(): string;
  126744. /**
  126745. * Gets the rgba component (input)
  126746. */
  126747. readonly rgba: NodeMaterialConnectionPoint;
  126748. /**
  126749. * Gets the rgb component (input)
  126750. */
  126751. readonly rgbIn: NodeMaterialConnectionPoint;
  126752. /**
  126753. * Gets the rgb component (output)
  126754. */
  126755. readonly rgbOut: NodeMaterialConnectionPoint;
  126756. /**
  126757. * Gets the r component (output)
  126758. */
  126759. readonly r: NodeMaterialConnectionPoint;
  126760. /**
  126761. * Gets the g component (output)
  126762. */
  126763. readonly g: NodeMaterialConnectionPoint;
  126764. /**
  126765. * Gets the b component (output)
  126766. */
  126767. readonly b: NodeMaterialConnectionPoint;
  126768. /**
  126769. * Gets the a component (output)
  126770. */
  126771. readonly a: NodeMaterialConnectionPoint;
  126772. protected _inputRename(name: string): string;
  126773. protected _outputRename(name: string): string;
  126774. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126775. }
  126776. }
  126777. declare module BABYLON {
  126778. /**
  126779. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  126780. */
  126781. export class VectorSplitterBlock extends NodeMaterialBlock {
  126782. /**
  126783. * Create a new VectorSplitterBlock
  126784. * @param name defines the block name
  126785. */
  126786. constructor(name: string);
  126787. /**
  126788. * Gets the current class name
  126789. * @returns the class name
  126790. */
  126791. getClassName(): string;
  126792. /**
  126793. * Gets the xyzw component (input)
  126794. */
  126795. readonly xyzw: NodeMaterialConnectionPoint;
  126796. /**
  126797. * Gets the xyz component (input)
  126798. */
  126799. readonly xyzIn: NodeMaterialConnectionPoint;
  126800. /**
  126801. * Gets the xy component (input)
  126802. */
  126803. readonly xyIn: NodeMaterialConnectionPoint;
  126804. /**
  126805. * Gets the xyz component (output)
  126806. */
  126807. readonly xyzOut: NodeMaterialConnectionPoint;
  126808. /**
  126809. * Gets the xy component (output)
  126810. */
  126811. readonly xyOut: NodeMaterialConnectionPoint;
  126812. /**
  126813. * Gets the x component (output)
  126814. */
  126815. readonly x: NodeMaterialConnectionPoint;
  126816. /**
  126817. * Gets the y component (output)
  126818. */
  126819. readonly y: NodeMaterialConnectionPoint;
  126820. /**
  126821. * Gets the z component (output)
  126822. */
  126823. readonly z: NodeMaterialConnectionPoint;
  126824. /**
  126825. * Gets the w component (output)
  126826. */
  126827. readonly w: NodeMaterialConnectionPoint;
  126828. protected _inputRename(name: string): string;
  126829. protected _outputRename(name: string): string;
  126830. protected _buildBlock(state: NodeMaterialBuildState): this;
  126831. }
  126832. }
  126833. declare module BABYLON {
  126834. /**
  126835. * Block used to lerp between 2 values
  126836. */
  126837. export class LerpBlock extends NodeMaterialBlock {
  126838. /**
  126839. * Creates a new LerpBlock
  126840. * @param name defines the block name
  126841. */
  126842. constructor(name: string);
  126843. /**
  126844. * Gets the current class name
  126845. * @returns the class name
  126846. */
  126847. getClassName(): string;
  126848. /**
  126849. * Gets the left operand input component
  126850. */
  126851. readonly left: NodeMaterialConnectionPoint;
  126852. /**
  126853. * Gets the right operand input component
  126854. */
  126855. readonly right: NodeMaterialConnectionPoint;
  126856. /**
  126857. * Gets the gradient operand input component
  126858. */
  126859. readonly gradient: NodeMaterialConnectionPoint;
  126860. /**
  126861. * Gets the output component
  126862. */
  126863. readonly output: NodeMaterialConnectionPoint;
  126864. protected _buildBlock(state: NodeMaterialBuildState): this;
  126865. }
  126866. }
  126867. declare module BABYLON {
  126868. /**
  126869. * Block used to divide 2 vectors
  126870. */
  126871. export class DivideBlock extends NodeMaterialBlock {
  126872. /**
  126873. * Creates a new DivideBlock
  126874. * @param name defines the block name
  126875. */
  126876. constructor(name: string);
  126877. /**
  126878. * Gets the current class name
  126879. * @returns the class name
  126880. */
  126881. getClassName(): string;
  126882. /**
  126883. * Gets the left operand input component
  126884. */
  126885. readonly left: NodeMaterialConnectionPoint;
  126886. /**
  126887. * Gets the right operand input component
  126888. */
  126889. readonly right: NodeMaterialConnectionPoint;
  126890. /**
  126891. * Gets the output component
  126892. */
  126893. readonly output: NodeMaterialConnectionPoint;
  126894. protected _buildBlock(state: NodeMaterialBuildState): this;
  126895. }
  126896. }
  126897. declare module BABYLON {
  126898. /**
  126899. * Block used to subtract 2 vectors
  126900. */
  126901. export class SubtractBlock extends NodeMaterialBlock {
  126902. /**
  126903. * Creates a new SubtractBlock
  126904. * @param name defines the block name
  126905. */
  126906. constructor(name: string);
  126907. /**
  126908. * Gets the current class name
  126909. * @returns the class name
  126910. */
  126911. getClassName(): string;
  126912. /**
  126913. * Gets the left operand input component
  126914. */
  126915. readonly left: NodeMaterialConnectionPoint;
  126916. /**
  126917. * Gets the right operand input component
  126918. */
  126919. readonly right: NodeMaterialConnectionPoint;
  126920. /**
  126921. * Gets the output component
  126922. */
  126923. readonly output: NodeMaterialConnectionPoint;
  126924. protected _buildBlock(state: NodeMaterialBuildState): this;
  126925. }
  126926. }
  126927. declare module BABYLON {
  126928. /**
  126929. * Block used to step a value
  126930. */
  126931. export class StepBlock extends NodeMaterialBlock {
  126932. /**
  126933. * Creates a new StepBlock
  126934. * @param name defines the block name
  126935. */
  126936. constructor(name: string);
  126937. /**
  126938. * Gets the current class name
  126939. * @returns the class name
  126940. */
  126941. getClassName(): string;
  126942. /**
  126943. * Gets the value operand input component
  126944. */
  126945. readonly value: NodeMaterialConnectionPoint;
  126946. /**
  126947. * Gets the edge operand input component
  126948. */
  126949. readonly edge: NodeMaterialConnectionPoint;
  126950. /**
  126951. * Gets the output component
  126952. */
  126953. readonly output: NodeMaterialConnectionPoint;
  126954. protected _buildBlock(state: NodeMaterialBuildState): this;
  126955. }
  126956. }
  126957. declare module BABYLON {
  126958. /**
  126959. * Block used to get the opposite (1 - x) of a value
  126960. */
  126961. export class OneMinusBlock extends NodeMaterialBlock {
  126962. /**
  126963. * Creates a new OneMinusBlock
  126964. * @param name defines the block name
  126965. */
  126966. constructor(name: string);
  126967. /**
  126968. * Gets the current class name
  126969. * @returns the class name
  126970. */
  126971. getClassName(): string;
  126972. /**
  126973. * Gets the input component
  126974. */
  126975. readonly input: NodeMaterialConnectionPoint;
  126976. /**
  126977. * Gets the output component
  126978. */
  126979. readonly output: NodeMaterialConnectionPoint;
  126980. protected _buildBlock(state: NodeMaterialBuildState): this;
  126981. }
  126982. }
  126983. declare module BABYLON {
  126984. /**
  126985. * Block used to get the view direction
  126986. */
  126987. export class ViewDirectionBlock extends NodeMaterialBlock {
  126988. /**
  126989. * Creates a new ViewDirectionBlock
  126990. * @param name defines the block name
  126991. */
  126992. constructor(name: string);
  126993. /**
  126994. * Gets the current class name
  126995. * @returns the class name
  126996. */
  126997. getClassName(): string;
  126998. /**
  126999. * Gets the world position component
  127000. */
  127001. readonly worldPosition: NodeMaterialConnectionPoint;
  127002. /**
  127003. * Gets the camera position component
  127004. */
  127005. readonly cameraPosition: NodeMaterialConnectionPoint;
  127006. /**
  127007. * Gets the output component
  127008. */
  127009. readonly output: NodeMaterialConnectionPoint;
  127010. autoConfigure(material: NodeMaterial): void;
  127011. protected _buildBlock(state: NodeMaterialBuildState): this;
  127012. }
  127013. }
  127014. declare module BABYLON {
  127015. /**
  127016. * Block used to compute fresnel value
  127017. */
  127018. export class FresnelBlock extends NodeMaterialBlock {
  127019. /**
  127020. * Create a new FresnelBlock
  127021. * @param name defines the block name
  127022. */
  127023. constructor(name: string);
  127024. /**
  127025. * Gets the current class name
  127026. * @returns the class name
  127027. */
  127028. getClassName(): string;
  127029. /**
  127030. * Gets the world normal input component
  127031. */
  127032. readonly worldNormal: NodeMaterialConnectionPoint;
  127033. /**
  127034. * Gets the view direction input component
  127035. */
  127036. readonly viewDirection: NodeMaterialConnectionPoint;
  127037. /**
  127038. * Gets the bias input component
  127039. */
  127040. readonly bias: NodeMaterialConnectionPoint;
  127041. /**
  127042. * Gets the camera (or eye) position component
  127043. */
  127044. readonly power: NodeMaterialConnectionPoint;
  127045. /**
  127046. * Gets the fresnel output component
  127047. */
  127048. readonly fresnel: NodeMaterialConnectionPoint;
  127049. autoConfigure(material: NodeMaterial): void;
  127050. protected _buildBlock(state: NodeMaterialBuildState): this;
  127051. }
  127052. }
  127053. declare module BABYLON {
  127054. /**
  127055. * Block used to get the max of 2 values
  127056. */
  127057. export class MaxBlock extends NodeMaterialBlock {
  127058. /**
  127059. * Creates a new MaxBlock
  127060. * @param name defines the block name
  127061. */
  127062. constructor(name: string);
  127063. /**
  127064. * Gets the current class name
  127065. * @returns the class name
  127066. */
  127067. getClassName(): string;
  127068. /**
  127069. * Gets the left operand input component
  127070. */
  127071. readonly left: NodeMaterialConnectionPoint;
  127072. /**
  127073. * Gets the right operand input component
  127074. */
  127075. readonly right: NodeMaterialConnectionPoint;
  127076. /**
  127077. * Gets the output component
  127078. */
  127079. readonly output: NodeMaterialConnectionPoint;
  127080. protected _buildBlock(state: NodeMaterialBuildState): this;
  127081. }
  127082. }
  127083. declare module BABYLON {
  127084. /**
  127085. * Block used to get the min of 2 values
  127086. */
  127087. export class MinBlock extends NodeMaterialBlock {
  127088. /**
  127089. * Creates a new MinBlock
  127090. * @param name defines the block name
  127091. */
  127092. constructor(name: string);
  127093. /**
  127094. * Gets the current class name
  127095. * @returns the class name
  127096. */
  127097. getClassName(): string;
  127098. /**
  127099. * Gets the left operand input component
  127100. */
  127101. readonly left: NodeMaterialConnectionPoint;
  127102. /**
  127103. * Gets the right operand input component
  127104. */
  127105. readonly right: NodeMaterialConnectionPoint;
  127106. /**
  127107. * Gets the output component
  127108. */
  127109. readonly output: NodeMaterialConnectionPoint;
  127110. protected _buildBlock(state: NodeMaterialBuildState): this;
  127111. }
  127112. }
  127113. declare module BABYLON {
  127114. /**
  127115. * Block used to get the distance between 2 values
  127116. */
  127117. export class DistanceBlock extends NodeMaterialBlock {
  127118. /**
  127119. * Creates a new DistanceBlock
  127120. * @param name defines the block name
  127121. */
  127122. constructor(name: string);
  127123. /**
  127124. * Gets the current class name
  127125. * @returns the class name
  127126. */
  127127. getClassName(): string;
  127128. /**
  127129. * Gets the left operand input component
  127130. */
  127131. readonly left: NodeMaterialConnectionPoint;
  127132. /**
  127133. * Gets the right operand input component
  127134. */
  127135. readonly right: NodeMaterialConnectionPoint;
  127136. /**
  127137. * Gets the output component
  127138. */
  127139. readonly output: NodeMaterialConnectionPoint;
  127140. protected _buildBlock(state: NodeMaterialBuildState): this;
  127141. }
  127142. }
  127143. declare module BABYLON {
  127144. /**
  127145. * Block used to get the length of a vector
  127146. */
  127147. export class LengthBlock extends NodeMaterialBlock {
  127148. /**
  127149. * Creates a new LengthBlock
  127150. * @param name defines the block name
  127151. */
  127152. constructor(name: string);
  127153. /**
  127154. * Gets the current class name
  127155. * @returns the class name
  127156. */
  127157. getClassName(): string;
  127158. /**
  127159. * Gets the value input component
  127160. */
  127161. readonly value: NodeMaterialConnectionPoint;
  127162. /**
  127163. * Gets the output component
  127164. */
  127165. readonly output: NodeMaterialConnectionPoint;
  127166. protected _buildBlock(state: NodeMaterialBuildState): this;
  127167. }
  127168. }
  127169. declare module BABYLON {
  127170. /**
  127171. * Block used to get negative version of a value (i.e. x * -1)
  127172. */
  127173. export class NegateBlock extends NodeMaterialBlock {
  127174. /**
  127175. * Creates a new NegateBlock
  127176. * @param name defines the block name
  127177. */
  127178. constructor(name: string);
  127179. /**
  127180. * Gets the current class name
  127181. * @returns the class name
  127182. */
  127183. getClassName(): string;
  127184. /**
  127185. * Gets the value input component
  127186. */
  127187. readonly value: NodeMaterialConnectionPoint;
  127188. /**
  127189. * Gets the output component
  127190. */
  127191. readonly output: NodeMaterialConnectionPoint;
  127192. protected _buildBlock(state: NodeMaterialBuildState): this;
  127193. }
  127194. }
  127195. declare module BABYLON {
  127196. /**
  127197. * Block used to get the value of the first parameter raised to the power of the second
  127198. */
  127199. export class PowBlock extends NodeMaterialBlock {
  127200. /**
  127201. * Creates a new PowBlock
  127202. * @param name defines the block name
  127203. */
  127204. constructor(name: string);
  127205. /**
  127206. * Gets the current class name
  127207. * @returns the class name
  127208. */
  127209. getClassName(): string;
  127210. /**
  127211. * Gets the value operand input component
  127212. */
  127213. readonly value: NodeMaterialConnectionPoint;
  127214. /**
  127215. * Gets the power operand input component
  127216. */
  127217. readonly power: NodeMaterialConnectionPoint;
  127218. /**
  127219. * Gets the output component
  127220. */
  127221. readonly output: NodeMaterialConnectionPoint;
  127222. protected _buildBlock(state: NodeMaterialBuildState): this;
  127223. }
  127224. }
  127225. declare module BABYLON {
  127226. /**
  127227. * Block used to get a random number
  127228. */
  127229. export class RandomNumberBlock extends NodeMaterialBlock {
  127230. /**
  127231. * Creates a new RandomNumberBlock
  127232. * @param name defines the block name
  127233. */
  127234. constructor(name: string);
  127235. /**
  127236. * Gets the current class name
  127237. * @returns the class name
  127238. */
  127239. getClassName(): string;
  127240. /**
  127241. * Gets the seed input component
  127242. */
  127243. readonly seed: NodeMaterialConnectionPoint;
  127244. /**
  127245. * Gets the output component
  127246. */
  127247. readonly output: NodeMaterialConnectionPoint;
  127248. protected _buildBlock(state: NodeMaterialBuildState): this;
  127249. }
  127250. }
  127251. declare module BABYLON {
  127252. /**
  127253. * Block used to compute arc tangent of 2 values
  127254. */
  127255. export class ArcTan2Block extends NodeMaterialBlock {
  127256. /**
  127257. * Creates a new ArcTan2Block
  127258. * @param name defines the block name
  127259. */
  127260. constructor(name: string);
  127261. /**
  127262. * Gets the current class name
  127263. * @returns the class name
  127264. */
  127265. getClassName(): string;
  127266. /**
  127267. * Gets the x operand input component
  127268. */
  127269. readonly x: NodeMaterialConnectionPoint;
  127270. /**
  127271. * Gets the y operand input component
  127272. */
  127273. readonly y: NodeMaterialConnectionPoint;
  127274. /**
  127275. * Gets the output component
  127276. */
  127277. readonly output: NodeMaterialConnectionPoint;
  127278. protected _buildBlock(state: NodeMaterialBuildState): this;
  127279. }
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * Block used to smooth step a value
  127284. */
  127285. export class SmoothStepBlock extends NodeMaterialBlock {
  127286. /**
  127287. * Creates a new SmoothStepBlock
  127288. * @param name defines the block name
  127289. */
  127290. constructor(name: string);
  127291. /**
  127292. * Gets the current class name
  127293. * @returns the class name
  127294. */
  127295. getClassName(): string;
  127296. /**
  127297. * Gets the value operand input component
  127298. */
  127299. readonly value: NodeMaterialConnectionPoint;
  127300. /**
  127301. * Gets the first edge operand input component
  127302. */
  127303. readonly edge0: NodeMaterialConnectionPoint;
  127304. /**
  127305. * Gets the second edge operand input component
  127306. */
  127307. readonly edge1: NodeMaterialConnectionPoint;
  127308. /**
  127309. * Gets the output component
  127310. */
  127311. readonly output: NodeMaterialConnectionPoint;
  127312. protected _buildBlock(state: NodeMaterialBuildState): this;
  127313. }
  127314. }
  127315. declare module BABYLON {
  127316. /**
  127317. * Block used to get the reciprocal (1 / x) of a value
  127318. */
  127319. export class ReciprocalBlock extends NodeMaterialBlock {
  127320. /**
  127321. * Creates a new ReciprocalBlock
  127322. * @param name defines the block name
  127323. */
  127324. constructor(name: string);
  127325. /**
  127326. * Gets the current class name
  127327. * @returns the class name
  127328. */
  127329. getClassName(): string;
  127330. /**
  127331. * Gets the input component
  127332. */
  127333. readonly input: NodeMaterialConnectionPoint;
  127334. /**
  127335. * Gets the output component
  127336. */
  127337. readonly output: NodeMaterialConnectionPoint;
  127338. protected _buildBlock(state: NodeMaterialBuildState): this;
  127339. }
  127340. }
  127341. declare module BABYLON {
  127342. /**
  127343. * Block used to replace a color by another one
  127344. */
  127345. export class ReplaceColorBlock extends NodeMaterialBlock {
  127346. /**
  127347. * Creates a new ReplaceColorBlock
  127348. * @param name defines the block name
  127349. */
  127350. constructor(name: string);
  127351. /**
  127352. * Gets the current class name
  127353. * @returns the class name
  127354. */
  127355. getClassName(): string;
  127356. /**
  127357. * Gets the value input component
  127358. */
  127359. readonly value: NodeMaterialConnectionPoint;
  127360. /**
  127361. * Gets the reference input component
  127362. */
  127363. readonly reference: NodeMaterialConnectionPoint;
  127364. /**
  127365. * Gets the distance input component
  127366. */
  127367. readonly distance: NodeMaterialConnectionPoint;
  127368. /**
  127369. * Gets the replacement input component
  127370. */
  127371. readonly replacement: NodeMaterialConnectionPoint;
  127372. /**
  127373. * Gets the output component
  127374. */
  127375. readonly output: NodeMaterialConnectionPoint;
  127376. protected _buildBlock(state: NodeMaterialBuildState): this;
  127377. }
  127378. }
  127379. declare module BABYLON {
  127380. /**
  127381. * Block used to posterize a value
  127382. * @see https://en.wikipedia.org/wiki/Posterization
  127383. */
  127384. export class PosterizeBlock extends NodeMaterialBlock {
  127385. /**
  127386. * Creates a new PosterizeBlock
  127387. * @param name defines the block name
  127388. */
  127389. constructor(name: string);
  127390. /**
  127391. * Gets the current class name
  127392. * @returns the class name
  127393. */
  127394. getClassName(): string;
  127395. /**
  127396. * Gets the value input component
  127397. */
  127398. readonly value: NodeMaterialConnectionPoint;
  127399. /**
  127400. * Gets the steps input component
  127401. */
  127402. readonly steps: NodeMaterialConnectionPoint;
  127403. /**
  127404. * Gets the output component
  127405. */
  127406. readonly output: NodeMaterialConnectionPoint;
  127407. protected _buildBlock(state: NodeMaterialBuildState): this;
  127408. }
  127409. }
  127410. declare module BABYLON {
  127411. /**
  127412. * Operations supported by the Wave block
  127413. */
  127414. export enum WaveBlockKind {
  127415. /** SawTooth */
  127416. SawTooth = 0,
  127417. /** Square */
  127418. Square = 1,
  127419. /** Triangle */
  127420. Triangle = 2
  127421. }
  127422. /**
  127423. * Block used to apply wave operation to floats
  127424. */
  127425. export class WaveBlock extends NodeMaterialBlock {
  127426. /**
  127427. * Gets or sets the kibnd of wave to be applied by the block
  127428. */
  127429. kind: WaveBlockKind;
  127430. /**
  127431. * Creates a new WaveBlock
  127432. * @param name defines the block name
  127433. */
  127434. constructor(name: string);
  127435. /**
  127436. * Gets the current class name
  127437. * @returns the class name
  127438. */
  127439. getClassName(): string;
  127440. /**
  127441. * Gets the input component
  127442. */
  127443. readonly input: NodeMaterialConnectionPoint;
  127444. /**
  127445. * Gets the output component
  127446. */
  127447. readonly output: NodeMaterialConnectionPoint;
  127448. protected _buildBlock(state: NodeMaterialBuildState): this;
  127449. serialize(): any;
  127450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127451. }
  127452. }
  127453. declare module BABYLON {
  127454. /**
  127455. * Class used to store a color step for the GradientBlock
  127456. */
  127457. export class GradientBlockColorStep {
  127458. /**
  127459. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  127460. */
  127461. step: number;
  127462. /**
  127463. * Gets or sets the color associated with this step
  127464. */
  127465. color: Color3;
  127466. /**
  127467. * Creates a new GradientBlockColorStep
  127468. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  127469. * @param color defines the color associated with this step
  127470. */
  127471. constructor(
  127472. /**
  127473. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  127474. */
  127475. step: number,
  127476. /**
  127477. * Gets or sets the color associated with this step
  127478. */
  127479. color: Color3);
  127480. }
  127481. /**
  127482. * Block used to return a color from a gradient based on an input value between 0 and 1
  127483. */
  127484. export class GradientBlock extends NodeMaterialBlock {
  127485. /**
  127486. * Gets or sets the list of color steps
  127487. */
  127488. colorSteps: GradientBlockColorStep[];
  127489. /**
  127490. * Creates a new GradientBlock
  127491. * @param name defines the block name
  127492. */
  127493. constructor(name: string);
  127494. /**
  127495. * Gets the current class name
  127496. * @returns the class name
  127497. */
  127498. getClassName(): string;
  127499. /**
  127500. * Gets the gradient input component
  127501. */
  127502. readonly gradient: NodeMaterialConnectionPoint;
  127503. /**
  127504. * Gets the output component
  127505. */
  127506. readonly output: NodeMaterialConnectionPoint;
  127507. private _writeColorConstant;
  127508. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127509. serialize(): any;
  127510. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127511. protected _dumpPropertiesCode(): string;
  127512. }
  127513. }
  127514. declare module BABYLON {
  127515. /**
  127516. * Block used to normalize lerp between 2 values
  127517. */
  127518. export class NLerpBlock extends NodeMaterialBlock {
  127519. /**
  127520. * Creates a new NLerpBlock
  127521. * @param name defines the block name
  127522. */
  127523. constructor(name: string);
  127524. /**
  127525. * Gets the current class name
  127526. * @returns the class name
  127527. */
  127528. getClassName(): string;
  127529. /**
  127530. * Gets the left operand input component
  127531. */
  127532. readonly left: NodeMaterialConnectionPoint;
  127533. /**
  127534. * Gets the right operand input component
  127535. */
  127536. readonly right: NodeMaterialConnectionPoint;
  127537. /**
  127538. * Gets the gradient operand input component
  127539. */
  127540. readonly gradient: NodeMaterialConnectionPoint;
  127541. /**
  127542. * Gets the output component
  127543. */
  127544. readonly output: NodeMaterialConnectionPoint;
  127545. protected _buildBlock(state: NodeMaterialBuildState): this;
  127546. }
  127547. }
  127548. declare module BABYLON {
  127549. /**
  127550. * block used to Generate a Worley Noise 3D Noise Pattern
  127551. */
  127552. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  127553. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127554. manhattanDistance: boolean;
  127555. /**
  127556. * Creates a new WorleyNoise3DBlock
  127557. * @param name defines the block name
  127558. */
  127559. constructor(name: string);
  127560. /**
  127561. * Gets the current class name
  127562. * @returns the class name
  127563. */
  127564. getClassName(): string;
  127565. /**
  127566. * Gets the seed input component
  127567. */
  127568. readonly seed: NodeMaterialConnectionPoint;
  127569. /**
  127570. * Gets the jitter input component
  127571. */
  127572. readonly jitter: NodeMaterialConnectionPoint;
  127573. /**
  127574. * Gets the output component
  127575. */
  127576. readonly output: NodeMaterialConnectionPoint;
  127577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127578. /**
  127579. * Exposes the properties to the UI?
  127580. */
  127581. protected _dumpPropertiesCode(): string;
  127582. /**
  127583. * Exposes the properties to the Seralize?
  127584. */
  127585. serialize(): any;
  127586. /**
  127587. * Exposes the properties to the deseralize?
  127588. */
  127589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127590. }
  127591. }
  127592. declare module BABYLON {
  127593. /**
  127594. * block used to Generate a Simplex Perlin 3d Noise Pattern
  127595. */
  127596. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  127597. /**
  127598. * Creates a new SimplexPerlin3DBlock
  127599. * @param name defines the block name
  127600. */
  127601. constructor(name: string);
  127602. /**
  127603. * Gets the current class name
  127604. * @returns the class name
  127605. */
  127606. getClassName(): string;
  127607. /**
  127608. * Gets the seed operand input component
  127609. */
  127610. readonly seed: NodeMaterialConnectionPoint;
  127611. /**
  127612. * Gets the output component
  127613. */
  127614. readonly output: NodeMaterialConnectionPoint;
  127615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127616. }
  127617. }
  127618. declare module BABYLON {
  127619. /**
  127620. * Block used to blend normals
  127621. */
  127622. export class NormalBlendBlock extends NodeMaterialBlock {
  127623. /**
  127624. * Creates a new NormalBlendBlock
  127625. * @param name defines the block name
  127626. */
  127627. constructor(name: string);
  127628. /**
  127629. * Gets the current class name
  127630. * @returns the class name
  127631. */
  127632. getClassName(): string;
  127633. /**
  127634. * Gets the first input component
  127635. */
  127636. readonly normalMap0: NodeMaterialConnectionPoint;
  127637. /**
  127638. * Gets the second input component
  127639. */
  127640. readonly normalMap1: NodeMaterialConnectionPoint;
  127641. /**
  127642. * Gets the output component
  127643. */
  127644. readonly output: NodeMaterialConnectionPoint;
  127645. protected _buildBlock(state: NodeMaterialBuildState): this;
  127646. }
  127647. }
  127648. declare module BABYLON {
  127649. /**
  127650. * Block used to rotate a 2d vector by a given angle
  127651. */
  127652. export class Rotate2dBlock extends NodeMaterialBlock {
  127653. /**
  127654. * Creates a new Rotate2dBlock
  127655. * @param name defines the block name
  127656. */
  127657. constructor(name: string);
  127658. /**
  127659. * Gets the current class name
  127660. * @returns the class name
  127661. */
  127662. getClassName(): string;
  127663. /**
  127664. * Gets the input vector
  127665. */
  127666. readonly input: NodeMaterialConnectionPoint;
  127667. /**
  127668. * Gets the input angle
  127669. */
  127670. readonly angle: NodeMaterialConnectionPoint;
  127671. /**
  127672. * Gets the output component
  127673. */
  127674. readonly output: NodeMaterialConnectionPoint;
  127675. autoConfigure(material: NodeMaterial): void;
  127676. protected _buildBlock(state: NodeMaterialBuildState): this;
  127677. }
  127678. }
  127679. declare module BABYLON {
  127680. /**
  127681. * Block used to get the reflected vector from a direction and a normal
  127682. */
  127683. export class ReflectBlock extends NodeMaterialBlock {
  127684. /**
  127685. * Creates a new ReflectBlock
  127686. * @param name defines the block name
  127687. */
  127688. constructor(name: string);
  127689. /**
  127690. * Gets the current class name
  127691. * @returns the class name
  127692. */
  127693. getClassName(): string;
  127694. /**
  127695. * Gets the incident component
  127696. */
  127697. readonly incident: NodeMaterialConnectionPoint;
  127698. /**
  127699. * Gets the normal component
  127700. */
  127701. readonly normal: NodeMaterialConnectionPoint;
  127702. /**
  127703. * Gets the output component
  127704. */
  127705. readonly output: NodeMaterialConnectionPoint;
  127706. protected _buildBlock(state: NodeMaterialBuildState): this;
  127707. }
  127708. }
  127709. declare module BABYLON {
  127710. /**
  127711. * Block used to get the refracted vector from a direction and a normal
  127712. */
  127713. export class RefractBlock extends NodeMaterialBlock {
  127714. /**
  127715. * Creates a new RefractBlock
  127716. * @param name defines the block name
  127717. */
  127718. constructor(name: string);
  127719. /**
  127720. * Gets the current class name
  127721. * @returns the class name
  127722. */
  127723. getClassName(): string;
  127724. /**
  127725. * Gets the incident component
  127726. */
  127727. readonly incident: NodeMaterialConnectionPoint;
  127728. /**
  127729. * Gets the normal component
  127730. */
  127731. readonly normal: NodeMaterialConnectionPoint;
  127732. /**
  127733. * Gets the index of refraction component
  127734. */
  127735. readonly ior: NodeMaterialConnectionPoint;
  127736. /**
  127737. * Gets the output component
  127738. */
  127739. readonly output: NodeMaterialConnectionPoint;
  127740. protected _buildBlock(state: NodeMaterialBuildState): this;
  127741. }
  127742. }
  127743. declare module BABYLON {
  127744. /**
  127745. * Block used to desaturate a color
  127746. */
  127747. export class DesaturateBlock extends NodeMaterialBlock {
  127748. /**
  127749. * Creates a new DesaturateBlock
  127750. * @param name defines the block name
  127751. */
  127752. constructor(name: string);
  127753. /**
  127754. * Gets the current class name
  127755. * @returns the class name
  127756. */
  127757. getClassName(): string;
  127758. /**
  127759. * Gets the color operand input component
  127760. */
  127761. readonly color: NodeMaterialConnectionPoint;
  127762. /**
  127763. * Gets the level operand input component
  127764. */
  127765. readonly level: NodeMaterialConnectionPoint;
  127766. /**
  127767. * Gets the output component
  127768. */
  127769. readonly output: NodeMaterialConnectionPoint;
  127770. protected _buildBlock(state: NodeMaterialBuildState): this;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. /**
  127775. * Effect Render Options
  127776. */
  127777. export interface IEffectRendererOptions {
  127778. /**
  127779. * Defines the vertices positions.
  127780. */
  127781. positions?: number[];
  127782. /**
  127783. * Defines the indices.
  127784. */
  127785. indices?: number[];
  127786. }
  127787. /**
  127788. * Helper class to render one or more effects
  127789. */
  127790. export class EffectRenderer {
  127791. private engine;
  127792. private static _DefaultOptions;
  127793. private _vertexBuffers;
  127794. private _indexBuffer;
  127795. private _ringBufferIndex;
  127796. private _ringScreenBuffer;
  127797. private _fullscreenViewport;
  127798. private _getNextFrameBuffer;
  127799. /**
  127800. * Creates an effect renderer
  127801. * @param engine the engine to use for rendering
  127802. * @param options defines the options of the effect renderer
  127803. */
  127804. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  127805. /**
  127806. * Sets the current viewport in normalized coordinates 0-1
  127807. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  127808. */
  127809. setViewport(viewport?: Viewport): void;
  127810. /**
  127811. * Binds the embedded attributes buffer to the effect.
  127812. * @param effect Defines the effect to bind the attributes for
  127813. */
  127814. bindBuffers(effect: Effect): void;
  127815. /**
  127816. * Sets the current effect wrapper to use during draw.
  127817. * The effect needs to be ready before calling this api.
  127818. * This also sets the default full screen position attribute.
  127819. * @param effectWrapper Defines the effect to draw with
  127820. */
  127821. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  127822. /**
  127823. * Draws a full screen quad.
  127824. */
  127825. draw(): void;
  127826. /**
  127827. * renders one or more effects to a specified texture
  127828. * @param effectWrappers list of effects to renderer
  127829. * @param outputTexture texture to draw to, if null it will render to the screen
  127830. */
  127831. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  127832. /**
  127833. * Disposes of the effect renderer
  127834. */
  127835. dispose(): void;
  127836. }
  127837. /**
  127838. * Options to create an EffectWrapper
  127839. */
  127840. interface EffectWrapperCreationOptions {
  127841. /**
  127842. * Engine to use to create the effect
  127843. */
  127844. engine: ThinEngine;
  127845. /**
  127846. * Fragment shader for the effect
  127847. */
  127848. fragmentShader: string;
  127849. /**
  127850. * Vertex shader for the effect
  127851. */
  127852. vertexShader?: string;
  127853. /**
  127854. * Attributes to use in the shader
  127855. */
  127856. attributeNames?: Array<string>;
  127857. /**
  127858. * Uniforms to use in the shader
  127859. */
  127860. uniformNames?: Array<string>;
  127861. /**
  127862. * Texture sampler names to use in the shader
  127863. */
  127864. samplerNames?: Array<string>;
  127865. /**
  127866. * The friendly name of the effect displayed in Spector.
  127867. */
  127868. name?: string;
  127869. }
  127870. /**
  127871. * Wraps an effect to be used for rendering
  127872. */
  127873. export class EffectWrapper {
  127874. /**
  127875. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  127876. */
  127877. onApplyObservable: Observable<{}>;
  127878. /**
  127879. * The underlying effect
  127880. */
  127881. effect: Effect;
  127882. /**
  127883. * Creates an effect to be renderer
  127884. * @param creationOptions options to create the effect
  127885. */
  127886. constructor(creationOptions: EffectWrapperCreationOptions);
  127887. /**
  127888. * Disposes of the effect wrapper
  127889. */
  127890. dispose(): void;
  127891. }
  127892. }
  127893. declare module BABYLON {
  127894. /**
  127895. * Helper class to push actions to a pool of workers.
  127896. */
  127897. export class WorkerPool implements IDisposable {
  127898. private _workerInfos;
  127899. private _pendingActions;
  127900. /**
  127901. * Constructor
  127902. * @param workers Array of workers to use for actions
  127903. */
  127904. constructor(workers: Array<Worker>);
  127905. /**
  127906. * Terminates all workers and clears any pending actions.
  127907. */
  127908. dispose(): void;
  127909. /**
  127910. * Pushes an action to the worker pool. If all the workers are active, the action will be
  127911. * pended until a worker has completed its action.
  127912. * @param action The action to perform. Call onComplete when the action is complete.
  127913. */
  127914. push(action: (worker: Worker, onComplete: () => void) => void): void;
  127915. private _execute;
  127916. }
  127917. }
  127918. declare module BABYLON {
  127919. /**
  127920. * Configuration for Draco compression
  127921. */
  127922. export interface IDracoCompressionConfiguration {
  127923. /**
  127924. * Configuration for the decoder.
  127925. */
  127926. decoder: {
  127927. /**
  127928. * The url to the WebAssembly module.
  127929. */
  127930. wasmUrl?: string;
  127931. /**
  127932. * The url to the WebAssembly binary.
  127933. */
  127934. wasmBinaryUrl?: string;
  127935. /**
  127936. * The url to the fallback JavaScript module.
  127937. */
  127938. fallbackUrl?: string;
  127939. };
  127940. }
  127941. /**
  127942. * Draco compression (https://google.github.io/draco/)
  127943. *
  127944. * This class wraps the Draco module.
  127945. *
  127946. * **Encoder**
  127947. *
  127948. * The encoder is not currently implemented.
  127949. *
  127950. * **Decoder**
  127951. *
  127952. * 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.
  127953. *
  127954. * To update the configuration, use the following code:
  127955. * ```javascript
  127956. * DracoCompression.Configuration = {
  127957. * decoder: {
  127958. * wasmUrl: "<url to the WebAssembly library>",
  127959. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  127960. * fallbackUrl: "<url to the fallback JavaScript library>",
  127961. * }
  127962. * };
  127963. * ```
  127964. *
  127965. * 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.
  127966. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  127967. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  127968. *
  127969. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  127970. * ```javascript
  127971. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  127972. * ```
  127973. *
  127974. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  127975. */
  127976. export class DracoCompression implements IDisposable {
  127977. private _workerPoolPromise?;
  127978. private _decoderModulePromise?;
  127979. /**
  127980. * The configuration. Defaults to the following urls:
  127981. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  127982. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  127983. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  127984. */
  127985. static Configuration: IDracoCompressionConfiguration;
  127986. /**
  127987. * Returns true if the decoder configuration is available.
  127988. */
  127989. static readonly DecoderAvailable: boolean;
  127990. /**
  127991. * Default number of workers to create when creating the draco compression object.
  127992. */
  127993. static DefaultNumWorkers: number;
  127994. private static GetDefaultNumWorkers;
  127995. private static _Default;
  127996. /**
  127997. * Default instance for the draco compression object.
  127998. */
  127999. static readonly Default: DracoCompression;
  128000. /**
  128001. * Constructor
  128002. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  128003. */
  128004. constructor(numWorkers?: number);
  128005. /**
  128006. * Stop all async operations and release resources.
  128007. */
  128008. dispose(): void;
  128009. /**
  128010. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  128011. * @returns a promise that resolves when ready
  128012. */
  128013. whenReadyAsync(): Promise<void>;
  128014. /**
  128015. * Decode Draco compressed mesh data to vertex data.
  128016. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  128017. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  128018. * @returns A promise that resolves with the decoded vertex data
  128019. */
  128020. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  128021. [kind: string]: number;
  128022. }): Promise<VertexData>;
  128023. }
  128024. }
  128025. declare module BABYLON {
  128026. /**
  128027. * Class for building Constructive Solid Geometry
  128028. */
  128029. export class CSG {
  128030. private polygons;
  128031. /**
  128032. * The world matrix
  128033. */
  128034. matrix: Matrix;
  128035. /**
  128036. * Stores the position
  128037. */
  128038. position: Vector3;
  128039. /**
  128040. * Stores the rotation
  128041. */
  128042. rotation: Vector3;
  128043. /**
  128044. * Stores the rotation quaternion
  128045. */
  128046. rotationQuaternion: Nullable<Quaternion>;
  128047. /**
  128048. * Stores the scaling vector
  128049. */
  128050. scaling: Vector3;
  128051. /**
  128052. * Convert the Mesh to CSG
  128053. * @param mesh The Mesh to convert to CSG
  128054. * @returns A new CSG from the Mesh
  128055. */
  128056. static FromMesh(mesh: Mesh): CSG;
  128057. /**
  128058. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  128059. * @param polygons Polygons used to construct a CSG solid
  128060. */
  128061. private static FromPolygons;
  128062. /**
  128063. * Clones, or makes a deep copy, of the CSG
  128064. * @returns A new CSG
  128065. */
  128066. clone(): CSG;
  128067. /**
  128068. * Unions this CSG with another CSG
  128069. * @param csg The CSG to union against this CSG
  128070. * @returns The unioned CSG
  128071. */
  128072. union(csg: CSG): CSG;
  128073. /**
  128074. * Unions this CSG with another CSG in place
  128075. * @param csg The CSG to union against this CSG
  128076. */
  128077. unionInPlace(csg: CSG): void;
  128078. /**
  128079. * Subtracts this CSG with another CSG
  128080. * @param csg The CSG to subtract against this CSG
  128081. * @returns A new CSG
  128082. */
  128083. subtract(csg: CSG): CSG;
  128084. /**
  128085. * Subtracts this CSG with another CSG in place
  128086. * @param csg The CSG to subtact against this CSG
  128087. */
  128088. subtractInPlace(csg: CSG): void;
  128089. /**
  128090. * Intersect this CSG with another CSG
  128091. * @param csg The CSG to intersect against this CSG
  128092. * @returns A new CSG
  128093. */
  128094. intersect(csg: CSG): CSG;
  128095. /**
  128096. * Intersects this CSG with another CSG in place
  128097. * @param csg The CSG to intersect against this CSG
  128098. */
  128099. intersectInPlace(csg: CSG): void;
  128100. /**
  128101. * Return a new CSG solid with solid and empty space switched. This solid is
  128102. * not modified.
  128103. * @returns A new CSG solid with solid and empty space switched
  128104. */
  128105. inverse(): CSG;
  128106. /**
  128107. * Inverses the CSG in place
  128108. */
  128109. inverseInPlace(): void;
  128110. /**
  128111. * This is used to keep meshes transformations so they can be restored
  128112. * when we build back a Babylon Mesh
  128113. * NB : All CSG operations are performed in world coordinates
  128114. * @param csg The CSG to copy the transform attributes from
  128115. * @returns This CSG
  128116. */
  128117. copyTransformAttributes(csg: CSG): CSG;
  128118. /**
  128119. * Build Raw mesh from CSG
  128120. * Coordinates here are in world space
  128121. * @param name The name of the mesh geometry
  128122. * @param scene The Scene
  128123. * @param keepSubMeshes Specifies if the submeshes should be kept
  128124. * @returns A new Mesh
  128125. */
  128126. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  128127. /**
  128128. * Build Mesh from CSG taking material and transforms into account
  128129. * @param name The name of the Mesh
  128130. * @param material The material of the Mesh
  128131. * @param scene The Scene
  128132. * @param keepSubMeshes Specifies if submeshes should be kept
  128133. * @returns The new Mesh
  128134. */
  128135. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  128136. }
  128137. }
  128138. declare module BABYLON {
  128139. /**
  128140. * Class used to create a trail following a mesh
  128141. */
  128142. export class TrailMesh extends Mesh {
  128143. private _generator;
  128144. private _autoStart;
  128145. private _running;
  128146. private _diameter;
  128147. private _length;
  128148. private _sectionPolygonPointsCount;
  128149. private _sectionVectors;
  128150. private _sectionNormalVectors;
  128151. private _beforeRenderObserver;
  128152. /**
  128153. * @constructor
  128154. * @param name The value used by scene.getMeshByName() to do a lookup.
  128155. * @param generator The mesh to generate a trail.
  128156. * @param scene The scene to add this mesh to.
  128157. * @param diameter Diameter of trailing mesh. Default is 1.
  128158. * @param length Length of trailing mesh. Default is 60.
  128159. * @param autoStart Automatically start trailing mesh. Default true.
  128160. */
  128161. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  128162. /**
  128163. * "TrailMesh"
  128164. * @returns "TrailMesh"
  128165. */
  128166. getClassName(): string;
  128167. private _createMesh;
  128168. /**
  128169. * Start trailing mesh.
  128170. */
  128171. start(): void;
  128172. /**
  128173. * Stop trailing mesh.
  128174. */
  128175. stop(): void;
  128176. /**
  128177. * Update trailing mesh geometry.
  128178. */
  128179. update(): void;
  128180. /**
  128181. * Returns a new TrailMesh object.
  128182. * @param name is a string, the name given to the new mesh
  128183. * @param newGenerator use new generator object for cloned trail mesh
  128184. * @returns a new mesh
  128185. */
  128186. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  128187. /**
  128188. * Serializes this trail mesh
  128189. * @param serializationObject object to write serialization to
  128190. */
  128191. serialize(serializationObject: any): void;
  128192. /**
  128193. * Parses a serialized trail mesh
  128194. * @param parsedMesh the serialized mesh
  128195. * @param scene the scene to create the trail mesh in
  128196. * @returns the created trail mesh
  128197. */
  128198. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  128199. }
  128200. }
  128201. declare module BABYLON {
  128202. /**
  128203. * Class containing static functions to help procedurally build meshes
  128204. */
  128205. export class TiledBoxBuilder {
  128206. /**
  128207. * Creates a box mesh
  128208. * 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)
  128209. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128213. * @param name defines the name of the mesh
  128214. * @param options defines the options used to create the mesh
  128215. * @param scene defines the hosting scene
  128216. * @returns the box mesh
  128217. */
  128218. static CreateTiledBox(name: string, options: {
  128219. pattern?: number;
  128220. width?: number;
  128221. height?: number;
  128222. depth?: number;
  128223. tileSize?: number;
  128224. tileWidth?: number;
  128225. tileHeight?: number;
  128226. alignHorizontal?: number;
  128227. alignVertical?: number;
  128228. faceUV?: Vector4[];
  128229. faceColors?: Color4[];
  128230. sideOrientation?: number;
  128231. updatable?: boolean;
  128232. }, scene?: Nullable<Scene>): Mesh;
  128233. }
  128234. }
  128235. declare module BABYLON {
  128236. /**
  128237. * Class containing static functions to help procedurally build meshes
  128238. */
  128239. export class TorusKnotBuilder {
  128240. /**
  128241. * Creates a torus knot mesh
  128242. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  128243. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  128244. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  128245. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  128246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128249. * @param name defines the name of the mesh
  128250. * @param options defines the options used to create the mesh
  128251. * @param scene defines the hosting scene
  128252. * @returns the torus knot mesh
  128253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  128254. */
  128255. static CreateTorusKnot(name: string, options: {
  128256. radius?: number;
  128257. tube?: number;
  128258. radialSegments?: number;
  128259. tubularSegments?: number;
  128260. p?: number;
  128261. q?: number;
  128262. updatable?: boolean;
  128263. sideOrientation?: number;
  128264. frontUVs?: Vector4;
  128265. backUVs?: Vector4;
  128266. }, scene: any): Mesh;
  128267. }
  128268. }
  128269. declare module BABYLON {
  128270. /**
  128271. * Polygon
  128272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  128273. */
  128274. export class Polygon {
  128275. /**
  128276. * Creates a rectangle
  128277. * @param xmin bottom X coord
  128278. * @param ymin bottom Y coord
  128279. * @param xmax top X coord
  128280. * @param ymax top Y coord
  128281. * @returns points that make the resulting rectation
  128282. */
  128283. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  128284. /**
  128285. * Creates a circle
  128286. * @param radius radius of circle
  128287. * @param cx scale in x
  128288. * @param cy scale in y
  128289. * @param numberOfSides number of sides that make up the circle
  128290. * @returns points that make the resulting circle
  128291. */
  128292. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  128293. /**
  128294. * Creates a polygon from input string
  128295. * @param input Input polygon data
  128296. * @returns the parsed points
  128297. */
  128298. static Parse(input: string): Vector2[];
  128299. /**
  128300. * Starts building a polygon from x and y coordinates
  128301. * @param x x coordinate
  128302. * @param y y coordinate
  128303. * @returns the started path2
  128304. */
  128305. static StartingAt(x: number, y: number): Path2;
  128306. }
  128307. /**
  128308. * Builds a polygon
  128309. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  128310. */
  128311. export class PolygonMeshBuilder {
  128312. private _points;
  128313. private _outlinepoints;
  128314. private _holes;
  128315. private _name;
  128316. private _scene;
  128317. private _epoints;
  128318. private _eholes;
  128319. private _addToepoint;
  128320. /**
  128321. * Babylon reference to the earcut plugin.
  128322. */
  128323. bjsEarcut: any;
  128324. /**
  128325. * Creates a PolygonMeshBuilder
  128326. * @param name name of the builder
  128327. * @param contours Path of the polygon
  128328. * @param scene scene to add to when creating the mesh
  128329. * @param earcutInjection can be used to inject your own earcut reference
  128330. */
  128331. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  128332. /**
  128333. * Adds a whole within the polygon
  128334. * @param hole Array of points defining the hole
  128335. * @returns this
  128336. */
  128337. addHole(hole: Vector2[]): PolygonMeshBuilder;
  128338. /**
  128339. * Creates the polygon
  128340. * @param updatable If the mesh should be updatable
  128341. * @param depth The depth of the mesh created
  128342. * @returns the created mesh
  128343. */
  128344. build(updatable?: boolean, depth?: number): Mesh;
  128345. /**
  128346. * Creates the polygon
  128347. * @param depth The depth of the mesh created
  128348. * @returns the created VertexData
  128349. */
  128350. buildVertexData(depth?: number): VertexData;
  128351. /**
  128352. * Adds a side to the polygon
  128353. * @param positions points that make the polygon
  128354. * @param normals normals of the polygon
  128355. * @param uvs uvs of the polygon
  128356. * @param indices indices of the polygon
  128357. * @param bounds bounds of the polygon
  128358. * @param points points of the polygon
  128359. * @param depth depth of the polygon
  128360. * @param flip flip of the polygon
  128361. */
  128362. private addSide;
  128363. }
  128364. }
  128365. declare module BABYLON {
  128366. /**
  128367. * Class containing static functions to help procedurally build meshes
  128368. */
  128369. export class PolygonBuilder {
  128370. /**
  128371. * Creates a polygon mesh
  128372. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  128373. * * 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
  128374. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  128375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  128377. * * Remember you can only change the shape positions, not their number when updating a polygon
  128378. * @param name defines the name of the mesh
  128379. * @param options defines the options used to create the mesh
  128380. * @param scene defines the hosting scene
  128381. * @param earcutInjection can be used to inject your own earcut reference
  128382. * @returns the polygon mesh
  128383. */
  128384. static CreatePolygon(name: string, options: {
  128385. shape: Vector3[];
  128386. holes?: Vector3[][];
  128387. depth?: number;
  128388. faceUV?: Vector4[];
  128389. faceColors?: Color4[];
  128390. updatable?: boolean;
  128391. sideOrientation?: number;
  128392. frontUVs?: Vector4;
  128393. backUVs?: Vector4;
  128394. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128395. /**
  128396. * Creates an extruded polygon mesh, with depth in the Y direction.
  128397. * * 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)
  128398. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128399. * @param name defines the name of the mesh
  128400. * @param options defines the options used to create the mesh
  128401. * @param scene defines the hosting scene
  128402. * @param earcutInjection can be used to inject your own earcut reference
  128403. * @returns the polygon mesh
  128404. */
  128405. static ExtrudePolygon(name: string, options: {
  128406. shape: Vector3[];
  128407. holes?: Vector3[][];
  128408. depth?: number;
  128409. faceUV?: Vector4[];
  128410. faceColors?: Color4[];
  128411. updatable?: boolean;
  128412. sideOrientation?: number;
  128413. frontUVs?: Vector4;
  128414. backUVs?: Vector4;
  128415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128416. }
  128417. }
  128418. declare module BABYLON {
  128419. /**
  128420. * Class containing static functions to help procedurally build meshes
  128421. */
  128422. export class LatheBuilder {
  128423. /**
  128424. * Creates lathe mesh.
  128425. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  128426. * * 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
  128427. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  128428. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  128429. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  128430. * * 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
  128431. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  128432. * * 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
  128433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128437. * @param name defines the name of the mesh
  128438. * @param options defines the options used to create the mesh
  128439. * @param scene defines the hosting scene
  128440. * @returns the lathe mesh
  128441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  128442. */
  128443. static CreateLathe(name: string, options: {
  128444. shape: Vector3[];
  128445. radius?: number;
  128446. tessellation?: number;
  128447. clip?: number;
  128448. arc?: number;
  128449. closed?: boolean;
  128450. updatable?: boolean;
  128451. sideOrientation?: number;
  128452. frontUVs?: Vector4;
  128453. backUVs?: Vector4;
  128454. cap?: number;
  128455. invertUV?: boolean;
  128456. }, scene?: Nullable<Scene>): Mesh;
  128457. }
  128458. }
  128459. declare module BABYLON {
  128460. /**
  128461. * Class containing static functions to help procedurally build meshes
  128462. */
  128463. export class TiledPlaneBuilder {
  128464. /**
  128465. * Creates a tiled plane mesh
  128466. * * The parameter `pattern` will, depending on value, do nothing or
  128467. * * * flip (reflect about central vertical) alternate tiles across and up
  128468. * * * flip every tile on alternate rows
  128469. * * * rotate (180 degs) alternate tiles across and up
  128470. * * * rotate every tile on alternate rows
  128471. * * * flip and rotate alternate tiles across and up
  128472. * * * flip and rotate every tile on alternate rows
  128473. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  128474. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  128475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  128477. * * 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)
  128478. * * 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)
  128479. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128480. * @param name defines the name of the mesh
  128481. * @param options defines the options used to create the mesh
  128482. * @param scene defines the hosting scene
  128483. * @returns the box mesh
  128484. */
  128485. static CreateTiledPlane(name: string, options: {
  128486. pattern?: number;
  128487. tileSize?: number;
  128488. tileWidth?: number;
  128489. tileHeight?: number;
  128490. size?: number;
  128491. width?: number;
  128492. height?: number;
  128493. alignHorizontal?: number;
  128494. alignVertical?: number;
  128495. sideOrientation?: number;
  128496. frontUVs?: Vector4;
  128497. backUVs?: Vector4;
  128498. updatable?: boolean;
  128499. }, scene?: Nullable<Scene>): Mesh;
  128500. }
  128501. }
  128502. declare module BABYLON {
  128503. /**
  128504. * Class containing static functions to help procedurally build meshes
  128505. */
  128506. export class TubeBuilder {
  128507. /**
  128508. * Creates a tube mesh.
  128509. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128510. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  128511. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  128512. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  128513. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  128514. * * 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)
  128515. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  128516. * * 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
  128517. * * 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
  128518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128522. * @param name defines the name of the mesh
  128523. * @param options defines the options used to create the mesh
  128524. * @param scene defines the hosting scene
  128525. * @returns the tube mesh
  128526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128527. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  128528. */
  128529. static CreateTube(name: string, options: {
  128530. path: Vector3[];
  128531. radius?: number;
  128532. tessellation?: number;
  128533. radiusFunction?: {
  128534. (i: number, distance: number): number;
  128535. };
  128536. cap?: number;
  128537. arc?: number;
  128538. updatable?: boolean;
  128539. sideOrientation?: number;
  128540. frontUVs?: Vector4;
  128541. backUVs?: Vector4;
  128542. instance?: Mesh;
  128543. invertUV?: boolean;
  128544. }, scene?: Nullable<Scene>): Mesh;
  128545. }
  128546. }
  128547. declare module BABYLON {
  128548. /**
  128549. * Class containing static functions to help procedurally build meshes
  128550. */
  128551. export class IcoSphereBuilder {
  128552. /**
  128553. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  128554. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  128555. * * 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`)
  128556. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  128557. * * 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
  128558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128561. * @param name defines the name of the mesh
  128562. * @param options defines the options used to create the mesh
  128563. * @param scene defines the hosting scene
  128564. * @returns the icosahedron mesh
  128565. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  128566. */
  128567. static CreateIcoSphere(name: string, options: {
  128568. radius?: number;
  128569. radiusX?: number;
  128570. radiusY?: number;
  128571. radiusZ?: number;
  128572. flat?: boolean;
  128573. subdivisions?: number;
  128574. sideOrientation?: number;
  128575. frontUVs?: Vector4;
  128576. backUVs?: Vector4;
  128577. updatable?: boolean;
  128578. }, scene?: Nullable<Scene>): Mesh;
  128579. }
  128580. }
  128581. declare module BABYLON {
  128582. /**
  128583. * Class containing static functions to help procedurally build meshes
  128584. */
  128585. export class DecalBuilder {
  128586. /**
  128587. * Creates a decal mesh.
  128588. * 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
  128589. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  128590. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  128591. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  128592. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  128593. * @param name defines the name of the mesh
  128594. * @param sourceMesh defines the mesh where the decal must be applied
  128595. * @param options defines the options used to create the mesh
  128596. * @param scene defines the hosting scene
  128597. * @returns the decal mesh
  128598. * @see https://doc.babylonjs.com/how_to/decals
  128599. */
  128600. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  128601. position?: Vector3;
  128602. normal?: Vector3;
  128603. size?: Vector3;
  128604. angle?: number;
  128605. }): Mesh;
  128606. }
  128607. }
  128608. declare module BABYLON {
  128609. /**
  128610. * Class containing static functions to help procedurally build meshes
  128611. */
  128612. export class MeshBuilder {
  128613. /**
  128614. * Creates a box mesh
  128615. * * The parameter `size` sets the size (float) of each box side (default 1)
  128616. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128617. * * 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)
  128618. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128622. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128623. * @param name defines the name of the mesh
  128624. * @param options defines the options used to create the mesh
  128625. * @param scene defines the hosting scene
  128626. * @returns the box mesh
  128627. */
  128628. static CreateBox(name: string, options: {
  128629. size?: number;
  128630. width?: number;
  128631. height?: number;
  128632. depth?: number;
  128633. faceUV?: Vector4[];
  128634. faceColors?: Color4[];
  128635. sideOrientation?: number;
  128636. frontUVs?: Vector4;
  128637. backUVs?: Vector4;
  128638. updatable?: boolean;
  128639. }, scene?: Nullable<Scene>): Mesh;
  128640. /**
  128641. * Creates a tiled box mesh
  128642. * * faceTiles sets the pattern, tile size and number of tiles for a face
  128643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128644. * @param name defines the name of the mesh
  128645. * @param options defines the options used to create the mesh
  128646. * @param scene defines the hosting scene
  128647. * @returns the tiled box mesh
  128648. */
  128649. static CreateTiledBox(name: string, options: {
  128650. pattern?: number;
  128651. size?: number;
  128652. width?: number;
  128653. height?: number;
  128654. depth: number;
  128655. tileSize?: number;
  128656. tileWidth?: number;
  128657. tileHeight?: number;
  128658. faceUV?: Vector4[];
  128659. faceColors?: Color4[];
  128660. alignHorizontal?: number;
  128661. alignVertical?: number;
  128662. sideOrientation?: number;
  128663. updatable?: boolean;
  128664. }, scene?: Nullable<Scene>): Mesh;
  128665. /**
  128666. * Creates a sphere mesh
  128667. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128668. * * 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`)
  128669. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128670. * * 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
  128671. * * 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)
  128672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128675. * @param name defines the name of the mesh
  128676. * @param options defines the options used to create the mesh
  128677. * @param scene defines the hosting scene
  128678. * @returns the sphere mesh
  128679. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128680. */
  128681. static CreateSphere(name: string, options: {
  128682. segments?: number;
  128683. diameter?: number;
  128684. diameterX?: number;
  128685. diameterY?: number;
  128686. diameterZ?: number;
  128687. arc?: number;
  128688. slice?: number;
  128689. sideOrientation?: number;
  128690. frontUVs?: Vector4;
  128691. backUVs?: Vector4;
  128692. updatable?: boolean;
  128693. }, scene?: Nullable<Scene>): Mesh;
  128694. /**
  128695. * Creates a plane polygonal mesh. By default, this is a disc
  128696. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  128697. * * 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
  128698. * * 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
  128699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128702. * @param name defines the name of the mesh
  128703. * @param options defines the options used to create the mesh
  128704. * @param scene defines the hosting scene
  128705. * @returns the plane polygonal mesh
  128706. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  128707. */
  128708. static CreateDisc(name: string, options: {
  128709. radius?: number;
  128710. tessellation?: number;
  128711. arc?: number;
  128712. updatable?: boolean;
  128713. sideOrientation?: number;
  128714. frontUVs?: Vector4;
  128715. backUVs?: Vector4;
  128716. }, scene?: Nullable<Scene>): Mesh;
  128717. /**
  128718. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  128719. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  128720. * * 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`)
  128721. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  128722. * * 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
  128723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128726. * @param name defines the name of the mesh
  128727. * @param options defines the options used to create the mesh
  128728. * @param scene defines the hosting scene
  128729. * @returns the icosahedron mesh
  128730. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  128731. */
  128732. static CreateIcoSphere(name: string, options: {
  128733. radius?: number;
  128734. radiusX?: number;
  128735. radiusY?: number;
  128736. radiusZ?: number;
  128737. flat?: boolean;
  128738. subdivisions?: number;
  128739. sideOrientation?: number;
  128740. frontUVs?: Vector4;
  128741. backUVs?: Vector4;
  128742. updatable?: boolean;
  128743. }, scene?: Nullable<Scene>): Mesh;
  128744. /**
  128745. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128746. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128747. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128748. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128749. * * 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
  128750. * * 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
  128751. * * 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
  128752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128755. * * 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
  128756. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128757. * * 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
  128758. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128760. * @param name defines the name of the mesh
  128761. * @param options defines the options used to create the mesh
  128762. * @param scene defines the hosting scene
  128763. * @returns the ribbon mesh
  128764. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128765. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128766. */
  128767. static CreateRibbon(name: string, options: {
  128768. pathArray: Vector3[][];
  128769. closeArray?: boolean;
  128770. closePath?: boolean;
  128771. offset?: number;
  128772. updatable?: boolean;
  128773. sideOrientation?: number;
  128774. frontUVs?: Vector4;
  128775. backUVs?: Vector4;
  128776. instance?: Mesh;
  128777. invertUV?: boolean;
  128778. uvs?: Vector2[];
  128779. colors?: Color4[];
  128780. }, scene?: Nullable<Scene>): Mesh;
  128781. /**
  128782. * Creates a cylinder or a cone mesh
  128783. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  128784. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  128785. * * 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.
  128786. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  128787. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  128788. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  128789. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  128790. * * 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).
  128791. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  128792. * * 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).
  128793. * * 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
  128794. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  128795. * * 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
  128796. * * 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.
  128797. * * If `enclose` is false, a ring surface is one element.
  128798. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  128799. * * 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
  128800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128803. * @param name defines the name of the mesh
  128804. * @param options defines the options used to create the mesh
  128805. * @param scene defines the hosting scene
  128806. * @returns the cylinder mesh
  128807. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  128808. */
  128809. static CreateCylinder(name: string, options: {
  128810. height?: number;
  128811. diameterTop?: number;
  128812. diameterBottom?: number;
  128813. diameter?: number;
  128814. tessellation?: number;
  128815. subdivisions?: number;
  128816. arc?: number;
  128817. faceColors?: Color4[];
  128818. faceUV?: Vector4[];
  128819. updatable?: boolean;
  128820. hasRings?: boolean;
  128821. enclose?: boolean;
  128822. cap?: number;
  128823. sideOrientation?: number;
  128824. frontUVs?: Vector4;
  128825. backUVs?: Vector4;
  128826. }, scene?: Nullable<Scene>): Mesh;
  128827. /**
  128828. * Creates a torus mesh
  128829. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  128830. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  128831. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  128832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128835. * @param name defines the name of the mesh
  128836. * @param options defines the options used to create the mesh
  128837. * @param scene defines the hosting scene
  128838. * @returns the torus mesh
  128839. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  128840. */
  128841. static CreateTorus(name: string, options: {
  128842. diameter?: number;
  128843. thickness?: number;
  128844. tessellation?: number;
  128845. updatable?: boolean;
  128846. sideOrientation?: number;
  128847. frontUVs?: Vector4;
  128848. backUVs?: Vector4;
  128849. }, scene?: Nullable<Scene>): Mesh;
  128850. /**
  128851. * Creates a torus knot mesh
  128852. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  128853. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  128854. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  128855. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  128856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128859. * @param name defines the name of the mesh
  128860. * @param options defines the options used to create the mesh
  128861. * @param scene defines the hosting scene
  128862. * @returns the torus knot mesh
  128863. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  128864. */
  128865. static CreateTorusKnot(name: string, options: {
  128866. radius?: number;
  128867. tube?: number;
  128868. radialSegments?: number;
  128869. tubularSegments?: number;
  128870. p?: number;
  128871. q?: number;
  128872. updatable?: boolean;
  128873. sideOrientation?: number;
  128874. frontUVs?: Vector4;
  128875. backUVs?: Vector4;
  128876. }, scene?: Nullable<Scene>): Mesh;
  128877. /**
  128878. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128879. * * 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
  128880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128881. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128882. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128883. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128884. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128885. * * 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
  128886. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128889. * @param name defines the name of the new line system
  128890. * @param options defines the options used to create the line system
  128891. * @param scene defines the hosting scene
  128892. * @returns a new line system mesh
  128893. */
  128894. static CreateLineSystem(name: string, options: {
  128895. lines: Vector3[][];
  128896. updatable?: boolean;
  128897. instance?: Nullable<LinesMesh>;
  128898. colors?: Nullable<Color4[][]>;
  128899. useVertexAlpha?: boolean;
  128900. }, scene: Nullable<Scene>): LinesMesh;
  128901. /**
  128902. * Creates a line mesh
  128903. * 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
  128904. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128905. * * The parameter `points` is an array successive Vector3
  128906. * * 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
  128907. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128908. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128909. * * When updating an instance, remember that only point positions can change, not the number of points
  128910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128912. * @param name defines the name of the new line system
  128913. * @param options defines the options used to create the line system
  128914. * @param scene defines the hosting scene
  128915. * @returns a new line mesh
  128916. */
  128917. static CreateLines(name: string, options: {
  128918. points: Vector3[];
  128919. updatable?: boolean;
  128920. instance?: Nullable<LinesMesh>;
  128921. colors?: Color4[];
  128922. useVertexAlpha?: boolean;
  128923. }, scene?: Nullable<Scene>): LinesMesh;
  128924. /**
  128925. * Creates a dashed line mesh
  128926. * * 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
  128927. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128928. * * The parameter `points` is an array successive Vector3
  128929. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128930. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128931. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128932. * * 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
  128933. * * When updating an instance, remember that only point positions can change, not the number of points
  128934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128935. * @param name defines the name of the mesh
  128936. * @param options defines the options used to create the mesh
  128937. * @param scene defines the hosting scene
  128938. * @returns the dashed line mesh
  128939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128940. */
  128941. static CreateDashedLines(name: string, options: {
  128942. points: Vector3[];
  128943. dashSize?: number;
  128944. gapSize?: number;
  128945. dashNb?: number;
  128946. updatable?: boolean;
  128947. instance?: LinesMesh;
  128948. }, scene?: Nullable<Scene>): LinesMesh;
  128949. /**
  128950. * 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.
  128951. * * 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.
  128952. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128953. * * 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.
  128954. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128955. * * 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
  128956. * * 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
  128957. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128960. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128962. * @param name defines the name of the mesh
  128963. * @param options defines the options used to create the mesh
  128964. * @param scene defines the hosting scene
  128965. * @returns the extruded shape mesh
  128966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128967. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128968. */
  128969. static ExtrudeShape(name: string, options: {
  128970. shape: Vector3[];
  128971. path: Vector3[];
  128972. scale?: number;
  128973. rotation?: number;
  128974. cap?: number;
  128975. updatable?: boolean;
  128976. sideOrientation?: number;
  128977. frontUVs?: Vector4;
  128978. backUVs?: Vector4;
  128979. instance?: Mesh;
  128980. invertUV?: boolean;
  128981. }, scene?: Nullable<Scene>): Mesh;
  128982. /**
  128983. * Creates an custom extruded shape mesh.
  128984. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128985. * * 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.
  128986. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128987. * * 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
  128988. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128989. * * 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
  128990. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128991. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128992. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128993. * * 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
  128994. * * 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
  128995. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129000. * @param name defines the name of the mesh
  129001. * @param options defines the options used to create the mesh
  129002. * @param scene defines the hosting scene
  129003. * @returns the custom extruded shape mesh
  129004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129007. */
  129008. static ExtrudeShapeCustom(name: string, options: {
  129009. shape: Vector3[];
  129010. path: Vector3[];
  129011. scaleFunction?: any;
  129012. rotationFunction?: any;
  129013. ribbonCloseArray?: boolean;
  129014. ribbonClosePath?: boolean;
  129015. cap?: number;
  129016. updatable?: boolean;
  129017. sideOrientation?: number;
  129018. frontUVs?: Vector4;
  129019. backUVs?: Vector4;
  129020. instance?: Mesh;
  129021. invertUV?: boolean;
  129022. }, scene?: Nullable<Scene>): Mesh;
  129023. /**
  129024. * Creates lathe mesh.
  129025. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129026. * * 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
  129027. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129028. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129029. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129030. * * 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
  129031. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129032. * * 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
  129033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129037. * @param name defines the name of the mesh
  129038. * @param options defines the options used to create the mesh
  129039. * @param scene defines the hosting scene
  129040. * @returns the lathe mesh
  129041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129042. */
  129043. static CreateLathe(name: string, options: {
  129044. shape: Vector3[];
  129045. radius?: number;
  129046. tessellation?: number;
  129047. clip?: number;
  129048. arc?: number;
  129049. closed?: boolean;
  129050. updatable?: boolean;
  129051. sideOrientation?: number;
  129052. frontUVs?: Vector4;
  129053. backUVs?: Vector4;
  129054. cap?: number;
  129055. invertUV?: boolean;
  129056. }, scene?: Nullable<Scene>): Mesh;
  129057. /**
  129058. * Creates a tiled plane mesh
  129059. * * You can set a limited pattern arrangement with the tiles
  129060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129063. * @param name defines the name of the mesh
  129064. * @param options defines the options used to create the mesh
  129065. * @param scene defines the hosting scene
  129066. * @returns the plane mesh
  129067. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  129068. */
  129069. static CreateTiledPlane(name: string, options: {
  129070. pattern?: number;
  129071. tileSize?: number;
  129072. tileWidth?: number;
  129073. tileHeight?: number;
  129074. size?: number;
  129075. width?: number;
  129076. height?: number;
  129077. alignHorizontal?: number;
  129078. alignVertical?: number;
  129079. sideOrientation?: number;
  129080. frontUVs?: Vector4;
  129081. backUVs?: Vector4;
  129082. updatable?: boolean;
  129083. }, scene?: Nullable<Scene>): Mesh;
  129084. /**
  129085. * Creates a plane mesh
  129086. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  129087. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  129088. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  129089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129092. * @param name defines the name of the mesh
  129093. * @param options defines the options used to create the mesh
  129094. * @param scene defines the hosting scene
  129095. * @returns the plane mesh
  129096. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  129097. */
  129098. static CreatePlane(name: string, options: {
  129099. size?: number;
  129100. width?: number;
  129101. height?: number;
  129102. sideOrientation?: number;
  129103. frontUVs?: Vector4;
  129104. backUVs?: Vector4;
  129105. updatable?: boolean;
  129106. sourcePlane?: Plane;
  129107. }, scene?: Nullable<Scene>): Mesh;
  129108. /**
  129109. * Creates a ground mesh
  129110. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  129111. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  129112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129113. * @param name defines the name of the mesh
  129114. * @param options defines the options used to create the mesh
  129115. * @param scene defines the hosting scene
  129116. * @returns the ground mesh
  129117. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  129118. */
  129119. static CreateGround(name: string, options: {
  129120. width?: number;
  129121. height?: number;
  129122. subdivisions?: number;
  129123. subdivisionsX?: number;
  129124. subdivisionsY?: number;
  129125. updatable?: boolean;
  129126. }, scene?: Nullable<Scene>): Mesh;
  129127. /**
  129128. * Creates a tiled ground mesh
  129129. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  129130. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  129131. * * 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
  129132. * * 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
  129133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129134. * @param name defines the name of the mesh
  129135. * @param options defines the options used to create the mesh
  129136. * @param scene defines the hosting scene
  129137. * @returns the tiled ground mesh
  129138. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  129139. */
  129140. static CreateTiledGround(name: string, options: {
  129141. xmin: number;
  129142. zmin: number;
  129143. xmax: number;
  129144. zmax: number;
  129145. subdivisions?: {
  129146. w: number;
  129147. h: number;
  129148. };
  129149. precision?: {
  129150. w: number;
  129151. h: number;
  129152. };
  129153. updatable?: boolean;
  129154. }, scene?: Nullable<Scene>): Mesh;
  129155. /**
  129156. * Creates a ground mesh from a height map
  129157. * * The parameter `url` sets the URL of the height map image resource.
  129158. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  129159. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  129160. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  129161. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  129162. * * 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.
  129163. * * 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).
  129164. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  129165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129166. * @param name defines the name of the mesh
  129167. * @param url defines the url to the height map
  129168. * @param options defines the options used to create the mesh
  129169. * @param scene defines the hosting scene
  129170. * @returns the ground mesh
  129171. * @see https://doc.babylonjs.com/babylon101/height_map
  129172. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  129173. */
  129174. static CreateGroundFromHeightMap(name: string, url: string, options: {
  129175. width?: number;
  129176. height?: number;
  129177. subdivisions?: number;
  129178. minHeight?: number;
  129179. maxHeight?: number;
  129180. colorFilter?: Color3;
  129181. alphaFilter?: number;
  129182. updatable?: boolean;
  129183. onReady?: (mesh: GroundMesh) => void;
  129184. }, scene?: Nullable<Scene>): GroundMesh;
  129185. /**
  129186. * Creates a polygon mesh
  129187. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129188. * * 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
  129189. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129192. * * Remember you can only change the shape positions, not their number when updating a polygon
  129193. * @param name defines the name of the mesh
  129194. * @param options defines the options used to create the mesh
  129195. * @param scene defines the hosting scene
  129196. * @param earcutInjection can be used to inject your own earcut reference
  129197. * @returns the polygon mesh
  129198. */
  129199. static CreatePolygon(name: string, options: {
  129200. shape: Vector3[];
  129201. holes?: Vector3[][];
  129202. depth?: number;
  129203. faceUV?: Vector4[];
  129204. faceColors?: Color4[];
  129205. updatable?: boolean;
  129206. sideOrientation?: number;
  129207. frontUVs?: Vector4;
  129208. backUVs?: Vector4;
  129209. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129210. /**
  129211. * Creates an extruded polygon mesh, with depth in the Y direction.
  129212. * * 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)
  129213. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129214. * @param name defines the name of the mesh
  129215. * @param options defines the options used to create the mesh
  129216. * @param scene defines the hosting scene
  129217. * @param earcutInjection can be used to inject your own earcut reference
  129218. * @returns the polygon mesh
  129219. */
  129220. static ExtrudePolygon(name: string, options: {
  129221. shape: Vector3[];
  129222. holes?: Vector3[][];
  129223. depth?: number;
  129224. faceUV?: Vector4[];
  129225. faceColors?: Color4[];
  129226. updatable?: boolean;
  129227. sideOrientation?: number;
  129228. frontUVs?: Vector4;
  129229. backUVs?: Vector4;
  129230. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129231. /**
  129232. * Creates a tube mesh.
  129233. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129234. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129235. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129236. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129237. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129238. * * 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)
  129239. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129240. * * 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
  129241. * * 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
  129242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129246. * @param name defines the name of the mesh
  129247. * @param options defines the options used to create the mesh
  129248. * @param scene defines the hosting scene
  129249. * @returns the tube mesh
  129250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129251. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129252. */
  129253. static CreateTube(name: string, options: {
  129254. path: Vector3[];
  129255. radius?: number;
  129256. tessellation?: number;
  129257. radiusFunction?: {
  129258. (i: number, distance: number): number;
  129259. };
  129260. cap?: number;
  129261. arc?: number;
  129262. updatable?: boolean;
  129263. sideOrientation?: number;
  129264. frontUVs?: Vector4;
  129265. backUVs?: Vector4;
  129266. instance?: Mesh;
  129267. invertUV?: boolean;
  129268. }, scene?: Nullable<Scene>): Mesh;
  129269. /**
  129270. * Creates a polyhedron mesh
  129271. * * 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
  129272. * * The parameter `size` (positive float, default 1) sets the polygon size
  129273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129274. * * 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`
  129275. * * 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
  129276. * * 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)`)
  129277. * * 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
  129278. * * 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
  129279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129282. * @param name defines the name of the mesh
  129283. * @param options defines the options used to create the mesh
  129284. * @param scene defines the hosting scene
  129285. * @returns the polyhedron mesh
  129286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129287. */
  129288. static CreatePolyhedron(name: string, options: {
  129289. type?: number;
  129290. size?: number;
  129291. sizeX?: number;
  129292. sizeY?: number;
  129293. sizeZ?: number;
  129294. custom?: any;
  129295. faceUV?: Vector4[];
  129296. faceColors?: Color4[];
  129297. flat?: boolean;
  129298. updatable?: boolean;
  129299. sideOrientation?: number;
  129300. frontUVs?: Vector4;
  129301. backUVs?: Vector4;
  129302. }, scene?: Nullable<Scene>): Mesh;
  129303. /**
  129304. * Creates a decal mesh.
  129305. * 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
  129306. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129307. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129308. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129309. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129310. * @param name defines the name of the mesh
  129311. * @param sourceMesh defines the mesh where the decal must be applied
  129312. * @param options defines the options used to create the mesh
  129313. * @param scene defines the hosting scene
  129314. * @returns the decal mesh
  129315. * @see https://doc.babylonjs.com/how_to/decals
  129316. */
  129317. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129318. position?: Vector3;
  129319. normal?: Vector3;
  129320. size?: Vector3;
  129321. angle?: number;
  129322. }): Mesh;
  129323. }
  129324. }
  129325. declare module BABYLON {
  129326. /**
  129327. * A simplifier interface for future simplification implementations
  129328. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129329. */
  129330. export interface ISimplifier {
  129331. /**
  129332. * Simplification of a given mesh according to the given settings.
  129333. * Since this requires computation, it is assumed that the function runs async.
  129334. * @param settings The settings of the simplification, including quality and distance
  129335. * @param successCallback A callback that will be called after the mesh was simplified.
  129336. * @param errorCallback in case of an error, this callback will be called. optional.
  129337. */
  129338. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  129339. }
  129340. /**
  129341. * Expected simplification settings.
  129342. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  129343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129344. */
  129345. export interface ISimplificationSettings {
  129346. /**
  129347. * Gets or sets the expected quality
  129348. */
  129349. quality: number;
  129350. /**
  129351. * Gets or sets the distance when this optimized version should be used
  129352. */
  129353. distance: number;
  129354. /**
  129355. * Gets an already optimized mesh
  129356. */
  129357. optimizeMesh?: boolean;
  129358. }
  129359. /**
  129360. * Class used to specify simplification options
  129361. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129362. */
  129363. export class SimplificationSettings implements ISimplificationSettings {
  129364. /** expected quality */
  129365. quality: number;
  129366. /** distance when this optimized version should be used */
  129367. distance: number;
  129368. /** already optimized mesh */
  129369. optimizeMesh?: boolean | undefined;
  129370. /**
  129371. * Creates a SimplificationSettings
  129372. * @param quality expected quality
  129373. * @param distance distance when this optimized version should be used
  129374. * @param optimizeMesh already optimized mesh
  129375. */
  129376. constructor(
  129377. /** expected quality */
  129378. quality: number,
  129379. /** distance when this optimized version should be used */
  129380. distance: number,
  129381. /** already optimized mesh */
  129382. optimizeMesh?: boolean | undefined);
  129383. }
  129384. /**
  129385. * Interface used to define a simplification task
  129386. */
  129387. export interface ISimplificationTask {
  129388. /**
  129389. * Array of settings
  129390. */
  129391. settings: Array<ISimplificationSettings>;
  129392. /**
  129393. * Simplification type
  129394. */
  129395. simplificationType: SimplificationType;
  129396. /**
  129397. * Mesh to simplify
  129398. */
  129399. mesh: Mesh;
  129400. /**
  129401. * Callback called on success
  129402. */
  129403. successCallback?: () => void;
  129404. /**
  129405. * Defines if parallel processing can be used
  129406. */
  129407. parallelProcessing: boolean;
  129408. }
  129409. /**
  129410. * Queue used to order the simplification tasks
  129411. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129412. */
  129413. export class SimplificationQueue {
  129414. private _simplificationArray;
  129415. /**
  129416. * Gets a boolean indicating that the process is still running
  129417. */
  129418. running: boolean;
  129419. /**
  129420. * Creates a new queue
  129421. */
  129422. constructor();
  129423. /**
  129424. * Adds a new simplification task
  129425. * @param task defines a task to add
  129426. */
  129427. addTask(task: ISimplificationTask): void;
  129428. /**
  129429. * Execute next task
  129430. */
  129431. executeNext(): void;
  129432. /**
  129433. * Execute a simplification task
  129434. * @param task defines the task to run
  129435. */
  129436. runSimplification(task: ISimplificationTask): void;
  129437. private getSimplifier;
  129438. }
  129439. /**
  129440. * The implemented types of simplification
  129441. * At the moment only Quadratic Error Decimation is implemented
  129442. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129443. */
  129444. export enum SimplificationType {
  129445. /** Quadratic error decimation */
  129446. QUADRATIC = 0
  129447. }
  129448. }
  129449. declare module BABYLON {
  129450. interface Scene {
  129451. /** @hidden (Backing field) */
  129452. _simplificationQueue: SimplificationQueue;
  129453. /**
  129454. * Gets or sets the simplification queue attached to the scene
  129455. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  129456. */
  129457. simplificationQueue: SimplificationQueue;
  129458. }
  129459. interface Mesh {
  129460. /**
  129461. * Simplify the mesh according to the given array of settings.
  129462. * Function will return immediately and will simplify async
  129463. * @param settings a collection of simplification settings
  129464. * @param parallelProcessing should all levels calculate parallel or one after the other
  129465. * @param simplificationType the type of simplification to run
  129466. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  129467. * @returns the current mesh
  129468. */
  129469. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  129470. }
  129471. /**
  129472. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  129473. * created in a scene
  129474. */
  129475. export class SimplicationQueueSceneComponent implements ISceneComponent {
  129476. /**
  129477. * The component name helpfull to identify the component in the list of scene components.
  129478. */
  129479. readonly name: string;
  129480. /**
  129481. * The scene the component belongs to.
  129482. */
  129483. scene: Scene;
  129484. /**
  129485. * Creates a new instance of the component for the given scene
  129486. * @param scene Defines the scene to register the component in
  129487. */
  129488. constructor(scene: Scene);
  129489. /**
  129490. * Registers the component in a given scene
  129491. */
  129492. register(): void;
  129493. /**
  129494. * Rebuilds the elements related to this component in case of
  129495. * context lost for instance.
  129496. */
  129497. rebuild(): void;
  129498. /**
  129499. * Disposes the component and the associated ressources
  129500. */
  129501. dispose(): void;
  129502. private _beforeCameraUpdate;
  129503. }
  129504. }
  129505. declare module BABYLON {
  129506. /**
  129507. * Navigation plugin interface to add navigation constrained by a navigation mesh
  129508. */
  129509. export interface INavigationEnginePlugin {
  129510. /**
  129511. * plugin name
  129512. */
  129513. name: string;
  129514. /**
  129515. * Creates a navigation mesh
  129516. * @param meshes array of all the geometry used to compute the navigatio mesh
  129517. * @param parameters bunch of parameters used to filter geometry
  129518. */
  129519. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  129520. /**
  129521. * Create a navigation mesh debug mesh
  129522. * @param scene is where the mesh will be added
  129523. * @returns debug display mesh
  129524. */
  129525. createDebugNavMesh(scene: Scene): Mesh;
  129526. /**
  129527. * Get a navigation mesh constrained position, closest to the parameter position
  129528. * @param position world position
  129529. * @returns the closest point to position constrained by the navigation mesh
  129530. */
  129531. getClosestPoint(position: Vector3): Vector3;
  129532. /**
  129533. * Get a navigation mesh constrained position, within a particular radius
  129534. * @param position world position
  129535. * @param maxRadius the maximum distance to the constrained world position
  129536. * @returns the closest point to position constrained by the navigation mesh
  129537. */
  129538. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  129539. /**
  129540. * Compute the final position from a segment made of destination-position
  129541. * @param position world position
  129542. * @param destination world position
  129543. * @returns the resulting point along the navmesh
  129544. */
  129545. moveAlong(position: Vector3, destination: Vector3): Vector3;
  129546. /**
  129547. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  129548. * @param start world position
  129549. * @param end world position
  129550. * @returns array containing world position composing the path
  129551. */
  129552. computePath(start: Vector3, end: Vector3): Vector3[];
  129553. /**
  129554. * If this plugin is supported
  129555. * @returns true if plugin is supported
  129556. */
  129557. isSupported(): boolean;
  129558. /**
  129559. * Create a new Crowd so you can add agents
  129560. * @param maxAgents the maximum agent count in the crowd
  129561. * @param maxAgentRadius the maximum radius an agent can have
  129562. * @param scene to attach the crowd to
  129563. * @returns the crowd you can add agents to
  129564. */
  129565. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  129566. /**
  129567. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  129568. * The queries will try to find a solution within those bounds
  129569. * default is (1,1,1)
  129570. * @param extent x,y,z value that define the extent around the queries point of reference
  129571. */
  129572. setDefaultQueryExtent(extent: Vector3): void;
  129573. /**
  129574. * Get the Bounding box extent specified by setDefaultQueryExtent
  129575. * @returns the box extent values
  129576. */
  129577. getDefaultQueryExtent(): Vector3;
  129578. /**
  129579. * Release all resources
  129580. */
  129581. dispose(): void;
  129582. }
  129583. /**
  129584. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  129585. */
  129586. export interface ICrowd {
  129587. /**
  129588. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  129589. * You can attach anything to that node. The node position is updated in the scene update tick.
  129590. * @param pos world position that will be constrained by the navigation mesh
  129591. * @param parameters agent parameters
  129592. * @param transform hooked to the agent that will be update by the scene
  129593. * @returns agent index
  129594. */
  129595. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  129596. /**
  129597. * Returns the agent position in world space
  129598. * @param index agent index returned by addAgent
  129599. * @returns world space position
  129600. */
  129601. getAgentPosition(index: number): Vector3;
  129602. /**
  129603. * Gets the agent velocity in world space
  129604. * @param index agent index returned by addAgent
  129605. * @returns world space velocity
  129606. */
  129607. getAgentVelocity(index: number): Vector3;
  129608. /**
  129609. * remove a particular agent previously created
  129610. * @param index agent index returned by addAgent
  129611. */
  129612. removeAgent(index: number): void;
  129613. /**
  129614. * get the list of all agents attached to this crowd
  129615. * @returns list of agent indices
  129616. */
  129617. getAgents(): number[];
  129618. /**
  129619. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  129620. * @param deltaTime in seconds
  129621. */
  129622. update(deltaTime: number): void;
  129623. /**
  129624. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  129625. * @param index agent index returned by addAgent
  129626. * @param destination targeted world position
  129627. */
  129628. agentGoto(index: number, destination: Vector3): void;
  129629. /**
  129630. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  129631. * The queries will try to find a solution within those bounds
  129632. * default is (1,1,1)
  129633. * @param extent x,y,z value that define the extent around the queries point of reference
  129634. */
  129635. setDefaultQueryExtent(extent: Vector3): void;
  129636. /**
  129637. * Get the Bounding box extent specified by setDefaultQueryExtent
  129638. * @returns the box extent values
  129639. */
  129640. getDefaultQueryExtent(): Vector3;
  129641. /**
  129642. * Release all resources
  129643. */
  129644. dispose(): void;
  129645. }
  129646. /**
  129647. * Configures an agent
  129648. */
  129649. export interface IAgentParameters {
  129650. /**
  129651. * Agent radius. [Limit: >= 0]
  129652. */
  129653. radius: number;
  129654. /**
  129655. * Agent height. [Limit: > 0]
  129656. */
  129657. height: number;
  129658. /**
  129659. * Maximum allowed acceleration. [Limit: >= 0]
  129660. */
  129661. maxAcceleration: number;
  129662. /**
  129663. * Maximum allowed speed. [Limit: >= 0]
  129664. */
  129665. maxSpeed: number;
  129666. /**
  129667. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  129668. */
  129669. collisionQueryRange: number;
  129670. /**
  129671. * The path visibility optimization range. [Limit: > 0]
  129672. */
  129673. pathOptimizationRange: number;
  129674. /**
  129675. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  129676. */
  129677. separationWeight: number;
  129678. }
  129679. /**
  129680. * Configures the navigation mesh creation
  129681. */
  129682. export interface INavMeshParameters {
  129683. /**
  129684. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  129685. */
  129686. cs: number;
  129687. /**
  129688. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  129689. */
  129690. ch: number;
  129691. /**
  129692. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  129693. */
  129694. walkableSlopeAngle: number;
  129695. /**
  129696. * Minimum floor to 'ceiling' height that will still allow the floor area to
  129697. * be considered walkable. [Limit: >= 3] [Units: vx]
  129698. */
  129699. walkableHeight: number;
  129700. /**
  129701. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  129702. */
  129703. walkableClimb: number;
  129704. /**
  129705. * The distance to erode/shrink the walkable area of the heightfield away from
  129706. * obstructions. [Limit: >=0] [Units: vx]
  129707. */
  129708. walkableRadius: number;
  129709. /**
  129710. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  129711. */
  129712. maxEdgeLen: number;
  129713. /**
  129714. * The maximum distance a simplfied contour's border edges should deviate
  129715. * the original raw contour. [Limit: >=0] [Units: vx]
  129716. */
  129717. maxSimplificationError: number;
  129718. /**
  129719. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  129720. */
  129721. minRegionArea: number;
  129722. /**
  129723. * Any regions with a span count smaller than this value will, if possible,
  129724. * be merged with larger regions. [Limit: >=0] [Units: vx]
  129725. */
  129726. mergeRegionArea: number;
  129727. /**
  129728. * The maximum number of vertices allowed for polygons generated during the
  129729. * contour to polygon conversion process. [Limit: >= 3]
  129730. */
  129731. maxVertsPerPoly: number;
  129732. /**
  129733. * Sets the sampling distance to use when generating the detail mesh.
  129734. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  129735. */
  129736. detailSampleDist: number;
  129737. /**
  129738. * The maximum distance the detail mesh surface should deviate from heightfield
  129739. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  129740. */
  129741. detailSampleMaxError: number;
  129742. }
  129743. }
  129744. declare module BABYLON {
  129745. /**
  129746. * RecastJS navigation plugin
  129747. */
  129748. export class RecastJSPlugin implements INavigationEnginePlugin {
  129749. /**
  129750. * Reference to the Recast library
  129751. */
  129752. bjsRECAST: any;
  129753. /**
  129754. * plugin name
  129755. */
  129756. name: string;
  129757. /**
  129758. * the first navmesh created. We might extend this to support multiple navmeshes
  129759. */
  129760. navMesh: any;
  129761. /**
  129762. * Initializes the recastJS plugin
  129763. * @param recastInjection can be used to inject your own recast reference
  129764. */
  129765. constructor(recastInjection?: any);
  129766. /**
  129767. * Creates a navigation mesh
  129768. * @param meshes array of all the geometry used to compute the navigatio mesh
  129769. * @param parameters bunch of parameters used to filter geometry
  129770. */
  129771. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  129772. /**
  129773. * Create a navigation mesh debug mesh
  129774. * @param scene is where the mesh will be added
  129775. * @returns debug display mesh
  129776. */
  129777. createDebugNavMesh(scene: Scene): Mesh;
  129778. /**
  129779. * Get a navigation mesh constrained position, closest to the parameter position
  129780. * @param position world position
  129781. * @returns the closest point to position constrained by the navigation mesh
  129782. */
  129783. getClosestPoint(position: Vector3): Vector3;
  129784. /**
  129785. * Get a navigation mesh constrained position, within a particular radius
  129786. * @param position world position
  129787. * @param maxRadius the maximum distance to the constrained world position
  129788. * @returns the closest point to position constrained by the navigation mesh
  129789. */
  129790. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  129791. /**
  129792. * Compute the final position from a segment made of destination-position
  129793. * @param position world position
  129794. * @param destination world position
  129795. * @returns the resulting point along the navmesh
  129796. */
  129797. moveAlong(position: Vector3, destination: Vector3): Vector3;
  129798. /**
  129799. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  129800. * @param start world position
  129801. * @param end world position
  129802. * @returns array containing world position composing the path
  129803. */
  129804. computePath(start: Vector3, end: Vector3): Vector3[];
  129805. /**
  129806. * Create a new Crowd so you can add agents
  129807. * @param maxAgents the maximum agent count in the crowd
  129808. * @param maxAgentRadius the maximum radius an agent can have
  129809. * @param scene to attach the crowd to
  129810. * @returns the crowd you can add agents to
  129811. */
  129812. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  129813. /**
  129814. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  129815. * The queries will try to find a solution within those bounds
  129816. * default is (1,1,1)
  129817. * @param extent x,y,z value that define the extent around the queries point of reference
  129818. */
  129819. setDefaultQueryExtent(extent: Vector3): void;
  129820. /**
  129821. * Get the Bounding box extent specified by setDefaultQueryExtent
  129822. * @returns the box extent values
  129823. */
  129824. getDefaultQueryExtent(): Vector3;
  129825. /**
  129826. * Disposes
  129827. */
  129828. dispose(): void;
  129829. /**
  129830. * If this plugin is supported
  129831. * @returns true if plugin is supported
  129832. */
  129833. isSupported(): boolean;
  129834. }
  129835. /**
  129836. * Recast detour crowd implementation
  129837. */
  129838. export class RecastJSCrowd implements ICrowd {
  129839. /**
  129840. * Recast/detour plugin
  129841. */
  129842. bjsRECASTPlugin: RecastJSPlugin;
  129843. /**
  129844. * Link to the detour crowd
  129845. */
  129846. recastCrowd: any;
  129847. /**
  129848. * One transform per agent
  129849. */
  129850. transforms: TransformNode[];
  129851. /**
  129852. * All agents created
  129853. */
  129854. agents: number[];
  129855. /**
  129856. * Link to the scene is kept to unregister the crowd from the scene
  129857. */
  129858. private _scene;
  129859. /**
  129860. * Observer for crowd updates
  129861. */
  129862. private _onBeforeAnimationsObserver;
  129863. /**
  129864. * Constructor
  129865. * @param plugin recastJS plugin
  129866. * @param maxAgents the maximum agent count in the crowd
  129867. * @param maxAgentRadius the maximum radius an agent can have
  129868. * @param scene to attach the crowd to
  129869. * @returns the crowd you can add agents to
  129870. */
  129871. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  129872. /**
  129873. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  129874. * You can attach anything to that node. The node position is updated in the scene update tick.
  129875. * @param pos world position that will be constrained by the navigation mesh
  129876. * @param parameters agent parameters
  129877. * @param transform hooked to the agent that will be update by the scene
  129878. * @returns agent index
  129879. */
  129880. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  129881. /**
  129882. * Returns the agent position in world space
  129883. * @param index agent index returned by addAgent
  129884. * @returns world space position
  129885. */
  129886. getAgentPosition(index: number): Vector3;
  129887. /**
  129888. * Returns the agent velocity in world space
  129889. * @param index agent index returned by addAgent
  129890. * @returns world space velocity
  129891. */
  129892. getAgentVelocity(index: number): Vector3;
  129893. /**
  129894. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  129895. * @param index agent index returned by addAgent
  129896. * @param destination targeted world position
  129897. */
  129898. agentGoto(index: number, destination: Vector3): void;
  129899. /**
  129900. * remove a particular agent previously created
  129901. * @param index agent index returned by addAgent
  129902. */
  129903. removeAgent(index: number): void;
  129904. /**
  129905. * get the list of all agents attached to this crowd
  129906. * @returns list of agent indices
  129907. */
  129908. getAgents(): number[];
  129909. /**
  129910. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  129911. * @param deltaTime in seconds
  129912. */
  129913. update(deltaTime: number): void;
  129914. /**
  129915. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  129916. * The queries will try to find a solution within those bounds
  129917. * default is (1,1,1)
  129918. * @param extent x,y,z value that define the extent around the queries point of reference
  129919. */
  129920. setDefaultQueryExtent(extent: Vector3): void;
  129921. /**
  129922. * Get the Bounding box extent specified by setDefaultQueryExtent
  129923. * @returns the box extent values
  129924. */
  129925. getDefaultQueryExtent(): Vector3;
  129926. /**
  129927. * Release all resources
  129928. */
  129929. dispose(): void;
  129930. }
  129931. }
  129932. declare module BABYLON {
  129933. /**
  129934. * Class used to enable access to IndexedDB
  129935. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  129936. */
  129937. export class Database implements IOfflineProvider {
  129938. private _callbackManifestChecked;
  129939. private _currentSceneUrl;
  129940. private _db;
  129941. private _enableSceneOffline;
  129942. private _enableTexturesOffline;
  129943. private _manifestVersionFound;
  129944. private _mustUpdateRessources;
  129945. private _hasReachedQuota;
  129946. private _isSupported;
  129947. private _idbFactory;
  129948. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  129949. private static IsUASupportingBlobStorage;
  129950. /**
  129951. * Gets a boolean indicating if Database storate is enabled (off by default)
  129952. */
  129953. static IDBStorageEnabled: boolean;
  129954. /**
  129955. * Gets a boolean indicating if scene must be saved in the database
  129956. */
  129957. readonly enableSceneOffline: boolean;
  129958. /**
  129959. * Gets a boolean indicating if textures must be saved in the database
  129960. */
  129961. readonly enableTexturesOffline: boolean;
  129962. /**
  129963. * Creates a new Database
  129964. * @param urlToScene defines the url to load the scene
  129965. * @param callbackManifestChecked defines the callback to use when manifest is checked
  129966. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  129967. */
  129968. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  129969. private static _ParseURL;
  129970. private static _ReturnFullUrlLocation;
  129971. private _checkManifestFile;
  129972. /**
  129973. * Open the database and make it available
  129974. * @param successCallback defines the callback to call on success
  129975. * @param errorCallback defines the callback to call on error
  129976. */
  129977. open(successCallback: () => void, errorCallback: () => void): void;
  129978. /**
  129979. * Loads an image from the database
  129980. * @param url defines the url to load from
  129981. * @param image defines the target DOM image
  129982. */
  129983. loadImage(url: string, image: HTMLImageElement): void;
  129984. private _loadImageFromDBAsync;
  129985. private _saveImageIntoDBAsync;
  129986. private _checkVersionFromDB;
  129987. private _loadVersionFromDBAsync;
  129988. private _saveVersionIntoDBAsync;
  129989. /**
  129990. * Loads a file from database
  129991. * @param url defines the URL to load from
  129992. * @param sceneLoaded defines a callback to call on success
  129993. * @param progressCallBack defines a callback to call when progress changed
  129994. * @param errorCallback defines a callback to call on error
  129995. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  129996. */
  129997. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  129998. private _loadFileAsync;
  129999. private _saveFileAsync;
  130000. /**
  130001. * Validates if xhr data is correct
  130002. * @param xhr defines the request to validate
  130003. * @param dataType defines the expected data type
  130004. * @returns true if data is correct
  130005. */
  130006. private static _ValidateXHRData;
  130007. }
  130008. }
  130009. declare module BABYLON {
  130010. /** @hidden */
  130011. export var gpuUpdateParticlesPixelShader: {
  130012. name: string;
  130013. shader: string;
  130014. };
  130015. }
  130016. declare module BABYLON {
  130017. /** @hidden */
  130018. export var gpuUpdateParticlesVertexShader: {
  130019. name: string;
  130020. shader: string;
  130021. };
  130022. }
  130023. declare module BABYLON {
  130024. /** @hidden */
  130025. export var clipPlaneFragmentDeclaration2: {
  130026. name: string;
  130027. shader: string;
  130028. };
  130029. }
  130030. declare module BABYLON {
  130031. /** @hidden */
  130032. export var gpuRenderParticlesPixelShader: {
  130033. name: string;
  130034. shader: string;
  130035. };
  130036. }
  130037. declare module BABYLON {
  130038. /** @hidden */
  130039. export var clipPlaneVertexDeclaration2: {
  130040. name: string;
  130041. shader: string;
  130042. };
  130043. }
  130044. declare module BABYLON {
  130045. /** @hidden */
  130046. export var gpuRenderParticlesVertexShader: {
  130047. name: string;
  130048. shader: string;
  130049. };
  130050. }
  130051. declare module BABYLON {
  130052. /**
  130053. * This represents a GPU particle system in Babylon
  130054. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  130055. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  130056. */
  130057. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  130058. /**
  130059. * The layer mask we are rendering the particles through.
  130060. */
  130061. layerMask: number;
  130062. private _capacity;
  130063. private _activeCount;
  130064. private _currentActiveCount;
  130065. private _accumulatedCount;
  130066. private _renderEffect;
  130067. private _updateEffect;
  130068. private _buffer0;
  130069. private _buffer1;
  130070. private _spriteBuffer;
  130071. private _updateVAO;
  130072. private _renderVAO;
  130073. private _targetIndex;
  130074. private _sourceBuffer;
  130075. private _targetBuffer;
  130076. private _engine;
  130077. private _currentRenderId;
  130078. private _started;
  130079. private _stopped;
  130080. private _timeDelta;
  130081. private _randomTexture;
  130082. private _randomTexture2;
  130083. private _attributesStrideSize;
  130084. private _updateEffectOptions;
  130085. private _randomTextureSize;
  130086. private _actualFrame;
  130087. private readonly _rawTextureWidth;
  130088. /**
  130089. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  130090. */
  130091. static readonly IsSupported: boolean;
  130092. /**
  130093. * An event triggered when the system is disposed.
  130094. */
  130095. onDisposeObservable: Observable<GPUParticleSystem>;
  130096. /**
  130097. * Gets the maximum number of particles active at the same time.
  130098. * @returns The max number of active particles.
  130099. */
  130100. getCapacity(): number;
  130101. /**
  130102. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  130103. * to override the particles.
  130104. */
  130105. forceDepthWrite: boolean;
  130106. /**
  130107. * Gets or set the number of active particles
  130108. */
  130109. activeParticleCount: number;
  130110. private _preWarmDone;
  130111. /**
  130112. * Is this system ready to be used/rendered
  130113. * @return true if the system is ready
  130114. */
  130115. isReady(): boolean;
  130116. /**
  130117. * Gets if the system has been started. (Note: this will still be true after stop is called)
  130118. * @returns True if it has been started, otherwise false.
  130119. */
  130120. isStarted(): boolean;
  130121. /**
  130122. * Starts the particle system and begins to emit
  130123. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  130124. */
  130125. start(delay?: number): void;
  130126. /**
  130127. * Stops the particle system.
  130128. */
  130129. stop(): void;
  130130. /**
  130131. * Remove all active particles
  130132. */
  130133. reset(): void;
  130134. /**
  130135. * Returns the string "GPUParticleSystem"
  130136. * @returns a string containing the class name
  130137. */
  130138. getClassName(): string;
  130139. private _colorGradientsTexture;
  130140. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  130141. /**
  130142. * Adds a new color gradient
  130143. * @param gradient defines the gradient to use (between 0 and 1)
  130144. * @param color1 defines the color to affect to the specified gradient
  130145. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  130146. * @returns the current particle system
  130147. */
  130148. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  130149. /**
  130150. * Remove a specific color gradient
  130151. * @param gradient defines the gradient to remove
  130152. * @returns the current particle system
  130153. */
  130154. removeColorGradient(gradient: number): GPUParticleSystem;
  130155. private _angularSpeedGradientsTexture;
  130156. private _sizeGradientsTexture;
  130157. private _velocityGradientsTexture;
  130158. private _limitVelocityGradientsTexture;
  130159. private _dragGradientsTexture;
  130160. private _addFactorGradient;
  130161. /**
  130162. * Adds a new size gradient
  130163. * @param gradient defines the gradient to use (between 0 and 1)
  130164. * @param factor defines the size factor to affect to the specified gradient
  130165. * @returns the current particle system
  130166. */
  130167. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  130168. /**
  130169. * Remove a specific size gradient
  130170. * @param gradient defines the gradient to remove
  130171. * @returns the current particle system
  130172. */
  130173. removeSizeGradient(gradient: number): GPUParticleSystem;
  130174. /**
  130175. * Adds a new angular speed gradient
  130176. * @param gradient defines the gradient to use (between 0 and 1)
  130177. * @param factor defines the angular speed to affect to the specified gradient
  130178. * @returns the current particle system
  130179. */
  130180. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  130181. /**
  130182. * Remove a specific angular speed gradient
  130183. * @param gradient defines the gradient to remove
  130184. * @returns the current particle system
  130185. */
  130186. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  130187. /**
  130188. * Adds a new velocity gradient
  130189. * @param gradient defines the gradient to use (between 0 and 1)
  130190. * @param factor defines the velocity to affect to the specified gradient
  130191. * @returns the current particle system
  130192. */
  130193. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  130194. /**
  130195. * Remove a specific velocity gradient
  130196. * @param gradient defines the gradient to remove
  130197. * @returns the current particle system
  130198. */
  130199. removeVelocityGradient(gradient: number): GPUParticleSystem;
  130200. /**
  130201. * Adds a new limit velocity gradient
  130202. * @param gradient defines the gradient to use (between 0 and 1)
  130203. * @param factor defines the limit velocity value to affect to the specified gradient
  130204. * @returns the current particle system
  130205. */
  130206. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  130207. /**
  130208. * Remove a specific limit velocity gradient
  130209. * @param gradient defines the gradient to remove
  130210. * @returns the current particle system
  130211. */
  130212. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  130213. /**
  130214. * Adds a new drag gradient
  130215. * @param gradient defines the gradient to use (between 0 and 1)
  130216. * @param factor defines the drag value to affect to the specified gradient
  130217. * @returns the current particle system
  130218. */
  130219. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  130220. /**
  130221. * Remove a specific drag gradient
  130222. * @param gradient defines the gradient to remove
  130223. * @returns the current particle system
  130224. */
  130225. removeDragGradient(gradient: number): GPUParticleSystem;
  130226. /**
  130227. * Not supported by GPUParticleSystem
  130228. * @param gradient defines the gradient to use (between 0 and 1)
  130229. * @param factor defines the emit rate value to affect to the specified gradient
  130230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  130231. * @returns the current particle system
  130232. */
  130233. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  130234. /**
  130235. * Not supported by GPUParticleSystem
  130236. * @param gradient defines the gradient to remove
  130237. * @returns the current particle system
  130238. */
  130239. removeEmitRateGradient(gradient: number): IParticleSystem;
  130240. /**
  130241. * Not supported by GPUParticleSystem
  130242. * @param gradient defines the gradient to use (between 0 and 1)
  130243. * @param factor defines the start size value to affect to the specified gradient
  130244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  130245. * @returns the current particle system
  130246. */
  130247. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  130248. /**
  130249. * Not supported by GPUParticleSystem
  130250. * @param gradient defines the gradient to remove
  130251. * @returns the current particle system
  130252. */
  130253. removeStartSizeGradient(gradient: number): IParticleSystem;
  130254. /**
  130255. * Not supported by GPUParticleSystem
  130256. * @param gradient defines the gradient to use (between 0 and 1)
  130257. * @param min defines the color remap minimal range
  130258. * @param max defines the color remap maximal range
  130259. * @returns the current particle system
  130260. */
  130261. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  130262. /**
  130263. * Not supported by GPUParticleSystem
  130264. * @param gradient defines the gradient to remove
  130265. * @returns the current particle system
  130266. */
  130267. removeColorRemapGradient(): IParticleSystem;
  130268. /**
  130269. * Not supported by GPUParticleSystem
  130270. * @param gradient defines the gradient to use (between 0 and 1)
  130271. * @param min defines the alpha remap minimal range
  130272. * @param max defines the alpha remap maximal range
  130273. * @returns the current particle system
  130274. */
  130275. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  130276. /**
  130277. * Not supported by GPUParticleSystem
  130278. * @param gradient defines the gradient to remove
  130279. * @returns the current particle system
  130280. */
  130281. removeAlphaRemapGradient(): IParticleSystem;
  130282. /**
  130283. * Not supported by GPUParticleSystem
  130284. * @param gradient defines the gradient to use (between 0 and 1)
  130285. * @param color defines the color to affect to the specified gradient
  130286. * @returns the current particle system
  130287. */
  130288. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  130289. /**
  130290. * Not supported by GPUParticleSystem
  130291. * @param gradient defines the gradient to remove
  130292. * @returns the current particle system
  130293. */
  130294. removeRampGradient(): IParticleSystem;
  130295. /**
  130296. * Not supported by GPUParticleSystem
  130297. * @returns the list of ramp gradients
  130298. */
  130299. getRampGradients(): Nullable<Array<Color3Gradient>>;
  130300. /**
  130301. * Not supported by GPUParticleSystem
  130302. * Gets or sets a boolean indicating that ramp gradients must be used
  130303. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  130304. */
  130305. useRampGradients: boolean;
  130306. /**
  130307. * Not supported by GPUParticleSystem
  130308. * @param gradient defines the gradient to use (between 0 and 1)
  130309. * @param factor defines the life time factor to affect to the specified gradient
  130310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  130311. * @returns the current particle system
  130312. */
  130313. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  130314. /**
  130315. * Not supported by GPUParticleSystem
  130316. * @param gradient defines the gradient to remove
  130317. * @returns the current particle system
  130318. */
  130319. removeLifeTimeGradient(gradient: number): IParticleSystem;
  130320. /**
  130321. * Instantiates a GPU particle system.
  130322. * 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.
  130323. * @param name The name of the particle system
  130324. * @param options The options used to create the system
  130325. * @param scene The scene the particle system belongs to
  130326. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  130327. */
  130328. constructor(name: string, options: Partial<{
  130329. capacity: number;
  130330. randomTextureSize: number;
  130331. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  130332. protected _reset(): void;
  130333. private _createUpdateVAO;
  130334. private _createRenderVAO;
  130335. private _initialize;
  130336. /** @hidden */
  130337. _recreateUpdateEffect(): void;
  130338. /** @hidden */
  130339. _recreateRenderEffect(): void;
  130340. /**
  130341. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  130342. * @param preWarm defines if we are in the pre-warmimg phase
  130343. */
  130344. animate(preWarm?: boolean): void;
  130345. private _createFactorGradientTexture;
  130346. private _createSizeGradientTexture;
  130347. private _createAngularSpeedGradientTexture;
  130348. private _createVelocityGradientTexture;
  130349. private _createLimitVelocityGradientTexture;
  130350. private _createDragGradientTexture;
  130351. private _createColorGradientTexture;
  130352. /**
  130353. * Renders the particle system in its current state
  130354. * @param preWarm defines if the system should only update the particles but not render them
  130355. * @returns the current number of particles
  130356. */
  130357. render(preWarm?: boolean): number;
  130358. /**
  130359. * Rebuilds the particle system
  130360. */
  130361. rebuild(): void;
  130362. private _releaseBuffers;
  130363. private _releaseVAOs;
  130364. /**
  130365. * Disposes the particle system and free the associated resources
  130366. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  130367. */
  130368. dispose(disposeTexture?: boolean): void;
  130369. /**
  130370. * Clones the particle system.
  130371. * @param name The name of the cloned object
  130372. * @param newEmitter The new emitter to use
  130373. * @returns the cloned particle system
  130374. */
  130375. clone(name: string, newEmitter: any): GPUParticleSystem;
  130376. /**
  130377. * Serializes the particle system to a JSON object.
  130378. * @returns the JSON object
  130379. */
  130380. serialize(): any;
  130381. /**
  130382. * Parses a JSON object to create a GPU particle system.
  130383. * @param parsedParticleSystem The JSON object to parse
  130384. * @param scene The scene to create the particle system in
  130385. * @param rootUrl The root url to use to load external dependencies like texture
  130386. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  130387. * @returns the parsed GPU particle system
  130388. */
  130389. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  130390. }
  130391. }
  130392. declare module BABYLON {
  130393. /**
  130394. * Represents a set of particle systems working together to create a specific effect
  130395. */
  130396. export class ParticleSystemSet implements IDisposable {
  130397. /**
  130398. * Gets or sets base Assets URL
  130399. */
  130400. static BaseAssetsUrl: string;
  130401. private _emitterCreationOptions;
  130402. private _emitterNode;
  130403. /**
  130404. * Gets the particle system list
  130405. */
  130406. systems: IParticleSystem[];
  130407. /**
  130408. * Gets the emitter node used with this set
  130409. */
  130410. readonly emitterNode: Nullable<TransformNode>;
  130411. /**
  130412. * Creates a new emitter mesh as a sphere
  130413. * @param options defines the options used to create the sphere
  130414. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  130415. * @param scene defines the hosting scene
  130416. */
  130417. setEmitterAsSphere(options: {
  130418. diameter: number;
  130419. segments: number;
  130420. color: Color3;
  130421. }, renderingGroupId: number, scene: Scene): void;
  130422. /**
  130423. * Starts all particle systems of the set
  130424. * @param emitter defines an optional mesh to use as emitter for the particle systems
  130425. */
  130426. start(emitter?: AbstractMesh): void;
  130427. /**
  130428. * Release all associated resources
  130429. */
  130430. dispose(): void;
  130431. /**
  130432. * Serialize the set into a JSON compatible object
  130433. * @returns a JSON compatible representation of the set
  130434. */
  130435. serialize(): any;
  130436. /**
  130437. * Parse a new ParticleSystemSet from a serialized source
  130438. * @param data defines a JSON compatible representation of the set
  130439. * @param scene defines the hosting scene
  130440. * @param gpu defines if we want GPU particles or CPU particles
  130441. * @returns a new ParticleSystemSet
  130442. */
  130443. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  130444. }
  130445. }
  130446. declare module BABYLON {
  130447. /**
  130448. * This class is made for on one-liner static method to help creating particle system set.
  130449. */
  130450. export class ParticleHelper {
  130451. /**
  130452. * Gets or sets base Assets URL
  130453. */
  130454. static BaseAssetsUrl: string;
  130455. /**
  130456. * Create a default particle system that you can tweak
  130457. * @param emitter defines the emitter to use
  130458. * @param capacity defines the system capacity (default is 500 particles)
  130459. * @param scene defines the hosting scene
  130460. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  130461. * @returns the new Particle system
  130462. */
  130463. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  130464. /**
  130465. * This is the main static method (one-liner) of this helper to create different particle systems
  130466. * @param type This string represents the type to the particle system to create
  130467. * @param scene The scene where the particle system should live
  130468. * @param gpu If the system will use gpu
  130469. * @returns the ParticleSystemSet created
  130470. */
  130471. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  130472. /**
  130473. * Static function used to export a particle system to a ParticleSystemSet variable.
  130474. * Please note that the emitter shape is not exported
  130475. * @param systems defines the particle systems to export
  130476. * @returns the created particle system set
  130477. */
  130478. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  130479. }
  130480. }
  130481. declare module BABYLON {
  130482. interface Engine {
  130483. /**
  130484. * Create an effect to use with particle systems.
  130485. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  130486. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  130487. * @param uniformsNames defines a list of attribute names
  130488. * @param samplers defines an array of string used to represent textures
  130489. * @param defines defines the string containing the defines to use to compile the shaders
  130490. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  130491. * @param onCompiled defines a function to call when the effect creation is successful
  130492. * @param onError defines a function to call when the effect creation has failed
  130493. * @returns the new Effect
  130494. */
  130495. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  130496. }
  130497. interface Mesh {
  130498. /**
  130499. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  130500. * @returns an array of IParticleSystem
  130501. */
  130502. getEmittedParticleSystems(): IParticleSystem[];
  130503. /**
  130504. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  130505. * @returns an array of IParticleSystem
  130506. */
  130507. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  130508. }
  130509. /**
  130510. * @hidden
  130511. */
  130512. export var _IDoNeedToBeInTheBuild: number;
  130513. }
  130514. declare module BABYLON {
  130515. /** Defines the 4 color options */
  130516. export enum PointColor {
  130517. /** color value */
  130518. Color = 2,
  130519. /** uv value */
  130520. UV = 1,
  130521. /** random value */
  130522. Random = 0,
  130523. /** stated value */
  130524. Stated = 3
  130525. }
  130526. /**
  130527. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  130528. * 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.
  130529. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  130530. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  130531. *
  130532. * Full documentation here : TO BE ENTERED
  130533. */
  130534. export class PointsCloudSystem implements IDisposable {
  130535. /**
  130536. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  130537. * Example : var p = SPS.particles[i];
  130538. */
  130539. particles: CloudPoint[];
  130540. /**
  130541. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  130542. */
  130543. nbParticles: number;
  130544. /**
  130545. * This a counter for your own usage. It's not set by any SPS functions.
  130546. */
  130547. counter: number;
  130548. /**
  130549. * The PCS name. This name is also given to the underlying mesh.
  130550. */
  130551. name: string;
  130552. /**
  130553. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  130554. */
  130555. mesh: Mesh;
  130556. /**
  130557. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  130558. * Please read :
  130559. */
  130560. vars: any;
  130561. /**
  130562. * @hidden
  130563. */
  130564. _size: number;
  130565. private _scene;
  130566. private _promises;
  130567. private _positions;
  130568. private _indices;
  130569. private _normals;
  130570. private _colors;
  130571. private _uvs;
  130572. private _indices32;
  130573. private _positions32;
  130574. private _colors32;
  130575. private _uvs32;
  130576. private _updatable;
  130577. private _isVisibilityBoxLocked;
  130578. private _alwaysVisible;
  130579. private _groups;
  130580. private _groupCounter;
  130581. private _computeParticleColor;
  130582. private _computeParticleTexture;
  130583. private _computeParticleRotation;
  130584. private _computeBoundingBox;
  130585. private _isReady;
  130586. /**
  130587. * Creates a PCS (Points Cloud System) object
  130588. * @param name (String) is the PCS name, this will be the underlying mesh name
  130589. * @param pointSize (number) is the size for each point
  130590. * @param scene (Scene) is the scene in which the PCS is added
  130591. * @param options defines the options of the PCS e.g.
  130592. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  130593. */
  130594. constructor(name: string, pointSize: number, scene: Scene, options?: {
  130595. updatable?: boolean;
  130596. });
  130597. /**
  130598. * Builds the PCS underlying mesh. Returns a standard Mesh.
  130599. * If no points were added to the PCS, the returned mesh is just a single point.
  130600. * @returns a promise for the created mesh
  130601. */
  130602. buildMeshAsync(): Promise<Mesh>;
  130603. /**
  130604. * @hidden
  130605. */
  130606. private _buildMesh;
  130607. private _addParticle;
  130608. private _randomUnitVector;
  130609. private _getColorIndicesForCoord;
  130610. private _setPointsColorOrUV;
  130611. private _colorFromTexture;
  130612. private _calculateDensity;
  130613. /**
  130614. * Adds points to the PCS in random positions within a unit sphere
  130615. * @param nb (positive integer) the number of particles to be created from this model
  130616. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  130617. * @returns the number of groups in the system
  130618. */
  130619. addPoints(nb: number, pointFunction?: any): number;
  130620. /**
  130621. * Adds points to the PCS from the surface of the model shape
  130622. * @param mesh is any Mesh object that will be used as a surface model for the points
  130623. * @param nb (positive integer) the number of particles to be created from this model
  130624. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  130625. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  130626. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  130627. * @returns the number of groups in the system
  130628. */
  130629. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  130630. /**
  130631. * Adds points to the PCS inside the model shape
  130632. * @param mesh is any Mesh object that will be used as a surface model for the points
  130633. * @param nb (positive integer) the number of particles to be created from this model
  130634. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  130635. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  130636. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  130637. * @returns the number of groups in the system
  130638. */
  130639. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  130640. /**
  130641. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  130642. * This method calls `updateParticle()` for each particle of the SPS.
  130643. * For an animated SPS, it is usually called within the render loop.
  130644. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  130645. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  130646. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  130647. * @returns the PCS.
  130648. */
  130649. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  130650. /**
  130651. * Disposes the PCS.
  130652. */
  130653. dispose(): void;
  130654. /**
  130655. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  130656. * doc :
  130657. * @returns the PCS.
  130658. */
  130659. refreshVisibleSize(): PointsCloudSystem;
  130660. /**
  130661. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  130662. * @param size the size (float) of the visibility box
  130663. * note : this doesn't lock the PCS mesh bounding box.
  130664. * doc :
  130665. */
  130666. setVisibilityBox(size: number): void;
  130667. /**
  130668. * Gets whether the PCS is always visible or not
  130669. * doc :
  130670. */
  130671. /**
  130672. * Sets the PCS as always visible or not
  130673. * doc :
  130674. */
  130675. isAlwaysVisible: boolean;
  130676. /**
  130677. * Tells to `setParticles()` to compute the particle rotations or not
  130678. * Default value : false. The PCS is faster when it's set to false
  130679. * Note : particle rotations are only applied to parent particles
  130680. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  130681. */
  130682. computeParticleRotation: boolean;
  130683. /**
  130684. * Tells to `setParticles()` to compute the particle colors or not.
  130685. * Default value : true. The PCS is faster when it's set to false.
  130686. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  130687. */
  130688. /**
  130689. * Gets if `setParticles()` computes the particle colors or not.
  130690. * Default value : false. The PCS is faster when it's set to false.
  130691. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  130692. */
  130693. computeParticleColor: boolean;
  130694. /**
  130695. * Gets if `setParticles()` computes the particle textures or not.
  130696. * Default value : false. The PCS is faster when it's set to false.
  130697. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  130698. */
  130699. computeParticleTexture: boolean;
  130700. /**
  130701. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  130702. */
  130703. /**
  130704. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  130705. */
  130706. computeBoundingBox: boolean;
  130707. /**
  130708. * This function does nothing. It may be overwritten to set all the particle first values.
  130709. * The PCS doesn't call this function, you may have to call it by your own.
  130710. * doc :
  130711. */
  130712. initParticles(): void;
  130713. /**
  130714. * This function does nothing. It may be overwritten to recycle a particle
  130715. * The PCS doesn't call this function, you can to call it
  130716. * doc :
  130717. * @param particle The particle to recycle
  130718. * @returns the recycled particle
  130719. */
  130720. recycleParticle(particle: CloudPoint): CloudPoint;
  130721. /**
  130722. * Updates a particle : this function should be overwritten by the user.
  130723. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  130724. * doc :
  130725. * @example : just set a particle position or velocity and recycle conditions
  130726. * @param particle The particle to update
  130727. * @returns the updated particle
  130728. */
  130729. updateParticle(particle: CloudPoint): CloudPoint;
  130730. /**
  130731. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  130732. * This does nothing and may be overwritten by the user.
  130733. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  130734. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  130735. * @param update the boolean update value actually passed to setParticles()
  130736. */
  130737. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  130738. /**
  130739. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  130740. * This will be passed three parameters.
  130741. * This does nothing and may be overwritten by the user.
  130742. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  130743. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  130744. * @param update the boolean update value actually passed to setParticles()
  130745. */
  130746. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  130747. }
  130748. }
  130749. declare module BABYLON {
  130750. /**
  130751. * Represents one particle of a points cloud system.
  130752. */
  130753. export class CloudPoint {
  130754. /**
  130755. * particle global index
  130756. */
  130757. idx: number;
  130758. /**
  130759. * The color of the particle
  130760. */
  130761. color: Nullable<Color4>;
  130762. /**
  130763. * The world space position of the particle.
  130764. */
  130765. position: Vector3;
  130766. /**
  130767. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  130768. */
  130769. rotation: Vector3;
  130770. /**
  130771. * The world space rotation quaternion of the particle.
  130772. */
  130773. rotationQuaternion: Nullable<Quaternion>;
  130774. /**
  130775. * The uv of the particle.
  130776. */
  130777. uv: Nullable<Vector2>;
  130778. /**
  130779. * The current speed of the particle.
  130780. */
  130781. velocity: Vector3;
  130782. /**
  130783. * The pivot point in the particle local space.
  130784. */
  130785. pivot: Vector3;
  130786. /**
  130787. * Must the particle be translated from its pivot point in its local space ?
  130788. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  130789. * Default : false
  130790. */
  130791. translateFromPivot: boolean;
  130792. /**
  130793. * Index of this particle in the global "positions" array (Internal use)
  130794. * @hidden
  130795. */
  130796. _pos: number;
  130797. /**
  130798. * @hidden Index of this particle in the global "indices" array (Internal use)
  130799. */
  130800. _ind: number;
  130801. /**
  130802. * Group this particle belongs to
  130803. */
  130804. _group: PointsGroup;
  130805. /**
  130806. * Group id of this particle
  130807. */
  130808. groupId: number;
  130809. /**
  130810. * Index of the particle in its group id (Internal use)
  130811. */
  130812. idxInGroup: number;
  130813. /**
  130814. * @hidden Particle BoundingInfo object (Internal use)
  130815. */
  130816. _boundingInfo: BoundingInfo;
  130817. /**
  130818. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  130819. */
  130820. _pcs: PointsCloudSystem;
  130821. /**
  130822. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  130823. */
  130824. _stillInvisible: boolean;
  130825. /**
  130826. * @hidden Last computed particle rotation matrix
  130827. */
  130828. _rotationMatrix: number[];
  130829. /**
  130830. * Parent particle Id, if any.
  130831. * Default null.
  130832. */
  130833. parentId: Nullable<number>;
  130834. /**
  130835. * @hidden Internal global position in the PCS.
  130836. */
  130837. _globalPosition: Vector3;
  130838. /**
  130839. * Creates a Point Cloud object.
  130840. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  130841. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  130842. * @param group (PointsGroup) is the group the particle belongs to
  130843. * @param groupId (integer) is the group identifier in the PCS.
  130844. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  130845. * @param pcs defines the PCS it is associated to
  130846. */
  130847. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  130848. /**
  130849. * get point size
  130850. */
  130851. /**
  130852. * Set point size
  130853. */
  130854. size: Vector3;
  130855. /**
  130856. * Legacy support, changed quaternion to rotationQuaternion
  130857. */
  130858. /**
  130859. * Legacy support, changed quaternion to rotationQuaternion
  130860. */
  130861. quaternion: Nullable<Quaternion>;
  130862. /**
  130863. * Returns a boolean. True if the particle intersects a mesh, else false
  130864. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  130865. * @param target is the object (point or mesh) what the intersection is computed against
  130866. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  130867. * @returns true if it intersects
  130868. */
  130869. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  130870. /**
  130871. * get the rotation matrix of the particle
  130872. * @hidden
  130873. */
  130874. getRotationMatrix(m: Matrix): void;
  130875. }
  130876. /**
  130877. * Represents a group of points in a points cloud system
  130878. * * PCS internal tool, don't use it manually.
  130879. */
  130880. export class PointsGroup {
  130881. /**
  130882. * The group id
  130883. * @hidden
  130884. */
  130885. groupID: number;
  130886. /**
  130887. * image data for group (internal use)
  130888. * @hidden
  130889. */
  130890. _groupImageData: Nullable<ArrayBufferView>;
  130891. /**
  130892. * Image Width (internal use)
  130893. * @hidden
  130894. */
  130895. _groupImgWidth: number;
  130896. /**
  130897. * Image Height (internal use)
  130898. * @hidden
  130899. */
  130900. _groupImgHeight: number;
  130901. /**
  130902. * Custom position function (internal use)
  130903. * @hidden
  130904. */
  130905. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  130906. /**
  130907. * density per facet for surface points
  130908. * @hidden
  130909. */
  130910. _groupDensity: number[];
  130911. /**
  130912. * Only when points are colored by texture carries pointer to texture list array
  130913. * @hidden
  130914. */
  130915. _textureNb: number;
  130916. /**
  130917. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  130918. * PCS internal tool, don't use it manually.
  130919. * @hidden
  130920. */
  130921. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  130922. }
  130923. }
  130924. declare module BABYLON {
  130925. interface Scene {
  130926. /** @hidden (Backing field) */
  130927. _physicsEngine: Nullable<IPhysicsEngine>;
  130928. /** @hidden */
  130929. _physicsTimeAccumulator: number;
  130930. /**
  130931. * Gets the current physics engine
  130932. * @returns a IPhysicsEngine or null if none attached
  130933. */
  130934. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  130935. /**
  130936. * Enables physics to the current scene
  130937. * @param gravity defines the scene's gravity for the physics engine
  130938. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  130939. * @return a boolean indicating if the physics engine was initialized
  130940. */
  130941. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  130942. /**
  130943. * Disables and disposes the physics engine associated with the scene
  130944. */
  130945. disablePhysicsEngine(): void;
  130946. /**
  130947. * Gets a boolean indicating if there is an active physics engine
  130948. * @returns a boolean indicating if there is an active physics engine
  130949. */
  130950. isPhysicsEnabled(): boolean;
  130951. /**
  130952. * Deletes a physics compound impostor
  130953. * @param compound defines the compound to delete
  130954. */
  130955. deleteCompoundImpostor(compound: any): void;
  130956. /**
  130957. * An event triggered when physic simulation is about to be run
  130958. */
  130959. onBeforePhysicsObservable: Observable<Scene>;
  130960. /**
  130961. * An event triggered when physic simulation has been done
  130962. */
  130963. onAfterPhysicsObservable: Observable<Scene>;
  130964. }
  130965. interface AbstractMesh {
  130966. /** @hidden */
  130967. _physicsImpostor: Nullable<PhysicsImpostor>;
  130968. /**
  130969. * Gets or sets impostor used for physic simulation
  130970. * @see http://doc.babylonjs.com/features/physics_engine
  130971. */
  130972. physicsImpostor: Nullable<PhysicsImpostor>;
  130973. /**
  130974. * Gets the current physics impostor
  130975. * @see http://doc.babylonjs.com/features/physics_engine
  130976. * @returns a physics impostor or null
  130977. */
  130978. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  130979. /** Apply a physic impulse to the mesh
  130980. * @param force defines the force to apply
  130981. * @param contactPoint defines where to apply the force
  130982. * @returns the current mesh
  130983. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  130984. */
  130985. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  130986. /**
  130987. * Creates a physic joint between two meshes
  130988. * @param otherMesh defines the other mesh to use
  130989. * @param pivot1 defines the pivot to use on this mesh
  130990. * @param pivot2 defines the pivot to use on the other mesh
  130991. * @param options defines additional options (can be plugin dependent)
  130992. * @returns the current mesh
  130993. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  130994. */
  130995. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  130996. /** @hidden */
  130997. _disposePhysicsObserver: Nullable<Observer<Node>>;
  130998. }
  130999. /**
  131000. * Defines the physics engine scene component responsible to manage a physics engine
  131001. */
  131002. export class PhysicsEngineSceneComponent implements ISceneComponent {
  131003. /**
  131004. * The component name helpful to identify the component in the list of scene components.
  131005. */
  131006. readonly name: string;
  131007. /**
  131008. * The scene the component belongs to.
  131009. */
  131010. scene: Scene;
  131011. /**
  131012. * Creates a new instance of the component for the given scene
  131013. * @param scene Defines the scene to register the component in
  131014. */
  131015. constructor(scene: Scene);
  131016. /**
  131017. * Registers the component in a given scene
  131018. */
  131019. register(): void;
  131020. /**
  131021. * Rebuilds the elements related to this component in case of
  131022. * context lost for instance.
  131023. */
  131024. rebuild(): void;
  131025. /**
  131026. * Disposes the component and the associated ressources
  131027. */
  131028. dispose(): void;
  131029. }
  131030. }
  131031. declare module BABYLON {
  131032. /**
  131033. * A helper for physics simulations
  131034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131035. */
  131036. export class PhysicsHelper {
  131037. private _scene;
  131038. private _physicsEngine;
  131039. /**
  131040. * Initializes the Physics helper
  131041. * @param scene Babylon.js scene
  131042. */
  131043. constructor(scene: Scene);
  131044. /**
  131045. * Applies a radial explosion impulse
  131046. * @param origin the origin of the explosion
  131047. * @param radiusOrEventOptions the radius or the options of radial explosion
  131048. * @param strength the explosion strength
  131049. * @param falloff possible options: Constant & Linear. Defaults to Constant
  131050. * @returns A physics radial explosion event, or null
  131051. */
  131052. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  131053. /**
  131054. * Applies a radial explosion force
  131055. * @param origin the origin of the explosion
  131056. * @param radiusOrEventOptions the radius or the options of radial explosion
  131057. * @param strength the explosion strength
  131058. * @param falloff possible options: Constant & Linear. Defaults to Constant
  131059. * @returns A physics radial explosion event, or null
  131060. */
  131061. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  131062. /**
  131063. * Creates a gravitational field
  131064. * @param origin the origin of the explosion
  131065. * @param radiusOrEventOptions the radius or the options of radial explosion
  131066. * @param strength the explosion strength
  131067. * @param falloff possible options: Constant & Linear. Defaults to Constant
  131068. * @returns A physics gravitational field event, or null
  131069. */
  131070. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  131071. /**
  131072. * Creates a physics updraft event
  131073. * @param origin the origin of the updraft
  131074. * @param radiusOrEventOptions the radius or the options of the updraft
  131075. * @param strength the strength of the updraft
  131076. * @param height the height of the updraft
  131077. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  131078. * @returns A physics updraft event, or null
  131079. */
  131080. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  131081. /**
  131082. * Creates a physics vortex event
  131083. * @param origin the of the vortex
  131084. * @param radiusOrEventOptions the radius or the options of the vortex
  131085. * @param strength the strength of the vortex
  131086. * @param height the height of the vortex
  131087. * @returns a Physics vortex event, or null
  131088. * A physics vortex event or null
  131089. */
  131090. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  131091. }
  131092. /**
  131093. * Represents a physics radial explosion event
  131094. */
  131095. class PhysicsRadialExplosionEvent {
  131096. private _scene;
  131097. private _options;
  131098. private _sphere;
  131099. private _dataFetched;
  131100. /**
  131101. * Initializes a radial explosioin event
  131102. * @param _scene BabylonJS scene
  131103. * @param _options The options for the vortex event
  131104. */
  131105. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  131106. /**
  131107. * Returns the data related to the radial explosion event (sphere).
  131108. * @returns The radial explosion event data
  131109. */
  131110. getData(): PhysicsRadialExplosionEventData;
  131111. /**
  131112. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  131113. * @param impostor A physics imposter
  131114. * @param origin the origin of the explosion
  131115. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  131116. */
  131117. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  131118. /**
  131119. * Triggers affecterd impostors callbacks
  131120. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  131121. */
  131122. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  131123. /**
  131124. * Disposes the sphere.
  131125. * @param force Specifies if the sphere should be disposed by force
  131126. */
  131127. dispose(force?: boolean): void;
  131128. /*** Helpers ***/
  131129. private _prepareSphere;
  131130. private _intersectsWithSphere;
  131131. }
  131132. /**
  131133. * Represents a gravitational field event
  131134. */
  131135. class PhysicsGravitationalFieldEvent {
  131136. private _physicsHelper;
  131137. private _scene;
  131138. private _origin;
  131139. private _options;
  131140. private _tickCallback;
  131141. private _sphere;
  131142. private _dataFetched;
  131143. /**
  131144. * Initializes the physics gravitational field event
  131145. * @param _physicsHelper A physics helper
  131146. * @param _scene BabylonJS scene
  131147. * @param _origin The origin position of the gravitational field event
  131148. * @param _options The options for the vortex event
  131149. */
  131150. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  131151. /**
  131152. * Returns the data related to the gravitational field event (sphere).
  131153. * @returns A gravitational field event
  131154. */
  131155. getData(): PhysicsGravitationalFieldEventData;
  131156. /**
  131157. * Enables the gravitational field.
  131158. */
  131159. enable(): void;
  131160. /**
  131161. * Disables the gravitational field.
  131162. */
  131163. disable(): void;
  131164. /**
  131165. * Disposes the sphere.
  131166. * @param force The force to dispose from the gravitational field event
  131167. */
  131168. dispose(force?: boolean): void;
  131169. private _tick;
  131170. }
  131171. /**
  131172. * Represents a physics updraft event
  131173. */
  131174. class PhysicsUpdraftEvent {
  131175. private _scene;
  131176. private _origin;
  131177. private _options;
  131178. private _physicsEngine;
  131179. private _originTop;
  131180. private _originDirection;
  131181. private _tickCallback;
  131182. private _cylinder;
  131183. private _cylinderPosition;
  131184. private _dataFetched;
  131185. /**
  131186. * Initializes the physics updraft event
  131187. * @param _scene BabylonJS scene
  131188. * @param _origin The origin position of the updraft
  131189. * @param _options The options for the updraft event
  131190. */
  131191. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  131192. /**
  131193. * Returns the data related to the updraft event (cylinder).
  131194. * @returns A physics updraft event
  131195. */
  131196. getData(): PhysicsUpdraftEventData;
  131197. /**
  131198. * Enables the updraft.
  131199. */
  131200. enable(): void;
  131201. /**
  131202. * Disables the updraft.
  131203. */
  131204. disable(): void;
  131205. /**
  131206. * Disposes the cylinder.
  131207. * @param force Specifies if the updraft should be disposed by force
  131208. */
  131209. dispose(force?: boolean): void;
  131210. private getImpostorHitData;
  131211. private _tick;
  131212. /*** Helpers ***/
  131213. private _prepareCylinder;
  131214. private _intersectsWithCylinder;
  131215. }
  131216. /**
  131217. * Represents a physics vortex event
  131218. */
  131219. class PhysicsVortexEvent {
  131220. private _scene;
  131221. private _origin;
  131222. private _options;
  131223. private _physicsEngine;
  131224. private _originTop;
  131225. private _tickCallback;
  131226. private _cylinder;
  131227. private _cylinderPosition;
  131228. private _dataFetched;
  131229. /**
  131230. * Initializes the physics vortex event
  131231. * @param _scene The BabylonJS scene
  131232. * @param _origin The origin position of the vortex
  131233. * @param _options The options for the vortex event
  131234. */
  131235. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  131236. /**
  131237. * Returns the data related to the vortex event (cylinder).
  131238. * @returns The physics vortex event data
  131239. */
  131240. getData(): PhysicsVortexEventData;
  131241. /**
  131242. * Enables the vortex.
  131243. */
  131244. enable(): void;
  131245. /**
  131246. * Disables the cortex.
  131247. */
  131248. disable(): void;
  131249. /**
  131250. * Disposes the sphere.
  131251. * @param force
  131252. */
  131253. dispose(force?: boolean): void;
  131254. private getImpostorHitData;
  131255. private _tick;
  131256. /*** Helpers ***/
  131257. private _prepareCylinder;
  131258. private _intersectsWithCylinder;
  131259. }
  131260. /**
  131261. * Options fot the radial explosion event
  131262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131263. */
  131264. export class PhysicsRadialExplosionEventOptions {
  131265. /**
  131266. * The radius of the sphere for the radial explosion.
  131267. */
  131268. radius: number;
  131269. /**
  131270. * The strenth of the explosion.
  131271. */
  131272. strength: number;
  131273. /**
  131274. * The strenght of the force in correspondence to the distance of the affected object
  131275. */
  131276. falloff: PhysicsRadialImpulseFalloff;
  131277. /**
  131278. * Sphere options for the radial explosion.
  131279. */
  131280. sphere: {
  131281. segments: number;
  131282. diameter: number;
  131283. };
  131284. /**
  131285. * Sphere options for the radial explosion.
  131286. */
  131287. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  131288. }
  131289. /**
  131290. * Options fot the updraft event
  131291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131292. */
  131293. export class PhysicsUpdraftEventOptions {
  131294. /**
  131295. * The radius of the cylinder for the vortex
  131296. */
  131297. radius: number;
  131298. /**
  131299. * The strenth of the updraft.
  131300. */
  131301. strength: number;
  131302. /**
  131303. * The height of the cylinder for the updraft.
  131304. */
  131305. height: number;
  131306. /**
  131307. * The mode for the the updraft.
  131308. */
  131309. updraftMode: PhysicsUpdraftMode;
  131310. }
  131311. /**
  131312. * Options fot the vortex event
  131313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131314. */
  131315. export class PhysicsVortexEventOptions {
  131316. /**
  131317. * The radius of the cylinder for the vortex
  131318. */
  131319. radius: number;
  131320. /**
  131321. * The strenth of the vortex.
  131322. */
  131323. strength: number;
  131324. /**
  131325. * The height of the cylinder for the vortex.
  131326. */
  131327. height: number;
  131328. /**
  131329. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  131330. */
  131331. centripetalForceThreshold: number;
  131332. /**
  131333. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  131334. */
  131335. centripetalForceMultiplier: number;
  131336. /**
  131337. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  131338. */
  131339. centrifugalForceMultiplier: number;
  131340. /**
  131341. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  131342. */
  131343. updraftForceMultiplier: number;
  131344. }
  131345. /**
  131346. * The strenght of the force in correspondence to the distance of the affected object
  131347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131348. */
  131349. export enum PhysicsRadialImpulseFalloff {
  131350. /** Defines that impulse is constant in strength across it's whole radius */
  131351. Constant = 0,
  131352. /** Defines that impulse gets weaker if it's further from the origin */
  131353. Linear = 1
  131354. }
  131355. /**
  131356. * The strength of the force in correspondence to the distance of the affected object
  131357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131358. */
  131359. export enum PhysicsUpdraftMode {
  131360. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  131361. Center = 0,
  131362. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  131363. Perpendicular = 1
  131364. }
  131365. /**
  131366. * Interface for a physics hit data
  131367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131368. */
  131369. export interface PhysicsHitData {
  131370. /**
  131371. * The force applied at the contact point
  131372. */
  131373. force: Vector3;
  131374. /**
  131375. * The contact point
  131376. */
  131377. contactPoint: Vector3;
  131378. /**
  131379. * The distance from the origin to the contact point
  131380. */
  131381. distanceFromOrigin: number;
  131382. }
  131383. /**
  131384. * Interface for radial explosion event data
  131385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131386. */
  131387. export interface PhysicsRadialExplosionEventData {
  131388. /**
  131389. * A sphere used for the radial explosion event
  131390. */
  131391. sphere: Mesh;
  131392. }
  131393. /**
  131394. * Interface for gravitational field event data
  131395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131396. */
  131397. export interface PhysicsGravitationalFieldEventData {
  131398. /**
  131399. * A sphere mesh used for the gravitational field event
  131400. */
  131401. sphere: Mesh;
  131402. }
  131403. /**
  131404. * Interface for updraft event data
  131405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131406. */
  131407. export interface PhysicsUpdraftEventData {
  131408. /**
  131409. * A cylinder used for the updraft event
  131410. */
  131411. cylinder: Mesh;
  131412. }
  131413. /**
  131414. * Interface for vortex event data
  131415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131416. */
  131417. export interface PhysicsVortexEventData {
  131418. /**
  131419. * A cylinder used for the vortex event
  131420. */
  131421. cylinder: Mesh;
  131422. }
  131423. /**
  131424. * Interface for an affected physics impostor
  131425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  131426. */
  131427. export interface PhysicsAffectedImpostorWithData {
  131428. /**
  131429. * The impostor affected by the effect
  131430. */
  131431. impostor: PhysicsImpostor;
  131432. /**
  131433. * The data about the hit/horce from the explosion
  131434. */
  131435. hitData: PhysicsHitData;
  131436. }
  131437. }
  131438. declare module BABYLON {
  131439. /** @hidden */
  131440. export var blackAndWhitePixelShader: {
  131441. name: string;
  131442. shader: string;
  131443. };
  131444. }
  131445. declare module BABYLON {
  131446. /**
  131447. * Post process used to render in black and white
  131448. */
  131449. export class BlackAndWhitePostProcess extends PostProcess {
  131450. /**
  131451. * Linear about to convert he result to black and white (default: 1)
  131452. */
  131453. degree: number;
  131454. /**
  131455. * Creates a black and white post process
  131456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  131457. * @param name The name of the effect.
  131458. * @param options The required width/height ratio to downsize to before computing the render pass.
  131459. * @param camera The camera to apply the render pass to.
  131460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131461. * @param engine The engine which the post process will be applied. (default: current engine)
  131462. * @param reusable If the post process can be reused on the same frame. (default: false)
  131463. */
  131464. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  131465. }
  131466. }
  131467. declare module BABYLON {
  131468. /**
  131469. * This represents a set of one or more post processes in Babylon.
  131470. * A post process can be used to apply a shader to a texture after it is rendered.
  131471. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131472. */
  131473. export class PostProcessRenderEffect {
  131474. private _postProcesses;
  131475. private _getPostProcesses;
  131476. private _singleInstance;
  131477. private _cameras;
  131478. private _indicesForCamera;
  131479. /**
  131480. * Name of the effect
  131481. * @hidden
  131482. */
  131483. _name: string;
  131484. /**
  131485. * Instantiates a post process render effect.
  131486. * A post process can be used to apply a shader to a texture after it is rendered.
  131487. * @param engine The engine the effect is tied to
  131488. * @param name The name of the effect
  131489. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  131490. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  131491. */
  131492. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  131493. /**
  131494. * Checks if all the post processes in the effect are supported.
  131495. */
  131496. readonly isSupported: boolean;
  131497. /**
  131498. * Updates the current state of the effect
  131499. * @hidden
  131500. */
  131501. _update(): void;
  131502. /**
  131503. * Attaches the effect on cameras
  131504. * @param cameras The camera to attach to.
  131505. * @hidden
  131506. */
  131507. _attachCameras(cameras: Camera): void;
  131508. /**
  131509. * Attaches the effect on cameras
  131510. * @param cameras The camera to attach to.
  131511. * @hidden
  131512. */
  131513. _attachCameras(cameras: Camera[]): void;
  131514. /**
  131515. * Detaches the effect on cameras
  131516. * @param cameras The camera to detatch from.
  131517. * @hidden
  131518. */
  131519. _detachCameras(cameras: Camera): void;
  131520. /**
  131521. * Detatches the effect on cameras
  131522. * @param cameras The camera to detatch from.
  131523. * @hidden
  131524. */
  131525. _detachCameras(cameras: Camera[]): void;
  131526. /**
  131527. * Enables the effect on given cameras
  131528. * @param cameras The camera to enable.
  131529. * @hidden
  131530. */
  131531. _enable(cameras: Camera): void;
  131532. /**
  131533. * Enables the effect on given cameras
  131534. * @param cameras The camera to enable.
  131535. * @hidden
  131536. */
  131537. _enable(cameras: Nullable<Camera[]>): void;
  131538. /**
  131539. * Disables the effect on the given cameras
  131540. * @param cameras The camera to disable.
  131541. * @hidden
  131542. */
  131543. _disable(cameras: Camera): void;
  131544. /**
  131545. * Disables the effect on the given cameras
  131546. * @param cameras The camera to disable.
  131547. * @hidden
  131548. */
  131549. _disable(cameras: Nullable<Camera[]>): void;
  131550. /**
  131551. * Gets a list of the post processes contained in the effect.
  131552. * @param camera The camera to get the post processes on.
  131553. * @returns The list of the post processes in the effect.
  131554. */
  131555. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  131556. }
  131557. }
  131558. declare module BABYLON {
  131559. /** @hidden */
  131560. export var extractHighlightsPixelShader: {
  131561. name: string;
  131562. shader: string;
  131563. };
  131564. }
  131565. declare module BABYLON {
  131566. /**
  131567. * 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.
  131568. */
  131569. export class ExtractHighlightsPostProcess extends PostProcess {
  131570. /**
  131571. * The luminance threshold, pixels below this value will be set to black.
  131572. */
  131573. threshold: number;
  131574. /** @hidden */
  131575. _exposure: number;
  131576. /**
  131577. * Post process which has the input texture to be used when performing highlight extraction
  131578. * @hidden
  131579. */
  131580. _inputPostProcess: Nullable<PostProcess>;
  131581. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131582. }
  131583. }
  131584. declare module BABYLON {
  131585. /** @hidden */
  131586. export var bloomMergePixelShader: {
  131587. name: string;
  131588. shader: string;
  131589. };
  131590. }
  131591. declare module BABYLON {
  131592. /**
  131593. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  131594. */
  131595. export class BloomMergePostProcess extends PostProcess {
  131596. /** Weight of the bloom to be added to the original input. */
  131597. weight: number;
  131598. /**
  131599. * Creates a new instance of @see BloomMergePostProcess
  131600. * @param name The name of the effect.
  131601. * @param originalFromInput Post process which's input will be used for the merge.
  131602. * @param blurred Blurred highlights post process which's output will be used.
  131603. * @param weight Weight of the bloom to be added to the original input.
  131604. * @param options The required width/height ratio to downsize to before computing the render pass.
  131605. * @param camera The camera to apply the render pass to.
  131606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131607. * @param engine The engine which the post process will be applied. (default: current engine)
  131608. * @param reusable If the post process can be reused on the same frame. (default: false)
  131609. * @param textureType Type of textures used when performing the post process. (default: 0)
  131610. * @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)
  131611. */
  131612. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  131613. /** Weight of the bloom to be added to the original input. */
  131614. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131615. }
  131616. }
  131617. declare module BABYLON {
  131618. /**
  131619. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  131620. */
  131621. export class BloomEffect extends PostProcessRenderEffect {
  131622. private bloomScale;
  131623. /**
  131624. * @hidden Internal
  131625. */
  131626. _effects: Array<PostProcess>;
  131627. /**
  131628. * @hidden Internal
  131629. */
  131630. _downscale: ExtractHighlightsPostProcess;
  131631. private _blurX;
  131632. private _blurY;
  131633. private _merge;
  131634. /**
  131635. * The luminance threshold to find bright areas of the image to bloom.
  131636. */
  131637. threshold: number;
  131638. /**
  131639. * The strength of the bloom.
  131640. */
  131641. weight: number;
  131642. /**
  131643. * Specifies the size of the bloom blur kernel, relative to the final output size
  131644. */
  131645. kernel: number;
  131646. /**
  131647. * Creates a new instance of @see BloomEffect
  131648. * @param scene The scene the effect belongs to.
  131649. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  131650. * @param bloomKernel The size of the kernel to be used when applying the blur.
  131651. * @param bloomWeight The the strength of bloom.
  131652. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  131653. * @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)
  131654. */
  131655. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  131656. /**
  131657. * Disposes each of the internal effects for a given camera.
  131658. * @param camera The camera to dispose the effect on.
  131659. */
  131660. disposeEffects(camera: Camera): void;
  131661. /**
  131662. * @hidden Internal
  131663. */
  131664. _updateEffects(): void;
  131665. /**
  131666. * Internal
  131667. * @returns if all the contained post processes are ready.
  131668. * @hidden
  131669. */
  131670. _isReady(): boolean;
  131671. }
  131672. }
  131673. declare module BABYLON {
  131674. /** @hidden */
  131675. export var chromaticAberrationPixelShader: {
  131676. name: string;
  131677. shader: string;
  131678. };
  131679. }
  131680. declare module BABYLON {
  131681. /**
  131682. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  131683. */
  131684. export class ChromaticAberrationPostProcess extends PostProcess {
  131685. /**
  131686. * The amount of seperation of rgb channels (default: 30)
  131687. */
  131688. aberrationAmount: number;
  131689. /**
  131690. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  131691. */
  131692. radialIntensity: number;
  131693. /**
  131694. * 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))
  131695. */
  131696. direction: Vector2;
  131697. /**
  131698. * 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))
  131699. */
  131700. centerPosition: Vector2;
  131701. /**
  131702. * Creates a new instance ChromaticAberrationPostProcess
  131703. * @param name The name of the effect.
  131704. * @param screenWidth The width of the screen to apply the effect on.
  131705. * @param screenHeight The height of the screen to apply the effect on.
  131706. * @param options The required width/height ratio to downsize to before computing the render pass.
  131707. * @param camera The camera to apply the render pass to.
  131708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131709. * @param engine The engine which the post process will be applied. (default: current engine)
  131710. * @param reusable If the post process can be reused on the same frame. (default: false)
  131711. * @param textureType Type of textures used when performing the post process. (default: 0)
  131712. * @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)
  131713. */
  131714. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131715. }
  131716. }
  131717. declare module BABYLON {
  131718. /** @hidden */
  131719. export var circleOfConfusionPixelShader: {
  131720. name: string;
  131721. shader: string;
  131722. };
  131723. }
  131724. declare module BABYLON {
  131725. /**
  131726. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  131727. */
  131728. export class CircleOfConfusionPostProcess extends PostProcess {
  131729. /**
  131730. * 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.
  131731. */
  131732. lensSize: number;
  131733. /**
  131734. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  131735. */
  131736. fStop: number;
  131737. /**
  131738. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  131739. */
  131740. focusDistance: number;
  131741. /**
  131742. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  131743. */
  131744. focalLength: number;
  131745. private _depthTexture;
  131746. /**
  131747. * Creates a new instance CircleOfConfusionPostProcess
  131748. * @param name The name of the effect.
  131749. * @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.
  131750. * @param options The required width/height ratio to downsize to before computing the render pass.
  131751. * @param camera The camera to apply the render pass to.
  131752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131753. * @param engine The engine which the post process will be applied. (default: current engine)
  131754. * @param reusable If the post process can be reused on the same frame. (default: false)
  131755. * @param textureType Type of textures used when performing the post process. (default: 0)
  131756. * @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)
  131757. */
  131758. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131759. /**
  131760. * 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.
  131761. */
  131762. depthTexture: RenderTargetTexture;
  131763. }
  131764. }
  131765. declare module BABYLON {
  131766. /** @hidden */
  131767. export var colorCorrectionPixelShader: {
  131768. name: string;
  131769. shader: string;
  131770. };
  131771. }
  131772. declare module BABYLON {
  131773. /**
  131774. *
  131775. * This post-process allows the modification of rendered colors by using
  131776. * a 'look-up table' (LUT). This effect is also called Color Grading.
  131777. *
  131778. * The object needs to be provided an url to a texture containing the color
  131779. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  131780. * Use an image editing software to tweak the LUT to match your needs.
  131781. *
  131782. * For an example of a color LUT, see here:
  131783. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  131784. * For explanations on color grading, see here:
  131785. * @see http://udn.epicgames.com/Three/ColorGrading.html
  131786. *
  131787. */
  131788. export class ColorCorrectionPostProcess extends PostProcess {
  131789. private _colorTableTexture;
  131790. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  131791. }
  131792. }
  131793. declare module BABYLON {
  131794. /** @hidden */
  131795. export var convolutionPixelShader: {
  131796. name: string;
  131797. shader: string;
  131798. };
  131799. }
  131800. declare module BABYLON {
  131801. /**
  131802. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  131803. * input texture to perform effects such as edge detection or sharpening
  131804. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  131805. */
  131806. export class ConvolutionPostProcess extends PostProcess {
  131807. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  131808. kernel: number[];
  131809. /**
  131810. * Creates a new instance ConvolutionPostProcess
  131811. * @param name The name of the effect.
  131812. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  131813. * @param options The required width/height ratio to downsize to before computing the render pass.
  131814. * @param camera The camera to apply the render pass to.
  131815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131816. * @param engine The engine which the post process will be applied. (default: current engine)
  131817. * @param reusable If the post process can be reused on the same frame. (default: false)
  131818. * @param textureType Type of textures used when performing the post process. (default: 0)
  131819. */
  131820. constructor(name: string,
  131821. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  131822. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  131823. /**
  131824. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131825. */
  131826. static EdgeDetect0Kernel: number[];
  131827. /**
  131828. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131829. */
  131830. static EdgeDetect1Kernel: number[];
  131831. /**
  131832. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131833. */
  131834. static EdgeDetect2Kernel: number[];
  131835. /**
  131836. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131837. */
  131838. static SharpenKernel: number[];
  131839. /**
  131840. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131841. */
  131842. static EmbossKernel: number[];
  131843. /**
  131844. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  131845. */
  131846. static GaussianKernel: number[];
  131847. }
  131848. }
  131849. declare module BABYLON {
  131850. /**
  131851. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  131852. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  131853. * based on samples that have a large difference in distance than the center pixel.
  131854. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  131855. */
  131856. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  131857. direction: Vector2;
  131858. /**
  131859. * Creates a new instance CircleOfConfusionPostProcess
  131860. * @param name The name of the effect.
  131861. * @param scene The scene the effect belongs to.
  131862. * @param direction The direction the blur should be applied.
  131863. * @param kernel The size of the kernel used to blur.
  131864. * @param options The required width/height ratio to downsize to before computing the render pass.
  131865. * @param camera The camera to apply the render pass to.
  131866. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  131867. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  131868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131869. * @param engine The engine which the post process will be applied. (default: current engine)
  131870. * @param reusable If the post process can be reused on the same frame. (default: false)
  131871. * @param textureType Type of textures used when performing the post process. (default: 0)
  131872. * @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)
  131873. */
  131874. 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);
  131875. }
  131876. }
  131877. declare module BABYLON {
  131878. /** @hidden */
  131879. export var depthOfFieldMergePixelShader: {
  131880. name: string;
  131881. shader: string;
  131882. };
  131883. }
  131884. declare module BABYLON {
  131885. /**
  131886. * Options to be set when merging outputs from the default pipeline.
  131887. */
  131888. export class DepthOfFieldMergePostProcessOptions {
  131889. /**
  131890. * The original image to merge on top of
  131891. */
  131892. originalFromInput: PostProcess;
  131893. /**
  131894. * Parameters to perform the merge of the depth of field effect
  131895. */
  131896. depthOfField?: {
  131897. circleOfConfusion: PostProcess;
  131898. blurSteps: Array<PostProcess>;
  131899. };
  131900. /**
  131901. * Parameters to perform the merge of bloom effect
  131902. */
  131903. bloom?: {
  131904. blurred: PostProcess;
  131905. weight: number;
  131906. };
  131907. }
  131908. /**
  131909. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  131910. */
  131911. export class DepthOfFieldMergePostProcess extends PostProcess {
  131912. private blurSteps;
  131913. /**
  131914. * Creates a new instance of DepthOfFieldMergePostProcess
  131915. * @param name The name of the effect.
  131916. * @param originalFromInput Post process which's input will be used for the merge.
  131917. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  131918. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  131919. * @param options The required width/height ratio to downsize to before computing the render pass.
  131920. * @param camera The camera to apply the render pass to.
  131921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131922. * @param engine The engine which the post process will be applied. (default: current engine)
  131923. * @param reusable If the post process can be reused on the same frame. (default: false)
  131924. * @param textureType Type of textures used when performing the post process. (default: 0)
  131925. * @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)
  131926. */
  131927. 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);
  131928. /**
  131929. * Updates the effect with the current post process compile time values and recompiles the shader.
  131930. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  131931. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  131932. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  131933. * @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
  131934. * @param onCompiled Called when the shader has been compiled.
  131935. * @param onError Called if there is an error when compiling a shader.
  131936. */
  131937. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  131938. }
  131939. }
  131940. declare module BABYLON {
  131941. /**
  131942. * Specifies the level of max blur that should be applied when using the depth of field effect
  131943. */
  131944. export enum DepthOfFieldEffectBlurLevel {
  131945. /**
  131946. * Subtle blur
  131947. */
  131948. Low = 0,
  131949. /**
  131950. * Medium blur
  131951. */
  131952. Medium = 1,
  131953. /**
  131954. * Large blur
  131955. */
  131956. High = 2
  131957. }
  131958. /**
  131959. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  131960. */
  131961. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  131962. private _circleOfConfusion;
  131963. /**
  131964. * @hidden Internal, blurs from high to low
  131965. */
  131966. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  131967. private _depthOfFieldBlurY;
  131968. private _dofMerge;
  131969. /**
  131970. * @hidden Internal post processes in depth of field effect
  131971. */
  131972. _effects: Array<PostProcess>;
  131973. /**
  131974. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  131975. */
  131976. focalLength: number;
  131977. /**
  131978. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  131979. */
  131980. fStop: number;
  131981. /**
  131982. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  131983. */
  131984. focusDistance: number;
  131985. /**
  131986. * 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.
  131987. */
  131988. lensSize: number;
  131989. /**
  131990. * Creates a new instance DepthOfFieldEffect
  131991. * @param scene The scene the effect belongs to.
  131992. * @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.
  131993. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  131994. * @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)
  131995. */
  131996. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  131997. /**
  131998. * Get the current class name of the current effet
  131999. * @returns "DepthOfFieldEffect"
  132000. */
  132001. getClassName(): string;
  132002. /**
  132003. * 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.
  132004. */
  132005. depthTexture: RenderTargetTexture;
  132006. /**
  132007. * Disposes each of the internal effects for a given camera.
  132008. * @param camera The camera to dispose the effect on.
  132009. */
  132010. disposeEffects(camera: Camera): void;
  132011. /**
  132012. * @hidden Internal
  132013. */
  132014. _updateEffects(): void;
  132015. /**
  132016. * Internal
  132017. * @returns if all the contained post processes are ready.
  132018. * @hidden
  132019. */
  132020. _isReady(): boolean;
  132021. }
  132022. }
  132023. declare module BABYLON {
  132024. /** @hidden */
  132025. export var displayPassPixelShader: {
  132026. name: string;
  132027. shader: string;
  132028. };
  132029. }
  132030. declare module BABYLON {
  132031. /**
  132032. * DisplayPassPostProcess which produces an output the same as it's input
  132033. */
  132034. export class DisplayPassPostProcess extends PostProcess {
  132035. /**
  132036. * Creates the DisplayPassPostProcess
  132037. * @param name The name of the effect.
  132038. * @param options The required width/height ratio to downsize to before computing the render pass.
  132039. * @param camera The camera to apply the render pass to.
  132040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132041. * @param engine The engine which the post process will be applied. (default: current engine)
  132042. * @param reusable If the post process can be reused on the same frame. (default: false)
  132043. */
  132044. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132045. }
  132046. }
  132047. declare module BABYLON {
  132048. /** @hidden */
  132049. export var filterPixelShader: {
  132050. name: string;
  132051. shader: string;
  132052. };
  132053. }
  132054. declare module BABYLON {
  132055. /**
  132056. * Applies a kernel filter to the image
  132057. */
  132058. export class FilterPostProcess extends PostProcess {
  132059. /** The matrix to be applied to the image */
  132060. kernelMatrix: Matrix;
  132061. /**
  132062. *
  132063. * @param name The name of the effect.
  132064. * @param kernelMatrix The matrix to be applied to the image
  132065. * @param options The required width/height ratio to downsize to before computing the render pass.
  132066. * @param camera The camera to apply the render pass to.
  132067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132068. * @param engine The engine which the post process will be applied. (default: current engine)
  132069. * @param reusable If the post process can be reused on the same frame. (default: false)
  132070. */
  132071. constructor(name: string,
  132072. /** The matrix to be applied to the image */
  132073. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132074. }
  132075. }
  132076. declare module BABYLON {
  132077. /** @hidden */
  132078. export var fxaaPixelShader: {
  132079. name: string;
  132080. shader: string;
  132081. };
  132082. }
  132083. declare module BABYLON {
  132084. /** @hidden */
  132085. export var fxaaVertexShader: {
  132086. name: string;
  132087. shader: string;
  132088. };
  132089. }
  132090. declare module BABYLON {
  132091. /**
  132092. * Fxaa post process
  132093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  132094. */
  132095. export class FxaaPostProcess extends PostProcess {
  132096. /** @hidden */
  132097. texelWidth: number;
  132098. /** @hidden */
  132099. texelHeight: number;
  132100. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132101. private _getDefines;
  132102. }
  132103. }
  132104. declare module BABYLON {
  132105. /** @hidden */
  132106. export var grainPixelShader: {
  132107. name: string;
  132108. shader: string;
  132109. };
  132110. }
  132111. declare module BABYLON {
  132112. /**
  132113. * The GrainPostProcess adds noise to the image at mid luminance levels
  132114. */
  132115. export class GrainPostProcess extends PostProcess {
  132116. /**
  132117. * The intensity of the grain added (default: 30)
  132118. */
  132119. intensity: number;
  132120. /**
  132121. * If the grain should be randomized on every frame
  132122. */
  132123. animated: boolean;
  132124. /**
  132125. * Creates a new instance of @see GrainPostProcess
  132126. * @param name The name of the effect.
  132127. * @param options The required width/height ratio to downsize to before computing the render pass.
  132128. * @param camera The camera to apply the render pass to.
  132129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132130. * @param engine The engine which the post process will be applied. (default: current engine)
  132131. * @param reusable If the post process can be reused on the same frame. (default: false)
  132132. * @param textureType Type of textures used when performing the post process. (default: 0)
  132133. * @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)
  132134. */
  132135. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132136. }
  132137. }
  132138. declare module BABYLON {
  132139. /** @hidden */
  132140. export var highlightsPixelShader: {
  132141. name: string;
  132142. shader: string;
  132143. };
  132144. }
  132145. declare module BABYLON {
  132146. /**
  132147. * Extracts highlights from the image
  132148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  132149. */
  132150. export class HighlightsPostProcess extends PostProcess {
  132151. /**
  132152. * Extracts highlights from the image
  132153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  132154. * @param name The name of the effect.
  132155. * @param options The required width/height ratio to downsize to before computing the render pass.
  132156. * @param camera The camera to apply the render pass to.
  132157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132158. * @param engine The engine which the post process will be applied. (default: current engine)
  132159. * @param reusable If the post process can be reused on the same frame. (default: false)
  132160. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  132161. */
  132162. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132163. }
  132164. }
  132165. declare module BABYLON {
  132166. /** @hidden */
  132167. export var mrtFragmentDeclaration: {
  132168. name: string;
  132169. shader: string;
  132170. };
  132171. }
  132172. declare module BABYLON {
  132173. /** @hidden */
  132174. export var geometryPixelShader: {
  132175. name: string;
  132176. shader: string;
  132177. };
  132178. }
  132179. declare module BABYLON {
  132180. /** @hidden */
  132181. export var geometryVertexShader: {
  132182. name: string;
  132183. shader: string;
  132184. };
  132185. }
  132186. declare module BABYLON {
  132187. /** @hidden */
  132188. interface ISavedTransformationMatrix {
  132189. world: Matrix;
  132190. viewProjection: Matrix;
  132191. }
  132192. /**
  132193. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  132194. */
  132195. export class GeometryBufferRenderer {
  132196. /**
  132197. * Constant used to retrieve the position texture index in the G-Buffer textures array
  132198. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  132199. */
  132200. static readonly POSITION_TEXTURE_TYPE: number;
  132201. /**
  132202. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  132203. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  132204. */
  132205. static readonly VELOCITY_TEXTURE_TYPE: number;
  132206. /**
  132207. * Dictionary used to store the previous transformation matrices of each rendered mesh
  132208. * in order to compute objects velocities when enableVelocity is set to "true"
  132209. * @hidden
  132210. */
  132211. _previousTransformationMatrices: {
  132212. [index: number]: ISavedTransformationMatrix;
  132213. };
  132214. /**
  132215. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  132216. * in order to compute objects velocities when enableVelocity is set to "true"
  132217. * @hidden
  132218. */
  132219. _previousBonesTransformationMatrices: {
  132220. [index: number]: Float32Array;
  132221. };
  132222. /**
  132223. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  132224. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  132225. */
  132226. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  132227. private _scene;
  132228. private _multiRenderTarget;
  132229. private _ratio;
  132230. private _enablePosition;
  132231. private _enableVelocity;
  132232. private _positionIndex;
  132233. private _velocityIndex;
  132234. protected _effect: Effect;
  132235. protected _cachedDefines: string;
  132236. /**
  132237. * Set the render list (meshes to be rendered) used in the G buffer.
  132238. */
  132239. renderList: Mesh[];
  132240. /**
  132241. * Gets wether or not G buffer are supported by the running hardware.
  132242. * This requires draw buffer supports
  132243. */
  132244. readonly isSupported: boolean;
  132245. /**
  132246. * Returns the index of the given texture type in the G-Buffer textures array
  132247. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  132248. * @returns the index of the given texture type in the G-Buffer textures array
  132249. */
  132250. getTextureIndex(textureType: number): number;
  132251. /**
  132252. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  132253. */
  132254. /**
  132255. * Sets whether or not objects positions are enabled for the G buffer.
  132256. */
  132257. enablePosition: boolean;
  132258. /**
  132259. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  132260. */
  132261. /**
  132262. * Sets wether or not objects velocities are enabled for the G buffer.
  132263. */
  132264. enableVelocity: boolean;
  132265. /**
  132266. * Gets the scene associated with the buffer.
  132267. */
  132268. readonly scene: Scene;
  132269. /**
  132270. * Gets the ratio used by the buffer during its creation.
  132271. * How big is the buffer related to the main canvas.
  132272. */
  132273. readonly ratio: number;
  132274. /** @hidden */
  132275. static _SceneComponentInitialization: (scene: Scene) => void;
  132276. /**
  132277. * Creates a new G Buffer for the scene
  132278. * @param scene The scene the buffer belongs to
  132279. * @param ratio How big is the buffer related to the main canvas.
  132280. */
  132281. constructor(scene: Scene, ratio?: number);
  132282. /**
  132283. * Checks wether everything is ready to render a submesh to the G buffer.
  132284. * @param subMesh the submesh to check readiness for
  132285. * @param useInstances is the mesh drawn using instance or not
  132286. * @returns true if ready otherwise false
  132287. */
  132288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132289. /**
  132290. * Gets the current underlying G Buffer.
  132291. * @returns the buffer
  132292. */
  132293. getGBuffer(): MultiRenderTarget;
  132294. /**
  132295. * Gets the number of samples used to render the buffer (anti aliasing).
  132296. */
  132297. /**
  132298. * Sets the number of samples used to render the buffer (anti aliasing).
  132299. */
  132300. samples: number;
  132301. /**
  132302. * Disposes the renderer and frees up associated resources.
  132303. */
  132304. dispose(): void;
  132305. protected _createRenderTargets(): void;
  132306. private _copyBonesTransformationMatrices;
  132307. }
  132308. }
  132309. declare module BABYLON {
  132310. interface Scene {
  132311. /** @hidden (Backing field) */
  132312. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  132313. /**
  132314. * Gets or Sets the current geometry buffer associated to the scene.
  132315. */
  132316. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  132317. /**
  132318. * Enables a GeometryBufferRender and associates it with the scene
  132319. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  132320. * @returns the GeometryBufferRenderer
  132321. */
  132322. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  132323. /**
  132324. * Disables the GeometryBufferRender associated with the scene
  132325. */
  132326. disableGeometryBufferRenderer(): void;
  132327. }
  132328. /**
  132329. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  132330. * in several rendering techniques.
  132331. */
  132332. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  132333. /**
  132334. * The component name helpful to identify the component in the list of scene components.
  132335. */
  132336. readonly name: string;
  132337. /**
  132338. * The scene the component belongs to.
  132339. */
  132340. scene: Scene;
  132341. /**
  132342. * Creates a new instance of the component for the given scene
  132343. * @param scene Defines the scene to register the component in
  132344. */
  132345. constructor(scene: Scene);
  132346. /**
  132347. * Registers the component in a given scene
  132348. */
  132349. register(): void;
  132350. /**
  132351. * Rebuilds the elements related to this component in case of
  132352. * context lost for instance.
  132353. */
  132354. rebuild(): void;
  132355. /**
  132356. * Disposes the component and the associated ressources
  132357. */
  132358. dispose(): void;
  132359. private _gatherRenderTargets;
  132360. }
  132361. }
  132362. declare module BABYLON {
  132363. /** @hidden */
  132364. export var motionBlurPixelShader: {
  132365. name: string;
  132366. shader: string;
  132367. };
  132368. }
  132369. declare module BABYLON {
  132370. /**
  132371. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  132372. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  132373. * As an example, all you have to do is to create the post-process:
  132374. * var mb = new BABYLON.MotionBlurPostProcess(
  132375. * 'mb', // The name of the effect.
  132376. * scene, // The scene containing the objects to blur according to their velocity.
  132377. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  132378. * camera // The camera to apply the render pass to.
  132379. * );
  132380. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  132381. */
  132382. export class MotionBlurPostProcess extends PostProcess {
  132383. /**
  132384. * Defines how much the image is blurred by the movement. Default value is equal to 1
  132385. */
  132386. motionStrength: number;
  132387. /**
  132388. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  132389. */
  132390. /**
  132391. * Sets the number of iterations to be used for motion blur quality
  132392. */
  132393. motionBlurSamples: number;
  132394. private _motionBlurSamples;
  132395. private _geometryBufferRenderer;
  132396. /**
  132397. * Creates a new instance MotionBlurPostProcess
  132398. * @param name The name of the effect.
  132399. * @param scene The scene containing the objects to blur according to their velocity.
  132400. * @param options The required width/height ratio to downsize to before computing the render pass.
  132401. * @param camera The camera to apply the render pass to.
  132402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132403. * @param engine The engine which the post process will be applied. (default: current engine)
  132404. * @param reusable If the post process can be reused on the same frame. (default: false)
  132405. * @param textureType Type of textures used when performing the post process. (default: 0)
  132406. * @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)
  132407. */
  132408. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132409. /**
  132410. * Excludes the given skinned mesh from computing bones velocities.
  132411. * 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.
  132412. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  132413. */
  132414. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  132415. /**
  132416. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  132417. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  132418. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  132419. */
  132420. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  132421. /**
  132422. * Disposes the post process.
  132423. * @param camera The camera to dispose the post process on.
  132424. */
  132425. dispose(camera?: Camera): void;
  132426. }
  132427. }
  132428. declare module BABYLON {
  132429. /** @hidden */
  132430. export var refractionPixelShader: {
  132431. name: string;
  132432. shader: string;
  132433. };
  132434. }
  132435. declare module BABYLON {
  132436. /**
  132437. * Post process which applies a refractin texture
  132438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  132439. */
  132440. export class RefractionPostProcess extends PostProcess {
  132441. /** the base color of the refraction (used to taint the rendering) */
  132442. color: Color3;
  132443. /** simulated refraction depth */
  132444. depth: number;
  132445. /** the coefficient of the base color (0 to remove base color tainting) */
  132446. colorLevel: number;
  132447. private _refTexture;
  132448. private _ownRefractionTexture;
  132449. /**
  132450. * Gets or sets the refraction texture
  132451. * Please note that you are responsible for disposing the texture if you set it manually
  132452. */
  132453. refractionTexture: Texture;
  132454. /**
  132455. * Initializes the RefractionPostProcess
  132456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  132457. * @param name The name of the effect.
  132458. * @param refractionTextureUrl Url of the refraction texture to use
  132459. * @param color the base color of the refraction (used to taint the rendering)
  132460. * @param depth simulated refraction depth
  132461. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  132462. * @param camera The camera to apply the render pass to.
  132463. * @param options The required width/height ratio to downsize to before computing the render pass.
  132464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132465. * @param engine The engine which the post process will be applied. (default: current engine)
  132466. * @param reusable If the post process can be reused on the same frame. (default: false)
  132467. */
  132468. constructor(name: string, refractionTextureUrl: string,
  132469. /** the base color of the refraction (used to taint the rendering) */
  132470. color: Color3,
  132471. /** simulated refraction depth */
  132472. depth: number,
  132473. /** the coefficient of the base color (0 to remove base color tainting) */
  132474. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132475. /**
  132476. * Disposes of the post process
  132477. * @param camera Camera to dispose post process on
  132478. */
  132479. dispose(camera: Camera): void;
  132480. }
  132481. }
  132482. declare module BABYLON {
  132483. /** @hidden */
  132484. export var sharpenPixelShader: {
  132485. name: string;
  132486. shader: string;
  132487. };
  132488. }
  132489. declare module BABYLON {
  132490. /**
  132491. * The SharpenPostProcess applies a sharpen kernel to every pixel
  132492. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  132493. */
  132494. export class SharpenPostProcess extends PostProcess {
  132495. /**
  132496. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  132497. */
  132498. colorAmount: number;
  132499. /**
  132500. * How much sharpness should be applied (default: 0.3)
  132501. */
  132502. edgeAmount: number;
  132503. /**
  132504. * Creates a new instance ConvolutionPostProcess
  132505. * @param name The name of the effect.
  132506. * @param options The required width/height ratio to downsize to before computing the render pass.
  132507. * @param camera The camera to apply the render pass to.
  132508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132509. * @param engine The engine which the post process will be applied. (default: current engine)
  132510. * @param reusable If the post process can be reused on the same frame. (default: false)
  132511. * @param textureType Type of textures used when performing the post process. (default: 0)
  132512. * @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)
  132513. */
  132514. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132515. }
  132516. }
  132517. declare module BABYLON {
  132518. /**
  132519. * PostProcessRenderPipeline
  132520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132521. */
  132522. export class PostProcessRenderPipeline {
  132523. private engine;
  132524. private _renderEffects;
  132525. private _renderEffectsForIsolatedPass;
  132526. /**
  132527. * List of inspectable custom properties (used by the Inspector)
  132528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  132529. */
  132530. inspectableCustomProperties: IInspectable[];
  132531. /**
  132532. * @hidden
  132533. */
  132534. protected _cameras: Camera[];
  132535. /** @hidden */
  132536. _name: string;
  132537. /**
  132538. * Gets pipeline name
  132539. */
  132540. readonly name: string;
  132541. /** Gets the list of attached cameras */
  132542. readonly cameras: Camera[];
  132543. /**
  132544. * Initializes a PostProcessRenderPipeline
  132545. * @param engine engine to add the pipeline to
  132546. * @param name name of the pipeline
  132547. */
  132548. constructor(engine: Engine, name: string);
  132549. /**
  132550. * Gets the class name
  132551. * @returns "PostProcessRenderPipeline"
  132552. */
  132553. getClassName(): string;
  132554. /**
  132555. * If all the render effects in the pipeline are supported
  132556. */
  132557. readonly isSupported: boolean;
  132558. /**
  132559. * Adds an effect to the pipeline
  132560. * @param renderEffect the effect to add
  132561. */
  132562. addEffect(renderEffect: PostProcessRenderEffect): void;
  132563. /** @hidden */
  132564. _rebuild(): void;
  132565. /** @hidden */
  132566. _enableEffect(renderEffectName: string, cameras: Camera): void;
  132567. /** @hidden */
  132568. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  132569. /** @hidden */
  132570. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  132571. /** @hidden */
  132572. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  132573. /** @hidden */
  132574. _attachCameras(cameras: Camera, unique: boolean): void;
  132575. /** @hidden */
  132576. _attachCameras(cameras: Camera[], unique: boolean): void;
  132577. /** @hidden */
  132578. _detachCameras(cameras: Camera): void;
  132579. /** @hidden */
  132580. _detachCameras(cameras: Nullable<Camera[]>): void;
  132581. /** @hidden */
  132582. _update(): void;
  132583. /** @hidden */
  132584. _reset(): void;
  132585. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  132586. /**
  132587. * Disposes of the pipeline
  132588. */
  132589. dispose(): void;
  132590. }
  132591. }
  132592. declare module BABYLON {
  132593. /**
  132594. * PostProcessRenderPipelineManager class
  132595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132596. */
  132597. export class PostProcessRenderPipelineManager {
  132598. private _renderPipelines;
  132599. /**
  132600. * Initializes a PostProcessRenderPipelineManager
  132601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132602. */
  132603. constructor();
  132604. /**
  132605. * Gets the list of supported render pipelines
  132606. */
  132607. readonly supportedPipelines: PostProcessRenderPipeline[];
  132608. /**
  132609. * Adds a pipeline to the manager
  132610. * @param renderPipeline The pipeline to add
  132611. */
  132612. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  132613. /**
  132614. * Attaches a camera to the pipeline
  132615. * @param renderPipelineName The name of the pipeline to attach to
  132616. * @param cameras the camera to attach
  132617. * @param unique if the camera can be attached multiple times to the pipeline
  132618. */
  132619. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  132620. /**
  132621. * Detaches a camera from the pipeline
  132622. * @param renderPipelineName The name of the pipeline to detach from
  132623. * @param cameras the camera to detach
  132624. */
  132625. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  132626. /**
  132627. * Enables an effect by name on a pipeline
  132628. * @param renderPipelineName the name of the pipeline to enable the effect in
  132629. * @param renderEffectName the name of the effect to enable
  132630. * @param cameras the cameras that the effect should be enabled on
  132631. */
  132632. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  132633. /**
  132634. * Disables an effect by name on a pipeline
  132635. * @param renderPipelineName the name of the pipeline to disable the effect in
  132636. * @param renderEffectName the name of the effect to disable
  132637. * @param cameras the cameras that the effect should be disabled on
  132638. */
  132639. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  132640. /**
  132641. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  132642. */
  132643. update(): void;
  132644. /** @hidden */
  132645. _rebuild(): void;
  132646. /**
  132647. * Disposes of the manager and pipelines
  132648. */
  132649. dispose(): void;
  132650. }
  132651. }
  132652. declare module BABYLON {
  132653. interface Scene {
  132654. /** @hidden (Backing field) */
  132655. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  132656. /**
  132657. * Gets the postprocess render pipeline manager
  132658. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132659. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  132660. */
  132661. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  132662. }
  132663. /**
  132664. * Defines the Render Pipeline scene component responsible to rendering pipelines
  132665. */
  132666. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  132667. /**
  132668. * The component name helpfull to identify the component in the list of scene components.
  132669. */
  132670. readonly name: string;
  132671. /**
  132672. * The scene the component belongs to.
  132673. */
  132674. scene: Scene;
  132675. /**
  132676. * Creates a new instance of the component for the given scene
  132677. * @param scene Defines the scene to register the component in
  132678. */
  132679. constructor(scene: Scene);
  132680. /**
  132681. * Registers the component in a given scene
  132682. */
  132683. register(): void;
  132684. /**
  132685. * Rebuilds the elements related to this component in case of
  132686. * context lost for instance.
  132687. */
  132688. rebuild(): void;
  132689. /**
  132690. * Disposes the component and the associated ressources
  132691. */
  132692. dispose(): void;
  132693. private _gatherRenderTargets;
  132694. }
  132695. }
  132696. declare module BABYLON {
  132697. /**
  132698. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  132699. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  132700. */
  132701. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  132702. private _scene;
  132703. private _camerasToBeAttached;
  132704. /**
  132705. * ID of the sharpen post process,
  132706. */
  132707. private readonly SharpenPostProcessId;
  132708. /**
  132709. * @ignore
  132710. * ID of the image processing post process;
  132711. */
  132712. readonly ImageProcessingPostProcessId: string;
  132713. /**
  132714. * @ignore
  132715. * ID of the Fast Approximate Anti-Aliasing post process;
  132716. */
  132717. readonly FxaaPostProcessId: string;
  132718. /**
  132719. * ID of the chromatic aberration post process,
  132720. */
  132721. private readonly ChromaticAberrationPostProcessId;
  132722. /**
  132723. * ID of the grain post process
  132724. */
  132725. private readonly GrainPostProcessId;
  132726. /**
  132727. * Sharpen post process which will apply a sharpen convolution to enhance edges
  132728. */
  132729. sharpen: SharpenPostProcess;
  132730. private _sharpenEffect;
  132731. private bloom;
  132732. /**
  132733. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  132734. */
  132735. depthOfField: DepthOfFieldEffect;
  132736. /**
  132737. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  132738. */
  132739. fxaa: FxaaPostProcess;
  132740. /**
  132741. * Image post processing pass used to perform operations such as tone mapping or color grading.
  132742. */
  132743. imageProcessing: ImageProcessingPostProcess;
  132744. /**
  132745. * Chromatic aberration post process which will shift rgb colors in the image
  132746. */
  132747. chromaticAberration: ChromaticAberrationPostProcess;
  132748. private _chromaticAberrationEffect;
  132749. /**
  132750. * Grain post process which add noise to the image
  132751. */
  132752. grain: GrainPostProcess;
  132753. private _grainEffect;
  132754. /**
  132755. * Glow post process which adds a glow to emissive areas of the image
  132756. */
  132757. private _glowLayer;
  132758. /**
  132759. * Animations which can be used to tweak settings over a period of time
  132760. */
  132761. animations: Animation[];
  132762. private _imageProcessingConfigurationObserver;
  132763. private _sharpenEnabled;
  132764. private _bloomEnabled;
  132765. private _depthOfFieldEnabled;
  132766. private _depthOfFieldBlurLevel;
  132767. private _fxaaEnabled;
  132768. private _imageProcessingEnabled;
  132769. private _defaultPipelineTextureType;
  132770. private _bloomScale;
  132771. private _chromaticAberrationEnabled;
  132772. private _grainEnabled;
  132773. private _buildAllowed;
  132774. /**
  132775. * Gets active scene
  132776. */
  132777. readonly scene: Scene;
  132778. /**
  132779. * Enable or disable the sharpen process from the pipeline
  132780. */
  132781. sharpenEnabled: boolean;
  132782. private _resizeObserver;
  132783. private _hardwareScaleLevel;
  132784. private _bloomKernel;
  132785. /**
  132786. * Specifies the size of the bloom blur kernel, relative to the final output size
  132787. */
  132788. bloomKernel: number;
  132789. /**
  132790. * Specifies the weight of the bloom in the final rendering
  132791. */
  132792. private _bloomWeight;
  132793. /**
  132794. * Specifies the luma threshold for the area that will be blurred by the bloom
  132795. */
  132796. private _bloomThreshold;
  132797. private _hdr;
  132798. /**
  132799. * The strength of the bloom.
  132800. */
  132801. bloomWeight: number;
  132802. /**
  132803. * The strength of the bloom.
  132804. */
  132805. bloomThreshold: number;
  132806. /**
  132807. * The scale of the bloom, lower value will provide better performance.
  132808. */
  132809. bloomScale: number;
  132810. /**
  132811. * Enable or disable the bloom from the pipeline
  132812. */
  132813. bloomEnabled: boolean;
  132814. private _rebuildBloom;
  132815. /**
  132816. * If the depth of field is enabled.
  132817. */
  132818. depthOfFieldEnabled: boolean;
  132819. /**
  132820. * Blur level of the depth of field effect. (Higher blur will effect performance)
  132821. */
  132822. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  132823. /**
  132824. * If the anti aliasing is enabled.
  132825. */
  132826. fxaaEnabled: boolean;
  132827. private _samples;
  132828. /**
  132829. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  132830. */
  132831. samples: number;
  132832. /**
  132833. * If image processing is enabled.
  132834. */
  132835. imageProcessingEnabled: boolean;
  132836. /**
  132837. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  132838. */
  132839. glowLayerEnabled: boolean;
  132840. /**
  132841. * Gets the glow layer (or null if not defined)
  132842. */
  132843. readonly glowLayer: Nullable<GlowLayer>;
  132844. /**
  132845. * Enable or disable the chromaticAberration process from the pipeline
  132846. */
  132847. chromaticAberrationEnabled: boolean;
  132848. /**
  132849. * Enable or disable the grain process from the pipeline
  132850. */
  132851. grainEnabled: boolean;
  132852. /**
  132853. * @constructor
  132854. * @param name - The rendering pipeline name (default: "")
  132855. * @param hdr - If high dynamic range textures should be used (default: true)
  132856. * @param scene - The scene linked to this pipeline (default: the last created scene)
  132857. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  132858. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  132859. */
  132860. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  132861. /**
  132862. * Get the class name
  132863. * @returns "DefaultRenderingPipeline"
  132864. */
  132865. getClassName(): string;
  132866. /**
  132867. * Force the compilation of the entire pipeline.
  132868. */
  132869. prepare(): void;
  132870. private _hasCleared;
  132871. private _prevPostProcess;
  132872. private _prevPrevPostProcess;
  132873. private _setAutoClearAndTextureSharing;
  132874. private _depthOfFieldSceneObserver;
  132875. private _buildPipeline;
  132876. private _disposePostProcesses;
  132877. /**
  132878. * Adds a camera to the pipeline
  132879. * @param camera the camera to be added
  132880. */
  132881. addCamera(camera: Camera): void;
  132882. /**
  132883. * Removes a camera from the pipeline
  132884. * @param camera the camera to remove
  132885. */
  132886. removeCamera(camera: Camera): void;
  132887. /**
  132888. * Dispose of the pipeline and stop all post processes
  132889. */
  132890. dispose(): void;
  132891. /**
  132892. * Serialize the rendering pipeline (Used when exporting)
  132893. * @returns the serialized object
  132894. */
  132895. serialize(): any;
  132896. /**
  132897. * Parse the serialized pipeline
  132898. * @param source Source pipeline.
  132899. * @param scene The scene to load the pipeline to.
  132900. * @param rootUrl The URL of the serialized pipeline.
  132901. * @returns An instantiated pipeline from the serialized object.
  132902. */
  132903. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  132904. }
  132905. }
  132906. declare module BABYLON {
  132907. /** @hidden */
  132908. export var lensHighlightsPixelShader: {
  132909. name: string;
  132910. shader: string;
  132911. };
  132912. }
  132913. declare module BABYLON {
  132914. /** @hidden */
  132915. export var depthOfFieldPixelShader: {
  132916. name: string;
  132917. shader: string;
  132918. };
  132919. }
  132920. declare module BABYLON {
  132921. /**
  132922. * BABYLON.JS Chromatic Aberration GLSL Shader
  132923. * Author: Olivier Guyot
  132924. * Separates very slightly R, G and B colors on the edges of the screen
  132925. * Inspired by Francois Tarlier & Martins Upitis
  132926. */
  132927. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  132928. /**
  132929. * @ignore
  132930. * The chromatic aberration PostProcess id in the pipeline
  132931. */
  132932. LensChromaticAberrationEffect: string;
  132933. /**
  132934. * @ignore
  132935. * The highlights enhancing PostProcess id in the pipeline
  132936. */
  132937. HighlightsEnhancingEffect: string;
  132938. /**
  132939. * @ignore
  132940. * The depth-of-field PostProcess id in the pipeline
  132941. */
  132942. LensDepthOfFieldEffect: string;
  132943. private _scene;
  132944. private _depthTexture;
  132945. private _grainTexture;
  132946. private _chromaticAberrationPostProcess;
  132947. private _highlightsPostProcess;
  132948. private _depthOfFieldPostProcess;
  132949. private _edgeBlur;
  132950. private _grainAmount;
  132951. private _chromaticAberration;
  132952. private _distortion;
  132953. private _highlightsGain;
  132954. private _highlightsThreshold;
  132955. private _dofDistance;
  132956. private _dofAperture;
  132957. private _dofDarken;
  132958. private _dofPentagon;
  132959. private _blurNoise;
  132960. /**
  132961. * @constructor
  132962. *
  132963. * Effect parameters are as follow:
  132964. * {
  132965. * chromatic_aberration: number; // from 0 to x (1 for realism)
  132966. * edge_blur: number; // from 0 to x (1 for realism)
  132967. * distortion: number; // from 0 to x (1 for realism)
  132968. * grain_amount: number; // from 0 to 1
  132969. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  132970. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  132971. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  132972. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  132973. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  132974. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  132975. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  132976. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  132977. * }
  132978. * Note: if an effect parameter is unset, effect is disabled
  132979. *
  132980. * @param name The rendering pipeline name
  132981. * @param parameters - An object containing all parameters (see above)
  132982. * @param scene The scene linked to this pipeline
  132983. * @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)
  132984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132985. */
  132986. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  132987. /**
  132988. * Get the class name
  132989. * @returns "LensRenderingPipeline"
  132990. */
  132991. getClassName(): string;
  132992. /**
  132993. * Gets associated scene
  132994. */
  132995. readonly scene: Scene;
  132996. /**
  132997. * Gets or sets the edge blur
  132998. */
  132999. edgeBlur: number;
  133000. /**
  133001. * Gets or sets the grain amount
  133002. */
  133003. grainAmount: number;
  133004. /**
  133005. * Gets or sets the chromatic aberration amount
  133006. */
  133007. chromaticAberration: number;
  133008. /**
  133009. * Gets or sets the depth of field aperture
  133010. */
  133011. dofAperture: number;
  133012. /**
  133013. * Gets or sets the edge distortion
  133014. */
  133015. edgeDistortion: number;
  133016. /**
  133017. * Gets or sets the depth of field distortion
  133018. */
  133019. dofDistortion: number;
  133020. /**
  133021. * Gets or sets the darken out of focus amount
  133022. */
  133023. darkenOutOfFocus: number;
  133024. /**
  133025. * Gets or sets a boolean indicating if blur noise is enabled
  133026. */
  133027. blurNoise: boolean;
  133028. /**
  133029. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  133030. */
  133031. pentagonBokeh: boolean;
  133032. /**
  133033. * Gets or sets the highlight grain amount
  133034. */
  133035. highlightsGain: number;
  133036. /**
  133037. * Gets or sets the highlight threshold
  133038. */
  133039. highlightsThreshold: number;
  133040. /**
  133041. * Sets the amount of blur at the edges
  133042. * @param amount blur amount
  133043. */
  133044. setEdgeBlur(amount: number): void;
  133045. /**
  133046. * Sets edge blur to 0
  133047. */
  133048. disableEdgeBlur(): void;
  133049. /**
  133050. * Sets the amout of grain
  133051. * @param amount Amount of grain
  133052. */
  133053. setGrainAmount(amount: number): void;
  133054. /**
  133055. * Set grain amount to 0
  133056. */
  133057. disableGrain(): void;
  133058. /**
  133059. * Sets the chromatic aberration amount
  133060. * @param amount amount of chromatic aberration
  133061. */
  133062. setChromaticAberration(amount: number): void;
  133063. /**
  133064. * Sets chromatic aberration amount to 0
  133065. */
  133066. disableChromaticAberration(): void;
  133067. /**
  133068. * Sets the EdgeDistortion amount
  133069. * @param amount amount of EdgeDistortion
  133070. */
  133071. setEdgeDistortion(amount: number): void;
  133072. /**
  133073. * Sets edge distortion to 0
  133074. */
  133075. disableEdgeDistortion(): void;
  133076. /**
  133077. * Sets the FocusDistance amount
  133078. * @param amount amount of FocusDistance
  133079. */
  133080. setFocusDistance(amount: number): void;
  133081. /**
  133082. * Disables depth of field
  133083. */
  133084. disableDepthOfField(): void;
  133085. /**
  133086. * Sets the Aperture amount
  133087. * @param amount amount of Aperture
  133088. */
  133089. setAperture(amount: number): void;
  133090. /**
  133091. * Sets the DarkenOutOfFocus amount
  133092. * @param amount amount of DarkenOutOfFocus
  133093. */
  133094. setDarkenOutOfFocus(amount: number): void;
  133095. private _pentagonBokehIsEnabled;
  133096. /**
  133097. * Creates a pentagon bokeh effect
  133098. */
  133099. enablePentagonBokeh(): void;
  133100. /**
  133101. * Disables the pentagon bokeh effect
  133102. */
  133103. disablePentagonBokeh(): void;
  133104. /**
  133105. * Enables noise blur
  133106. */
  133107. enableNoiseBlur(): void;
  133108. /**
  133109. * Disables noise blur
  133110. */
  133111. disableNoiseBlur(): void;
  133112. /**
  133113. * Sets the HighlightsGain amount
  133114. * @param amount amount of HighlightsGain
  133115. */
  133116. setHighlightsGain(amount: number): void;
  133117. /**
  133118. * Sets the HighlightsThreshold amount
  133119. * @param amount amount of HighlightsThreshold
  133120. */
  133121. setHighlightsThreshold(amount: number): void;
  133122. /**
  133123. * Disables highlights
  133124. */
  133125. disableHighlights(): void;
  133126. /**
  133127. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  133128. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  133129. */
  133130. dispose(disableDepthRender?: boolean): void;
  133131. private _createChromaticAberrationPostProcess;
  133132. private _createHighlightsPostProcess;
  133133. private _createDepthOfFieldPostProcess;
  133134. private _createGrainTexture;
  133135. }
  133136. }
  133137. declare module BABYLON {
  133138. /** @hidden */
  133139. export var ssao2PixelShader: {
  133140. name: string;
  133141. shader: string;
  133142. };
  133143. }
  133144. declare module BABYLON {
  133145. /** @hidden */
  133146. export var ssaoCombinePixelShader: {
  133147. name: string;
  133148. shader: string;
  133149. };
  133150. }
  133151. declare module BABYLON {
  133152. /**
  133153. * Render pipeline to produce ssao effect
  133154. */
  133155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  133156. /**
  133157. * @ignore
  133158. * The PassPostProcess id in the pipeline that contains the original scene color
  133159. */
  133160. SSAOOriginalSceneColorEffect: string;
  133161. /**
  133162. * @ignore
  133163. * The SSAO PostProcess id in the pipeline
  133164. */
  133165. SSAORenderEffect: string;
  133166. /**
  133167. * @ignore
  133168. * The horizontal blur PostProcess id in the pipeline
  133169. */
  133170. SSAOBlurHRenderEffect: string;
  133171. /**
  133172. * @ignore
  133173. * The vertical blur PostProcess id in the pipeline
  133174. */
  133175. SSAOBlurVRenderEffect: string;
  133176. /**
  133177. * @ignore
  133178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  133179. */
  133180. SSAOCombineRenderEffect: string;
  133181. /**
  133182. * The output strength of the SSAO post-process. Default value is 1.0.
  133183. */
  133184. totalStrength: number;
  133185. /**
  133186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  133187. */
  133188. maxZ: number;
  133189. /**
  133190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  133191. */
  133192. minZAspect: number;
  133193. private _samples;
  133194. /**
  133195. * Number of samples used for the SSAO calculations. Default value is 8
  133196. */
  133197. samples: number;
  133198. private _textureSamples;
  133199. /**
  133200. * Number of samples to use for antialiasing
  133201. */
  133202. textureSamples: number;
  133203. /**
  133204. * Ratio object used for SSAO ratio and blur ratio
  133205. */
  133206. private _ratio;
  133207. /**
  133208. * Dynamically generated sphere sampler.
  133209. */
  133210. private _sampleSphere;
  133211. /**
  133212. * Blur filter offsets
  133213. */
  133214. private _samplerOffsets;
  133215. private _expensiveBlur;
  133216. /**
  133217. * If bilateral blur should be used
  133218. */
  133219. expensiveBlur: boolean;
  133220. /**
  133221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  133222. */
  133223. radius: number;
  133224. /**
  133225. * The base color of the SSAO post-process
  133226. * The final result is "base + ssao" between [0, 1]
  133227. */
  133228. base: number;
  133229. /**
  133230. * Support test.
  133231. */
  133232. static readonly IsSupported: boolean;
  133233. private _scene;
  133234. private _depthTexture;
  133235. private _normalTexture;
  133236. private _randomTexture;
  133237. private _originalColorPostProcess;
  133238. private _ssaoPostProcess;
  133239. private _blurHPostProcess;
  133240. private _blurVPostProcess;
  133241. private _ssaoCombinePostProcess;
  133242. /**
  133243. * Gets active scene
  133244. */
  133245. readonly scene: Scene;
  133246. /**
  133247. * @constructor
  133248. * @param name The rendering pipeline name
  133249. * @param scene The scene linked to this pipeline
  133250. * @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 }
  133251. * @param cameras The array of cameras that the rendering pipeline will be attached to
  133252. */
  133253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  133254. /**
  133255. * Get the class name
  133256. * @returns "SSAO2RenderingPipeline"
  133257. */
  133258. getClassName(): string;
  133259. /**
  133260. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  133261. */
  133262. dispose(disableGeometryBufferRenderer?: boolean): void;
  133263. private _createBlurPostProcess;
  133264. /** @hidden */
  133265. _rebuild(): void;
  133266. private _bits;
  133267. private _radicalInverse_VdC;
  133268. private _hammersley;
  133269. private _hemisphereSample_uniform;
  133270. private _generateHemisphere;
  133271. private _createSSAOPostProcess;
  133272. private _createSSAOCombinePostProcess;
  133273. private _createRandomTexture;
  133274. /**
  133275. * Serialize the rendering pipeline (Used when exporting)
  133276. * @returns the serialized object
  133277. */
  133278. serialize(): any;
  133279. /**
  133280. * Parse the serialized pipeline
  133281. * @param source Source pipeline.
  133282. * @param scene The scene to load the pipeline to.
  133283. * @param rootUrl The URL of the serialized pipeline.
  133284. * @returns An instantiated pipeline from the serialized object.
  133285. */
  133286. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  133287. }
  133288. }
  133289. declare module BABYLON {
  133290. /** @hidden */
  133291. export var ssaoPixelShader: {
  133292. name: string;
  133293. shader: string;
  133294. };
  133295. }
  133296. declare module BABYLON {
  133297. /**
  133298. * Render pipeline to produce ssao effect
  133299. */
  133300. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  133301. /**
  133302. * @ignore
  133303. * The PassPostProcess id in the pipeline that contains the original scene color
  133304. */
  133305. SSAOOriginalSceneColorEffect: string;
  133306. /**
  133307. * @ignore
  133308. * The SSAO PostProcess id in the pipeline
  133309. */
  133310. SSAORenderEffect: string;
  133311. /**
  133312. * @ignore
  133313. * The horizontal blur PostProcess id in the pipeline
  133314. */
  133315. SSAOBlurHRenderEffect: string;
  133316. /**
  133317. * @ignore
  133318. * The vertical blur PostProcess id in the pipeline
  133319. */
  133320. SSAOBlurVRenderEffect: string;
  133321. /**
  133322. * @ignore
  133323. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  133324. */
  133325. SSAOCombineRenderEffect: string;
  133326. /**
  133327. * The output strength of the SSAO post-process. Default value is 1.0.
  133328. */
  133329. totalStrength: number;
  133330. /**
  133331. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  133332. */
  133333. radius: number;
  133334. /**
  133335. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  133336. * Must not be equal to fallOff and superior to fallOff.
  133337. * Default value is 0.0075
  133338. */
  133339. area: number;
  133340. /**
  133341. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  133342. * Must not be equal to area and inferior to area.
  133343. * Default value is 0.000001
  133344. */
  133345. fallOff: number;
  133346. /**
  133347. * The base color of the SSAO post-process
  133348. * The final result is "base + ssao" between [0, 1]
  133349. */
  133350. base: number;
  133351. private _scene;
  133352. private _depthTexture;
  133353. private _randomTexture;
  133354. private _originalColorPostProcess;
  133355. private _ssaoPostProcess;
  133356. private _blurHPostProcess;
  133357. private _blurVPostProcess;
  133358. private _ssaoCombinePostProcess;
  133359. private _firstUpdate;
  133360. /**
  133361. * Gets active scene
  133362. */
  133363. readonly scene: Scene;
  133364. /**
  133365. * @constructor
  133366. * @param name - The rendering pipeline name
  133367. * @param scene - The scene linked to this pipeline
  133368. * @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 }
  133369. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  133370. */
  133371. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  133372. /**
  133373. * Get the class name
  133374. * @returns "SSAORenderingPipeline"
  133375. */
  133376. getClassName(): string;
  133377. /**
  133378. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  133379. */
  133380. dispose(disableDepthRender?: boolean): void;
  133381. private _createBlurPostProcess;
  133382. /** @hidden */
  133383. _rebuild(): void;
  133384. private _createSSAOPostProcess;
  133385. private _createSSAOCombinePostProcess;
  133386. private _createRandomTexture;
  133387. }
  133388. }
  133389. declare module BABYLON {
  133390. /** @hidden */
  133391. export var standardPixelShader: {
  133392. name: string;
  133393. shader: string;
  133394. };
  133395. }
  133396. declare module BABYLON {
  133397. /**
  133398. * Standard rendering pipeline
  133399. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  133400. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  133401. */
  133402. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133403. /**
  133404. * Public members
  133405. */
  133406. /**
  133407. * Post-process which contains the original scene color before the pipeline applies all the effects
  133408. */
  133409. originalPostProcess: Nullable<PostProcess>;
  133410. /**
  133411. * Post-process used to down scale an image x4
  133412. */
  133413. downSampleX4PostProcess: Nullable<PostProcess>;
  133414. /**
  133415. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  133416. */
  133417. brightPassPostProcess: Nullable<PostProcess>;
  133418. /**
  133419. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  133420. */
  133421. blurHPostProcesses: PostProcess[];
  133422. /**
  133423. * Post-process array storing all the vertical blur post-processes used by the pipeline
  133424. */
  133425. blurVPostProcesses: PostProcess[];
  133426. /**
  133427. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  133428. */
  133429. textureAdderPostProcess: Nullable<PostProcess>;
  133430. /**
  133431. * Post-process used to create volumetric lighting effect
  133432. */
  133433. volumetricLightPostProcess: Nullable<PostProcess>;
  133434. /**
  133435. * Post-process used to smooth the previous volumetric light post-process on the X axis
  133436. */
  133437. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  133438. /**
  133439. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  133440. */
  133441. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  133442. /**
  133443. * Post-process used to merge the volumetric light effect and the real scene color
  133444. */
  133445. volumetricLightMergePostProces: Nullable<PostProcess>;
  133446. /**
  133447. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  133448. */
  133449. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  133450. /**
  133451. * Base post-process used to calculate the average luminance of the final image for HDR
  133452. */
  133453. luminancePostProcess: Nullable<PostProcess>;
  133454. /**
  133455. * Post-processes used to create down sample post-processes in order to get
  133456. * the average luminance of the final image for HDR
  133457. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  133458. */
  133459. luminanceDownSamplePostProcesses: PostProcess[];
  133460. /**
  133461. * Post-process used to create a HDR effect (light adaptation)
  133462. */
  133463. hdrPostProcess: Nullable<PostProcess>;
  133464. /**
  133465. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  133466. */
  133467. textureAdderFinalPostProcess: Nullable<PostProcess>;
  133468. /**
  133469. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  133470. */
  133471. lensFlareFinalPostProcess: Nullable<PostProcess>;
  133472. /**
  133473. * Post-process used to merge the final HDR post-process and the real scene color
  133474. */
  133475. hdrFinalPostProcess: Nullable<PostProcess>;
  133476. /**
  133477. * Post-process used to create a lens flare effect
  133478. */
  133479. lensFlarePostProcess: Nullable<PostProcess>;
  133480. /**
  133481. * Post-process that merges the result of the lens flare post-process and the real scene color
  133482. */
  133483. lensFlareComposePostProcess: Nullable<PostProcess>;
  133484. /**
  133485. * Post-process used to create a motion blur effect
  133486. */
  133487. motionBlurPostProcess: Nullable<PostProcess>;
  133488. /**
  133489. * Post-process used to create a depth of field effect
  133490. */
  133491. depthOfFieldPostProcess: Nullable<PostProcess>;
  133492. /**
  133493. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133494. */
  133495. fxaaPostProcess: Nullable<FxaaPostProcess>;
  133496. /**
  133497. * Represents the brightness threshold in order to configure the illuminated surfaces
  133498. */
  133499. brightThreshold: number;
  133500. /**
  133501. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  133502. */
  133503. blurWidth: number;
  133504. /**
  133505. * Sets if the blur for highlighted surfaces must be only horizontal
  133506. */
  133507. horizontalBlur: boolean;
  133508. /**
  133509. * Gets the overall exposure used by the pipeline
  133510. */
  133511. /**
  133512. * Sets the overall exposure used by the pipeline
  133513. */
  133514. exposure: number;
  133515. /**
  133516. * Texture used typically to simulate "dirty" on camera lens
  133517. */
  133518. lensTexture: Nullable<Texture>;
  133519. /**
  133520. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  133521. */
  133522. volumetricLightCoefficient: number;
  133523. /**
  133524. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  133525. */
  133526. volumetricLightPower: number;
  133527. /**
  133528. * Used the set the blur intensity to smooth the volumetric lights
  133529. */
  133530. volumetricLightBlurScale: number;
  133531. /**
  133532. * Light (spot or directional) used to generate the volumetric lights rays
  133533. * The source light must have a shadow generate so the pipeline can get its
  133534. * depth map
  133535. */
  133536. sourceLight: Nullable<SpotLight | DirectionalLight>;
  133537. /**
  133538. * For eye adaptation, represents the minimum luminance the eye can see
  133539. */
  133540. hdrMinimumLuminance: number;
  133541. /**
  133542. * For eye adaptation, represents the decrease luminance speed
  133543. */
  133544. hdrDecreaseRate: number;
  133545. /**
  133546. * For eye adaptation, represents the increase luminance speed
  133547. */
  133548. hdrIncreaseRate: number;
  133549. /**
  133550. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  133551. */
  133552. /**
  133553. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  133554. */
  133555. hdrAutoExposure: boolean;
  133556. /**
  133557. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  133558. */
  133559. lensColorTexture: Nullable<Texture>;
  133560. /**
  133561. * The overall strengh for the lens flare effect
  133562. */
  133563. lensFlareStrength: number;
  133564. /**
  133565. * Dispersion coefficient for lens flare ghosts
  133566. */
  133567. lensFlareGhostDispersal: number;
  133568. /**
  133569. * Main lens flare halo width
  133570. */
  133571. lensFlareHaloWidth: number;
  133572. /**
  133573. * Based on the lens distortion effect, defines how much the lens flare result
  133574. * is distorted
  133575. */
  133576. lensFlareDistortionStrength: number;
  133577. /**
  133578. * Configures the blur intensity used for for lens flare (halo)
  133579. */
  133580. lensFlareBlurWidth: number;
  133581. /**
  133582. * Lens star texture must be used to simulate rays on the flares and is available
  133583. * in the documentation
  133584. */
  133585. lensStarTexture: Nullable<Texture>;
  133586. /**
  133587. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  133588. * flare effect by taking account of the dirt texture
  133589. */
  133590. lensFlareDirtTexture: Nullable<Texture>;
  133591. /**
  133592. * Represents the focal length for the depth of field effect
  133593. */
  133594. depthOfFieldDistance: number;
  133595. /**
  133596. * Represents the blur intensity for the blurred part of the depth of field effect
  133597. */
  133598. depthOfFieldBlurWidth: number;
  133599. /**
  133600. * Gets how much the image is blurred by the movement while using the motion blur post-process
  133601. */
  133602. /**
  133603. * Sets how much the image is blurred by the movement while using the motion blur post-process
  133604. */
  133605. motionStrength: number;
  133606. /**
  133607. * Gets wether or not the motion blur post-process is object based or screen based.
  133608. */
  133609. /**
  133610. * Sets wether or not the motion blur post-process should be object based or screen based
  133611. */
  133612. objectBasedMotionBlur: boolean;
  133613. /**
  133614. * List of animations for the pipeline (IAnimatable implementation)
  133615. */
  133616. animations: Animation[];
  133617. /**
  133618. * Private members
  133619. */
  133620. private _scene;
  133621. private _currentDepthOfFieldSource;
  133622. private _basePostProcess;
  133623. private _fixedExposure;
  133624. private _currentExposure;
  133625. private _hdrAutoExposure;
  133626. private _hdrCurrentLuminance;
  133627. private _motionStrength;
  133628. private _isObjectBasedMotionBlur;
  133629. private _floatTextureType;
  133630. private _camerasToBeAttached;
  133631. private _ratio;
  133632. private _bloomEnabled;
  133633. private _depthOfFieldEnabled;
  133634. private _vlsEnabled;
  133635. private _lensFlareEnabled;
  133636. private _hdrEnabled;
  133637. private _motionBlurEnabled;
  133638. private _fxaaEnabled;
  133639. private _motionBlurSamples;
  133640. private _volumetricLightStepsCount;
  133641. private _samples;
  133642. /**
  133643. * @ignore
  133644. * Specifies if the bloom pipeline is enabled
  133645. */
  133646. BloomEnabled: boolean;
  133647. /**
  133648. * @ignore
  133649. * Specifies if the depth of field pipeline is enabed
  133650. */
  133651. DepthOfFieldEnabled: boolean;
  133652. /**
  133653. * @ignore
  133654. * Specifies if the lens flare pipeline is enabed
  133655. */
  133656. LensFlareEnabled: boolean;
  133657. /**
  133658. * @ignore
  133659. * Specifies if the HDR pipeline is enabled
  133660. */
  133661. HDREnabled: boolean;
  133662. /**
  133663. * @ignore
  133664. * Specifies if the volumetric lights scattering effect is enabled
  133665. */
  133666. VLSEnabled: boolean;
  133667. /**
  133668. * @ignore
  133669. * Specifies if the motion blur effect is enabled
  133670. */
  133671. MotionBlurEnabled: boolean;
  133672. /**
  133673. * Specifies if anti-aliasing is enabled
  133674. */
  133675. fxaaEnabled: boolean;
  133676. /**
  133677. * Specifies the number of steps used to calculate the volumetric lights
  133678. * Typically in interval [50, 200]
  133679. */
  133680. volumetricLightStepsCount: number;
  133681. /**
  133682. * Specifies the number of samples used for the motion blur effect
  133683. * Typically in interval [16, 64]
  133684. */
  133685. motionBlurSamples: number;
  133686. /**
  133687. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  133688. */
  133689. samples: number;
  133690. /**
  133691. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  133692. * @constructor
  133693. * @param name The rendering pipeline name
  133694. * @param scene The scene linked to this pipeline
  133695. * @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)
  133696. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  133697. * @param cameras The array of cameras that the rendering pipeline will be attached to
  133698. */
  133699. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  133700. private _buildPipeline;
  133701. private _createDownSampleX4PostProcess;
  133702. private _createBrightPassPostProcess;
  133703. private _createBlurPostProcesses;
  133704. private _createTextureAdderPostProcess;
  133705. private _createVolumetricLightPostProcess;
  133706. private _createLuminancePostProcesses;
  133707. private _createHdrPostProcess;
  133708. private _createLensFlarePostProcess;
  133709. private _createDepthOfFieldPostProcess;
  133710. private _createMotionBlurPostProcess;
  133711. private _getDepthTexture;
  133712. private _disposePostProcesses;
  133713. /**
  133714. * Dispose of the pipeline and stop all post processes
  133715. */
  133716. dispose(): void;
  133717. /**
  133718. * Serialize the rendering pipeline (Used when exporting)
  133719. * @returns the serialized object
  133720. */
  133721. serialize(): any;
  133722. /**
  133723. * Parse the serialized pipeline
  133724. * @param source Source pipeline.
  133725. * @param scene The scene to load the pipeline to.
  133726. * @param rootUrl The URL of the serialized pipeline.
  133727. * @returns An instantiated pipeline from the serialized object.
  133728. */
  133729. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  133730. /**
  133731. * Luminance steps
  133732. */
  133733. static LuminanceSteps: number;
  133734. }
  133735. }
  133736. declare module BABYLON {
  133737. /** @hidden */
  133738. export var tonemapPixelShader: {
  133739. name: string;
  133740. shader: string;
  133741. };
  133742. }
  133743. declare module BABYLON {
  133744. /** Defines operator used for tonemapping */
  133745. export enum TonemappingOperator {
  133746. /** Hable */
  133747. Hable = 0,
  133748. /** Reinhard */
  133749. Reinhard = 1,
  133750. /** HejiDawson */
  133751. HejiDawson = 2,
  133752. /** Photographic */
  133753. Photographic = 3
  133754. }
  133755. /**
  133756. * Defines a post process to apply tone mapping
  133757. */
  133758. export class TonemapPostProcess extends PostProcess {
  133759. private _operator;
  133760. /** Defines the required exposure adjustement */
  133761. exposureAdjustment: number;
  133762. /**
  133763. * Creates a new TonemapPostProcess
  133764. * @param name defines the name of the postprocess
  133765. * @param _operator defines the operator to use
  133766. * @param exposureAdjustment defines the required exposure adjustement
  133767. * @param camera defines the camera to use (can be null)
  133768. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  133769. * @param engine defines the hosting engine (can be ignore if camera is set)
  133770. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  133771. */
  133772. constructor(name: string, _operator: TonemappingOperator,
  133773. /** Defines the required exposure adjustement */
  133774. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  133775. }
  133776. }
  133777. declare module BABYLON {
  133778. /** @hidden */
  133779. export var depthVertexShader: {
  133780. name: string;
  133781. shader: string;
  133782. };
  133783. }
  133784. declare module BABYLON {
  133785. /** @hidden */
  133786. export var volumetricLightScatteringPixelShader: {
  133787. name: string;
  133788. shader: string;
  133789. };
  133790. }
  133791. declare module BABYLON {
  133792. /** @hidden */
  133793. export var volumetricLightScatteringPassVertexShader: {
  133794. name: string;
  133795. shader: string;
  133796. };
  133797. }
  133798. declare module BABYLON {
  133799. /** @hidden */
  133800. export var volumetricLightScatteringPassPixelShader: {
  133801. name: string;
  133802. shader: string;
  133803. };
  133804. }
  133805. declare module BABYLON {
  133806. /**
  133807. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  133808. */
  133809. export class VolumetricLightScatteringPostProcess extends PostProcess {
  133810. private _volumetricLightScatteringPass;
  133811. private _volumetricLightScatteringRTT;
  133812. private _viewPort;
  133813. private _screenCoordinates;
  133814. private _cachedDefines;
  133815. /**
  133816. * If not undefined, the mesh position is computed from the attached node position
  133817. */
  133818. attachedNode: {
  133819. position: Vector3;
  133820. };
  133821. /**
  133822. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  133823. */
  133824. customMeshPosition: Vector3;
  133825. /**
  133826. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  133827. */
  133828. useCustomMeshPosition: boolean;
  133829. /**
  133830. * If the post-process should inverse the light scattering direction
  133831. */
  133832. invert: boolean;
  133833. /**
  133834. * The internal mesh used by the post-process
  133835. */
  133836. mesh: Mesh;
  133837. /**
  133838. * @hidden
  133839. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  133840. */
  133841. useDiffuseColor: boolean;
  133842. /**
  133843. * Array containing the excluded meshes not rendered in the internal pass
  133844. */
  133845. excludedMeshes: AbstractMesh[];
  133846. /**
  133847. * Controls the overall intensity of the post-process
  133848. */
  133849. exposure: number;
  133850. /**
  133851. * Dissipates each sample's contribution in range [0, 1]
  133852. */
  133853. decay: number;
  133854. /**
  133855. * Controls the overall intensity of each sample
  133856. */
  133857. weight: number;
  133858. /**
  133859. * Controls the density of each sample
  133860. */
  133861. density: number;
  133862. /**
  133863. * @constructor
  133864. * @param name The post-process name
  133865. * @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)
  133866. * @param camera The camera that the post-process will be attached to
  133867. * @param mesh The mesh used to create the light scattering
  133868. * @param samples The post-process quality, default 100
  133869. * @param samplingModeThe post-process filtering mode
  133870. * @param engine The babylon engine
  133871. * @param reusable If the post-process is reusable
  133872. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  133873. */
  133874. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  133875. /**
  133876. * Returns the string "VolumetricLightScatteringPostProcess"
  133877. * @returns "VolumetricLightScatteringPostProcess"
  133878. */
  133879. getClassName(): string;
  133880. private _isReady;
  133881. /**
  133882. * Sets the new light position for light scattering effect
  133883. * @param position The new custom light position
  133884. */
  133885. setCustomMeshPosition(position: Vector3): void;
  133886. /**
  133887. * Returns the light position for light scattering effect
  133888. * @return Vector3 The custom light position
  133889. */
  133890. getCustomMeshPosition(): Vector3;
  133891. /**
  133892. * Disposes the internal assets and detaches the post-process from the camera
  133893. */
  133894. dispose(camera: Camera): void;
  133895. /**
  133896. * Returns the render target texture used by the post-process
  133897. * @return the render target texture used by the post-process
  133898. */
  133899. getPass(): RenderTargetTexture;
  133900. private _meshExcluded;
  133901. private _createPass;
  133902. private _updateMeshScreenCoordinates;
  133903. /**
  133904. * Creates a default mesh for the Volumeric Light Scattering post-process
  133905. * @param name The mesh name
  133906. * @param scene The scene where to create the mesh
  133907. * @return the default mesh
  133908. */
  133909. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  133910. }
  133911. }
  133912. declare module BABYLON {
  133913. interface Scene {
  133914. /** @hidden (Backing field) */
  133915. _boundingBoxRenderer: BoundingBoxRenderer;
  133916. /** @hidden (Backing field) */
  133917. _forceShowBoundingBoxes: boolean;
  133918. /**
  133919. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  133920. */
  133921. forceShowBoundingBoxes: boolean;
  133922. /**
  133923. * Gets the bounding box renderer associated with the scene
  133924. * @returns a BoundingBoxRenderer
  133925. */
  133926. getBoundingBoxRenderer(): BoundingBoxRenderer;
  133927. }
  133928. interface AbstractMesh {
  133929. /** @hidden (Backing field) */
  133930. _showBoundingBox: boolean;
  133931. /**
  133932. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  133933. */
  133934. showBoundingBox: boolean;
  133935. }
  133936. /**
  133937. * Component responsible of rendering the bounding box of the meshes in a scene.
  133938. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  133939. */
  133940. export class BoundingBoxRenderer implements ISceneComponent {
  133941. /**
  133942. * The component name helpfull to identify the component in the list of scene components.
  133943. */
  133944. readonly name: string;
  133945. /**
  133946. * The scene the component belongs to.
  133947. */
  133948. scene: Scene;
  133949. /**
  133950. * Color of the bounding box lines placed in front of an object
  133951. */
  133952. frontColor: Color3;
  133953. /**
  133954. * Color of the bounding box lines placed behind an object
  133955. */
  133956. backColor: Color3;
  133957. /**
  133958. * Defines if the renderer should show the back lines or not
  133959. */
  133960. showBackLines: boolean;
  133961. /**
  133962. * @hidden
  133963. */
  133964. renderList: SmartArray<BoundingBox>;
  133965. private _colorShader;
  133966. private _vertexBuffers;
  133967. private _indexBuffer;
  133968. private _fillIndexBuffer;
  133969. private _fillIndexData;
  133970. /**
  133971. * Instantiates a new bounding box renderer in a scene.
  133972. * @param scene the scene the renderer renders in
  133973. */
  133974. constructor(scene: Scene);
  133975. /**
  133976. * Registers the component in a given scene
  133977. */
  133978. register(): void;
  133979. private _evaluateSubMesh;
  133980. private _activeMesh;
  133981. private _prepareRessources;
  133982. private _createIndexBuffer;
  133983. /**
  133984. * Rebuilds the elements related to this component in case of
  133985. * context lost for instance.
  133986. */
  133987. rebuild(): void;
  133988. /**
  133989. * @hidden
  133990. */
  133991. reset(): void;
  133992. /**
  133993. * Render the bounding boxes of a specific rendering group
  133994. * @param renderingGroupId defines the rendering group to render
  133995. */
  133996. render(renderingGroupId: number): void;
  133997. /**
  133998. * In case of occlusion queries, we can render the occlusion bounding box through this method
  133999. * @param mesh Define the mesh to render the occlusion bounding box for
  134000. */
  134001. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  134002. /**
  134003. * Dispose and release the resources attached to this renderer.
  134004. */
  134005. dispose(): void;
  134006. }
  134007. }
  134008. declare module BABYLON {
  134009. /** @hidden */
  134010. export var depthPixelShader: {
  134011. name: string;
  134012. shader: string;
  134013. };
  134014. }
  134015. declare module BABYLON {
  134016. /**
  134017. * This represents a depth renderer in Babylon.
  134018. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134019. */
  134020. export class DepthRenderer {
  134021. private _scene;
  134022. private _depthMap;
  134023. private _effect;
  134024. private readonly _storeNonLinearDepth;
  134025. private readonly _clearColor;
  134026. /** Get if the depth renderer is using packed depth or not */
  134027. readonly isPacked: boolean;
  134028. private _cachedDefines;
  134029. private _camera;
  134030. /**
  134031. * Specifiess that the depth renderer will only be used within
  134032. * the camera it is created for.
  134033. * This can help forcing its rendering during the camera processing.
  134034. */
  134035. useOnlyInActiveCamera: boolean;
  134036. /** @hidden */
  134037. static _SceneComponentInitialization: (scene: Scene) => void;
  134038. /**
  134039. * Instantiates a depth renderer
  134040. * @param scene The scene the renderer belongs to
  134041. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134042. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134043. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134044. */
  134045. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134046. /**
  134047. * Creates the depth rendering effect and checks if the effect is ready.
  134048. * @param subMesh The submesh to be used to render the depth map of
  134049. * @param useInstances If multiple world instances should be used
  134050. * @returns if the depth renderer is ready to render the depth map
  134051. */
  134052. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134053. /**
  134054. * Gets the texture which the depth map will be written to.
  134055. * @returns The depth map texture
  134056. */
  134057. getDepthMap(): RenderTargetTexture;
  134058. /**
  134059. * Disposes of the depth renderer.
  134060. */
  134061. dispose(): void;
  134062. }
  134063. }
  134064. declare module BABYLON {
  134065. interface Scene {
  134066. /** @hidden (Backing field) */
  134067. _depthRenderer: {
  134068. [id: string]: DepthRenderer;
  134069. };
  134070. /**
  134071. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  134072. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  134073. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134074. * @returns the created depth renderer
  134075. */
  134076. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  134077. /**
  134078. * Disables a depth renderer for a given camera
  134079. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  134080. */
  134081. disableDepthRenderer(camera?: Nullable<Camera>): void;
  134082. }
  134083. /**
  134084. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  134085. * in several rendering techniques.
  134086. */
  134087. export class DepthRendererSceneComponent implements ISceneComponent {
  134088. /**
  134089. * The component name helpfull to identify the component in the list of scene components.
  134090. */
  134091. readonly name: string;
  134092. /**
  134093. * The scene the component belongs to.
  134094. */
  134095. scene: Scene;
  134096. /**
  134097. * Creates a new instance of the component for the given scene
  134098. * @param scene Defines the scene to register the component in
  134099. */
  134100. constructor(scene: Scene);
  134101. /**
  134102. * Registers the component in a given scene
  134103. */
  134104. register(): void;
  134105. /**
  134106. * Rebuilds the elements related to this component in case of
  134107. * context lost for instance.
  134108. */
  134109. rebuild(): void;
  134110. /**
  134111. * Disposes the component and the associated ressources
  134112. */
  134113. dispose(): void;
  134114. private _gatherRenderTargets;
  134115. private _gatherActiveCameraRenderTargets;
  134116. }
  134117. }
  134118. declare module BABYLON {
  134119. /** @hidden */
  134120. export var outlinePixelShader: {
  134121. name: string;
  134122. shader: string;
  134123. };
  134124. }
  134125. declare module BABYLON {
  134126. /** @hidden */
  134127. export var outlineVertexShader: {
  134128. name: string;
  134129. shader: string;
  134130. };
  134131. }
  134132. declare module BABYLON {
  134133. interface Scene {
  134134. /** @hidden */
  134135. _outlineRenderer: OutlineRenderer;
  134136. /**
  134137. * Gets the outline renderer associated with the scene
  134138. * @returns a OutlineRenderer
  134139. */
  134140. getOutlineRenderer(): OutlineRenderer;
  134141. }
  134142. interface AbstractMesh {
  134143. /** @hidden (Backing field) */
  134144. _renderOutline: boolean;
  134145. /**
  134146. * Gets or sets a boolean indicating if the outline must be rendered as well
  134147. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  134148. */
  134149. renderOutline: boolean;
  134150. /** @hidden (Backing field) */
  134151. _renderOverlay: boolean;
  134152. /**
  134153. * Gets or sets a boolean indicating if the overlay must be rendered as well
  134154. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  134155. */
  134156. renderOverlay: boolean;
  134157. }
  134158. /**
  134159. * This class is responsible to draw bothe outline/overlay of meshes.
  134160. * It should not be used directly but through the available method on mesh.
  134161. */
  134162. export class OutlineRenderer implements ISceneComponent {
  134163. /**
  134164. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  134165. */
  134166. private static _StencilReference;
  134167. /**
  134168. * The name of the component. Each component must have a unique name.
  134169. */
  134170. name: string;
  134171. /**
  134172. * The scene the component belongs to.
  134173. */
  134174. scene: Scene;
  134175. /**
  134176. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  134177. */
  134178. zOffset: number;
  134179. private _engine;
  134180. private _effect;
  134181. private _cachedDefines;
  134182. private _savedDepthWrite;
  134183. /**
  134184. * Instantiates a new outline renderer. (There could be only one per scene).
  134185. * @param scene Defines the scene it belongs to
  134186. */
  134187. constructor(scene: Scene);
  134188. /**
  134189. * Register the component to one instance of a scene.
  134190. */
  134191. register(): void;
  134192. /**
  134193. * Rebuilds the elements related to this component in case of
  134194. * context lost for instance.
  134195. */
  134196. rebuild(): void;
  134197. /**
  134198. * Disposes the component and the associated ressources.
  134199. */
  134200. dispose(): void;
  134201. /**
  134202. * Renders the outline in the canvas.
  134203. * @param subMesh Defines the sumesh to render
  134204. * @param batch Defines the batch of meshes in case of instances
  134205. * @param useOverlay Defines if the rendering is for the overlay or the outline
  134206. */
  134207. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  134208. /**
  134209. * Returns whether or not the outline renderer is ready for a given submesh.
  134210. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  134211. * @param subMesh Defines the submesh to check readyness for
  134212. * @param useInstances Defines wheter wee are trying to render instances or not
  134213. * @returns true if ready otherwise false
  134214. */
  134215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134216. private _beforeRenderingMesh;
  134217. private _afterRenderingMesh;
  134218. }
  134219. }
  134220. declare module BABYLON {
  134221. /**
  134222. * Defines the basic options interface of a Sprite Frame Source Size.
  134223. */
  134224. export interface ISpriteJSONSpriteSourceSize {
  134225. /**
  134226. * number of the original width of the Frame
  134227. */
  134228. w: number;
  134229. /**
  134230. * number of the original height of the Frame
  134231. */
  134232. h: number;
  134233. }
  134234. /**
  134235. * Defines the basic options interface of a Sprite Frame Data.
  134236. */
  134237. export interface ISpriteJSONSpriteFrameData {
  134238. /**
  134239. * number of the x offset of the Frame
  134240. */
  134241. x: number;
  134242. /**
  134243. * number of the y offset of the Frame
  134244. */
  134245. y: number;
  134246. /**
  134247. * number of the width of the Frame
  134248. */
  134249. w: number;
  134250. /**
  134251. * number of the height of the Frame
  134252. */
  134253. h: number;
  134254. }
  134255. /**
  134256. * Defines the basic options interface of a JSON Sprite.
  134257. */
  134258. export interface ISpriteJSONSprite {
  134259. /**
  134260. * string name of the Frame
  134261. */
  134262. filename: string;
  134263. /**
  134264. * ISpriteJSONSpriteFrame basic object of the frame data
  134265. */
  134266. frame: ISpriteJSONSpriteFrameData;
  134267. /**
  134268. * boolean to flag is the frame was rotated.
  134269. */
  134270. rotated: boolean;
  134271. /**
  134272. * boolean to flag is the frame was trimmed.
  134273. */
  134274. trimmed: boolean;
  134275. /**
  134276. * ISpriteJSONSpriteFrame basic object of the source data
  134277. */
  134278. spriteSourceSize: ISpriteJSONSpriteFrameData;
  134279. /**
  134280. * ISpriteJSONSpriteFrame basic object of the source data
  134281. */
  134282. sourceSize: ISpriteJSONSpriteSourceSize;
  134283. }
  134284. /**
  134285. * Defines the basic options interface of a JSON atlas.
  134286. */
  134287. export interface ISpriteJSONAtlas {
  134288. /**
  134289. * Array of objects that contain the frame data.
  134290. */
  134291. frames: Array<ISpriteJSONSprite>;
  134292. /**
  134293. * object basic object containing the sprite meta data.
  134294. */
  134295. meta?: object;
  134296. }
  134297. }
  134298. declare module BABYLON {
  134299. /** @hidden */
  134300. export var spriteMapPixelShader: {
  134301. name: string;
  134302. shader: string;
  134303. };
  134304. }
  134305. declare module BABYLON {
  134306. /** @hidden */
  134307. export var spriteMapVertexShader: {
  134308. name: string;
  134309. shader: string;
  134310. };
  134311. }
  134312. declare module BABYLON {
  134313. /**
  134314. * Defines the basic options interface of a SpriteMap
  134315. */
  134316. export interface ISpriteMapOptions {
  134317. /**
  134318. * Vector2 of the number of cells in the grid.
  134319. */
  134320. stageSize?: Vector2;
  134321. /**
  134322. * Vector2 of the size of the output plane in World Units.
  134323. */
  134324. outputSize?: Vector2;
  134325. /**
  134326. * Vector3 of the position of the output plane in World Units.
  134327. */
  134328. outputPosition?: Vector3;
  134329. /**
  134330. * Vector3 of the rotation of the output plane.
  134331. */
  134332. outputRotation?: Vector3;
  134333. /**
  134334. * number of layers that the system will reserve in resources.
  134335. */
  134336. layerCount?: number;
  134337. /**
  134338. * number of max animation frames a single cell will reserve in resources.
  134339. */
  134340. maxAnimationFrames?: number;
  134341. /**
  134342. * number cell index of the base tile when the system compiles.
  134343. */
  134344. baseTile?: number;
  134345. /**
  134346. * boolean flip the sprite after its been repositioned by the framing data.
  134347. */
  134348. flipU?: boolean;
  134349. /**
  134350. * Vector3 scalar of the global RGB values of the SpriteMap.
  134351. */
  134352. colorMultiply?: Vector3;
  134353. }
  134354. /**
  134355. * Defines the IDisposable interface in order to be cleanable from resources.
  134356. */
  134357. export interface ISpriteMap extends IDisposable {
  134358. /**
  134359. * String name of the SpriteMap.
  134360. */
  134361. name: string;
  134362. /**
  134363. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  134364. */
  134365. atlasJSON: ISpriteJSONAtlas;
  134366. /**
  134367. * Texture of the SpriteMap.
  134368. */
  134369. spriteSheet: Texture;
  134370. /**
  134371. * The parameters to initialize the SpriteMap with.
  134372. */
  134373. options: ISpriteMapOptions;
  134374. }
  134375. /**
  134376. * Class used to manage a grid restricted sprite deployment on an Output plane.
  134377. */
  134378. export class SpriteMap implements ISpriteMap {
  134379. /** The Name of the spriteMap */
  134380. name: string;
  134381. /** The JSON file with the frame and meta data */
  134382. atlasJSON: ISpriteJSONAtlas;
  134383. /** The systems Sprite Sheet Texture */
  134384. spriteSheet: Texture;
  134385. /** Arguments passed with the Constructor */
  134386. options: ISpriteMapOptions;
  134387. /** Public Sprite Storage array, parsed from atlasJSON */
  134388. sprites: Array<ISpriteJSONSprite>;
  134389. /** Returns the Number of Sprites in the System */
  134390. readonly spriteCount: number;
  134391. /** Returns the Position of Output Plane*/
  134392. /** Returns the Position of Output Plane*/
  134393. position: Vector3;
  134394. /** Returns the Rotation of Output Plane*/
  134395. /** Returns the Rotation of Output Plane*/
  134396. rotation: Vector3;
  134397. /** Sets the AnimationMap*/
  134398. /** Sets the AnimationMap*/
  134399. animationMap: RawTexture;
  134400. /** Scene that the SpriteMap was created in */
  134401. private _scene;
  134402. /** Texture Buffer of Float32 that holds tile frame data*/
  134403. private _frameMap;
  134404. /** Texture Buffers of Float32 that holds tileMap data*/
  134405. private _tileMaps;
  134406. /** Texture Buffer of Float32 that holds Animation Data*/
  134407. private _animationMap;
  134408. /** Custom ShaderMaterial Central to the System*/
  134409. private _material;
  134410. /** Custom ShaderMaterial Central to the System*/
  134411. private _output;
  134412. /** Systems Time Ticker*/
  134413. private _time;
  134414. /**
  134415. * Creates a new SpriteMap
  134416. * @param name defines the SpriteMaps Name
  134417. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  134418. * @param spriteSheet is the Texture that the Sprites are on.
  134419. * @param options a basic deployment configuration
  134420. * @param scene The Scene that the map is deployed on
  134421. */
  134422. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  134423. /**
  134424. * Returns tileID location
  134425. * @returns Vector2 the cell position ID
  134426. */
  134427. getTileID(): Vector2;
  134428. /**
  134429. * Gets the UV location of the mouse over the SpriteMap.
  134430. * @returns Vector2 the UV position of the mouse interaction
  134431. */
  134432. getMousePosition(): Vector2;
  134433. /**
  134434. * Creates the "frame" texture Buffer
  134435. * -------------------------------------
  134436. * Structure of frames
  134437. * "filename": "Falling-Water-2.png",
  134438. * "frame": {"x":69,"y":103,"w":24,"h":32},
  134439. * "rotated": true,
  134440. * "trimmed": true,
  134441. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  134442. * "sourceSize": {"w":32,"h":32}
  134443. * @returns RawTexture of the frameMap
  134444. */
  134445. private _createFrameBuffer;
  134446. /**
  134447. * Creates the tileMap texture Buffer
  134448. * @param buffer normally and array of numbers, or a false to generate from scratch
  134449. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  134450. * @returns RawTexture of the tileMap
  134451. */
  134452. private _createTileBuffer;
  134453. /**
  134454. * Modifies the data of the tileMaps
  134455. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  134456. * @param pos is the iVector2 Coordinates of the Tile
  134457. * @param tile The SpriteIndex of the new Tile
  134458. */
  134459. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  134460. /**
  134461. * Creates the animationMap texture Buffer
  134462. * @param buffer normally and array of numbers, or a false to generate from scratch
  134463. * @returns RawTexture of the animationMap
  134464. */
  134465. private _createTileAnimationBuffer;
  134466. /**
  134467. * Modifies the data of the animationMap
  134468. * @param cellID is the Index of the Sprite
  134469. * @param _frame is the target Animation frame
  134470. * @param toCell is the Target Index of the next frame of the animation
  134471. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  134472. * @param speed is a global scalar of the time variable on the map.
  134473. */
  134474. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  134475. /**
  134476. * Exports the .tilemaps file
  134477. */
  134478. saveTileMaps(): void;
  134479. /**
  134480. * Imports the .tilemaps file
  134481. * @param url of the .tilemaps file
  134482. */
  134483. loadTileMaps(url: string): void;
  134484. /**
  134485. * Release associated resources
  134486. */
  134487. dispose(): void;
  134488. }
  134489. }
  134490. declare module BABYLON {
  134491. /**
  134492. * Class used to manage multiple sprites of different sizes on the same spritesheet
  134493. * @see http://doc.babylonjs.com/babylon101/sprites
  134494. */
  134495. export class SpritePackedManager extends SpriteManager {
  134496. /** defines the packed manager's name */
  134497. name: string;
  134498. /**
  134499. * Creates a new sprite manager from a packed sprite sheet
  134500. * @param name defines the manager's name
  134501. * @param imgUrl defines the sprite sheet url
  134502. * @param capacity defines the maximum allowed number of sprites
  134503. * @param scene defines the hosting scene
  134504. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  134505. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  134506. * @param samplingMode defines the smapling mode to use with spritesheet
  134507. * @param fromPacked set to true; do not alter
  134508. */
  134509. constructor(
  134510. /** defines the packed manager's name */
  134511. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  134512. }
  134513. }
  134514. declare module BABYLON {
  134515. /**
  134516. * Defines the list of states available for a task inside a AssetsManager
  134517. */
  134518. export enum AssetTaskState {
  134519. /**
  134520. * Initialization
  134521. */
  134522. INIT = 0,
  134523. /**
  134524. * Running
  134525. */
  134526. RUNNING = 1,
  134527. /**
  134528. * Done
  134529. */
  134530. DONE = 2,
  134531. /**
  134532. * Error
  134533. */
  134534. ERROR = 3
  134535. }
  134536. /**
  134537. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  134538. */
  134539. export abstract class AbstractAssetTask {
  134540. /**
  134541. * Task name
  134542. */ name: string;
  134543. /**
  134544. * Callback called when the task is successful
  134545. */
  134546. onSuccess: (task: any) => void;
  134547. /**
  134548. * Callback called when the task is not successful
  134549. */
  134550. onError: (task: any, message?: string, exception?: any) => void;
  134551. /**
  134552. * Creates a new AssetsManager
  134553. * @param name defines the name of the task
  134554. */
  134555. constructor(
  134556. /**
  134557. * Task name
  134558. */ name: string);
  134559. private _isCompleted;
  134560. private _taskState;
  134561. private _errorObject;
  134562. /**
  134563. * Get if the task is completed
  134564. */
  134565. readonly isCompleted: boolean;
  134566. /**
  134567. * Gets the current state of the task
  134568. */
  134569. readonly taskState: AssetTaskState;
  134570. /**
  134571. * Gets the current error object (if task is in error)
  134572. */
  134573. readonly errorObject: {
  134574. message?: string;
  134575. exception?: any;
  134576. };
  134577. /**
  134578. * Internal only
  134579. * @hidden
  134580. */
  134581. _setErrorObject(message?: string, exception?: any): void;
  134582. /**
  134583. * Execute the current task
  134584. * @param scene defines the scene where you want your assets to be loaded
  134585. * @param onSuccess is a callback called when the task is successfully executed
  134586. * @param onError is a callback called if an error occurs
  134587. */
  134588. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134589. /**
  134590. * Execute the current task
  134591. * @param scene defines the scene where you want your assets to be loaded
  134592. * @param onSuccess is a callback called when the task is successfully executed
  134593. * @param onError is a callback called if an error occurs
  134594. */
  134595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134596. /**
  134597. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  134598. * This can be used with failed tasks that have the reason for failure fixed.
  134599. */
  134600. reset(): void;
  134601. private onErrorCallback;
  134602. private onDoneCallback;
  134603. }
  134604. /**
  134605. * Define the interface used by progress events raised during assets loading
  134606. */
  134607. export interface IAssetsProgressEvent {
  134608. /**
  134609. * Defines the number of remaining tasks to process
  134610. */
  134611. remainingCount: number;
  134612. /**
  134613. * Defines the total number of tasks
  134614. */
  134615. totalCount: number;
  134616. /**
  134617. * Defines the task that was just processed
  134618. */
  134619. task: AbstractAssetTask;
  134620. }
  134621. /**
  134622. * Class used to share progress information about assets loading
  134623. */
  134624. export class AssetsProgressEvent implements IAssetsProgressEvent {
  134625. /**
  134626. * Defines the number of remaining tasks to process
  134627. */
  134628. remainingCount: number;
  134629. /**
  134630. * Defines the total number of tasks
  134631. */
  134632. totalCount: number;
  134633. /**
  134634. * Defines the task that was just processed
  134635. */
  134636. task: AbstractAssetTask;
  134637. /**
  134638. * Creates a AssetsProgressEvent
  134639. * @param remainingCount defines the number of remaining tasks to process
  134640. * @param totalCount defines the total number of tasks
  134641. * @param task defines the task that was just processed
  134642. */
  134643. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  134644. }
  134645. /**
  134646. * Define a task used by AssetsManager to load meshes
  134647. */
  134648. export class MeshAssetTask extends AbstractAssetTask {
  134649. /**
  134650. * Defines the name of the task
  134651. */
  134652. name: string;
  134653. /**
  134654. * Defines the list of mesh's names you want to load
  134655. */
  134656. meshesNames: any;
  134657. /**
  134658. * Defines the root url to use as a base to load your meshes and associated resources
  134659. */
  134660. rootUrl: string;
  134661. /**
  134662. * Defines the filename of the scene to load from
  134663. */
  134664. sceneFilename: string;
  134665. /**
  134666. * Gets the list of loaded meshes
  134667. */
  134668. loadedMeshes: Array<AbstractMesh>;
  134669. /**
  134670. * Gets the list of loaded particle systems
  134671. */
  134672. loadedParticleSystems: Array<IParticleSystem>;
  134673. /**
  134674. * Gets the list of loaded skeletons
  134675. */
  134676. loadedSkeletons: Array<Skeleton>;
  134677. /**
  134678. * Gets the list of loaded animation groups
  134679. */
  134680. loadedAnimationGroups: Array<AnimationGroup>;
  134681. /**
  134682. * Callback called when the task is successful
  134683. */
  134684. onSuccess: (task: MeshAssetTask) => void;
  134685. /**
  134686. * Callback called when the task is successful
  134687. */
  134688. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  134689. /**
  134690. * Creates a new MeshAssetTask
  134691. * @param name defines the name of the task
  134692. * @param meshesNames defines the list of mesh's names you want to load
  134693. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  134694. * @param sceneFilename defines the filename of the scene to load from
  134695. */
  134696. constructor(
  134697. /**
  134698. * Defines the name of the task
  134699. */
  134700. name: string,
  134701. /**
  134702. * Defines the list of mesh's names you want to load
  134703. */
  134704. meshesNames: any,
  134705. /**
  134706. * Defines the root url to use as a base to load your meshes and associated resources
  134707. */
  134708. rootUrl: string,
  134709. /**
  134710. * Defines the filename of the scene to load from
  134711. */
  134712. sceneFilename: string);
  134713. /**
  134714. * Execute the current task
  134715. * @param scene defines the scene where you want your assets to be loaded
  134716. * @param onSuccess is a callback called when the task is successfully executed
  134717. * @param onError is a callback called if an error occurs
  134718. */
  134719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134720. }
  134721. /**
  134722. * Define a task used by AssetsManager to load text content
  134723. */
  134724. export class TextFileAssetTask extends AbstractAssetTask {
  134725. /**
  134726. * Defines the name of the task
  134727. */
  134728. name: string;
  134729. /**
  134730. * Defines the location of the file to load
  134731. */
  134732. url: string;
  134733. /**
  134734. * Gets the loaded text string
  134735. */
  134736. text: string;
  134737. /**
  134738. * Callback called when the task is successful
  134739. */
  134740. onSuccess: (task: TextFileAssetTask) => void;
  134741. /**
  134742. * Callback called when the task is successful
  134743. */
  134744. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  134745. /**
  134746. * Creates a new TextFileAssetTask object
  134747. * @param name defines the name of the task
  134748. * @param url defines the location of the file to load
  134749. */
  134750. constructor(
  134751. /**
  134752. * Defines the name of the task
  134753. */
  134754. name: string,
  134755. /**
  134756. * Defines the location of the file to load
  134757. */
  134758. url: string);
  134759. /**
  134760. * Execute the current task
  134761. * @param scene defines the scene where you want your assets to be loaded
  134762. * @param onSuccess is a callback called when the task is successfully executed
  134763. * @param onError is a callback called if an error occurs
  134764. */
  134765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134766. }
  134767. /**
  134768. * Define a task used by AssetsManager to load binary data
  134769. */
  134770. export class BinaryFileAssetTask extends AbstractAssetTask {
  134771. /**
  134772. * Defines the name of the task
  134773. */
  134774. name: string;
  134775. /**
  134776. * Defines the location of the file to load
  134777. */
  134778. url: string;
  134779. /**
  134780. * Gets the lodaded data (as an array buffer)
  134781. */
  134782. data: ArrayBuffer;
  134783. /**
  134784. * Callback called when the task is successful
  134785. */
  134786. onSuccess: (task: BinaryFileAssetTask) => void;
  134787. /**
  134788. * Callback called when the task is successful
  134789. */
  134790. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  134791. /**
  134792. * Creates a new BinaryFileAssetTask object
  134793. * @param name defines the name of the new task
  134794. * @param url defines the location of the file to load
  134795. */
  134796. constructor(
  134797. /**
  134798. * Defines the name of the task
  134799. */
  134800. name: string,
  134801. /**
  134802. * Defines the location of the file to load
  134803. */
  134804. url: string);
  134805. /**
  134806. * Execute the current task
  134807. * @param scene defines the scene where you want your assets to be loaded
  134808. * @param onSuccess is a callback called when the task is successfully executed
  134809. * @param onError is a callback called if an error occurs
  134810. */
  134811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134812. }
  134813. /**
  134814. * Define a task used by AssetsManager to load images
  134815. */
  134816. export class ImageAssetTask extends AbstractAssetTask {
  134817. /**
  134818. * Defines the name of the task
  134819. */
  134820. name: string;
  134821. /**
  134822. * Defines the location of the image to load
  134823. */
  134824. url: string;
  134825. /**
  134826. * Gets the loaded images
  134827. */
  134828. image: HTMLImageElement;
  134829. /**
  134830. * Callback called when the task is successful
  134831. */
  134832. onSuccess: (task: ImageAssetTask) => void;
  134833. /**
  134834. * Callback called when the task is successful
  134835. */
  134836. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  134837. /**
  134838. * Creates a new ImageAssetTask
  134839. * @param name defines the name of the task
  134840. * @param url defines the location of the image to load
  134841. */
  134842. constructor(
  134843. /**
  134844. * Defines the name of the task
  134845. */
  134846. name: string,
  134847. /**
  134848. * Defines the location of the image to load
  134849. */
  134850. url: string);
  134851. /**
  134852. * Execute the current task
  134853. * @param scene defines the scene where you want your assets to be loaded
  134854. * @param onSuccess is a callback called when the task is successfully executed
  134855. * @param onError is a callback called if an error occurs
  134856. */
  134857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134858. }
  134859. /**
  134860. * Defines the interface used by texture loading tasks
  134861. */
  134862. export interface ITextureAssetTask<TEX extends BaseTexture> {
  134863. /**
  134864. * Gets the loaded texture
  134865. */
  134866. texture: TEX;
  134867. }
  134868. /**
  134869. * Define a task used by AssetsManager to load 2D textures
  134870. */
  134871. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  134872. /**
  134873. * Defines the name of the task
  134874. */
  134875. name: string;
  134876. /**
  134877. * Defines the location of the file to load
  134878. */
  134879. url: string;
  134880. /**
  134881. * Defines if mipmap should not be generated (default is false)
  134882. */
  134883. noMipmap?: boolean | undefined;
  134884. /**
  134885. * Defines if texture must be inverted on Y axis (default is false)
  134886. */
  134887. invertY?: boolean | undefined;
  134888. /**
  134889. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  134890. */
  134891. samplingMode: number;
  134892. /**
  134893. * Gets the loaded texture
  134894. */
  134895. texture: Texture;
  134896. /**
  134897. * Callback called when the task is successful
  134898. */
  134899. onSuccess: (task: TextureAssetTask) => void;
  134900. /**
  134901. * Callback called when the task is successful
  134902. */
  134903. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  134904. /**
  134905. * Creates a new TextureAssetTask object
  134906. * @param name defines the name of the task
  134907. * @param url defines the location of the file to load
  134908. * @param noMipmap defines if mipmap should not be generated (default is false)
  134909. * @param invertY defines if texture must be inverted on Y axis (default is false)
  134910. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  134911. */
  134912. constructor(
  134913. /**
  134914. * Defines the name of the task
  134915. */
  134916. name: string,
  134917. /**
  134918. * Defines the location of the file to load
  134919. */
  134920. url: string,
  134921. /**
  134922. * Defines if mipmap should not be generated (default is false)
  134923. */
  134924. noMipmap?: boolean | undefined,
  134925. /**
  134926. * Defines if texture must be inverted on Y axis (default is false)
  134927. */
  134928. invertY?: boolean | undefined,
  134929. /**
  134930. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  134931. */
  134932. samplingMode?: number);
  134933. /**
  134934. * Execute the current task
  134935. * @param scene defines the scene where you want your assets to be loaded
  134936. * @param onSuccess is a callback called when the task is successfully executed
  134937. * @param onError is a callback called if an error occurs
  134938. */
  134939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134940. }
  134941. /**
  134942. * Define a task used by AssetsManager to load cube textures
  134943. */
  134944. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  134945. /**
  134946. * Defines the name of the task
  134947. */
  134948. name: string;
  134949. /**
  134950. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  134951. */
  134952. url: string;
  134953. /**
  134954. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  134955. */
  134956. extensions?: string[] | undefined;
  134957. /**
  134958. * Defines if mipmaps should not be generated (default is false)
  134959. */
  134960. noMipmap?: boolean | undefined;
  134961. /**
  134962. * Defines the explicit list of files (undefined by default)
  134963. */
  134964. files?: string[] | undefined;
  134965. /**
  134966. * Gets the loaded texture
  134967. */
  134968. texture: CubeTexture;
  134969. /**
  134970. * Callback called when the task is successful
  134971. */
  134972. onSuccess: (task: CubeTextureAssetTask) => void;
  134973. /**
  134974. * Callback called when the task is successful
  134975. */
  134976. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  134977. /**
  134978. * Creates a new CubeTextureAssetTask
  134979. * @param name defines the name of the task
  134980. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  134981. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  134982. * @param noMipmap defines if mipmaps should not be generated (default is false)
  134983. * @param files defines the explicit list of files (undefined by default)
  134984. */
  134985. constructor(
  134986. /**
  134987. * Defines the name of the task
  134988. */
  134989. name: string,
  134990. /**
  134991. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  134992. */
  134993. url: string,
  134994. /**
  134995. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  134996. */
  134997. extensions?: string[] | undefined,
  134998. /**
  134999. * Defines if mipmaps should not be generated (default is false)
  135000. */
  135001. noMipmap?: boolean | undefined,
  135002. /**
  135003. * Defines the explicit list of files (undefined by default)
  135004. */
  135005. files?: string[] | undefined);
  135006. /**
  135007. * Execute the current task
  135008. * @param scene defines the scene where you want your assets to be loaded
  135009. * @param onSuccess is a callback called when the task is successfully executed
  135010. * @param onError is a callback called if an error occurs
  135011. */
  135012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135013. }
  135014. /**
  135015. * Define a task used by AssetsManager to load HDR cube textures
  135016. */
  135017. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  135018. /**
  135019. * Defines the name of the task
  135020. */
  135021. name: string;
  135022. /**
  135023. * Defines the location of the file to load
  135024. */
  135025. url: string;
  135026. /**
  135027. * Defines the desired size (the more it increases the longer the generation will be)
  135028. */
  135029. size: number;
  135030. /**
  135031. * Defines if mipmaps should not be generated (default is false)
  135032. */
  135033. noMipmap: boolean;
  135034. /**
  135035. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  135036. */
  135037. generateHarmonics: boolean;
  135038. /**
  135039. * 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)
  135040. */
  135041. gammaSpace: boolean;
  135042. /**
  135043. * Internal Use Only
  135044. */
  135045. reserved: boolean;
  135046. /**
  135047. * Gets the loaded texture
  135048. */
  135049. texture: HDRCubeTexture;
  135050. /**
  135051. * Callback called when the task is successful
  135052. */
  135053. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  135054. /**
  135055. * Callback called when the task is successful
  135056. */
  135057. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  135058. /**
  135059. * Creates a new HDRCubeTextureAssetTask object
  135060. * @param name defines the name of the task
  135061. * @param url defines the location of the file to load
  135062. * @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.
  135063. * @param noMipmap defines if mipmaps should not be generated (default is false)
  135064. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  135065. * @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)
  135066. * @param reserved Internal use only
  135067. */
  135068. constructor(
  135069. /**
  135070. * Defines the name of the task
  135071. */
  135072. name: string,
  135073. /**
  135074. * Defines the location of the file to load
  135075. */
  135076. url: string,
  135077. /**
  135078. * Defines the desired size (the more it increases the longer the generation will be)
  135079. */
  135080. size: number,
  135081. /**
  135082. * Defines if mipmaps should not be generated (default is false)
  135083. */
  135084. noMipmap?: boolean,
  135085. /**
  135086. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  135087. */
  135088. generateHarmonics?: boolean,
  135089. /**
  135090. * 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)
  135091. */
  135092. gammaSpace?: boolean,
  135093. /**
  135094. * Internal Use Only
  135095. */
  135096. reserved?: boolean);
  135097. /**
  135098. * Execute the current task
  135099. * @param scene defines the scene where you want your assets to be loaded
  135100. * @param onSuccess is a callback called when the task is successfully executed
  135101. * @param onError is a callback called if an error occurs
  135102. */
  135103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135104. }
  135105. /**
  135106. * Define a task used by AssetsManager to load Equirectangular cube textures
  135107. */
  135108. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  135109. /**
  135110. * Defines the name of the task
  135111. */
  135112. name: string;
  135113. /**
  135114. * Defines the location of the file to load
  135115. */
  135116. url: string;
  135117. /**
  135118. * Defines the desired size (the more it increases the longer the generation will be)
  135119. */
  135120. size: number;
  135121. /**
  135122. * Defines if mipmaps should not be generated (default is false)
  135123. */
  135124. noMipmap: boolean;
  135125. /**
  135126. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  135127. * but the standard material would require them in Gamma space) (default is true)
  135128. */
  135129. gammaSpace: boolean;
  135130. /**
  135131. * Gets the loaded texture
  135132. */
  135133. texture: EquiRectangularCubeTexture;
  135134. /**
  135135. * Callback called when the task is successful
  135136. */
  135137. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  135138. /**
  135139. * Callback called when the task is successful
  135140. */
  135141. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  135142. /**
  135143. * Creates a new EquiRectangularCubeTextureAssetTask object
  135144. * @param name defines the name of the task
  135145. * @param url defines the location of the file to load
  135146. * @param size defines the desired size (the more it increases the longer the generation will be)
  135147. * If the size is omitted this implies you are using a preprocessed cubemap.
  135148. * @param noMipmap defines if mipmaps should not be generated (default is false)
  135149. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  135150. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  135151. * (default is true)
  135152. */
  135153. constructor(
  135154. /**
  135155. * Defines the name of the task
  135156. */
  135157. name: string,
  135158. /**
  135159. * Defines the location of the file to load
  135160. */
  135161. url: string,
  135162. /**
  135163. * Defines the desired size (the more it increases the longer the generation will be)
  135164. */
  135165. size: number,
  135166. /**
  135167. * Defines if mipmaps should not be generated (default is false)
  135168. */
  135169. noMipmap?: boolean,
  135170. /**
  135171. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  135172. * but the standard material would require them in Gamma space) (default is true)
  135173. */
  135174. gammaSpace?: boolean);
  135175. /**
  135176. * Execute the current task
  135177. * @param scene defines the scene where you want your assets to be loaded
  135178. * @param onSuccess is a callback called when the task is successfully executed
  135179. * @param onError is a callback called if an error occurs
  135180. */
  135181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135182. }
  135183. /**
  135184. * This class can be used to easily import assets into a scene
  135185. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  135186. */
  135187. export class AssetsManager {
  135188. private _scene;
  135189. private _isLoading;
  135190. protected _tasks: AbstractAssetTask[];
  135191. protected _waitingTasksCount: number;
  135192. protected _totalTasksCount: number;
  135193. /**
  135194. * Callback called when all tasks are processed
  135195. */
  135196. onFinish: (tasks: AbstractAssetTask[]) => void;
  135197. /**
  135198. * Callback called when a task is successful
  135199. */
  135200. onTaskSuccess: (task: AbstractAssetTask) => void;
  135201. /**
  135202. * Callback called when a task had an error
  135203. */
  135204. onTaskError: (task: AbstractAssetTask) => void;
  135205. /**
  135206. * Callback called when a task is done (whatever the result is)
  135207. */
  135208. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  135209. /**
  135210. * Observable called when all tasks are processed
  135211. */
  135212. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  135213. /**
  135214. * Observable called when a task had an error
  135215. */
  135216. onTaskErrorObservable: Observable<AbstractAssetTask>;
  135217. /**
  135218. * Observable called when all tasks were executed
  135219. */
  135220. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  135221. /**
  135222. * Observable called when a task is done (whatever the result is)
  135223. */
  135224. onProgressObservable: Observable<IAssetsProgressEvent>;
  135225. /**
  135226. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  135227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  135228. */
  135229. useDefaultLoadingScreen: boolean;
  135230. /**
  135231. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  135232. * when all assets have been downloaded.
  135233. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  135234. */
  135235. autoHideLoadingUI: boolean;
  135236. /**
  135237. * Creates a new AssetsManager
  135238. * @param scene defines the scene to work on
  135239. */
  135240. constructor(scene: Scene);
  135241. /**
  135242. * Add a MeshAssetTask to the list of active tasks
  135243. * @param taskName defines the name of the new task
  135244. * @param meshesNames defines the name of meshes to load
  135245. * @param rootUrl defines the root url to use to locate files
  135246. * @param sceneFilename defines the filename of the scene file
  135247. * @returns a new MeshAssetTask object
  135248. */
  135249. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  135250. /**
  135251. * Add a TextFileAssetTask to the list of active tasks
  135252. * @param taskName defines the name of the new task
  135253. * @param url defines the url of the file to load
  135254. * @returns a new TextFileAssetTask object
  135255. */
  135256. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  135257. /**
  135258. * Add a BinaryFileAssetTask to the list of active tasks
  135259. * @param taskName defines the name of the new task
  135260. * @param url defines the url of the file to load
  135261. * @returns a new BinaryFileAssetTask object
  135262. */
  135263. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  135264. /**
  135265. * Add a ImageAssetTask to the list of active tasks
  135266. * @param taskName defines the name of the new task
  135267. * @param url defines the url of the file to load
  135268. * @returns a new ImageAssetTask object
  135269. */
  135270. addImageTask(taskName: string, url: string): ImageAssetTask;
  135271. /**
  135272. * Add a TextureAssetTask to the list of active tasks
  135273. * @param taskName defines the name of the new task
  135274. * @param url defines the url of the file to load
  135275. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  135276. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  135277. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  135278. * @returns a new TextureAssetTask object
  135279. */
  135280. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  135281. /**
  135282. * Add a CubeTextureAssetTask to the list of active tasks
  135283. * @param taskName defines the name of the new task
  135284. * @param url defines the url of the file to load
  135285. * @param extensions defines the extension to use to load the cube map (can be null)
  135286. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  135287. * @param files defines the list of files to load (can be null)
  135288. * @returns a new CubeTextureAssetTask object
  135289. */
  135290. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  135291. /**
  135292. *
  135293. * Add a HDRCubeTextureAssetTask to the list of active tasks
  135294. * @param taskName defines the name of the new task
  135295. * @param url defines the url of the file to load
  135296. * @param size defines the size you want for the cubemap (can be null)
  135297. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  135298. * @param generateHarmonics defines if you want to automatically generate (true by default)
  135299. * @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)
  135300. * @param reserved Internal use only
  135301. * @returns a new HDRCubeTextureAssetTask object
  135302. */
  135303. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  135304. /**
  135305. *
  135306. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  135307. * @param taskName defines the name of the new task
  135308. * @param url defines the url of the file to load
  135309. * @param size defines the size you want for the cubemap (can be null)
  135310. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  135311. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  135312. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  135313. * @returns a new EquiRectangularCubeTextureAssetTask object
  135314. */
  135315. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  135316. /**
  135317. * Remove a task from the assets manager.
  135318. * @param task the task to remove
  135319. */
  135320. removeTask(task: AbstractAssetTask): void;
  135321. private _decreaseWaitingTasksCount;
  135322. private _runTask;
  135323. /**
  135324. * Reset the AssetsManager and remove all tasks
  135325. * @return the current instance of the AssetsManager
  135326. */
  135327. reset(): AssetsManager;
  135328. /**
  135329. * Start the loading process
  135330. * @return the current instance of the AssetsManager
  135331. */
  135332. load(): AssetsManager;
  135333. /**
  135334. * Start the loading process as an async operation
  135335. * @return a promise returning the list of failed tasks
  135336. */
  135337. loadAsync(): Promise<void>;
  135338. }
  135339. }
  135340. declare module BABYLON {
  135341. /**
  135342. * Wrapper class for promise with external resolve and reject.
  135343. */
  135344. export class Deferred<T> {
  135345. /**
  135346. * The promise associated with this deferred object.
  135347. */
  135348. readonly promise: Promise<T>;
  135349. private _resolve;
  135350. private _reject;
  135351. /**
  135352. * The resolve method of the promise associated with this deferred object.
  135353. */
  135354. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  135355. /**
  135356. * The reject method of the promise associated with this deferred object.
  135357. */
  135358. readonly reject: (reason?: any) => void;
  135359. /**
  135360. * Constructor for this deferred object.
  135361. */
  135362. constructor();
  135363. }
  135364. }
  135365. declare module BABYLON {
  135366. /**
  135367. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  135368. */
  135369. export class MeshExploder {
  135370. private _centerMesh;
  135371. private _meshes;
  135372. private _meshesOrigins;
  135373. private _toCenterVectors;
  135374. private _scaledDirection;
  135375. private _newPosition;
  135376. private _centerPosition;
  135377. /**
  135378. * Explodes meshes from a center mesh.
  135379. * @param meshes The meshes to explode.
  135380. * @param centerMesh The mesh to be center of explosion.
  135381. */
  135382. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  135383. private _setCenterMesh;
  135384. /**
  135385. * Get class name
  135386. * @returns "MeshExploder"
  135387. */
  135388. getClassName(): string;
  135389. /**
  135390. * "Exploded meshes"
  135391. * @returns Array of meshes with the centerMesh at index 0.
  135392. */
  135393. getMeshes(): Array<Mesh>;
  135394. /**
  135395. * Explodes meshes giving a specific direction
  135396. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  135397. */
  135398. explode(direction?: number): void;
  135399. }
  135400. }
  135401. declare module BABYLON {
  135402. /**
  135403. * Class used to help managing file picking and drag'n'drop
  135404. */
  135405. export class FilesInput {
  135406. /**
  135407. * List of files ready to be loaded
  135408. */
  135409. static readonly FilesToLoad: {
  135410. [key: string]: File;
  135411. };
  135412. /**
  135413. * Callback called when a file is processed
  135414. */
  135415. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  135416. private _engine;
  135417. private _currentScene;
  135418. private _sceneLoadedCallback;
  135419. private _progressCallback;
  135420. private _additionalRenderLoopLogicCallback;
  135421. private _textureLoadingCallback;
  135422. private _startingProcessingFilesCallback;
  135423. private _onReloadCallback;
  135424. private _errorCallback;
  135425. private _elementToMonitor;
  135426. private _sceneFileToLoad;
  135427. private _filesToLoad;
  135428. /**
  135429. * Creates a new FilesInput
  135430. * @param engine defines the rendering engine
  135431. * @param scene defines the hosting scene
  135432. * @param sceneLoadedCallback callback called when scene is loaded
  135433. * @param progressCallback callback called to track progress
  135434. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  135435. * @param textureLoadingCallback callback called when a texture is loading
  135436. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  135437. * @param onReloadCallback callback called when a reload is requested
  135438. * @param errorCallback callback call if an error occurs
  135439. */
  135440. 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);
  135441. private _dragEnterHandler;
  135442. private _dragOverHandler;
  135443. private _dropHandler;
  135444. /**
  135445. * Calls this function to listen to drag'n'drop events on a specific DOM element
  135446. * @param elementToMonitor defines the DOM element to track
  135447. */
  135448. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  135449. /**
  135450. * Release all associated resources
  135451. */
  135452. dispose(): void;
  135453. private renderFunction;
  135454. private drag;
  135455. private drop;
  135456. private _traverseFolder;
  135457. private _processFiles;
  135458. /**
  135459. * Load files from a drop event
  135460. * @param event defines the drop event to use as source
  135461. */
  135462. loadFiles(event: any): void;
  135463. private _processReload;
  135464. /**
  135465. * Reload the current scene from the loaded files
  135466. */
  135467. reload(): void;
  135468. }
  135469. }
  135470. declare module BABYLON {
  135471. /**
  135472. * Defines the root class used to create scene optimization to use with SceneOptimizer
  135473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135474. */
  135475. export class SceneOptimization {
  135476. /**
  135477. * Defines the priority of this optimization (0 by default which means first in the list)
  135478. */
  135479. priority: number;
  135480. /**
  135481. * Gets a string describing the action executed by the current optimization
  135482. * @returns description string
  135483. */
  135484. getDescription(): string;
  135485. /**
  135486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135487. * @param scene defines the current scene where to apply this optimization
  135488. * @param optimizer defines the current optimizer
  135489. * @returns true if everything that can be done was applied
  135490. */
  135491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135492. /**
  135493. * Creates the SceneOptimization object
  135494. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  135495. * @param desc defines the description associated with the optimization
  135496. */
  135497. constructor(
  135498. /**
  135499. * Defines the priority of this optimization (0 by default which means first in the list)
  135500. */
  135501. priority?: number);
  135502. }
  135503. /**
  135504. * Defines an optimization used to reduce the size of render target textures
  135505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135506. */
  135507. export class TextureOptimization extends SceneOptimization {
  135508. /**
  135509. * Defines the priority of this optimization (0 by default which means first in the list)
  135510. */
  135511. priority: number;
  135512. /**
  135513. * 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
  135514. */
  135515. maximumSize: number;
  135516. /**
  135517. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  135518. */
  135519. step: number;
  135520. /**
  135521. * Gets a string describing the action executed by the current optimization
  135522. * @returns description string
  135523. */
  135524. getDescription(): string;
  135525. /**
  135526. * Creates the TextureOptimization object
  135527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  135528. * @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
  135529. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  135530. */
  135531. constructor(
  135532. /**
  135533. * Defines the priority of this optimization (0 by default which means first in the list)
  135534. */
  135535. priority?: number,
  135536. /**
  135537. * 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
  135538. */
  135539. maximumSize?: number,
  135540. /**
  135541. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  135542. */
  135543. step?: number);
  135544. /**
  135545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135546. * @param scene defines the current scene where to apply this optimization
  135547. * @param optimizer defines the current optimizer
  135548. * @returns true if everything that can be done was applied
  135549. */
  135550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135551. }
  135552. /**
  135553. * Defines an optimization used to increase or decrease the rendering resolution
  135554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135555. */
  135556. export class HardwareScalingOptimization extends SceneOptimization {
  135557. /**
  135558. * Defines the priority of this optimization (0 by default which means first in the list)
  135559. */
  135560. priority: number;
  135561. /**
  135562. * Defines the maximum scale to use (2 by default)
  135563. */
  135564. maximumScale: number;
  135565. /**
  135566. * Defines the step to use between two passes (0.5 by default)
  135567. */
  135568. step: number;
  135569. private _currentScale;
  135570. private _directionOffset;
  135571. /**
  135572. * Gets a string describing the action executed by the current optimization
  135573. * @return description string
  135574. */
  135575. getDescription(): string;
  135576. /**
  135577. * Creates the HardwareScalingOptimization object
  135578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  135579. * @param maximumScale defines the maximum scale to use (2 by default)
  135580. * @param step defines the step to use between two passes (0.5 by default)
  135581. */
  135582. constructor(
  135583. /**
  135584. * Defines the priority of this optimization (0 by default which means first in the list)
  135585. */
  135586. priority?: number,
  135587. /**
  135588. * Defines the maximum scale to use (2 by default)
  135589. */
  135590. maximumScale?: number,
  135591. /**
  135592. * Defines the step to use between two passes (0.5 by default)
  135593. */
  135594. step?: number);
  135595. /**
  135596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135597. * @param scene defines the current scene where to apply this optimization
  135598. * @param optimizer defines the current optimizer
  135599. * @returns true if everything that can be done was applied
  135600. */
  135601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135602. }
  135603. /**
  135604. * Defines an optimization used to remove shadows
  135605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135606. */
  135607. export class ShadowsOptimization extends SceneOptimization {
  135608. /**
  135609. * Gets a string describing the action executed by the current optimization
  135610. * @return description string
  135611. */
  135612. getDescription(): string;
  135613. /**
  135614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135615. * @param scene defines the current scene where to apply this optimization
  135616. * @param optimizer defines the current optimizer
  135617. * @returns true if everything that can be done was applied
  135618. */
  135619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135620. }
  135621. /**
  135622. * Defines an optimization used to turn post-processes off
  135623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135624. */
  135625. export class PostProcessesOptimization extends SceneOptimization {
  135626. /**
  135627. * Gets a string describing the action executed by the current optimization
  135628. * @return description string
  135629. */
  135630. getDescription(): string;
  135631. /**
  135632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135633. * @param scene defines the current scene where to apply this optimization
  135634. * @param optimizer defines the current optimizer
  135635. * @returns true if everything that can be done was applied
  135636. */
  135637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135638. }
  135639. /**
  135640. * Defines an optimization used to turn lens flares off
  135641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135642. */
  135643. export class LensFlaresOptimization extends SceneOptimization {
  135644. /**
  135645. * Gets a string describing the action executed by the current optimization
  135646. * @return description string
  135647. */
  135648. getDescription(): string;
  135649. /**
  135650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135651. * @param scene defines the current scene where to apply this optimization
  135652. * @param optimizer defines the current optimizer
  135653. * @returns true if everything that can be done was applied
  135654. */
  135655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135656. }
  135657. /**
  135658. * Defines an optimization based on user defined callback.
  135659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135660. */
  135661. export class CustomOptimization extends SceneOptimization {
  135662. /**
  135663. * Callback called to apply the custom optimization.
  135664. */
  135665. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  135666. /**
  135667. * Callback called to get custom description
  135668. */
  135669. onGetDescription: () => string;
  135670. /**
  135671. * Gets a string describing the action executed by the current optimization
  135672. * @returns description string
  135673. */
  135674. getDescription(): string;
  135675. /**
  135676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135677. * @param scene defines the current scene where to apply this optimization
  135678. * @param optimizer defines the current optimizer
  135679. * @returns true if everything that can be done was applied
  135680. */
  135681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135682. }
  135683. /**
  135684. * Defines an optimization used to turn particles off
  135685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135686. */
  135687. export class ParticlesOptimization extends SceneOptimization {
  135688. /**
  135689. * Gets a string describing the action executed by the current optimization
  135690. * @return description string
  135691. */
  135692. getDescription(): string;
  135693. /**
  135694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135695. * @param scene defines the current scene where to apply this optimization
  135696. * @param optimizer defines the current optimizer
  135697. * @returns true if everything that can be done was applied
  135698. */
  135699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135700. }
  135701. /**
  135702. * Defines an optimization used to turn render targets off
  135703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135704. */
  135705. export class RenderTargetsOptimization extends SceneOptimization {
  135706. /**
  135707. * Gets a string describing the action executed by the current optimization
  135708. * @return description string
  135709. */
  135710. getDescription(): string;
  135711. /**
  135712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135713. * @param scene defines the current scene where to apply this optimization
  135714. * @param optimizer defines the current optimizer
  135715. * @returns true if everything that can be done was applied
  135716. */
  135717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  135718. }
  135719. /**
  135720. * Defines an optimization used to merge meshes with compatible materials
  135721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135722. */
  135723. export class MergeMeshesOptimization extends SceneOptimization {
  135724. private static _UpdateSelectionTree;
  135725. /**
  135726. * Gets or sets a boolean which defines if optimization octree has to be updated
  135727. */
  135728. /**
  135729. * Gets or sets a boolean which defines if optimization octree has to be updated
  135730. */
  135731. static UpdateSelectionTree: boolean;
  135732. /**
  135733. * Gets a string describing the action executed by the current optimization
  135734. * @return description string
  135735. */
  135736. getDescription(): string;
  135737. private _canBeMerged;
  135738. /**
  135739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  135740. * @param scene defines the current scene where to apply this optimization
  135741. * @param optimizer defines the current optimizer
  135742. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  135743. * @returns true if everything that can be done was applied
  135744. */
  135745. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  135746. }
  135747. /**
  135748. * Defines a list of options used by SceneOptimizer
  135749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135750. */
  135751. export class SceneOptimizerOptions {
  135752. /**
  135753. * Defines the target frame rate to reach (60 by default)
  135754. */
  135755. targetFrameRate: number;
  135756. /**
  135757. * Defines the interval between two checkes (2000ms by default)
  135758. */
  135759. trackerDuration: number;
  135760. /**
  135761. * Gets the list of optimizations to apply
  135762. */
  135763. optimizations: SceneOptimization[];
  135764. /**
  135765. * Creates a new list of options used by SceneOptimizer
  135766. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  135767. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  135768. */
  135769. constructor(
  135770. /**
  135771. * Defines the target frame rate to reach (60 by default)
  135772. */
  135773. targetFrameRate?: number,
  135774. /**
  135775. * Defines the interval between two checkes (2000ms by default)
  135776. */
  135777. trackerDuration?: number);
  135778. /**
  135779. * Add a new optimization
  135780. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  135781. * @returns the current SceneOptimizerOptions
  135782. */
  135783. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  135784. /**
  135785. * Add a new custom optimization
  135786. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  135787. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  135788. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  135789. * @returns the current SceneOptimizerOptions
  135790. */
  135791. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  135792. /**
  135793. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  135794. * @param targetFrameRate defines the target frame rate (60 by default)
  135795. * @returns a SceneOptimizerOptions object
  135796. */
  135797. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  135798. /**
  135799. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  135800. * @param targetFrameRate defines the target frame rate (60 by default)
  135801. * @returns a SceneOptimizerOptions object
  135802. */
  135803. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  135804. /**
  135805. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  135806. * @param targetFrameRate defines the target frame rate (60 by default)
  135807. * @returns a SceneOptimizerOptions object
  135808. */
  135809. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  135810. }
  135811. /**
  135812. * Class used to run optimizations in order to reach a target frame rate
  135813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  135814. */
  135815. export class SceneOptimizer implements IDisposable {
  135816. private _isRunning;
  135817. private _options;
  135818. private _scene;
  135819. private _currentPriorityLevel;
  135820. private _targetFrameRate;
  135821. private _trackerDuration;
  135822. private _currentFrameRate;
  135823. private _sceneDisposeObserver;
  135824. private _improvementMode;
  135825. /**
  135826. * Defines an observable called when the optimizer reaches the target frame rate
  135827. */
  135828. onSuccessObservable: Observable<SceneOptimizer>;
  135829. /**
  135830. * Defines an observable called when the optimizer enables an optimization
  135831. */
  135832. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  135833. /**
  135834. * Defines an observable called when the optimizer is not able to reach the target frame rate
  135835. */
  135836. onFailureObservable: Observable<SceneOptimizer>;
  135837. /**
  135838. * Gets a boolean indicating if the optimizer is in improvement mode
  135839. */
  135840. readonly isInImprovementMode: boolean;
  135841. /**
  135842. * Gets the current priority level (0 at start)
  135843. */
  135844. readonly currentPriorityLevel: number;
  135845. /**
  135846. * Gets the current frame rate checked by the SceneOptimizer
  135847. */
  135848. readonly currentFrameRate: number;
  135849. /**
  135850. * Gets or sets the current target frame rate (60 by default)
  135851. */
  135852. /**
  135853. * Gets or sets the current target frame rate (60 by default)
  135854. */
  135855. targetFrameRate: number;
  135856. /**
  135857. * Gets or sets the current interval between two checks (every 2000ms by default)
  135858. */
  135859. /**
  135860. * Gets or sets the current interval between two checks (every 2000ms by default)
  135861. */
  135862. trackerDuration: number;
  135863. /**
  135864. * Gets the list of active optimizations
  135865. */
  135866. readonly optimizations: SceneOptimization[];
  135867. /**
  135868. * Creates a new SceneOptimizer
  135869. * @param scene defines the scene to work on
  135870. * @param options defines the options to use with the SceneOptimizer
  135871. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  135872. * @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)
  135873. */
  135874. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  135875. /**
  135876. * Stops the current optimizer
  135877. */
  135878. stop(): void;
  135879. /**
  135880. * Reset the optimizer to initial step (current priority level = 0)
  135881. */
  135882. reset(): void;
  135883. /**
  135884. * Start the optimizer. By default it will try to reach a specific framerate
  135885. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  135886. */
  135887. start(): void;
  135888. private _checkCurrentState;
  135889. /**
  135890. * Release all resources
  135891. */
  135892. dispose(): void;
  135893. /**
  135894. * Helper function to create a SceneOptimizer with one single line of code
  135895. * @param scene defines the scene to work on
  135896. * @param options defines the options to use with the SceneOptimizer
  135897. * @param onSuccess defines a callback to call on success
  135898. * @param onFailure defines a callback to call on failure
  135899. * @returns the new SceneOptimizer object
  135900. */
  135901. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  135902. }
  135903. }
  135904. declare module BABYLON {
  135905. /**
  135906. * Class used to serialize a scene into a string
  135907. */
  135908. export class SceneSerializer {
  135909. /**
  135910. * Clear cache used by a previous serialization
  135911. */
  135912. static ClearCache(): void;
  135913. /**
  135914. * Serialize a scene into a JSON compatible object
  135915. * @param scene defines the scene to serialize
  135916. * @returns a JSON compatible object
  135917. */
  135918. static Serialize(scene: Scene): any;
  135919. /**
  135920. * Serialize a mesh into a JSON compatible object
  135921. * @param toSerialize defines the mesh to serialize
  135922. * @param withParents defines if parents must be serialized as well
  135923. * @param withChildren defines if children must be serialized as well
  135924. * @returns a JSON compatible object
  135925. */
  135926. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  135927. }
  135928. }
  135929. declare module BABYLON {
  135930. /**
  135931. * Class used to host texture specific utilities
  135932. */
  135933. export class TextureTools {
  135934. /**
  135935. * Uses the GPU to create a copy texture rescaled at a given size
  135936. * @param texture Texture to copy from
  135937. * @param width defines the desired width
  135938. * @param height defines the desired height
  135939. * @param useBilinearMode defines if bilinear mode has to be used
  135940. * @return the generated texture
  135941. */
  135942. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  135943. }
  135944. }
  135945. declare module BABYLON {
  135946. /**
  135947. * This represents the different options available for the video capture.
  135948. */
  135949. export interface VideoRecorderOptions {
  135950. /** Defines the mime type of the video. */
  135951. mimeType: string;
  135952. /** Defines the FPS the video should be recorded at. */
  135953. fps: number;
  135954. /** Defines the chunk size for the recording data. */
  135955. recordChunckSize: number;
  135956. /** The audio tracks to attach to the recording. */
  135957. audioTracks?: MediaStreamTrack[];
  135958. }
  135959. /**
  135960. * This can help with recording videos from BabylonJS.
  135961. * This is based on the available WebRTC functionalities of the browser.
  135962. *
  135963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  135964. */
  135965. export class VideoRecorder {
  135966. private static readonly _defaultOptions;
  135967. /**
  135968. * Returns whether or not the VideoRecorder is available in your browser.
  135969. * @param engine Defines the Babylon Engine.
  135970. * @returns true if supported otherwise false.
  135971. */
  135972. static IsSupported(engine: Engine): boolean;
  135973. private readonly _options;
  135974. private _canvas;
  135975. private _mediaRecorder;
  135976. private _recordedChunks;
  135977. private _fileName;
  135978. private _resolve;
  135979. private _reject;
  135980. /**
  135981. * True when a recording is already in progress.
  135982. */
  135983. readonly isRecording: boolean;
  135984. /**
  135985. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  135986. * @param engine Defines the BabylonJS Engine you wish to record.
  135987. * @param options Defines options that can be used to customize the capture.
  135988. */
  135989. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  135990. /**
  135991. * Stops the current recording before the default capture timeout passed in the startRecording function.
  135992. */
  135993. stopRecording(): void;
  135994. /**
  135995. * Starts recording the canvas for a max duration specified in parameters.
  135996. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  135997. * If null no automatic download will start and you can rely on the promise to get the data back.
  135998. * @param maxDuration Defines the maximum recording time in seconds.
  135999. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  136000. * @return A promise callback at the end of the recording with the video data in Blob.
  136001. */
  136002. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  136003. /**
  136004. * Releases internal resources used during the recording.
  136005. */
  136006. dispose(): void;
  136007. private _handleDataAvailable;
  136008. private _handleError;
  136009. private _handleStop;
  136010. }
  136011. }
  136012. declare module BABYLON {
  136013. /**
  136014. * Class containing a set of static utilities functions for screenshots
  136015. */
  136016. export class ScreenshotTools {
  136017. /**
  136018. * Captures a screenshot of the current rendering
  136019. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  136020. * @param engine defines the rendering engine
  136021. * @param camera defines the source camera
  136022. * @param size This parameter can be set to a single number or to an object with the
  136023. * following (optional) properties: precision, width, height. If a single number is passed,
  136024. * it will be used for both width and height. If an object is passed, the screenshot size
  136025. * will be derived from the parameters. The precision property is a multiplier allowing
  136026. * rendering at a higher or lower resolution
  136027. * @param successCallback defines the callback receives a single parameter which contains the
  136028. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  136029. * src parameter of an <img> to display it
  136030. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  136031. * Check your browser for supported MIME types
  136032. */
  136033. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  136034. /**
  136035. * Captures a screenshot of the current rendering
  136036. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  136037. * @param engine defines the rendering engine
  136038. * @param camera defines the source camera
  136039. * @param size This parameter can be set to a single number or to an object with the
  136040. * following (optional) properties: precision, width, height. If a single number is passed,
  136041. * it will be used for both width and height. If an object is passed, the screenshot size
  136042. * will be derived from the parameters. The precision property is a multiplier allowing
  136043. * rendering at a higher or lower resolution
  136044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  136045. * Check your browser for supported MIME types
  136046. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  136047. * to the src parameter of an <img> to display it
  136048. */
  136049. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  136050. /**
  136051. * Generates an image screenshot from the specified camera.
  136052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  136053. * @param engine The engine to use for rendering
  136054. * @param camera The camera to use for rendering
  136055. * @param size This parameter can be set to a single number or to an object with the
  136056. * following (optional) properties: precision, width, height. If a single number is passed,
  136057. * it will be used for both width and height. If an object is passed, the screenshot size
  136058. * will be derived from the parameters. The precision property is a multiplier allowing
  136059. * rendering at a higher or lower resolution
  136060. * @param successCallback The callback receives a single parameter which contains the
  136061. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  136062. * src parameter of an <img> to display it
  136063. * @param mimeType The MIME type of the screenshot image (default: image/png).
  136064. * Check your browser for supported MIME types
  136065. * @param samples Texture samples (default: 1)
  136066. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  136067. * @param fileName A name for for the downloaded file.
  136068. */
  136069. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  136070. /**
  136071. * Generates an image screenshot from the specified camera.
  136072. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  136073. * @param engine The engine to use for rendering
  136074. * @param camera The camera to use for rendering
  136075. * @param size This parameter can be set to a single number or to an object with the
  136076. * following (optional) properties: precision, width, height. If a single number is passed,
  136077. * it will be used for both width and height. If an object is passed, the screenshot size
  136078. * will be derived from the parameters. The precision property is a multiplier allowing
  136079. * rendering at a higher or lower resolution
  136080. * @param mimeType The MIME type of the screenshot image (default: image/png).
  136081. * Check your browser for supported MIME types
  136082. * @param samples Texture samples (default: 1)
  136083. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  136084. * @param fileName A name for for the downloaded file.
  136085. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  136086. * to the src parameter of an <img> to display it
  136087. */
  136088. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  136089. /**
  136090. * Gets height and width for screenshot size
  136091. * @private
  136092. */
  136093. private static _getScreenshotSize;
  136094. }
  136095. }
  136096. declare module BABYLON {
  136097. /**
  136098. * Interface for a data buffer
  136099. */
  136100. export interface IDataBuffer {
  136101. /**
  136102. * Reads bytes from the data buffer.
  136103. * @param byteOffset The byte offset to read
  136104. * @param byteLength The byte length to read
  136105. * @returns A promise that resolves when the bytes are read
  136106. */
  136107. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  136108. /**
  136109. * The byte length of the buffer.
  136110. */
  136111. readonly byteLength: number;
  136112. }
  136113. /**
  136114. * Utility class for reading from a data buffer
  136115. */
  136116. export class DataReader {
  136117. /**
  136118. * The data buffer associated with this data reader.
  136119. */
  136120. readonly buffer: IDataBuffer;
  136121. /**
  136122. * The current byte offset from the beginning of the data buffer.
  136123. */
  136124. byteOffset: number;
  136125. private _dataView;
  136126. private _dataByteOffset;
  136127. /**
  136128. * Constructor
  136129. * @param buffer The buffer to read
  136130. */
  136131. constructor(buffer: IDataBuffer);
  136132. /**
  136133. * Loads the given byte length.
  136134. * @param byteLength The byte length to load
  136135. * @returns A promise that resolves when the load is complete
  136136. */
  136137. loadAsync(byteLength: number): Promise<void>;
  136138. /**
  136139. * Read a unsigned 32-bit integer from the currently loaded data range.
  136140. * @returns The 32-bit integer read
  136141. */
  136142. readUint32(): number;
  136143. /**
  136144. * Read a byte array from the currently loaded data range.
  136145. * @param byteLength The byte length to read
  136146. * @returns The byte array read
  136147. */
  136148. readUint8Array(byteLength: number): Uint8Array;
  136149. /**
  136150. * Read a string from the currently loaded data range.
  136151. * @param byteLength The byte length to read
  136152. * @returns The string read
  136153. */
  136154. readString(byteLength: number): string;
  136155. /**
  136156. * Skips the given byte length the currently loaded data range.
  136157. * @param byteLength The byte length to skip
  136158. */
  136159. skipBytes(byteLength: number): void;
  136160. }
  136161. }
  136162. declare module BABYLON {
  136163. /**
  136164. * A cursor which tracks a point on a path
  136165. */
  136166. export class PathCursor {
  136167. private path;
  136168. /**
  136169. * Stores path cursor callbacks for when an onchange event is triggered
  136170. */
  136171. private _onchange;
  136172. /**
  136173. * The value of the path cursor
  136174. */
  136175. value: number;
  136176. /**
  136177. * The animation array of the path cursor
  136178. */
  136179. animations: Animation[];
  136180. /**
  136181. * Initializes the path cursor
  136182. * @param path The path to track
  136183. */
  136184. constructor(path: Path2);
  136185. /**
  136186. * Gets the cursor point on the path
  136187. * @returns A point on the path cursor at the cursor location
  136188. */
  136189. getPoint(): Vector3;
  136190. /**
  136191. * Moves the cursor ahead by the step amount
  136192. * @param step The amount to move the cursor forward
  136193. * @returns This path cursor
  136194. */
  136195. moveAhead(step?: number): PathCursor;
  136196. /**
  136197. * Moves the cursor behind by the step amount
  136198. * @param step The amount to move the cursor back
  136199. * @returns This path cursor
  136200. */
  136201. moveBack(step?: number): PathCursor;
  136202. /**
  136203. * Moves the cursor by the step amount
  136204. * If the step amount is greater than one, an exception is thrown
  136205. * @param step The amount to move the cursor
  136206. * @returns This path cursor
  136207. */
  136208. move(step: number): PathCursor;
  136209. /**
  136210. * Ensures that the value is limited between zero and one
  136211. * @returns This path cursor
  136212. */
  136213. private ensureLimits;
  136214. /**
  136215. * Runs onchange callbacks on change (used by the animation engine)
  136216. * @returns This path cursor
  136217. */
  136218. private raiseOnChange;
  136219. /**
  136220. * Executes a function on change
  136221. * @param f A path cursor onchange callback
  136222. * @returns This path cursor
  136223. */
  136224. onchange(f: (cursor: PathCursor) => void): PathCursor;
  136225. }
  136226. }
  136227. declare module BABYLON {
  136228. /** @hidden */
  136229. export var blurPixelShader: {
  136230. name: string;
  136231. shader: string;
  136232. };
  136233. }
  136234. declare module BABYLON {
  136235. /** @hidden */
  136236. export var pointCloudVertexDeclaration: {
  136237. name: string;
  136238. shader: string;
  136239. };
  136240. }
  136241. // Mixins
  136242. interface Window {
  136243. mozIndexedDB: IDBFactory;
  136244. webkitIndexedDB: IDBFactory;
  136245. msIndexedDB: IDBFactory;
  136246. webkitURL: typeof URL;
  136247. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  136248. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  136249. WebGLRenderingContext: WebGLRenderingContext;
  136250. MSGesture: MSGesture;
  136251. CANNON: any;
  136252. AudioContext: AudioContext;
  136253. webkitAudioContext: AudioContext;
  136254. PointerEvent: any;
  136255. Math: Math;
  136256. Uint8Array: Uint8ArrayConstructor;
  136257. Float32Array: Float32ArrayConstructor;
  136258. mozURL: typeof URL;
  136259. msURL: typeof URL;
  136260. VRFrameData: any; // WebVR, from specs 1.1
  136261. DracoDecoderModule: any;
  136262. setImmediate(handler: (...args: any[]) => void): number;
  136263. }
  136264. interface HTMLCanvasElement {
  136265. requestPointerLock(): void;
  136266. msRequestPointerLock?(): void;
  136267. mozRequestPointerLock?(): void;
  136268. webkitRequestPointerLock?(): void;
  136269. /** Track wether a record is in progress */
  136270. isRecording: boolean;
  136271. /** Capture Stream method defined by some browsers */
  136272. captureStream(fps?: number): MediaStream;
  136273. }
  136274. interface CanvasRenderingContext2D {
  136275. msImageSmoothingEnabled: boolean;
  136276. }
  136277. interface MouseEvent {
  136278. mozMovementX: number;
  136279. mozMovementY: number;
  136280. webkitMovementX: number;
  136281. webkitMovementY: number;
  136282. msMovementX: number;
  136283. msMovementY: number;
  136284. }
  136285. interface Navigator {
  136286. mozGetVRDevices: (any: any) => any;
  136287. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  136288. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  136289. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  136290. webkitGetGamepads(): Gamepad[];
  136291. msGetGamepads(): Gamepad[];
  136292. webkitGamepads(): Gamepad[];
  136293. }
  136294. interface HTMLVideoElement {
  136295. mozSrcObject: any;
  136296. }
  136297. interface Math {
  136298. fround(x: number): number;
  136299. imul(a: number, b: number): number;
  136300. }
  136301. interface WebGLRenderingContext {
  136302. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  136303. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  136304. vertexAttribDivisor(index: number, divisor: number): void;
  136305. createVertexArray(): any;
  136306. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  136307. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  136308. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  136309. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  136310. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  136311. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  136312. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  136313. // Queries
  136314. createQuery(): WebGLQuery;
  136315. deleteQuery(query: WebGLQuery): void;
  136316. beginQuery(target: number, query: WebGLQuery): void;
  136317. endQuery(target: number): void;
  136318. getQueryParameter(query: WebGLQuery, pname: number): any;
  136319. getQuery(target: number, pname: number): any;
  136320. MAX_SAMPLES: number;
  136321. RGBA8: number;
  136322. READ_FRAMEBUFFER: number;
  136323. DRAW_FRAMEBUFFER: number;
  136324. UNIFORM_BUFFER: number;
  136325. HALF_FLOAT_OES: number;
  136326. RGBA16F: number;
  136327. RGBA32F: number;
  136328. R32F: number;
  136329. RG32F: number;
  136330. RGB32F: number;
  136331. R16F: number;
  136332. RG16F: number;
  136333. RGB16F: number;
  136334. RED: number;
  136335. RG: number;
  136336. R8: number;
  136337. RG8: number;
  136338. UNSIGNED_INT_24_8: number;
  136339. DEPTH24_STENCIL8: number;
  136340. MIN: number;
  136341. MAX: number;
  136342. /* Multiple Render Targets */
  136343. drawBuffers(buffers: number[]): void;
  136344. readBuffer(src: number): void;
  136345. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  136346. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  136347. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  136348. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  136349. // Occlusion Query
  136350. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  136351. ANY_SAMPLES_PASSED: number;
  136352. QUERY_RESULT_AVAILABLE: number;
  136353. QUERY_RESULT: number;
  136354. }
  136355. interface WebGLProgram {
  136356. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  136357. }
  136358. interface EXT_disjoint_timer_query {
  136359. QUERY_COUNTER_BITS_EXT: number;
  136360. TIME_ELAPSED_EXT: number;
  136361. TIMESTAMP_EXT: number;
  136362. GPU_DISJOINT_EXT: number;
  136363. QUERY_RESULT_EXT: number;
  136364. QUERY_RESULT_AVAILABLE_EXT: number;
  136365. queryCounterEXT(query: WebGLQuery, target: number): void;
  136366. createQueryEXT(): WebGLQuery;
  136367. beginQueryEXT(target: number, query: WebGLQuery): void;
  136368. endQueryEXT(target: number): void;
  136369. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  136370. deleteQueryEXT(query: WebGLQuery): void;
  136371. }
  136372. interface WebGLUniformLocation {
  136373. _currentState: any;
  136374. }
  136375. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  136376. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  136377. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  136378. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  136379. interface WebGLRenderingContext {
  136380. readonly RASTERIZER_DISCARD: number;
  136381. readonly DEPTH_COMPONENT24: number;
  136382. readonly TEXTURE_3D: number;
  136383. readonly TEXTURE_2D_ARRAY: number;
  136384. readonly TEXTURE_COMPARE_FUNC: number;
  136385. readonly TEXTURE_COMPARE_MODE: number;
  136386. readonly COMPARE_REF_TO_TEXTURE: number;
  136387. readonly TEXTURE_WRAP_R: number;
  136388. readonly HALF_FLOAT: number;
  136389. readonly RGB8: number;
  136390. readonly RED_INTEGER: number;
  136391. readonly RG_INTEGER: number;
  136392. readonly RGB_INTEGER: number;
  136393. readonly RGBA_INTEGER: number;
  136394. readonly R8_SNORM: number;
  136395. readonly RG8_SNORM: number;
  136396. readonly RGB8_SNORM: number;
  136397. readonly RGBA8_SNORM: number;
  136398. readonly R8I: number;
  136399. readonly RG8I: number;
  136400. readonly RGB8I: number;
  136401. readonly RGBA8I: number;
  136402. readonly R8UI: number;
  136403. readonly RG8UI: number;
  136404. readonly RGB8UI: number;
  136405. readonly RGBA8UI: number;
  136406. readonly R16I: number;
  136407. readonly RG16I: number;
  136408. readonly RGB16I: number;
  136409. readonly RGBA16I: number;
  136410. readonly R16UI: number;
  136411. readonly RG16UI: number;
  136412. readonly RGB16UI: number;
  136413. readonly RGBA16UI: number;
  136414. readonly R32I: number;
  136415. readonly RG32I: number;
  136416. readonly RGB32I: number;
  136417. readonly RGBA32I: number;
  136418. readonly R32UI: number;
  136419. readonly RG32UI: number;
  136420. readonly RGB32UI: number;
  136421. readonly RGBA32UI: number;
  136422. readonly RGB10_A2UI: number;
  136423. readonly R11F_G11F_B10F: number;
  136424. readonly RGB9_E5: number;
  136425. readonly RGB10_A2: number;
  136426. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  136427. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  136428. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  136429. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  136430. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  136431. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  136432. 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;
  136433. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  136434. readonly TRANSFORM_FEEDBACK: number;
  136435. readonly INTERLEAVED_ATTRIBS: number;
  136436. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  136437. createTransformFeedback(): WebGLTransformFeedback;
  136438. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  136439. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  136440. beginTransformFeedback(primitiveMode: number): void;
  136441. endTransformFeedback(): void;
  136442. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  136443. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  136444. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  136445. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  136446. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  136447. }
  136448. interface ImageBitmap {
  136449. readonly width: number;
  136450. readonly height: number;
  136451. close(): void;
  136452. }
  136453. interface WebGLQuery extends WebGLObject {
  136454. }
  136455. declare var WebGLQuery: {
  136456. prototype: WebGLQuery;
  136457. new(): WebGLQuery;
  136458. };
  136459. interface WebGLSampler extends WebGLObject {
  136460. }
  136461. declare var WebGLSampler: {
  136462. prototype: WebGLSampler;
  136463. new(): WebGLSampler;
  136464. };
  136465. interface WebGLSync extends WebGLObject {
  136466. }
  136467. declare var WebGLSync: {
  136468. prototype: WebGLSync;
  136469. new(): WebGLSync;
  136470. };
  136471. interface WebGLTransformFeedback extends WebGLObject {
  136472. }
  136473. declare var WebGLTransformFeedback: {
  136474. prototype: WebGLTransformFeedback;
  136475. new(): WebGLTransformFeedback;
  136476. };
  136477. interface WebGLVertexArrayObject extends WebGLObject {
  136478. }
  136479. declare var WebGLVertexArrayObject: {
  136480. prototype: WebGLVertexArrayObject;
  136481. new(): WebGLVertexArrayObject;
  136482. };
  136483. // Type definitions for WebVR API
  136484. // Project: https://w3c.github.io/webvr/
  136485. // Definitions by: six a <https://github.com/lostfictions>
  136486. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  136487. interface VRDisplay extends EventTarget {
  136488. /**
  136489. * Dictionary of capabilities describing the VRDisplay.
  136490. */
  136491. readonly capabilities: VRDisplayCapabilities;
  136492. /**
  136493. * z-depth defining the far plane of the eye view frustum
  136494. * enables mapping of values in the render target depth
  136495. * attachment to scene coordinates. Initially set to 10000.0.
  136496. */
  136497. depthFar: number;
  136498. /**
  136499. * z-depth defining the near plane of the eye view frustum
  136500. * enables mapping of values in the render target depth
  136501. * attachment to scene coordinates. Initially set to 0.01.
  136502. */
  136503. depthNear: number;
  136504. /**
  136505. * An identifier for this distinct VRDisplay. Used as an
  136506. * association point in the Gamepad API.
  136507. */
  136508. readonly displayId: number;
  136509. /**
  136510. * A display name, a user-readable name identifying it.
  136511. */
  136512. readonly displayName: string;
  136513. readonly isConnected: boolean;
  136514. readonly isPresenting: boolean;
  136515. /**
  136516. * If this VRDisplay supports room-scale experiences, the optional
  136517. * stage attribute contains details on the room-scale parameters.
  136518. */
  136519. readonly stageParameters: VRStageParameters | null;
  136520. /**
  136521. * Passing the value returned by `requestAnimationFrame` to
  136522. * `cancelAnimationFrame` will unregister the callback.
  136523. * @param handle Define the hanle of the request to cancel
  136524. */
  136525. cancelAnimationFrame(handle: number): void;
  136526. /**
  136527. * Stops presenting to the VRDisplay.
  136528. * @returns a promise to know when it stopped
  136529. */
  136530. exitPresent(): Promise<void>;
  136531. /**
  136532. * Return the current VREyeParameters for the given eye.
  136533. * @param whichEye Define the eye we want the parameter for
  136534. * @returns the eye parameters
  136535. */
  136536. getEyeParameters(whichEye: string): VREyeParameters;
  136537. /**
  136538. * Populates the passed VRFrameData with the information required to render
  136539. * the current frame.
  136540. * @param frameData Define the data structure to populate
  136541. * @returns true if ok otherwise false
  136542. */
  136543. getFrameData(frameData: VRFrameData): boolean;
  136544. /**
  136545. * Get the layers currently being presented.
  136546. * @returns the list of VR layers
  136547. */
  136548. getLayers(): VRLayer[];
  136549. /**
  136550. * Return a VRPose containing the future predicted pose of the VRDisplay
  136551. * when the current frame will be presented. The value returned will not
  136552. * change until JavaScript has returned control to the browser.
  136553. *
  136554. * The VRPose will contain the position, orientation, velocity,
  136555. * and acceleration of each of these properties.
  136556. * @returns the pose object
  136557. */
  136558. getPose(): VRPose;
  136559. /**
  136560. * Return the current instantaneous pose of the VRDisplay, with no
  136561. * prediction applied.
  136562. * @returns the current instantaneous pose
  136563. */
  136564. getImmediatePose(): VRPose;
  136565. /**
  136566. * The callback passed to `requestAnimationFrame` will be called
  136567. * any time a new frame should be rendered. When the VRDisplay is
  136568. * presenting the callback will be called at the native refresh
  136569. * rate of the HMD. When not presenting this function acts
  136570. * identically to how window.requestAnimationFrame acts. Content should
  136571. * make no assumptions of frame rate or vsync behavior as the HMD runs
  136572. * asynchronously from other displays and at differing refresh rates.
  136573. * @param callback Define the eaction to run next frame
  136574. * @returns the request handle it
  136575. */
  136576. requestAnimationFrame(callback: FrameRequestCallback): number;
  136577. /**
  136578. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  136579. * Repeat calls while already presenting will update the VRLayers being displayed.
  136580. * @param layers Define the list of layer to present
  136581. * @returns a promise to know when the request has been fulfilled
  136582. */
  136583. requestPresent(layers: VRLayer[]): Promise<void>;
  136584. /**
  136585. * Reset the pose for this display, treating its current position and
  136586. * orientation as the "origin/zero" values. VRPose.position,
  136587. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  136588. * updated when calling resetPose(). This should be called in only
  136589. * sitting-space experiences.
  136590. */
  136591. resetPose(): void;
  136592. /**
  136593. * The VRLayer provided to the VRDisplay will be captured and presented
  136594. * in the HMD. Calling this function has the same effect on the source
  136595. * canvas as any other operation that uses its source image, and canvases
  136596. * created without preserveDrawingBuffer set to true will be cleared.
  136597. * @param pose Define the pose to submit
  136598. */
  136599. submitFrame(pose?: VRPose): void;
  136600. }
  136601. declare var VRDisplay: {
  136602. prototype: VRDisplay;
  136603. new(): VRDisplay;
  136604. };
  136605. interface VRLayer {
  136606. leftBounds?: number[] | Float32Array | null;
  136607. rightBounds?: number[] | Float32Array | null;
  136608. source?: HTMLCanvasElement | null;
  136609. }
  136610. interface VRDisplayCapabilities {
  136611. readonly canPresent: boolean;
  136612. readonly hasExternalDisplay: boolean;
  136613. readonly hasOrientation: boolean;
  136614. readonly hasPosition: boolean;
  136615. readonly maxLayers: number;
  136616. }
  136617. interface VREyeParameters {
  136618. /** @deprecated */
  136619. readonly fieldOfView: VRFieldOfView;
  136620. readonly offset: Float32Array;
  136621. readonly renderHeight: number;
  136622. readonly renderWidth: number;
  136623. }
  136624. interface VRFieldOfView {
  136625. readonly downDegrees: number;
  136626. readonly leftDegrees: number;
  136627. readonly rightDegrees: number;
  136628. readonly upDegrees: number;
  136629. }
  136630. interface VRFrameData {
  136631. readonly leftProjectionMatrix: Float32Array;
  136632. readonly leftViewMatrix: Float32Array;
  136633. readonly pose: VRPose;
  136634. readonly rightProjectionMatrix: Float32Array;
  136635. readonly rightViewMatrix: Float32Array;
  136636. readonly timestamp: number;
  136637. }
  136638. interface VRPose {
  136639. readonly angularAcceleration: Float32Array | null;
  136640. readonly angularVelocity: Float32Array | null;
  136641. readonly linearAcceleration: Float32Array | null;
  136642. readonly linearVelocity: Float32Array | null;
  136643. readonly orientation: Float32Array | null;
  136644. readonly position: Float32Array | null;
  136645. readonly timestamp: number;
  136646. }
  136647. interface VRStageParameters {
  136648. sittingToStandingTransform?: Float32Array;
  136649. sizeX?: number;
  136650. sizeY?: number;
  136651. }
  136652. interface Navigator {
  136653. getVRDisplays(): Promise<VRDisplay[]>;
  136654. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  136655. }
  136656. interface Window {
  136657. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  136658. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  136659. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  136660. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  136661. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  136662. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  136663. }
  136664. interface Gamepad {
  136665. readonly displayId: number;
  136666. }
  136667. type XRSessionMode =
  136668. | "inline"
  136669. | "immersive-vr"
  136670. | "immersive-ar";
  136671. type XRReferenceSpaceType =
  136672. | "viewer"
  136673. | "local"
  136674. | "local-floor"
  136675. | "bounded-floor"
  136676. | "unbounded";
  136677. type XREnvironmentBlendMode =
  136678. | "opaque"
  136679. | "additive"
  136680. | "alpha-blend";
  136681. type XRVisibilityState =
  136682. | "visible"
  136683. | "visible-blurred"
  136684. | "hidden";
  136685. type XRHandedness =
  136686. | "none"
  136687. | "left"
  136688. | "right";
  136689. type XRTargetRayMode =
  136690. | "gaze"
  136691. | "tracked-pointer"
  136692. | "screen";
  136693. type XREye =
  136694. | "none"
  136695. | "left"
  136696. | "right";
  136697. interface XRSpace extends EventTarget {
  136698. }
  136699. interface XRRenderState {
  136700. depthNear?: number;
  136701. depthFar?: number;
  136702. inlineVerticalFieldOfView?: number;
  136703. baseLayer?: XRWebGLLayer;
  136704. }
  136705. interface XRInputSource {
  136706. handedness: XRHandedness;
  136707. targetRayMode: XRTargetRayMode;
  136708. targetRaySpace: XRSpace;
  136709. gripSpace: XRSpace | undefined;
  136710. gamepad: Gamepad | undefined;
  136711. profiles: Array<string>;
  136712. }
  136713. interface XRSession extends XRAnchorCreator {
  136714. addEventListener: Function;
  136715. removeEventListener: Function;
  136716. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  136717. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  136718. requestAnimationFrame: Function;
  136719. end(): Promise<void>;
  136720. renderState: XRRenderState;
  136721. inputSources: Array<XRInputSource>;
  136722. // AR hit test
  136723. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  136724. updateWorldTrackingState(options: {
  136725. planeDetectionState?: { enabled: boolean; }
  136726. }): void;
  136727. }
  136728. interface XRReferenceSpace extends XRSpace {
  136729. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  136730. onreset: any;
  136731. }
  136732. type XRPlaneSet = Set<XRPlane>;
  136733. type XRAnchorSet = Set<XRAnchor>;
  136734. interface XRFrame {
  136735. session: XRSession;
  136736. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  136737. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  136738. // Anchors
  136739. trackedAnchors?: XRAnchorSet;
  136740. // Planes
  136741. worldInformation: {
  136742. detectedPlanes?: XRPlaneSet;
  136743. };
  136744. }
  136745. interface XRViewerPose extends XRPose {
  136746. views: Array<XRView>;
  136747. }
  136748. interface XRPose {
  136749. transform: XRRigidTransform;
  136750. emulatedPosition: boolean;
  136751. }
  136752. interface XRWebGLLayerOptions {
  136753. antialias?: boolean;
  136754. depth?: boolean;
  136755. stencil?: boolean;
  136756. alpha?: boolean;
  136757. multiview?: boolean;
  136758. framebufferScaleFactor?: number;
  136759. }
  136760. declare var XRWebGLLayer: {
  136761. prototype: XRWebGLLayer;
  136762. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  136763. };
  136764. interface XRWebGLLayer {
  136765. framebuffer: WebGLFramebuffer;
  136766. framebufferWidth: number;
  136767. framebufferHeight: number;
  136768. getViewport: Function;
  136769. }
  136770. declare class XRRigidTransform {
  136771. constructor(matrix: Float32Array);
  136772. position: DOMPointReadOnly;
  136773. orientation: DOMPointReadOnly;
  136774. matrix: Float32Array;
  136775. inverse: XRRigidTransform;
  136776. }
  136777. interface XRView {
  136778. eye: XREye;
  136779. projectionMatrix: Float32Array;
  136780. transform: XRRigidTransform;
  136781. }
  136782. interface XRInputSourceChangeEvent {
  136783. session: XRSession;
  136784. removed: Array<XRInputSource>;
  136785. added: Array<XRInputSource>;
  136786. }
  136787. interface XRInputSourceEvent extends Event {
  136788. readonly frame: XRFrame;
  136789. readonly inputSource: XRInputSource;
  136790. }
  136791. // Experimental(er) features
  136792. declare class XRRay {
  136793. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  136794. origin: DOMPointReadOnly;
  136795. direction: DOMPointReadOnly;
  136796. matrix: Float32Array;
  136797. }
  136798. interface XRHitResult {
  136799. hitMatrix: Float32Array;
  136800. }
  136801. interface XRAnchor {
  136802. // remove?
  136803. id?: string;
  136804. anchorSpace: XRSpace;
  136805. lastChangedTime: number;
  136806. detach(): void;
  136807. }
  136808. interface XRPlane extends XRAnchorCreator {
  136809. orientation: "Horizontal" | "Vertical";
  136810. planeSpace: XRSpace;
  136811. polygon: Array<DOMPointReadOnly>;
  136812. lastChangedTime: number;
  136813. }
  136814. interface XRAnchorCreator {
  136815. // AR Anchors
  136816. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  136817. }